aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Array
diff options
context:
space:
mode:
Diffstat (limited to 'Eigen/src/Array')
-rw-r--r--Eigen/src/Array/Array.h290
-rw-r--r--Eigen/src/Array/ArrayBase.h245
-rw-r--r--Eigen/src/Array/ArrayWrapper.h168
-rw-r--r--Eigen/src/Array/BooleanRedux.h14
-rw-r--r--Eigen/src/Array/CwiseOperators.h421
-rw-r--r--Eigen/src/Array/Norms.h8
-rw-r--r--Eigen/src/Array/Random.h20
-rw-r--r--Eigen/src/Array/Replicate.h21
-rw-r--r--Eigen/src/Array/Reverse.h13
-rw-r--r--Eigen/src/Array/Select.h31
-rw-r--r--Eigen/src/Array/VectorwiseOp.h7
11 files changed, 766 insertions, 472 deletions
diff --git a/Eigen/src/Array/Array.h b/Eigen/src/Array/Array.h
new file mode 100644
index 000000000..2f155aeeb
--- /dev/null
+++ b/Eigen/src/Array/Array.h
@@ -0,0 +1,290 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_ARRAY_H
+#define EIGEN_ARRAY_H
+
+template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
+struct ei_traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
+{
+ typedef DenseStorageArray DenseStorageType;
+};
+
+template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
+class Array
+ : public DenseStorageBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, ArrayBase, _Options>
+{
+ public:
+
+ typedef DenseStorageBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, ArrayBase, _Options> Base;
+ _EIGEN_DENSE_PUBLIC_INTERFACE(Array)
+
+ enum { Options = _Options };
+ typedef typename Base::PlainMatrixType PlainMatrixType;
+
+ protected:
+ using Base::m_storage;
+ public:
+ enum { NeedsToAlign = (!(Options&DontAlign))
+ && SizeAtCompileTime!=Dynamic && ((sizeof(Scalar)*SizeAtCompileTime)%16)==0 };
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
+
+ using Base::base;
+ using Base::coeff;
+ using Base::coeffRef;
+ using Base::operator=;
+ using Base::operator+=;
+ using Base::operator-=;
+ using Base::operator*=;
+ using Base::operator/=;
+
+ /** Copies the value of the expression \a other into \c *this with automatic resizing.
+ *
+ * *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized),
+ * it will be initialized.
+ *
+ * Note that copying a row-vector into a vector (and conversely) is allowed.
+ * The resizing, if any, is then done in the appropriate way so that row-vectors
+ * remain row-vectors and vectors remain vectors.
+ */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE Array& operator=(const ArrayBase<OtherDerived>& other)
+ {
+ return Base::_set(other);
+ }
+
+ /** This is a special case of the templated operator=. Its purpose is to
+ * prevent a default operator= from hiding the templated operator=.
+ */
+ EIGEN_STRONG_INLINE Array& operator=(const Array& other)
+ {
+ return Base::_set(other);
+ }
+
+ /** Default constructor.
+ *
+ * For fixed-size matrices, does nothing.
+ *
+ * For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix
+ * is called a null matrix. This constructor is the unique way to create null matrices: resizing
+ * a matrix to 0 is not supported.
+ *
+ * \sa resize(int,int)
+ */
+ EIGEN_STRONG_INLINE explicit Array() : Base()
+ {
+ Base::_check_template_params();
+ EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ }
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ // FIXME is it still needed ??
+ /** \internal */
+ Array(ei_constructor_without_unaligned_array_assert)
+ : Base(ei_constructor_without_unaligned_array_assert())
+ {
+ Base::_check_template_params();
+ EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ }
+#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.
+ */
+ EIGEN_STRONG_INLINE explicit Array(int dim)
+ : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
+ {
+ Base::_check_template_params();
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array)
+ ei_assert(dim > 0);
+ ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
+ EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ }
+
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
+ template<typename T0, typename T1>
+ EIGEN_STRONG_INLINE Array(const T0& x, const T1& y)
+ {
+ Base::_check_template_params();
+ this->template _init2<T0,T1>(x, y);
+ }
+ #else
+ /** constructs an uninitialized matrix with \a rows rows and \a cols columns.
+ *
+ * This is useful for dynamic-size matrices. For fixed-size matrices,
+ * it is redundant to pass these parameters, so one should use the default constructor
+ * Matrix() instead. */
+ Array(int rows, int cols);
+ /** constructs an initialized 2D vector with given coefficients */
+ Array(const Scalar& x, const Scalar& y);
+ #endif
+
+ /** constructs an initialized 3D vector with given coefficients */
+ EIGEN_STRONG_INLINE Array(const Scalar& x, const Scalar& y, const Scalar& z)
+ {
+ Base::_check_template_params();
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3)
+ m_storage.data()[0] = x;
+ m_storage.data()[1] = y;
+ m_storage.data()[2] = z;
+ }
+ /** constructs an initialized 4D vector with given coefficients */
+ EIGEN_STRONG_INLINE Array(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
+ {
+ Base::_check_template_params();
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4)
+ m_storage.data()[0] = x;
+ m_storage.data()[1] = y;
+ m_storage.data()[2] = z;
+ m_storage.data()[3] = w;
+ }
+
+ explicit Array(const Scalar *data);
+
+ /** Constructor copying the value of the expression \a other */
+ template<typename OtherDerived>
+ 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_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_STRONG_INLINE Array(const ReturnByValue<OtherDerived>& other)
+ {
+ Base::_check_template_params();
+ Base::resize(other.rows(), other.cols());
+ other.evalTo(*this);
+ }
+
+ /** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE Array(const AnyMatrixBase<OtherDerived> &other)
+ : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
+ {
+ Base::_check_template_params();
+ Base::resize(other.rows(), other.cols());
+ *this = other;
+ }
+
+ /** Override MatrixBase::swap() since for dynamic-sized matrices of same type it is enough to swap the
+ * data pointers.
+ */
+ template<typename OtherDerived>
+ void swap(ArrayBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
+ { this->_swap(other.derived()); }
+
+ #ifdef EIGEN_ARRAY_PLUGIN
+ #include EIGEN_ARRAY_PLUGIN
+ #endif
+
+ private:
+
+ template<typename MatrixType, typename OtherDerived, bool SwapPointers>
+ friend struct ei_matrix_swap_impl;
+};
+
+/** \defgroup arraytypedefs Global array typedefs
+ *
+ * \ingroup Array_Module
+ *
+ * Eigen defines several typedef shortcuts for most common 1D and 2D array types.
+ *
+ * The general patterns are the following:
+ *
+ * \c ArrayRowsColsType where \c Rows and \c Cols can be \c 2,\c 3,\c 4 for fixed size square matrices or \c X for dynamic size,
+ * and where \c Type can be \c i for integer, \c f for float, \c d for double, \c cf for complex float, \c cd
+ * for complex double.
+ *
+ * For example, \c Array33d is a fixed-size 3x3 array type of doubles, and \c ArrayXXf is a dynamic-size matrix of floats.
+ *
+ * There are also \c ArraySizeType which are self-explanatory. For example, \c Array4cf is
+ * a fixed-size 1D array of 4 complex floats.
+ *
+ * \sa class Array
+ */
+
+#define EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
+/** \ingroup arraytypedefs */ \
+typedef Array<Type, Size, Size> Array##SizeSuffix##SizeSuffix##TypeSuffix; \
+/** \ingroup matrixtypedefs */ \
+typedef Array<Type, Size, 1> Array##SizeSuffix##TypeSuffix;
+
+#define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
+/** \ingroup arraytypedefs */ \
+typedef Array<Type, Size, Dynamic> Array##Size##X##TypeSuffix; \
+/** \ingroup arraytypedefs */ \
+typedef Array<Type, Dynamic, Size> Array##X##Size##TypeSuffix;
+
+#define EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
+EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \
+EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \
+EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \
+EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
+EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
+EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
+EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
+
+EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int, i)
+EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float, f)
+EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double, d)
+EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
+EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
+
+#undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES
+#undef EIGEN_MAKE_ARRAY_TYPEDEFS
+
+#undef EIGEN_MAKE_ARRAY_TYPEDEFS_LARGE
+
+#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
+using Eigen::Matrix##SizeSuffix##TypeSuffix; \
+using Eigen::Vector##SizeSuffix##TypeSuffix; \
+using Eigen::RowVector##SizeSuffix##TypeSuffix;
+
+#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
+
+#define EIGEN_USING_ARRAY_TYPEDEFS \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \
+EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd)
+
+
+#endif // EIGEN_ARRAY_H
diff --git a/Eigen/src/Array/ArrayBase.h b/Eigen/src/Array/ArrayBase.h
new file mode 100644
index 000000000..ccc8b8373
--- /dev/null
+++ b/Eigen/src/Array/ArrayBase.h
@@ -0,0 +1,245 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_ARRAYBASE_H
+#define EIGEN_ARRAYBASE_H
+
+template<typename ExpressionType> class MatrixWrapper;
+
+/** \ingroup Array_Module
+ *
+ * \class ArrayBase
+ *
+ * \brief Base class for all 1D and 2D array, and related expressions
+ *
+ * An array is similar to a dense vector or matrix. While matrices are mathematical
+ * objects with well defined linear algebra operators, an array is just a collection
+ * of scalar values arranged in a one or two dimensionnal fashion. The main consequence,
+ * is that all operations applied to an array are performed coefficient wise. Furthermore,
+ * arays support scalar math functions of the c++ standard library, and convenient
+ * constructors allowing to easily write generic code working for both scalar values
+ * and arrays.
+ *
+ * This class is the base that is inherited by all array expression types.
+ *
+ * \param Derived is the derived type, e.g. an array type, or an expression, etc.
+ *
+ * \sa class ArrayBase
+ */
+template<typename Derived> class ArrayBase
+ : public DenseBase<Derived>
+{
+ public:
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ /** The base class for a given storage type. */
+ typedef ArrayBase StorageBaseType;
+ /** Construct the base class type for the derived class OtherDerived */
+ template <typename OtherDerived> struct MakeBase { typedef ArrayBase<OtherDerived> Type; };
+
+ using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
+ typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*;
+
+ class InnerIterator;
+
+ typedef typename ei_traits<Derived>::Scalar Scalar;
+ typedef typename ei_packet_traits<Scalar>::type PacketScalar;
+
+ typedef DenseBase<Derived> Base;
+ using Base::RowsAtCompileTime;
+ using Base::ColsAtCompileTime;
+ using Base::SizeAtCompileTime;
+ using Base::MaxRowsAtCompileTime;
+ using Base::MaxColsAtCompileTime;
+ using Base::MaxSizeAtCompileTime;
+ using Base::IsVectorAtCompileTime;
+ using Base::Flags;
+ using Base::CoeffReadCost;
+ using Base::_HasDirectAccess;
+
+ using Base::derived;
+ using Base::const_cast_derived;
+ using Base::rows;
+ using Base::cols;
+ using Base::size;
+ using Base::coeff;
+ using Base::coeffRef;
+ using Base::lazyAssign;
+ using Base::operator=;
+ using Base::operator+=;
+ using Base::operator-=;
+ using Base::operator*=;
+ using Base::operator/=;
+
+ typedef typename Base::RealScalar RealScalar;
+ typedef typename Base::CoeffReturnType CoeffReturnType;
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ /** \internal the plain matrix type corresponding to this expression. Note that is not necessarily
+ * exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const
+ * reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either
+ * PlainMatrixType or const PlainMatrixType&.
+ */
+ typedef Array<typename ei_traits<Derived>::Scalar,
+ ei_traits<Derived>::RowsAtCompileTime,
+ ei_traits<Derived>::ColsAtCompileTime,
+ AutoAlign | (ei_traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
+ ei_traits<Derived>::MaxRowsAtCompileTime,
+ ei_traits<Derived>::MaxColsAtCompileTime
+ > PlainMatrixType;
+
+
+ /** \internal Represents a matrix with all coefficients equal to one another*/
+ typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
+# include "../plugins/CommonCwiseUnaryOps.h"
+# include "../plugins/MatrixCwiseUnaryOps.h"
+# include "../plugins/ArrayCwiseUnaryOps.h"
+# include "../plugins/CommonCwiseBinaryOps.h"
+# include "../plugins/MatrixCwiseBinaryOps.h"
+# include "../plugins/ArrayCwiseBinaryOps.h"
+# ifdef EIGEN_ARRAYBASE_PLUGIN
+# include EIGEN_ARRAYBASE_PLUGIN
+# endif
+#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
+
+
+ /** Copies \a other into *this. \returns a reference to *this. */
+// template<typename OtherDerived>
+// Derived& operator=(const ArrayBase<OtherDerived>& other);
+
+ /** Special case of the template operator=, in order to prevent the compiler
+ * from generating a default operator= (issue hit with g++ 4.1)
+ */
+ Derived& operator=(const ArrayBase& other)
+ {
+ return ei_assign_selector<Derived,Derived>::run(derived(), other.derived());
+ }
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ /** Copies \a other into *this without evaluating other. \returns a reference to *this. */
+// template<typename OtherDerived>
+// Derived& lazyAssign(const ArrayBase<OtherDerived>& other);
+// template<typename OtherDerived>
+// Derived& lazyAssign(const MatrixBase<OtherDerived>& other);
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+ Derived& operator+=(const Scalar& scalar)
+ { return *this = derived() + scalar; }
+ Derived& operator-=(const Scalar& scalar)
+ { return *this = derived() - scalar; }
+
+ template<typename OtherDerived>
+ Derived& operator+=(const ArrayBase<OtherDerived>& other);
+ template<typename OtherDerived>
+ Derived& operator-=(const ArrayBase<OtherDerived>& other);
+
+ template<typename OtherDerived>
+ Derived& operator*=(const ArrayBase<OtherDerived>& other);
+
+ template<typename OtherDerived>
+ inline bool operator==(const ArrayBase<OtherDerived>& other) const
+ { return cwiseEqual(other).all(); }
+
+ template<typename OtherDerived>
+ inline bool operator!=(const ArrayBase<OtherDerived>& other) const
+ { return cwiseNotEqual(other).all(); }
+
+
+ /** \returns the matrix or vector obtained by evaluating this expression.
+ *
+ * Notice that in the case of a plain matrix or vector (not an expression) this function just returns
+ * a const reference, in order to avoid a useless copy.
+ */
+// EIGEN_STRONG_INLINE const typename ei_eval<Derived>::type eval() const
+// { return typename ei_eval<Derived>::type(derived()); }
+
+// template<typename OtherDerived>
+// void swap(ArrayBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
+
+
+// const VectorwiseOp<Derived,Horizontal> rowwise() const;
+// VectorwiseOp<Derived,Horizontal> rowwise();
+// const VectorwiseOp<Derived,Vertical> colwise() const;
+// VectorwiseOp<Derived,Vertical> colwise();
+
+
+
+ public:
+ MatrixWrapper<Derived> asMatrix() { return derived(); }
+ const MatrixWrapper<Derived> asMatrix() const { return derived(); }
+
+ template<typename Dest>
+ inline void evalTo(Dest& dst) const { dst = asMatrix(); }
+
+ protected:
+ /** Default constructor. Do nothing. */
+ ArrayBase()
+ {
+ /* Just checks for self-consistency of the flags.
+ * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down
+ */
+#ifdef EIGEN_INTERNAL_DEBUGGING
+ EIGEN_STATIC_ASSERT(ei_are_flags_consistent<Flags>::ret,
+ INVALID_MATRIXBASE_TEMPLATE_PARAMETERS)
+#endif
+ }
+
+ private:
+ explicit ArrayBase(int);
+ ArrayBase(int,int);
+ template<typename OtherDerived> explicit ArrayBase(const ArrayBase<OtherDerived>&);
+};
+
+/** replaces \c *this by \c *this - \a other.
+ *
+ * \returns a reference to \c *this
+ */
+template<typename Derived>
+template<typename OtherDerived>
+EIGEN_STRONG_INLINE Derived &
+ArrayBase<Derived>::operator-=(const ArrayBase<OtherDerived> &other)
+{
+ SelfCwiseBinaryOp<ei_scalar_difference_op<Scalar>, Derived> tmp(derived());
+ tmp = other;
+ return derived();
+}
+
+/** replaces \c *this by \c *this + \a other.
+ *
+ * \returns a reference to \c *this
+ */
+template<typename Derived>
+template<typename OtherDerived>
+EIGEN_STRONG_INLINE Derived &
+ArrayBase<Derived>::operator+=(const ArrayBase<OtherDerived>& other)
+{
+ SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived> tmp(derived());
+ tmp = other.derived();
+ return derived();
+}
+
+#endif // EIGEN_ARRAYBASE_H
diff --git a/Eigen/src/Array/ArrayWrapper.h b/Eigen/src/Array/ArrayWrapper.h
new file mode 100644
index 000000000..5850b6cb5
--- /dev/null
+++ b/Eigen/src/Array/ArrayWrapper.h
@@ -0,0 +1,168 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_ARRAYWRAPPER_H
+#define EIGEN_ARRAYWRAPPER_H
+
+template<typename ExpressionType>
+struct ei_traits<ArrayWrapper<ExpressionType> >
+ : public ei_traits<ExpressionType>
+{
+ typedef DenseStorageArray DenseStorageType;
+};
+
+template<typename ExpressionType>
+class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
+{
+ public:
+ typedef ArrayBase<ArrayWrapper> Base;
+ _EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
+
+ inline ArrayWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
+
+ inline int rows() const { return m_expression.rows(); }
+ inline int cols() const { return m_expression.cols(); }
+ inline int stride() const { return m_expression.stride(); }
+
+ inline const CoeffReturnType coeff(int row, int col) const
+ {
+ return m_expression.coeff(row, col);
+ }
+
+ inline Scalar& coeffRef(int row, int col)
+ {
+ return m_expression.const_cast_derived().coeffRef(row, col);
+ }
+
+ inline const CoeffReturnType coeff(int index) const
+ {
+ return m_expression.coeff(index);
+ }
+
+ inline Scalar& coeffRef(int index)
+ {
+ return m_expression.const_cast_derived().coeffRef(index);
+ }
+
+ template<int LoadMode>
+ inline const PacketScalar packet(int row, int col) const
+ {
+ return m_expression.template packet<LoadMode>(row, col);
+ }
+
+ template<int LoadMode>
+ inline void writePacket(int row, int col, const PacketScalar& x)
+ {
+ m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
+ }
+
+ template<int LoadMode>
+ inline const PacketScalar packet(int index) const
+ {
+ return m_expression.template packet<LoadMode>(index);
+ }
+
+ template<int LoadMode>
+ inline void writePacket(int index, const PacketScalar& x)
+ {
+ m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
+ }
+
+ template<typename Dest>
+ inline void evalTo(Dest& dst) const { dst = m_expression; }
+
+ protected:
+ const ExpressionType& m_expression;
+};
+
+template<typename ExpressionType>
+struct ei_traits<MatrixWrapper<ExpressionType> >
+ : public ei_traits<ExpressionType>
+{
+ typedef DenseStorageMatrix DenseStorageType;
+};
+
+template<typename ExpressionType>
+class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
+{
+ public:
+ EIGEN_GENERIC_PUBLIC_INTERFACE(MatrixWrapper)
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper);
+
+ inline MatrixWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
+
+ inline int rows() const { return m_expression.rows(); }
+ inline int cols() const { return m_expression.cols(); }
+ inline int stride() const { return m_expression.stride(); }
+
+ inline const CoeffReturnType coeff(int row, int col) const
+ {
+ return m_expression.coeff(row, col);
+ }
+
+ inline Scalar& coeffRef(int row, int col)
+ {
+ return m_expression.const_cast_derived().coeffRef(row, col);
+ }
+
+ inline const CoeffReturnType coeff(int index) const
+ {
+ return m_expression.coeff(index);
+ }
+
+ inline Scalar& coeffRef(int index)
+ {
+ return m_expression.const_cast_derived().coeffRef(index);
+ }
+
+ template<int LoadMode>
+ inline const PacketScalar packet(int row, int col) const
+ {
+ return m_expression.template packet<LoadMode>(row, col);
+ }
+
+ template<int LoadMode>
+ inline void writePacket(int row, int col, const PacketScalar& x)
+ {
+ m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
+ }
+
+ template<int LoadMode>
+ inline const PacketScalar packet(int index) const
+ {
+ return m_expression.template packet<LoadMode>(index);
+ }
+
+ template<int LoadMode>
+ inline void writePacket(int index, const PacketScalar& x)
+ {
+ m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
+ }
+
+ protected:
+ const ExpressionType& m_expression;
+};
+
+#endif // EIGEN_ARRAYWRAPPER_H
diff --git a/Eigen/src/Array/BooleanRedux.h b/Eigen/src/Array/BooleanRedux.h
index ab6e06d56..9c6985a29 100644
--- a/Eigen/src/Array/BooleanRedux.h
+++ b/Eigen/src/Array/BooleanRedux.h
@@ -84,10 +84,10 @@ struct ei_any_unroller<Derived, Dynamic>
* Example: \include MatrixBase_all.cpp
* Output: \verbinclude MatrixBase_all.out
*
- * \sa MatrixBase::any(), Cwise::operator<()
+ * \sa any(), Cwise::operator<()
*/
template<typename Derived>
-inline bool MatrixBase<Derived>::all() const
+inline bool DenseBase<Derived>::all() const
{
const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
<= EIGEN_UNROLLING_LIMIT;
@@ -108,10 +108,10 @@ inline bool MatrixBase<Derived>::all() const
*
* \returns true if at least one coefficient is true
*
- * \sa MatrixBase::all()
+ * \sa all()
*/
template<typename Derived>
-inline bool MatrixBase<Derived>::any() const
+inline bool DenseBase<Derived>::any() const
{
const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
<= EIGEN_UNROLLING_LIMIT;
@@ -132,12 +132,12 @@ inline bool MatrixBase<Derived>::any() const
*
* \returns the number of coefficients which evaluate to true
*
- * \sa MatrixBase::all(), MatrixBase::any()
+ * \sa all(), any()
*/
template<typename Derived>
-inline int MatrixBase<Derived>::count() const
+inline int DenseBase<Derived>::count() const
{
- return this->cast<bool>().cast<int>().sum();
+ return derived().template cast<bool>().template cast<int>().sum();
}
#endif // EIGEN_ALLANDANY_H
diff --git a/Eigen/src/Array/CwiseOperators.h b/Eigen/src/Array/CwiseOperators.h
deleted file mode 100644
index 1cd1866e7..000000000
--- a/Eigen/src/Array/CwiseOperators.h
+++ /dev/null
@@ -1,421 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// Eigen is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 3 of the License, or (at your option) any later version.
-//
-// Alternatively, you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of
-// the License, or (at your option) any later version.
-//
-// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License and a copy of the GNU General Public License along with
-// Eigen. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef EIGEN_ARRAY_CWISE_OPERATORS_H
-#define EIGEN_ARRAY_CWISE_OPERATORS_H
-
-// -- unary operators --
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise square root of *this.
- *
- * Example: \include Cwise_sqrt.cpp
- * Output: \verbinclude Cwise_sqrt.out
- *
- * \sa pow(), square()
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op)
-Cwise<ExpressionType>::sqrt() const
-{
- return _expression();
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise cosine of *this.
- *
- * Example: \include Cwise_cos.cpp
- * Output: \verbinclude Cwise_cos.out
- *
- * \sa sin(), exp(), EIGEN_FAST_MATH
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op)
-Cwise<ExpressionType>::cos() const
-{
- return _expression();
-}
-
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise sine of *this.
- *
- * Example: \include Cwise_sin.cpp
- * Output: \verbinclude Cwise_sin.out
- *
- * \sa cos(), exp(), EIGEN_FAST_MATH
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op)
-Cwise<ExpressionType>::sin() const
-{
- return _expression();
-}
-
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise power of *this to the given exponent.
- *
- * Example: \include Cwise_pow.cpp
- * Output: \verbinclude Cwise_pow.out
- *
- * \sa exp(), log()
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)
-Cwise<ExpressionType>::pow(const Scalar& exponent) const
-{
- return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op<Scalar>(exponent));
-}
-
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise inverse of *this.
- *
- * Example: \include Cwise_inverse.cpp
- * Output: \verbinclude Cwise_inverse.out
- *
- * \sa operator/(), operator*()
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op)
-Cwise<ExpressionType>::inverse() const
-{
- return _expression();
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise square of *this.
- *
- * Example: \include Cwise_square.cpp
- * Output: \verbinclude Cwise_square.out
- *
- * \sa operator/(), operator*(), abs2()
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op)
-Cwise<ExpressionType>::square() const
-{
- return _expression();
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise cube of *this.
- *
- * Example: \include Cwise_cube.cpp
- * Output: \verbinclude Cwise_cube.out
- *
- * \sa square(), pow()
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op)
-Cwise<ExpressionType>::cube() const
-{
- return _expression();
-}
-
-
-// -- binary operators --
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \< operator of *this and \a other
- *
- * Example: \include Cwise_less.cpp
- * Output: \verbinclude Cwise_less.out
- *
- * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
-Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \<= operator of *this and \a other
- *
- * Example: \include Cwise_less_equal.cpp
- * Output: \verbinclude Cwise_less_equal.out
- *
- * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
-Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \> operator of *this and \a other
- *
- * Example: \include Cwise_greater.cpp
- * Output: \verbinclude Cwise_greater.out
- *
- * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
-Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \>= operator of *this and \a other
- *
- * Example: \include Cwise_greater_equal.cpp
- * Output: \verbinclude Cwise_greater_equal.out
- *
- * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
-Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise == operator of *this and \a other
- *
- * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
- * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
- * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
- * MatrixBase::isMuchSmallerThan().
- *
- * Example: \include Cwise_equal_equal.cpp
- * Output: \verbinclude Cwise_equal_equal.out
- *
- * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
-Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise != operator of *this and \a other
- *
- * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
- * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
- * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
- * MatrixBase::isMuchSmallerThan().
- *
- * Example: \include Cwise_not_equal.cpp
- * Output: \verbinclude Cwise_not_equal.out
- *
- * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
-Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived());
-}
-
-// comparisons to scalar value
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \< operator of *this and a scalar \a s
- *
- * \sa operator<(const MatrixBase<OtherDerived> &) const
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
-Cwise<ExpressionType>::operator<(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \<= operator of *this and a scalar \a s
- *
- * \sa operator<=(const MatrixBase<OtherDerived> &) const
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
-Cwise<ExpressionType>::operator<=(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \> operator of *this and a scalar \a s
- *
- * \sa operator>(const MatrixBase<OtherDerived> &) const
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
-Cwise<ExpressionType>::operator>(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise \>= operator of *this and a scalar \a s
- *
- * \sa operator>=(const MatrixBase<OtherDerived> &) const
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
-Cwise<ExpressionType>::operator>=(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise == operator of *this and a scalar \a s
- *
- * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
- * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
- * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
- * MatrixBase::isMuchSmallerThan().
- *
- * \sa operator==(const MatrixBase<OtherDerived> &) const
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
-Cwise<ExpressionType>::operator==(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \array_module
- *
- * \returns an expression of the coefficient-wise != operator of *this and a scalar \a s
- *
- * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
- * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
- * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
- * MatrixBase::isMuchSmallerThan().
- *
- * \sa operator!=(const MatrixBase<OtherDerived> &) const
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
-Cwise<ExpressionType>::operator!=(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-// scalar addition
-
-/** \array_module
- *
- * \returns an expression of \c *this with each coeff incremented by the constant \a scalar
- *
- * Example: \include Cwise_plus.cpp
- * Output: \verbinclude Cwise_plus.out
- *
- * \sa operator+=(), operator-()
- */
-template<typename ExpressionType>
-inline const typename Cwise<ExpressionType>::ScalarAddReturnType
-Cwise<ExpressionType>::operator+(const Scalar& scalar) const
-{
- return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar));
-}
-
-/** \array_module
- *
- * Adds the given \a scalar to each coeff of this expression.
- *
- * Example: \include Cwise_plus_equal.cpp
- * Output: \verbinclude Cwise_plus_equal.out
- *
- * \sa operator+(), operator-=()
- */
-template<typename ExpressionType>
-inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
-{
- return m_matrix.const_cast_derived() = *this + scalar;
-}
-
-/** \array_module
- *
- * \returns an expression of \c *this with each coeff decremented by the constant \a scalar
- *
- * Example: \include Cwise_minus.cpp
- * Output: \verbinclude Cwise_minus.out
- *
- * \sa operator+(), operator-=()
- */
-template<typename ExpressionType>
-inline const typename Cwise<ExpressionType>::ScalarAddReturnType
-Cwise<ExpressionType>::operator-(const Scalar& scalar) const
-{
- return *this + (-scalar);
-}
-
-/** \array_module
- *
- * Substracts the given \a scalar from each coeff of this expression.
- *
- * Example: \include Cwise_minus_equal.cpp
- * Output: \verbinclude Cwise_minus_equal.out
- *
- * \sa operator+=(), operator-()
- */
-
-template<typename ExpressionType>
-inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
-{
- return m_matrix.const_cast_derived() = *this - scalar;
-}
-
-#endif // EIGEN_ARRAY_CWISE_OPERATORS_H
diff --git a/Eigen/src/Array/Norms.h b/Eigen/src/Array/Norms.h
index ef3f2f20d..07741cdc9 100644
--- a/Eigen/src/Array/Norms.h
+++ b/Eigen/src/Array/Norms.h
@@ -31,7 +31,7 @@ struct ei_lpNorm_selector
typedef typename NumTraits<typename ei_traits<Derived>::Scalar>::Real RealScalar;
inline static RealScalar run(const MatrixBase<Derived>& m)
{
- return ei_pow(m.cwise().abs().cwise().pow(p).sum(), RealScalar(1)/p);
+ return ei_pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);
}
};
@@ -40,7 +40,7 @@ struct ei_lpNorm_selector<Derived, 1>
{
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
{
- return m.cwise().abs().sum();
+ return m.cwiseAbs().sum();
}
};
@@ -58,12 +58,12 @@ struct ei_lpNorm_selector<Derived, Infinity>
{
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
{
- return m.cwise().abs().maxCoeff();
+ return m.cwiseAbs().maxCoeff();
}
};
/** \array_module
- *
+ *
* \returns the \f$ \ell^p \f$ norm of *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values
* of the coefficients of *this. If \a p is the special value \a Eigen::Infinity, this function returns the \f$ \ell^p\infty \f$
* norm, that is the maximum of the absolute values of the coefficients of *this.
diff --git a/Eigen/src/Array/Random.h b/Eigen/src/Array/Random.h
index b94ccda68..97ca0fba3 100644
--- a/Eigen/src/Array/Random.h
+++ b/Eigen/src/Array/Random.h
@@ -55,7 +55,7 @@ struct ei_functor_traits<ei_scalar_random_op<Scalar> >
*/
template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
-MatrixBase<Derived>::Random(int rows, int cols)
+DenseBase<Derived>::Random(int rows, int cols)
{
return NullaryExpr(rows, cols, ei_scalar_random_op<Scalar>());
}
@@ -84,7 +84,7 @@ MatrixBase<Derived>::Random(int rows, int cols)
*/
template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
-MatrixBase<Derived>::Random(int size)
+DenseBase<Derived>::Random(int size)
{
return NullaryExpr(size, ei_scalar_random_op<Scalar>());
}
@@ -107,7 +107,7 @@ MatrixBase<Derived>::Random(int size)
*/
template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
-MatrixBase<Derived>::Random()
+DenseBase<Derived>::Random()
{
return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>());
}
@@ -122,7 +122,7 @@ MatrixBase<Derived>::Random()
* \sa class CwiseNullaryOp, setRandom(int), setRandom(int,int)
*/
template<typename Derived>
-inline Derived& MatrixBase<Derived>::setRandom()
+inline Derived& DenseBase<Derived>::setRandom()
{
return *this = Random(rows(), cols());
}
@@ -136,9 +136,9 @@ inline Derived& MatrixBase<Derived>::setRandom()
*
* \sa MatrixBase::setRandom(), setRandom(int,int), class CwiseNullaryOp, MatrixBase::Random()
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int size)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setRandom(int size)
{
resize(size);
return setRandom();
@@ -154,9 +154,9 @@ Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int size)
*
* \sa MatrixBase::setRandom(), setRandom(int), class CwiseNullaryOp, MatrixBase::Random()
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int rows, int cols)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setRandom(int rows, int cols)
{
resize(rows, cols);
return setRandom();
diff --git a/Eigen/src/Array/Replicate.h b/Eigen/src/Array/Replicate.h
index 653bda666..3f87e09fe 100644
--- a/Eigen/src/Array/Replicate.h
+++ b/Eigen/src/Array/Replicate.h
@@ -33,15 +33,17 @@
* \param MatrixType the type of the object we are replicating
*
* This class represents an expression of the multiple replication of a matrix or vector.
- * It is the return type of MatrixBase::replicate() and most of the time
+ * It is the return type of DenseBase::replicate() and most of the time
* this is the only way it is used.
*
- * \sa MatrixBase::replicate()
+ * \sa DenseBase::replicate()
*/
template<typename MatrixType,int RowFactor,int ColFactor>
struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
+ : ei_traits<MatrixType>
{
typedef typename MatrixType::Scalar Scalar;
+ typedef typename ei_traits<MatrixType>::StorageType StorageType;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
@@ -59,11 +61,12 @@ struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
};
template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
- : public MatrixBase<Replicate<MatrixType,RowFactor,ColFactor> >
+ : public MatrixType::template MakeBase< Replicate<MatrixType,RowFactor,ColFactor> >::Type
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate)
+ typedef typename MatrixType::template MakeBase< Replicate<MatrixType,RowFactor,ColFactor> >::Type Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate)
template<typename OriginalMatrixType>
inline explicit Replicate(const OriginalMatrixType& matrix)
@@ -102,12 +105,12 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
* Example: \include MatrixBase_replicate.cpp
* Output: \verbinclude MatrixBase_replicate.out
*
- * \sa VectorwiseOp::replicate(), MatrixBase::replicate(int,int), class Replicate
+ * \sa VectorwiseOp::replicate(), DenseBase::replicate(int,int), class Replicate
*/
template<typename Derived>
template<int RowFactor, int ColFactor>
inline const Replicate<Derived,RowFactor,ColFactor>
-MatrixBase<Derived>::replicate() const
+DenseBase<Derived>::replicate() const
{
return Replicate<Derived,RowFactor,ColFactor>(derived());
}
@@ -118,11 +121,11 @@ MatrixBase<Derived>::replicate() const
* Example: \include MatrixBase_replicate_int_int.cpp
* Output: \verbinclude MatrixBase_replicate_int_int.out
*
- * \sa VectorwiseOp::replicate(), MatrixBase::replicate<int,int>(), class Replicate
+ * \sa VectorwiseOp::replicate(), DenseBase::replicate<int,int>(), class Replicate
*/
template<typename Derived>
inline const Replicate<Derived,Dynamic,Dynamic>
-MatrixBase<Derived>::replicate(int rowFactor,int colFactor) const
+DenseBase<Derived>::replicate(int rowFactor,int colFactor) const
{
return Replicate<Derived,Dynamic,Dynamic>(derived(),rowFactor,colFactor);
}
@@ -133,7 +136,7 @@ MatrixBase<Derived>::replicate(int rowFactor,int colFactor) const
* Example: \include DirectionWise_replicate_int.cpp
* Output: \verbinclude DirectionWise_replicate_int.out
*
- * \sa VectorwiseOp::replicate(), MatrixBase::replicate(), class Replicate
+ * \sa VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate
*/
template<typename ExpressionType, int Direction>
const Replicate<ExpressionType,(Direction==Vertical?Dynamic:1),(Direction==Horizontal?Dynamic:1)>
diff --git a/Eigen/src/Array/Reverse.h b/Eigen/src/Array/Reverse.h
index 4807bea55..a8d8310a9 100644
--- a/Eigen/src/Array/Reverse.h
+++ b/Eigen/src/Array/Reverse.h
@@ -43,8 +43,10 @@
*/
template<typename MatrixType, int Direction>
struct ei_traits<Reverse<MatrixType, Direction> >
+ : ei_traits<MatrixType>
{
typedef typename MatrixType::Scalar Scalar;
+ typedef typename ei_traits<MatrixType>::StorageType StorageType;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
@@ -75,11 +77,12 @@ template<typename PacketScalar> struct ei_reverse_packet_cond<PacketScalar,false
};
template<typename MatrixType, int Direction> class Reverse
- : public MatrixBase<Reverse<MatrixType, Direction> >
+ : public MatrixType::template MakeBase< Reverse<MatrixType, Direction> >::Type
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(Reverse)
+ typedef typename MatrixType::template MakeBase< Reverse<MatrixType, Direction> >::Type Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Reverse)
protected:
enum {
@@ -167,7 +170,7 @@ template<typename MatrixType, int Direction> class Reverse
*/
template<typename Derived>
inline Reverse<Derived, BothDirections>
-MatrixBase<Derived>::reverse()
+DenseBase<Derived>::reverse()
{
return derived();
}
@@ -175,7 +178,7 @@ MatrixBase<Derived>::reverse()
/** This is the const version of reverse(). */
template<typename Derived>
inline const Reverse<Derived, BothDirections>
-MatrixBase<Derived>::reverse() const
+DenseBase<Derived>::reverse() const
{
return derived();
}
@@ -193,7 +196,7 @@ MatrixBase<Derived>::reverse() const
*
* \sa reverse() */
template<typename Derived>
-inline void MatrixBase<Derived>::reverseInPlace()
+inline void DenseBase<Derived>::reverseInPlace()
{
derived() = derived().reverse().eval();
}
diff --git a/Eigen/src/Array/Select.h b/Eigen/src/Array/Select.h
index bc55147fd..b1fab69c9 100644
--- a/Eigen/src/Array/Select.h
+++ b/Eigen/src/Array/Select.h
@@ -36,15 +36,17 @@
* \param ElseMatrixType the type of the \em else expression
*
* This class represents an expression of a coefficient wise version of the C++ ternary operator ?:.
- * It is the return type of MatrixBase::select() and most of the time this is the only way it is used.
+ * It is the return type of DenseBase::select() and most of the time this is the only way it is used.
*
- * \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const
+ * \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const
*/
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
+ : ei_traits<ThenMatrixType>
{
typedef typename ei_traits<ThenMatrixType>::Scalar Scalar;
+ typedef Dense StorageType;
typedef typename ConditionMatrixType::Nested ConditionMatrixNested;
typedef typename ThenMatrixType::Nested ThenMatrixNested;
typedef typename ElseMatrixType::Nested ElseMatrixNested;
@@ -62,11 +64,12 @@ struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
class Select : ei_no_assignment_operator,
- public MatrixBase<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
+ public ThenMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(Select)
+ typedef typename ThenMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Select)
Select(const ConditionMatrixType& conditionMatrix,
const ThenMatrixType& thenMatrix,
@@ -87,7 +90,7 @@ class Select : ei_no_assignment_operator,
else
return m_else.coeff(i,j);
}
-
+
const Scalar coeff(int i) const
{
if (m_condition.coeff(i))
@@ -116,23 +119,23 @@ class Select : ei_no_assignment_operator,
template<typename Derived>
template<typename ThenDerived,typename ElseDerived>
inline const Select<Derived,ThenDerived,ElseDerived>
-MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
- const MatrixBase<ElseDerived>& elseMatrix) const
+DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
+ const DenseBase<ElseDerived>& elseMatrix) const
{
return Select<Derived,ThenDerived,ElseDerived>(derived(), thenMatrix.derived(), elseMatrix.derived());
}
/** \array_module
*
- * Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
+ * Version of DenseBase::select(const DenseBase&, const DenseBase&) with
* the \em else expression being a scalar value.
*
- * \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
+ * \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ThenDerived>
inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
-MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
+DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
typename ThenDerived::Scalar elseScalar) const
{
return Select<Derived,ThenDerived,typename ThenDerived::ConstantReturnType>(
@@ -141,16 +144,16 @@ MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
/** \array_module
*
- * Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
+ * Version of DenseBase::select(const DenseBase&, const DenseBase&) with
* the \em then expression being a scalar value.
*
- * \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
+ * \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ElseDerived>
inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
-MatrixBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
- const MatrixBase<ElseDerived>& elseMatrix) const
+DenseBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
+ const DenseBase<ElseDerived>& elseMatrix) const
{
return Select<Derived,typename ElseDerived::ConstantReturnType,ElseDerived>(
derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived());
diff --git a/Eigen/src/Array/VectorwiseOp.h b/Eigen/src/Array/VectorwiseOp.h
index bb695c795..05dd69789 100644
--- a/Eigen/src/Array/VectorwiseOp.h
+++ b/Eigen/src/Array/VectorwiseOp.h
@@ -48,8 +48,10 @@ class PartialReduxExpr;
template<typename MatrixType, typename MemberOp, int Direction>
struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
+ : ei_traits<MatrixType>
{
typedef typename MemberOp::result_type Scalar;
+ typedef typename ei_traits<MatrixType>::StorageType StorageType;
typedef typename MatrixType::Scalar InputScalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
@@ -73,11 +75,12 @@ struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
template< typename MatrixType, typename MemberOp, int Direction>
class PartialReduxExpr : ei_no_assignment_operator,
- public MatrixBase<PartialReduxExpr<MatrixType, MemberOp, Direction> >
+ public MatrixType::template MakeBase< PartialReduxExpr<MatrixType, MemberOp, Direction> >::Type
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr)
+ typedef typename MatrixType::template MakeBase< PartialReduxExpr<MatrixType, MemberOp, Direction> >::Type Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr)
typedef typename ei_traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested;
typedef typename ei_traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested;