getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5385 - /trunk/getfem/src/getfem/bgeot_tensor.h


From: Yves . Renard
Subject: [Getfem-commits] r5385 - /trunk/getfem/src/getfem/bgeot_tensor.h
Date: Wed, 05 Oct 2016 18:14:41 -0000

Author: renard
Date: Wed Oct  5 20:14:40 2016
New Revision: 5385

URL: http://svn.gna.org/viewcvs/getfem?rev=5385&view=rev
Log:
a copy operator for bgeot::tensor<T>

Modified:
    trunk/getfem/src/getfem/bgeot_tensor.h

Modified: trunk/getfem/src/getfem/bgeot_tensor.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_tensor.h?rev=5385&r1=5384&r2=5385&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_tensor.h      (original)
+++ trunk/getfem/src/getfem/bgeot_tensor.h      Wed Oct  5 20:14:40 2016
@@ -260,11 +260,6 @@
         init(i, j, k, l);
     }
 
-    tensor(const multi_index &c) { init(c); }
-    tensor(size_type i, size_type j, size_type k, size_type l)
-    { init(multi_index(i, j, k, l)); }
-    tensor(void) {}
-
     /** reduction of tensor t with respect to index ni with matrix m:
      *  t(...,j,...) <-- t(...,i,..) m(i, j)
      */
@@ -305,6 +300,21 @@
 
     tensor<T>& operator /=(const scalar_type w)
     { gmm::scale(this->as_vector(), scalar_type(1)/w); return *this; }
+
+    tensor &operator =(const tensor &t) {
+      if (this->size() != t.size()) this->resize(t.size());
+      std::copy(t.begin(), t.end(), this->begin());
+      if (sizes_.size() != t.sizes_.size()) sizes_.resize(t.sizes_.size());
+      std::copy(t.sizes_.begin(), t.sizes_.end(), sizes_.begin());
+      if (coeff.size() != t.coeff.size()) coeff.resize(t.coeff.size());
+      std::copy(t.coeff.begin(), t.coeff.end(), coeff.begin());
+      return *this;
+    }
+
+    tensor(const multi_index &c) { init(c); }
+    tensor(size_type i, size_type j, size_type k, size_type l)
+    { init(multi_index(i, j, k, l)); }
+    tensor(void) {}
   };
 
   template<class T> void tensor<T>::mat_transp_reduction




reply via email to

[Prev in Thread] Current Thread [Next in Thread]