From 3be9f5c4d7c114eeaf7ce372cccc0e1a2734bac9 Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 16 Apr 2015 13:25:20 +0200 Subject: Constructing a Matrix/Array with implicit transpose could lead to memory leaks. Also reduced code duplication for Matrix/Array constructors --- Eigen/src/Core/Array.h | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'Eigen/src/Core/Array.h') 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 EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE Array& operator=(const ArrayBase& other) + EIGEN_STRONG_INLINE Array& operator=(const DenseBase& 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 - EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE Array(const ArrayBase& 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 - EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE Array(const ReturnByValue& other) - { - Base::_check_template_params(); - Base::resize(other.rows(), other.cols()); - other.evalTo(*this); - } + : Base(other) + { } /** \sa MatrixBase::operator=(const EigenBase&) */ template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array(const EigenBase &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(); } -- cgit v1.2.3