Re: [Dolfin] Operator overloading for Vector

2010-06-18 Thread Garth N. Wells
On 17/06/10 14:23, Florian Rathgeber wrote: Hi, I was wondering why +=, *=, etc. are overloaded in the Vector class, but not addition of Vectors and multiplication of Vectors by scalars. Hence I tried the following: namespace dolfin { Vector operator*( double a, const Vector& v ) {

Re: [Dolfin] Operator overloading for Vector

2010-06-17 Thread Johan Hake
Florian! I cannot really follow your implementation of the binary addition operator. See http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html For an extensive discussion of the subject. But yes, the binary linear algebra operators were not implemented in C++ because of of

[Dolfin] Operator overloading for Vector

2010-06-17 Thread Florian Rathgeber
Hi, I was wondering why +=, *=, etc. are overloaded in the Vector class, but not addition of Vectors and multiplication of Vectors by scalars. Hence I tried the following: namespace dolfin { Vector operator*( double a, const Vector& v ) { Vector res( v ); res *= a; return res;