dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #14046
Re: PyDOLFIN and overloading '='
On Mon, Jun 22, 2009 at 10:44 AM, Garth N. Wells<gnw20@xxxxxxxxx> wrote:
> 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
The slicing means that the actual memory of A is overwritten. I guess
that is the same as the operator= did before?
Hence, I guess there will be no big difference.
Ola
>> 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
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>
--
Ola Skavhaug
Follow ups
References