mirror of
https://github.com/triqs/dft_tools
synced 2024-11-01 11:43:47 +01:00
7cf7d09c77
- The issue comes from the fact that the default generated += and co by the Python API is the one for immutable types, like int. - Indeed, in python, for an int : x=1 id(x) 140266967205832 x+=1 id(x) 140266967205808 - For a mutable type, like a gf, it is necessary to add explicitly the xxx_inplace_add functions. - Added : - the generation of the inplace_xxx functions - a method in class_ in the wrapper generator that deduce all += operator from the + operators. - this assumes that the +=, ... are defined in C++. - The generation of such operators are optional, with option with_inplace_operators in the arithmetic flag. - Also, added the overload g += M and g -= M for g : GfImfreq, M a complex matrix. Mainly for legacy Python codes.
13 lines
268 B
Plaintext
13 lines
268 B
Plaintext
Before:
|
|
G['up'] = 3.14159265359j
|
|
G['dn'] = 3.14159265359j
|
|
After G['up'] += G['dn']:
|
|
G['up'] = 6.28318530718j
|
|
G['dn'] = 3.14159265359j
|
|
After g_up += g_dn:
|
|
G['up'] = 9.42477796077j
|
|
G['dn'] = 3.14159265359j
|
|
After G += G:
|
|
G['up'] = 18.8495559215j
|
|
G['dn'] = 6.28318530718j
|