From 59b969dbd30e68e586eb74487292a753b92ecea8 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Mon, 30 Dec 2013 18:06:36 +0100 Subject: [PATCH] arrays: fix mapped_function (conj overload) - conj overload should return complex, as in standard. - changed the test output for mapped_function. - fixed make_matrix_view and example in doc. --- doc/reference/c++/arrays/algebras.rst | 2 +- test/triqs/arrays/mapped_functions.output | 12 ++++++------ triqs/arrays/mapped_functions.hpp | 6 +++--- triqs/arrays/matrix.hpp | 5 +---- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/doc/reference/c++/arrays/algebras.rst b/doc/reference/c++/arrays/algebras.rst index 0abeb66c..dabaaeb0 100644 --- a/doc/reference/c++/arrays/algebras.rst +++ b/doc/reference/c++/arrays/algebras.rst @@ -46,7 +46,7 @@ However, you can always use e.g. `matrix_view` from a array of rank 2 : //M + A; // --> ERROR. Rejected by the compiler. M + make_matrix_view(A); //--> OK. } - + .. note:: Making such a view is very cheap, it only copies the index systems. Nevertheless diff --git a/test/triqs/arrays/mapped_functions.output b/test/triqs/arrays/mapped_functions.output index 5843c2db..52a1789e 100644 --- a/test/triqs/arrays/mapped_functions.output +++ b/test/triqs/arrays/mapped_functions.output @@ -43,9 +43,9 @@ [[2.71828,7.38906] [20.0855,54.5982]] (make_matrix(conj(A))) ---> -[[1,3,5] - [2,4,6] - [3,5,7]] +[[(1,0),(3,0),(5,0)] + [(2,0),(4,0),(6,0)] + [(3,0),(5,0),(7,0)]] (A) ---> [[1,3,5] [2,4,6] @@ -91,9 +91,9 @@ [[2.71828,7.38906] [20.0855,54.5982]] (make_matrix(conj(A))) ---> -[[1,3,5] - [2,4,6] - [3,5,7]] +[[(1,0),(3,0),(5,0)] + [(2,0),(4,0),(6,0)] + [(3,0),(5,0),(7,0)]] (A) ---> [[1,3,5] [2,4,6] diff --git a/triqs/arrays/mapped_functions.hpp b/triqs/arrays/mapped_functions.hpp index d0a4eecd..89f27290 100644 --- a/triqs/arrays/mapped_functions.hpp +++ b/triqs/arrays/mapped_functions.hpp @@ -27,9 +27,9 @@ namespace triqs { namespace arrays { // not for libc++ (already defined) #if !defined(_LIBCPP_VERSION) // complex conjugation for integers - inline int conj(int x) { return x; } - inline long conj(long x) { return x; } - inline long long conj(long long x) { return x; } + inline std::complex conj(int x) { return x; } + inline std::complex conj(long x) { return x; } + inline std::complex conj(long long x) { return x; } inline std::complex conj(double x) { return x; } #endif diff --git a/triqs/arrays/matrix.hpp b/triqs/arrays/matrix.hpp index 9d3ac940..1562ef3d 100644 --- a/triqs/arrays/matrix.hpp +++ b/triqs/arrays/matrix.hpp @@ -208,18 +208,15 @@ namespace triqs { namespace arrays { #undef _IMPL_MATRIX_COMMON #undef IMPL_TYPE - - /* template matrix_view make_matrix_view(ArrayType const & a) { static_assert(ArrayType::rank ==2, "make_matrix_view only works for array of rank 2"); return a; } -*/ template - matrix //, ArrayType::opt_flags, ArrayType::traversal_order> + matrix make_matrix(ArrayType const & a) { static_assert(ArrayType::domain_type::rank ==2, "make_matrix only works for array of rank 2"); return a;