From f0ea6074798e7f4d595980a8a9d0f4f16fff08bc Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Sat, 15 Oct 2016 13:34:21 +0200
Subject: [PATCH] [MaL] more conveniently map to Eigen::VectorXd

---
 MathLib/LinAlg/Eigen/EigenMapTools.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/MathLib/LinAlg/Eigen/EigenMapTools.h b/MathLib/LinAlg/Eigen/EigenMapTools.h
index e4095e73241..c401f16089f 100644
--- a/MathLib/LinAlg/Eigen/EigenMapTools.h
+++ b/MathLib/LinAlg/Eigen/EigenMapTools.h
@@ -188,6 +188,28 @@ Eigen::Map<Vector> toVector(std::vector<double>& data,
     return {data.data(), size};
 }
 
+/*! Creates an Eigen mapped vector from the given data vector.
+ *
+ * This is a convienence method which makes the specification of dynamically
+ * allocated Eigen vectors as return type easier.
+ */
+inline Eigen::Map<const Eigen::VectorXd> toVector(
+    std::vector<double> const& data)
+{
+    return {data.data(), static_cast<Eigen::VectorXd::Index>(data.size())};
+}
+
+/*! Creates an Eigen mapped vector from the given data vector.
+ *
+ * This is a convienence method which makes the specification of dynamically
+ * allocated Eigen vectors as return type easier.
+ */
+inline Eigen::Map<Eigen::VectorXd> toVector(
+    std::vector<double>& data)
+{
+    return {data.data(), static_cast<Eigen::VectorXd::Index>(data.size())};
+}
+
 }  // MathLib
 
 #endif  // MATHLIB_EIGENMAPTOOLS_H
-- 
GitLab