When multiplying two Green functions with different shape, for example for downfolding / upfolding purposes, triqs gives an error, that the dimensions do not match. A simple example would be:
from triqs.gf import *
iw_mesh = MeshImFreq(beta=40, S='Fermion', n_max=1025)
# create upfolded Gf with 5x5 dim
G_upf = Gf(mesh=iw_mesh, target_shape=[5, 5])
# create downfolded target Gf with 3x3 dim
G_dnf = Gf(mesh=iw_mesh, target_shape=[3, 3])
# downfolding projector from the 5 to 3 orb
downfolding = Gf(mesh=iw_mesh, target_shape=[3,5])
# the downfolding / projection from 5 to 3 orbitals fails
# this should work since we are doing [3,5]x[5,5]x[5,3]
G_dnf << downfolding*(G_upf*downfolding.transpose().conjugate())
This should work as the multiplication of matrices of these dimensions makes sense and is often used for downfolding. The code gives the error:
Traceback (most recent call last):
File "/mnt/home/ahampel/Dropbox/git/triqs3/triqs.src/test/python/base/issue_gf_mult_dim.py", line 36, in <module>
G_dnf << downfolding*(G_upf*downfolding.transpose().conjugate())
File "/mnt/home/ahampel/git/triqs-3.x_unstable/triqs_fix_gf_mult.build/python/triqs/gf/gf.py", line 537, in __mul__
c.__imul__impl(y)
File "/mnt/home/ahampel/git/triqs-3.x_unstable/triqs_fix_gf_mult.build/python/triqs/gf/gf.py", line 494, in __imul__impl
d_self[n] = np.dot(d_self[n], d_args[n]) # put to C if too slow.
ValueError: could not broadcast input array from shape (5,3) into shape (5,5)
Triqs expect the outcoming Gf to have the same shape as the first input Gf.
This PR adds a simple test that fails at the moment and should be fixed.
When multiplying two Green functions with different shape, for example for downfolding / upfolding purposes, triqs gives an error, that the dimensions do not match. A simple example would be:
This should work as the multiplication of matrices of these dimensions makes sense and is often used for downfolding. The code gives the error:
Triqs expect the outcoming Gf to have the same shape as the first input Gf.
This PR adds a simple test that fails at the moment and should be fixed.
Thanks.