aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2019-01-22 17:08:47 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2019-01-22 17:08:47 +0100
commit80f81f9c4b01cc4f513c5b92c52c5a0efb68ecc3 (patch)
tree6e9c61e63dcb690afb48f40e1d470ed2c735ceff /Eigen/src
parentdb152b9ee6effd3799f70a621f495c427cb3c33f (diff)
Cleanup SFINAE in Array/Matrix(initializer_list) ctors and minor doc editing.
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Core/Array.h64
-rw-r--r--Eigen/src/Core/Matrix.h65
-rw-r--r--Eigen/src/Core/PlainObjectBase.h22
3 files changed, 80 insertions, 71 deletions
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h
index 7ef37de7c..ff0b69b84 100644
--- a/Eigen/src/Core/Array.h
+++ b/Eigen/src/Core/Array.h
@@ -180,13 +180,13 @@ class Array
}
#if EIGEN_HAS_CXX11
- template<typename T>
+ protected:
+ enum { IsFixedSizeVectorAtCompileTime = RowsAtCompileTime != Dynamic && ColsAtCompileTime != Dynamic && IsVectorAtCompileTime == 1 };
+ public:
+ template<typename T,
+ typename = typename internal::enable_if<IsFixedSizeVectorAtCompileTime && internal::is_same<T, Scalar>::value>::type>
EIGEN_DEVICE_FUNC
- explicit EIGEN_STRONG_INLINE Array(const std::initializer_list<T>& list,
- typename internal::enable_if<internal::is_same<T, Scalar>::value, T>::type* = 0,
- typename internal::enable_if<RowsAtCompileTime != Dynamic
- && ColsAtCompileTime != Dynamic
- && IsVectorAtCompileTime == 1, T>::type* = 0) : Base(list) {}
+ explicit EIGEN_STRONG_INLINE Array(const std::initializer_list<T>& list) : Base(list) {}
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Array(const std::initializer_list<std::initializer_list<Scalar> >& list) : Base(list) {}
@@ -219,35 +219,39 @@ class Array
* Example: \include Array_initializer_list2_cxx11.cpp
* Output: \verbinclude Array_initializer_list2_cxx11.out
*
- * \sa Array::Array(const Scalar& val0, const Scalar& val1)
- * \sa Array::Array(const Scalar& val0, const Scalar& val1, const Scalar& val2) */
+ * \sa Array(const std::initializer_list<std::initializer_list<Scalar> >&)
+ */
EIGEN_DEVICE_FUNC
explicit EIGEN_STRONG_INLINE Array(const std::initializer_list<Scalar>& list);
- /**
- * \brief Constructs an array and initializes it by elements given by an initializer list of initializer lists \cpp11
- *
- * This constructor distinguishes between the construction of arbitrary array and arrays with one fixed dimension,
- *
- * In the general case, the constructor takes an initializer list, representing the array rows, that contains for
- * each row an initializer list, representing a single column, containing scalar values. Each of the inner
- * initializer lists must contain the same number of elements.
- *
- * In the case of array with one fixed dimension, an initializer list containing just one other initializer list
- * that contains the array elements can be passed. Therefore \c Array<int,\c Dynamic,\c 1>\c {{1,\c 2,\c 3,\c 4}} is
- * legal and the more verbose syntax \c Array<int,\c Dynamic,\c 1>\c {{1},\c {2},\c {3},\c {4}} can be avoided.
- *
- * \warning In the case of fixed-sized arrays, the initializer list size must be equal to the array \a rows rows
- * and \a cols columns.
- *
- * Example: \include Array_initializer_list_cxx11.cpp
- * Output: \verbinclude Array_initializer_list_cxx11.out
- */
+ /** \brief Constructs an array and initializes it from the coefficients given as initializer-lists grouped by row. \cpp11
+ *
+ * In the general case, the constructor takes a list of rows, each row being represented as a list of coefficients:
+ *
+ * Example: \include Array_initializer_list_23_cxx11.cpp
+ * Output: \verbinclude Array_initializer_list_23_cxx11.out
+ *
+ * Each of the inner initializer lists must contain the exact same number of elements, otherwise an assertion is triggered.
+ *
+ * In the case of a compile-time column 1D array, implicit transposition from a single row is allowed.
+ * Therefore <code> Array<int,Dynamic,1>{{1,2,3,4,5}}</code> is legal and the more verbose syntax
+ * <code>Array<int,Dynamic,1>{{1},{2},{3},{4},{5}}</code> can be avoided:
+ *
+ * Example: \include Array_initializer_list_vector_cxx11.cpp
+ * Output: \verbinclude Array_initializer_list_vector_cxx11.out
+ *
+ * In the case of fixed-sized arrays, the initializer list sizes must exactly match the array sizes,
+ * and implicit transposition is allowed for compile-time 1D arrays only.
+ *
+ * \sa Array(const std::initializer_list<Scalar>&)
+ */
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Array(const std::initializer_list<std::initializer_list<Scalar> >& list);
#endif // end EIGEN_PARSED_BY_DOXYGEN
- /** constructs an initialized 3D vector with given coefficients */
+ /** constructs an initialized 3D vector with given coefficients
+ * \sa Array(const std::initializer_list<Scalar>&)
+ */
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2)
{
@@ -257,7 +261,9 @@ class Array
m_storage.data()[1] = val1;
m_storage.data()[2] = val2;
}
- /** constructs an initialized 4D vector with given coefficients */
+ /** constructs an initialized 4D vector with given coefficients
+ * \sa Array(const std::initializer_list<Scalar>&)
+ */
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2, const Scalar& val3)
{
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 5b375b41d..aaceceafe 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -303,13 +303,13 @@ class Matrix
}
#if EIGEN_HAS_CXX11
- template<typename T>
+ protected:
+ enum { IsFixedSizeVectorAtCompileTime = RowsAtCompileTime != Dynamic && ColsAtCompileTime != Dynamic && IsVectorAtCompileTime == 1 };
+ public:
+ template<typename T,
+ typename = typename internal::enable_if<IsFixedSizeVectorAtCompileTime && internal::is_same<T, Scalar>::value>::type>
EIGEN_DEVICE_FUNC
- explicit EIGEN_STRONG_INLINE Matrix(const std::initializer_list<T>& list,
- typename internal::enable_if<internal::is_same<T, Scalar>::value, T>::type* = 0,
- typename internal::enable_if<RowsAtCompileTime != Dynamic
- && ColsAtCompileTime != Dynamic
- && IsVectorAtCompileTime == 1, T>::type* = 0) : Base(list) {}
+ explicit EIGEN_STRONG_INLINE Matrix(const std::initializer_list<T>& list) : Base(list) {}
EIGEN_DEVICE_FUNC
explicit EIGEN_STRONG_INLINE Matrix(const std::initializer_list<std::initializer_list<Scalar>>& list) : Base(list) {}
@@ -358,37 +358,40 @@ class Matrix
* Example: \include Matrix_initializer_list2_cxx11.cpp
* Output: \verbinclude Matrix_initializer_list2_cxx11.out
*
- * \sa Matrix::Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
- * \sa Matrix::Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w) */
+ * \sa Matrix(const std::initializer_list<std::initializer_list<Scalar>>&)
+ */
EIGEN_DEVICE_FUNC
explicit EIGEN_STRONG_INLINE Matrix(const std::initializer_list<Scalar>& list);
- /**
- * \brief Constructs a matrix and initializes it by elements given by an initializer list of initializer lists \cpp11
- *
- * This constructor distinguishes between the construction of arbitrary matrices and matrices with one fixed dimension,
- * i.e., vectors or rowvectors.
- *
- * In the general case, the constructor takes an initializer list, representing the matrix rows, that contains for
- * each row an initializer list, representing a single column, containing scalar values. Each of the inner
- * initializer lists must contain the same number of elements.
- *
- * In the case of matrices with one fixed dimension, an initializer list containing just one other initializer list
- * that contains the matrix elements can be passed. Therefore \c VectorXi\c {{1,\c 2,\c 3,\c 4}} is legal and the more
- * verbose syntax \c VectorXi\c {{1},\c {2},\c {3},\c {4}} can be avoided.
- *
- * \warning In the case of fixed-sized matrices, the initializer list size must be equal to the matrix \a rows rows
- * and \a cols columns.
- *
- * Example: \include Matrix_initializer_list_cxx11.cpp
- * Output: \verbinclude Matrix_initializer_list_cxx11.out
- */
+ /** \brief Constructs a Matrix and initializes it from the coefficients given as initializer-lists grouped by row. \cpp11
+ *
+ * In the general case, the constructor takes a list of rows, each row being represented as a list of coefficients:
+ *
+ * Example: \include Matrix_initializer_list_23_cxx11.cpp
+ * Output: \verbinclude Matrix_initializer_list_23_cxx11.out
+ *
+ * Each of the inner initializer lists must contain the exact same number of elements, otherwise an assertion is triggered.
+ *
+ * In the case of a compile-time column vector, implicit transposition from a single row is allowed.
+ * Therefore <code>VectorXd{{1,2,3,4,5}}</code> is legal and the more verbose syntax
+ * <code>RowVectorXd{{1},{2},{3},{4},{5}}</code> can be avoided:
+ *
+ * Example: \include Matrix_initializer_list_vector_cxx11.cpp
+ * Output: \verbinclude Matrix_initializer_list_vector_cxx11.out
+ *
+ * In the case of fixed-sized matrices, the initializer list sizes must exactly match the matrix sizes,
+ * and implicit transposition is allowed for compile-time vectors only.
+ *
+ * \sa Matrix(const std::initializer_list<Scalar>&)
+ */
EIGEN_DEVICE_FUNC
explicit EIGEN_STRONG_INLINE Matrix(const std::initializer_list<std::initializer_list<Scalar>>& list);
#endif // end EIGEN_PARSED_BY_DOXYGEN
- /** \brief Constructs an initialized 3D vector with given coefficients */
+ /** \brief Constructs an initialized 3D vector with given coefficients
+ * \sa Matrix(const std::initializer_list<Scalar>&)
+ */
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
{
@@ -398,7 +401,9 @@ class Matrix
m_storage.data()[1] = y;
m_storage.data()[2] = z;
}
- /** \brief Constructs an initialized 4D vector with given coefficients */
+ /** \brief Constructs an initialized 4D vector with given coefficients
+ * \sa Matrix(const std::initializer_list<Scalar>&)
+ */
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
{
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h
index 1a996b0aa..04748e5e9 100644
--- a/Eigen/src/Core/PlainObjectBase.h
+++ b/Eigen/src/Core/PlainObjectBase.h
@@ -527,21 +527,19 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
}
#ifdef EIGEN_PARSED_BY_DOXYGEN
- /**
- * \brief Construct a vector with fixed number of rows or a rowvector with fixed number of
- * columns by passing an initializer list \cpp11
- *
- * \only_for_vectors
- *
- * \warning To construct a vector or rowvector of fixed size, the number of values passed through
- * the initializer list must match the the fixed number of rows in the vector case or
- * the fixed number of columns in the rowvector case. */
+ /** \brief Construct a row of column vector with fixed size from an initializer list of coefficients. \cpp11
+ *
+ * \only_for_vectors
+ *
+ * \warning To construct a column (resp. row) vector of fixed length, the number of values passed through
+ * the initializer list must match the the fixed number of rows (resp. columns) of \c *this.
+ */
EIGEN_DEVICE_FUNC
explicit EIGEN_STRONG_INLINE PlainObjectBase(const std::initializer_list<Scalar>& list);
- /**
- * \brief Constructs a Matrix or Array and initializes it by elements given by an initializer list of initializer
- * lists \cpp11 */
+ /** \brief Constructs a Matrix or Array and initializes it by elements given by an initializer list of initializer
+ * lists \cpp11
+ */
EIGEN_DEVICE_FUNC
explicit EIGEN_STRONG_INLINE PlainObjectBase(const std::initializer_list<std::initializer_list<Scalar>>& list);
#else // EIGEN_PARSED_BY_DOXYGEN