From 69828eec2bc2a946a5b4247c40c5e5007720edee Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Tue, 3 Sep 2013 16:30:48 +0000
Subject: [PATCH] Implement operator<<= and method 'rebind'

[[Imported from SVN: r9448]]
---
 dune/gfe/unitvector.hh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/dune/gfe/unitvector.hh b/dune/gfe/unitvector.hh
index 2de60fdc..e20e343c 100644
--- a/dune/gfe/unitvector.hh
+++ b/dune/gfe/unitvector.hh
@@ -60,6 +60,9 @@ class UnitVector
         }
     }
 
+    template <class T2, int N2>
+    friend class UnitVector;
+
 public:
 
     /** \brief The type used for coordinates */
@@ -101,6 +104,23 @@ public:
         data_ /= data_.two_norm();
     }
 
+    /** \brief Assigment from UnitVector with different type -- used for automatic differentiation with ADOL-C */
+    template <class T2>
+    UnitVector& operator <<= (const UnitVector<T2,N>& other) {
+        for (int i=0; i<N; i++)
+            data_[i] <<= other.data_[i];
+        return *this;
+    }
+
+     /** \brief Rebind the UnitVector to another coordinate type */
+    template<class U>
+    struct rebind
+    {
+      typedef UnitVector<U,N> other;
+    };
+
+
+
     UnitVector<T,N>& operator=(const Dune::FieldVector<T,N>& vector)
     {
         data_ = vector;
-- 
GitLab