← Back to team overview

dolfin team mailing list archive

Re: PyDOLFIN and overloading '='

 

Johan Hake wrote:
On Saturday 20 June 2009 13:10:46 Garth N. Wells wrote:
I tried to do

   u0.vector() = u1.vector()

where u0 and u1 are both discrete functions, in PyDOLFIN but it doesn't
work so I'm using

   u0.vector().assign( u1.vector() )

This is the correct way to do it. Assignment operators are just ignored for the dynamically typed languges supported by SWIG. We therefore rename the foo.operator= to foo.assign. However for the Vector and Matrix interfaces we also support the numpy lookalike assignment:

  v[:] = u

and

  A[:,:] = B

I have talked to Anders about removing both v.assign and v.set(double *) and "force" the PyDOLFIN users to use the numpy assignments.


Is there any difference in performance between the two?

Garth

Johan


Is there a fundamental reason why '=' can't be used or does SWIG just
need to be told how to overload '=' for vectors?

Garth
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev



Follow ups

References