From 89021f7eb488939c3f726887d6bfd8c0ab48adb7 Mon Sep 17 00:00:00 2001 From: Wenqing Wang <wenqing.wang@ufz.de> Date: Wed, 26 Jan 2022 11:38:12 +0100 Subject: [PATCH] [EigenVector] Added a member function to set several entries --- MathLib/LinAlg/Eigen/EigenVector.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MathLib/LinAlg/Eigen/EigenVector.h b/MathLib/LinAlg/Eigen/EigenVector.h index 6b81a1c2425..22f9b93450a 100644 --- a/MathLib/LinAlg/Eigen/EigenVector.h +++ b/MathLib/LinAlg/Eigen/EigenVector.h @@ -78,6 +78,17 @@ public: /// add entry void add(IndexType rowId, double v) { vec_[rowId] += v; } + /// set entries + template <class T_SUBVEC> + void set(const std::vector<IndexType>& pos, const T_SUBVEC& sub_vec) + { + auto const length = pos.size(); + for (std::size_t i = 0; i < length; ++i) + { + set(pos[i], sub_vec[i]); + } + } + /// add entries template <class T_SUBVEC> void add(const std::vector<IndexType>& pos, const T_SUBVEC& sub_vec) -- GitLab