aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Array.h
diff options
context:
space:
mode:
authorGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2014-06-23 11:15:42 +0200
committerGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2014-06-23 11:15:42 +0200
commit3117036b80075390dbc46f60aa0d595e5a44661b (patch)
treef8f5500d6df112ee06304800f844009a5c3cfbca /Eigen/src/Core/Array.h
parent1c3843bf867742a40e0c6b83c1200247bef5cde5 (diff)
Fix bug #826: Allow initialization of 1x1 Arrays/Matrices by passing a value.
Diffstat (limited to 'Eigen/src/Core/Array.h')
-rw-r--r--Eigen/src/Core/Array.h38
1 files changed, 20 insertions, 18 deletions
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h
index 8d2906a10..28d6f1443 100644
--- a/Eigen/src/Core/Array.h
+++ b/Eigen/src/Core/Array.h
@@ -144,24 +144,16 @@ class Array
}
#endif
- /** Constructs a vector or row-vector with given dimension. \only_for_vectors
- *
- * Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
- * it is redundant to pass the dimension here, so it makes more sense to use the default
- * constructor Matrix() instead.
- */
+
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
+ template<typename T>
EIGEN_DEVICE_FUNC
- EIGEN_STRONG_INLINE explicit Array(Index dim)
- : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
+ EIGEN_STRONG_INLINE explicit Array(const T& x)
{
Base::_check_template_params();
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array)
- eigen_assert(dim >= 0);
- eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
- EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
+ Base::template _init1<T>(x);
}
- #ifndef EIGEN_PARSED_BY_DOXYGEN
template<typename T0, typename T1>
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1)
@@ -170,11 +162,23 @@ class Array
this->template _init2<T0,T1>(val0, val1);
}
#else
- /** constructs an uninitialized matrix with \a rows rows and \a cols columns.
+ /** \brief Constructs a fixed-sized array initialized with coefficients starting at \a data */
+ EIGEN_DEVICE_FUNC explicit Array(const Scalar *data);
+ /** Constructs a vector or row-vector with given dimension. \only_for_vectors
*
- * This is useful for dynamic-size matrices. For fixed-size matrices,
+ * Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
+ * it is redundant to pass the dimension here, so it makes more sense to use the default
+ * constructor Array() instead.
+ */
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE explicit Array(Index dim);
+ /** constructs an initialized 1x1 Array with the given coefficient */
+ Array(const Scalar& value);
+ /** constructs an uninitialized array with \a rows rows and \a cols columns.
+ *
+ * This is useful for dynamic-size arrays. For fixed-size arrays,
* it is redundant to pass these parameters, so one should use the default constructor
- * Matrix() instead. */
+ * Array() instead. */
Array(Index rows, Index cols);
/** constructs an initialized 2D vector with given coefficients */
Array(const Scalar& val0, const Scalar& val1);
@@ -202,8 +206,6 @@ class Array
m_storage.data()[3] = val3;
}
- EIGEN_DEVICE_FUNC explicit Array(const Scalar *data);
-
/** Constructor copying the value of the expression \a other */
template<typename OtherDerived>
EIGEN_DEVICE_FUNC