diff options
author | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2015-04-16 13:25:20 +0200 |
---|---|---|
committer | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2015-04-16 13:25:20 +0200 |
commit | 3be9f5c4d7c114eeaf7ce372cccc0e1a2734bac9 (patch) | |
tree | 10c9b619ee7a55b0fef3e6f12650404df78262d1 /Eigen/src/Core/Array.h | |
parent | e0cff9ae0db1f37d9d463f8af09fd8298a6ccd0d (diff) |
Constructing a Matrix/Array with implicit transpose could lead to memory leaks.
Also reduced code duplication for Matrix/Array constructors
Diffstat (limited to 'Eigen/src/Core/Array.h')
-rw-r--r-- | Eigen/src/Core/Array.h | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h index 9a1f30bc8..d8a277143 100644 --- a/Eigen/src/Core/Array.h +++ b/Eigen/src/Core/Array.h @@ -74,7 +74,7 @@ class Array { return Base::operator=(other); } - + /** Set all the entries to \a value. * \sa DenseBase::setConstant(), DenseBase::fill() */ @@ -101,7 +101,7 @@ class Array */ template<typename OtherDerived> EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE Array& operator=(const ArrayBase<OtherDerived>& other) + EIGEN_STRONG_INLINE Array& operator=(const DenseBase<OtherDerived>& other) { return Base::_set(other); } @@ -222,43 +222,18 @@ class Array m_storage.data()[3] = val3; } - /** Constructor copying the value of the expression \a other */ - template<typename OtherDerived> - EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE Array(const ArrayBase<OtherDerived>& other) - : Base(other.rows() * other.cols(), other.rows(), other.cols()) - { - Base::_check_template_params(); - Base::_set_noalias(other); - } /** Copy constructor */ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array(const Array& other) - : Base(other.rows() * other.cols(), other.rows(), other.cols()) - { - Base::_check_template_params(); - Base::_set_noalias(other); - } - /** Copy constructor with in-place evaluation */ - template<typename OtherDerived> - EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE Array(const ReturnByValue<OtherDerived>& other) - { - Base::_check_template_params(); - Base::resize(other.rows(), other.cols()); - other.evalTo(*this); - } + : Base(other) + { } /** \sa MatrixBase::operator=(const EigenBase<OtherDerived>&) */ template<typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array(const EigenBase<OtherDerived> &other) - : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols()) - { - Base::_check_template_params(); - Base::_resize_to_match(other); - *this = other; - } + : Base(other.derived()) + { } EIGEN_DEVICE_FUNC inline Index innerStride() const { return 1; } EIGEN_DEVICE_FUNC inline Index outerStride() const { return this->innerSize(); } |