aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core
diff options
context:
space:
mode:
authorGravatar David Tellenbach <david.tellenbach@tellnotes.org>2019-03-14 10:18:24 +0100
committerGravatar David Tellenbach <david.tellenbach@tellnotes.org>2019-03-14 10:18:24 +0100
commit97f9a46cb90bc66e402c3873b5bf7d6ed58252d0 (patch)
tree613bba78aed545fa6dd7c2725401577fe42a41ee /Eigen/src/Core
parent45ab514fe2a2d0b63d6a8552814ce3de7687d50d (diff)
PR 593: Add variadtic ctor for DiagonalMatrix with unit tests
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h24
-rw-r--r--Eigen/src/Core/PlainObjectBase.h2
2 files changed, 25 insertions, 1 deletions
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h
index afab2f1b6..542685c65 100644
--- a/Eigen/src/Core/DiagonalMatrix.h
+++ b/Eigen/src/Core/DiagonalMatrix.h
@@ -178,6 +178,30 @@ class DiagonalMatrix
EIGEN_DEVICE_FUNC
inline DiagonalMatrix(const Scalar& x, const Scalar& y, const Scalar& z) : m_diagonal(x,y,z) {}
+ #if EIGEN_HAS_CXX11
+ /** \brief Construct a diagonal matrix with fixed size from an arbitrary number of coefficients. \cpp11
+ *
+ * There exists C++98 anologue constructors for fixed-size diagonal matrices having 2 or 3 coefficients.
+ *
+ * \warning To construct a diagonal matrix of fixed size, the number of values passed to this
+ * constructor must match the fixed dimension of \c *this.
+ *
+ * \sa DiagonalMatrix(const Scalar&, const Scalar&)
+ * \sa DiagonalMatrix(const Scalar&, const Scalar&, const Scalar&)
+ */
+ template <typename... ArgTypes>
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ DiagonalMatrix(const Scalar& a0, const Scalar& a1, const Scalar& a2, const ArgTypes&... args)
+ : m_diagonal(a0, a1, a2, args...) {}
+
+ /** \brief Constructs a DiagonalMatrix and initializes it by elements given by an initializer list of initializer
+ * lists \cpp11
+ */
+ EIGEN_DEVICE_FUNC
+ explicit EIGEN_STRONG_INLINE DiagonalMatrix(const std::initializer_list<std::initializer_list<Scalar>>& list)
+ : m_diagonal(list) {}
+ #endif // EIGEN_HAS_CXX11
+
/** Copy constructor. */
template<typename OtherDerived>
EIGEN_DEVICE_FUNC
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h
index bae186ecb..4dbc40e5b 100644
--- a/Eigen/src/Core/PlainObjectBase.h
+++ b/Eigen/src/Core/PlainObjectBase.h
@@ -532,7 +532,7 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
* \only_for_vectors
*
* This constructor is for 1D array or vectors with more than 4 coefficients.
- * There exists c++98 anologue constructors for fixed-size array/vector having 1, 2, 3, or 4 coefficients.
+ * There exists C++98 anologue constructors for fixed-size array/vector having 1, 2, 3, or 4 coefficients.
*
* \warning To construct a column (resp. row) vector of fixed length, the number of values passed to this
* constructor must match the the fixed number of rows (resp. columns) of \c *this.