diff --git a/src/array.hpp b/src/array.hpp index c5c3a9f13e24cf76042b9eaee1646dacd55bbbf1..e1f00eb3dd20c758ba6c54645cc8085b7cefd895 100644 --- a/src/array.hpp +++ b/src/array.hpp @@ -152,12 +152,12 @@ public: typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> EigenMatrix; typedef Eigen::Map<EigenMatrix, 0, Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic> > EigenMap; - operator EigenMap() const + EigenMap to_matrix() const { static_assert(NDim == 2, "matrixes must be two-dimensional"); - return EigenMap((Scalar *)data_.data() + offset_, - shape_[0], shape_[1], - {(long)stride_[1], (long)stride_[0]}); + return {(Scalar *)data_.data() + offset_, + shape_[0], shape_[1], + {(long)stride_[1], (long)stride_[0]}}; } }; diff --git a/src/main.cpp b/src/main.cpp index f4aaac31bf2080e41e95595bb734346cff03c52a..70ec82cfaf7db2a920a155f68a2cbb28f419a837 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ int main() std::cout << Q.index(0u,0u) << std::endl; - Array<ADComplex,3>::EigenMap mat(Q); + auto mat = Q.to_matrix(); mat(1,1) = 123;