TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
139 stars 72 forks source link

Cannot use transpose() on a matrix_proxy object #798

Closed krivenko closed 2 years ago

krivenko commented 3 years ago

Description

Compilation fails when I try to call transpose() on a matrix view object returned by a GF subscript operator. Similar code used to work with TRIQS 1.4.

Steps to Reproduce

Minimal example based on test/c++/gfs/multivar/gf_2times.cpp:

  auto m  = gf_mesh<retime>{0, 10, 99};
  auto G  = gf<cartesian_product<retime, retime>>{{m, m}, {2, 2}};

  transpose(G[{0, 0}]); // Fails
  transpose(matrix<std::complex<double>>(G[{0, 0}])); // This one compiles though

Compilation error message:

[ 74%] Building CXX object test/c++/gfs/multivar/CMakeFiles/gf_2times.dir/gf_2times.cpp.o
In file included from /home/igor/Physics/TRIQS/3.0/libs.git/test/c++/gfs/multivar/gf_2times.cpp:20:
In file included from /home/igor/Physics/TRIQS/3.0/libs.git/c++/triqs/test_tools/gfs.hpp:21:
In file included from /home/igor/Physics/TRIQS/3.0/libs.git/c++/triqs/test_tools/./arrays.hpp:24:
In file included from /home/igor/Physics/TRIQS/3.0/libs.git/c++/triqs/./gfs/gf/../../arrays.hpp:27:
/home/igor/Physics/TRIQS/3.0/libs.git/c++/triqs/arrays/./expression_template/../linalg/../matrix.hpp:312:118: error: no member named 'transpose' in 'triqs::arrays::matrix_proxy<triqs::arrays::array<std::complex<double>, 4> &, std::tuple<long, long> >'
    template <typename M> TYPE_ENABLE_IF(typename M::view_type, ImmutableMatrix<M>) transpose(M const &m) { return m.transpose(); }
                                                                                                                   ~ ^
/home/igor/Physics/TRIQS/3.0/libs.git/test/c++/gfs/multivar/gf_2times.cpp:28:3: note: in instantiation of function template specialization 'triqs::arrays::transpose<triqs::arrays::matrix_proxy<triqs::arrays::array<std::complex<double>, 4> &, std::tuple<long, long> > >' requested here
  transpose(G[{0, 0}]);
  ^
1 error generated.

Versions

Latest TRIQS 3.0.x branch. Clang 10.

Wentzell commented 2 years ago

Dear @krivenko,

Thank you for pointing this out!

This functionality was restored on the triqs/unstable branch and will be available in the coming 3.1 release. Please use this branch in the meantime or wait for the release.

I have extended the gf_base.cpp to cover your example

https://github.com/TRIQS/triqs/blob/63fa2a02446f49d42837aec17759c47c901df85b/test/c%2B%2B/gfs/gf_base.cpp#L224-L225