3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-24 13:23:37 +01:00

Fix for issue #134

There was a bug in the transpose of the indices. Added a test.
This commit is contained in:
Michel Ferrero 2014-10-09 12:30:50 +02:00
parent 0fd82579e3
commit 173a97d07c
5 changed files with 26 additions and 16 deletions

View File

@ -125,15 +125,16 @@ def invert(self):
#---------------------------------------------------
def transpose(self):
"""Transposes the GF Bloc: return a new transposed view"""
### WARNING: this depends on the C++ layering ....
return self.__class__(
indices = list(self.indices),
mesh = self.mesh,
data = self.data.transpose( (0, 2, 1) ),
tail = self.tail.transpose(),
name = self.name+'(t)')
# FIXME NEVER USED CLEAN UP
#def transpose(self):
# """Transposes the GF Bloc: return a new transposed view"""
# ### WARNING: this depends on the C++ layering ....
# return self.__class__(
# indices = list(self.indices),
# mesh = self.mesh,
# data = self.data.transpose( (0, 2, 1) ),
# tail = self.tail.transpose(),
# name = self.name+'(t)')
#---------------------------------------------------

View File

@ -21,3 +21,5 @@ add_triqs_test_hdf(pade " -d 1.e-6")
# Bug fix #112
add_triqs_test_txt(gf_inplace_112)
# Bug fix #134
add_triqs_test_txt(gf_transpose)

View File

@ -0,0 +1,4 @@
Old data shape = (1000, 3, 5)
Old tail shape = (10, 3, 5)
New data shape = (1000, 5, 3)
New tail shape = (10, 5, 3)

View File

@ -0,0 +1,9 @@
from pytriqs.gf.local import *
g = GfImFreq(indicesR = range(5), indicesL = range(3), beta = 40, n_points = 1000)
gt = g.transpose()
print "Old data shape = ", g.data.shape
print "Old tail shape = ", g.tail.data.shape
print "New data shape = ", gt.data.shape
print "New tail shape = ", gt.tail.data.shape

View File

@ -162,13 +162,7 @@ namespace gfs {
}
inline indices_2 transpose(indices_2 const &x) {
auto ind2 = x.ind;
if (x.ind.size() > 0) {
int im = x.ind.size(), jm = x.ind[0].size();
for (int i = 0; i < im; ++i)
for (int j = 0; j < jm; ++j) ind2[i][j] = x.ind[j][i];
}
return indices_2(std::move(ind2));
return std::vector<std::vector<std::string>> {x.ind[1],x.ind[0]};
}
//------------------------------------------------------