From 82373c704b71644b7fbaa55747cb586affc7fb2e Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Tue, 4 Nov 2014 14:18:49 +0000
Subject: [PATCH] Introduce method 'violate' which says whether a given vector
 is outside of the trust region

[[Imported from SVN: r9951]]
---
 dune/gfe/maxnormtrustregion.hh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/dune/gfe/maxnormtrustregion.hh b/dune/gfe/maxnormtrustregion.hh
index 5b1972e2..ab3c2cbb 100644
--- a/dune/gfe/maxnormtrustregion.hh
+++ b/dune/gfe/maxnormtrustregion.hh
@@ -33,6 +33,18 @@ public:
 
     }
 
+    /** \brief Return true if the given vector is not contained in the trust region */
+    bool violates(const Dune::BlockVector<Dune::FieldVector<double,blocksize> >& v) const
+    {
+      assert(v.size() == obstacles_.size());
+      for (size_t i=0; i<v.size(); i++)
+        for (size_t j=0; j<blocksize; j++)
+          if (v[i][j] < obstacles_[i].lower(j) or v[i][j] > obstacles_[i].upper(j))
+            return true;
+
+      return false;
+    }
+
     field_type radius() const {
         return radius_;
     }
-- 
GitLab