From a8a57e1c2d9558ac9a59e323d90542dbd96ed678 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen <pauli.t.virtanen@jyu.fi> Date: Tue, 2 Aug 2022 17:53:03 +0300 Subject: [PATCH] array: adjust eigen conversions --- src/action.hpp | 2 ++ src/array.hpp | 8 +++++--- src/main.cpp | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/action.hpp b/src/action.hpp index d220e3a..51e45b5 100644 --- a/src/action.hpp +++ b/src/action.hpp @@ -10,9 +10,11 @@ inline Scalar S_2(Array<Scalar,2> Q) { Q(0u,0u) = 1; Q(0u,1u) = 2; + Q(1u,1u) = 3; return Scalar(0); } #endif + diff --git a/src/array.hpp b/src/array.hpp index e1f00eb..b6ff32f 100644 --- a/src/array.hpp +++ b/src/array.hpp @@ -154,11 +154,13 @@ public: EigenMap to_matrix() const { - static_assert(NDim == 2, "matrixes must be two-dimensional"); + static_assert(NDim == 2, "matrix must be two-dimensional"); return {(Scalar *)data_.data() + offset_, - shape_[0], shape_[1], - {(long)stride_[1], (long)stride_[0]}}; + static_cast<Eigen::Index>(shape_[0]), static_cast<Eigen::Index>(shape_[1]), + {static_cast<Eigen::Index>(stride_[1]), static_cast<Eigen::Index>(stride_[0])}}; } + + operator EigenMap() const { return to_matrix(); } }; diff --git a/src/main.cpp b/src/main.cpp index 70ec82c..b45a36e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,7 @@ int main() auto mat = Q.to_matrix(); - mat(1,1) = 123; + mat = mat * mat; dump(Q0); std::cout << mat << std::endl; -- GitLab