Eigne Matrix Class Library

Dependents:   Eigen_test Odometry_test AttitudeEstimation_usingTicker MPU9250_Quaternion_Binary_Serial ... more

Eigen Matrix Class Library for mbed.

Finally, you can use Eigen on your mbed!!!

Committer:
ykuroda
Date:
Thu Oct 13 04:07:23 2016 +0000
Revision:
0:13a5d365ba16
First commint, Eigne Matrix Class Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ykuroda 0:13a5d365ba16 1 // This file is part of Eigen, a lightweight C++ template library
ykuroda 0:13a5d365ba16 2 // for linear algebra.
ykuroda 0:13a5d365ba16 3 //
ykuroda 0:13a5d365ba16 4 // Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
ykuroda 0:13a5d365ba16 5 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
ykuroda 0:13a5d365ba16 6 //
ykuroda 0:13a5d365ba16 7 // This Source Code Form is subject to the terms of the Mozilla
ykuroda 0:13a5d365ba16 8 // Public License v. 2.0. If a copy of the MPL was not distributed
ykuroda 0:13a5d365ba16 9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
ykuroda 0:13a5d365ba16 10
ykuroda 0:13a5d365ba16 11 #ifndef EIGEN_DENSEBASE_H
ykuroda 0:13a5d365ba16 12 #define EIGEN_DENSEBASE_H
ykuroda 0:13a5d365ba16 13
ykuroda 0:13a5d365ba16 14 namespace Eigen {
ykuroda 0:13a5d365ba16 15
ykuroda 0:13a5d365ba16 16 namespace internal {
ykuroda 0:13a5d365ba16 17
ykuroda 0:13a5d365ba16 18 // The index type defined by EIGEN_DEFAULT_DENSE_INDEX_TYPE must be a signed type.
ykuroda 0:13a5d365ba16 19 // This dummy function simply aims at checking that at compile time.
ykuroda 0:13a5d365ba16 20 static inline void check_DenseIndex_is_signed() {
ykuroda 0:13a5d365ba16 21 EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE);
ykuroda 0:13a5d365ba16 22 }
ykuroda 0:13a5d365ba16 23
ykuroda 0:13a5d365ba16 24 } // end namespace internal
ykuroda 0:13a5d365ba16 25
ykuroda 0:13a5d365ba16 26 /** \class DenseBase
ykuroda 0:13a5d365ba16 27 * \ingroup Core_Module
ykuroda 0:13a5d365ba16 28 *
ykuroda 0:13a5d365ba16 29 * \brief Base class for all dense matrices, vectors, and arrays
ykuroda 0:13a5d365ba16 30 *
ykuroda 0:13a5d365ba16 31 * This class is the base that is inherited by all dense objects (matrix, vector, arrays,
ykuroda 0:13a5d365ba16 32 * and related expression types). The common Eigen API for dense objects is contained in this class.
ykuroda 0:13a5d365ba16 33 *
ykuroda 0:13a5d365ba16 34 * \tparam Derived is the derived type, e.g., a matrix type or an expression.
ykuroda 0:13a5d365ba16 35 *
ykuroda 0:13a5d365ba16 36 * This class can be extended with the help of the plugin mechanism described on the page
ykuroda 0:13a5d365ba16 37 * \ref TopicCustomizingEigen by defining the preprocessor symbol \c EIGEN_DENSEBASE_PLUGIN.
ykuroda 0:13a5d365ba16 38 *
ykuroda 0:13a5d365ba16 39 * \sa \ref TopicClassHierarchy
ykuroda 0:13a5d365ba16 40 */
ykuroda 0:13a5d365ba16 41 template<typename Derived> class DenseBase
ykuroda 0:13a5d365ba16 42 #ifndef EIGEN_PARSED_BY_DOXYGEN
ykuroda 0:13a5d365ba16 43 : public internal::special_scalar_op_base<Derived, typename internal::traits<Derived>::Scalar,
ykuroda 0:13a5d365ba16 44 typename NumTraits<typename internal::traits<Derived>::Scalar>::Real,
ykuroda 0:13a5d365ba16 45 DenseCoeffsBase<Derived> >
ykuroda 0:13a5d365ba16 46 #else
ykuroda 0:13a5d365ba16 47 : public DenseCoeffsBase<Derived>
ykuroda 0:13a5d365ba16 48 #endif // not EIGEN_PARSED_BY_DOXYGEN
ykuroda 0:13a5d365ba16 49 {
ykuroda 0:13a5d365ba16 50 public:
ykuroda 0:13a5d365ba16 51
ykuroda 0:13a5d365ba16 52 class InnerIterator;
ykuroda 0:13a5d365ba16 53
ykuroda 0:13a5d365ba16 54 typedef typename internal::traits<Derived>::StorageKind StorageKind;
ykuroda 0:13a5d365ba16 55
ykuroda 0:13a5d365ba16 56 /** \brief The type of indices
ykuroda 0:13a5d365ba16 57 * \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE.
ykuroda 0:13a5d365ba16 58 * \sa \ref TopicPreprocessorDirectives.
ykuroda 0:13a5d365ba16 59 */
ykuroda 0:13a5d365ba16 60 typedef typename internal::traits<Derived>::Index Index;
ykuroda 0:13a5d365ba16 61
ykuroda 0:13a5d365ba16 62 typedef typename internal::traits<Derived>::Scalar Scalar;
ykuroda 0:13a5d365ba16 63 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
ykuroda 0:13a5d365ba16 64 typedef typename NumTraits<Scalar>::Real RealScalar;
ykuroda 0:13a5d365ba16 65 typedef internal::special_scalar_op_base<Derived,Scalar,RealScalar, DenseCoeffsBase<Derived> > Base;
ykuroda 0:13a5d365ba16 66
ykuroda 0:13a5d365ba16 67 using Base::operator*;
ykuroda 0:13a5d365ba16 68 using Base::derived;
ykuroda 0:13a5d365ba16 69 using Base::const_cast_derived;
ykuroda 0:13a5d365ba16 70 using Base::rows;
ykuroda 0:13a5d365ba16 71 using Base::cols;
ykuroda 0:13a5d365ba16 72 using Base::size;
ykuroda 0:13a5d365ba16 73 using Base::rowIndexByOuterInner;
ykuroda 0:13a5d365ba16 74 using Base::colIndexByOuterInner;
ykuroda 0:13a5d365ba16 75 using Base::coeff;
ykuroda 0:13a5d365ba16 76 using Base::coeffByOuterInner;
ykuroda 0:13a5d365ba16 77 using Base::packet;
ykuroda 0:13a5d365ba16 78 using Base::packetByOuterInner;
ykuroda 0:13a5d365ba16 79 using Base::writePacket;
ykuroda 0:13a5d365ba16 80 using Base::writePacketByOuterInner;
ykuroda 0:13a5d365ba16 81 using Base::coeffRef;
ykuroda 0:13a5d365ba16 82 using Base::coeffRefByOuterInner;
ykuroda 0:13a5d365ba16 83 using Base::copyCoeff;
ykuroda 0:13a5d365ba16 84 using Base::copyCoeffByOuterInner;
ykuroda 0:13a5d365ba16 85 using Base::copyPacket;
ykuroda 0:13a5d365ba16 86 using Base::copyPacketByOuterInner;
ykuroda 0:13a5d365ba16 87 using Base::operator();
ykuroda 0:13a5d365ba16 88 using Base::operator[];
ykuroda 0:13a5d365ba16 89 using Base::x;
ykuroda 0:13a5d365ba16 90 using Base::y;
ykuroda 0:13a5d365ba16 91 using Base::z;
ykuroda 0:13a5d365ba16 92 using Base::w;
ykuroda 0:13a5d365ba16 93 using Base::stride;
ykuroda 0:13a5d365ba16 94 using Base::innerStride;
ykuroda 0:13a5d365ba16 95 using Base::outerStride;
ykuroda 0:13a5d365ba16 96 using Base::rowStride;
ykuroda 0:13a5d365ba16 97 using Base::colStride;
ykuroda 0:13a5d365ba16 98 typedef typename Base::CoeffReturnType CoeffReturnType;
ykuroda 0:13a5d365ba16 99
ykuroda 0:13a5d365ba16 100 enum {
ykuroda 0:13a5d365ba16 101
ykuroda 0:13a5d365ba16 102 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
ykuroda 0:13a5d365ba16 103 /**< The number of rows at compile-time. This is just a copy of the value provided
ykuroda 0:13a5d365ba16 104 * by the \a Derived type. If a value is not known at compile-time,
ykuroda 0:13a5d365ba16 105 * it is set to the \a Dynamic constant.
ykuroda 0:13a5d365ba16 106 * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
ykuroda 0:13a5d365ba16 107
ykuroda 0:13a5d365ba16 108 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
ykuroda 0:13a5d365ba16 109 /**< The number of columns at compile-time. This is just a copy of the value provided
ykuroda 0:13a5d365ba16 110 * by the \a Derived type. If a value is not known at compile-time,
ykuroda 0:13a5d365ba16 111 * it is set to the \a Dynamic constant.
ykuroda 0:13a5d365ba16 112 * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
ykuroda 0:13a5d365ba16 113
ykuroda 0:13a5d365ba16 114
ykuroda 0:13a5d365ba16 115 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
ykuroda 0:13a5d365ba16 116 internal::traits<Derived>::ColsAtCompileTime>::ret),
ykuroda 0:13a5d365ba16 117 /**< This is equal to the number of coefficients, i.e. the number of
ykuroda 0:13a5d365ba16 118 * rows times the number of columns, or to \a Dynamic if this is not
ykuroda 0:13a5d365ba16 119 * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
ykuroda 0:13a5d365ba16 120
ykuroda 0:13a5d365ba16 121 MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
ykuroda 0:13a5d365ba16 122 /**< This value is equal to the maximum possible number of rows that this expression
ykuroda 0:13a5d365ba16 123 * might have. If this expression might have an arbitrarily high number of rows,
ykuroda 0:13a5d365ba16 124 * this value is set to \a Dynamic.
ykuroda 0:13a5d365ba16 125 *
ykuroda 0:13a5d365ba16 126 * This value is useful to know when evaluating an expression, in order to determine
ykuroda 0:13a5d365ba16 127 * whether it is possible to avoid doing a dynamic memory allocation.
ykuroda 0:13a5d365ba16 128 *
ykuroda 0:13a5d365ba16 129 * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
ykuroda 0:13a5d365ba16 130 */
ykuroda 0:13a5d365ba16 131
ykuroda 0:13a5d365ba16 132 MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
ykuroda 0:13a5d365ba16 133 /**< This value is equal to the maximum possible number of columns that this expression
ykuroda 0:13a5d365ba16 134 * might have. If this expression might have an arbitrarily high number of columns,
ykuroda 0:13a5d365ba16 135 * this value is set to \a Dynamic.
ykuroda 0:13a5d365ba16 136 *
ykuroda 0:13a5d365ba16 137 * This value is useful to know when evaluating an expression, in order to determine
ykuroda 0:13a5d365ba16 138 * whether it is possible to avoid doing a dynamic memory allocation.
ykuroda 0:13a5d365ba16 139 *
ykuroda 0:13a5d365ba16 140 * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
ykuroda 0:13a5d365ba16 141 */
ykuroda 0:13a5d365ba16 142
ykuroda 0:13a5d365ba16 143 MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,
ykuroda 0:13a5d365ba16 144 internal::traits<Derived>::MaxColsAtCompileTime>::ret),
ykuroda 0:13a5d365ba16 145 /**< This value is equal to the maximum possible number of coefficients that this expression
ykuroda 0:13a5d365ba16 146 * might have. If this expression might have an arbitrarily high number of coefficients,
ykuroda 0:13a5d365ba16 147 * this value is set to \a Dynamic.
ykuroda 0:13a5d365ba16 148 *
ykuroda 0:13a5d365ba16 149 * This value is useful to know when evaluating an expression, in order to determine
ykuroda 0:13a5d365ba16 150 * whether it is possible to avoid doing a dynamic memory allocation.
ykuroda 0:13a5d365ba16 151 *
ykuroda 0:13a5d365ba16 152 * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
ykuroda 0:13a5d365ba16 153 */
ykuroda 0:13a5d365ba16 154
ykuroda 0:13a5d365ba16 155 IsVectorAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime == 1
ykuroda 0:13a5d365ba16 156 || internal::traits<Derived>::MaxColsAtCompileTime == 1,
ykuroda 0:13a5d365ba16 157 /**< This is set to true if either the number of rows or the number of
ykuroda 0:13a5d365ba16 158 * columns is known at compile-time to be equal to 1. Indeed, in that case,
ykuroda 0:13a5d365ba16 159 * we are dealing with a column-vector (if there is only one column) or with
ykuroda 0:13a5d365ba16 160 * a row-vector (if there is only one row). */
ykuroda 0:13a5d365ba16 161
ykuroda 0:13a5d365ba16 162 Flags = internal::traits<Derived>::Flags,
ykuroda 0:13a5d365ba16 163 /**< This stores expression \ref flags flags which may or may not be inherited by new expressions
ykuroda 0:13a5d365ba16 164 * constructed from this one. See the \ref flags "list of flags".
ykuroda 0:13a5d365ba16 165 */
ykuroda 0:13a5d365ba16 166
ykuroda 0:13a5d365ba16 167 IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression has row-major storage order. */
ykuroda 0:13a5d365ba16 168
ykuroda 0:13a5d365ba16 169 InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)
ykuroda 0:13a5d365ba16 170 : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
ykuroda 0:13a5d365ba16 171
ykuroda 0:13a5d365ba16 172 CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
ykuroda 0:13a5d365ba16 173 /**< This is a rough measure of how expensive it is to read one coefficient from
ykuroda 0:13a5d365ba16 174 * this expression.
ykuroda 0:13a5d365ba16 175 */
ykuroda 0:13a5d365ba16 176
ykuroda 0:13a5d365ba16 177 InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret,
ykuroda 0:13a5d365ba16 178 OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret
ykuroda 0:13a5d365ba16 179 };
ykuroda 0:13a5d365ba16 180
ykuroda 0:13a5d365ba16 181 enum { ThisConstantIsPrivateInPlainObjectBase };
ykuroda 0:13a5d365ba16 182
ykuroda 0:13a5d365ba16 183 /** \returns the number of nonzero coefficients which is in practice the number
ykuroda 0:13a5d365ba16 184 * of stored coefficients. */
ykuroda 0:13a5d365ba16 185 inline Index nonZeros() const { return size(); }
ykuroda 0:13a5d365ba16 186
ykuroda 0:13a5d365ba16 187 /** \returns the outer size.
ykuroda 0:13a5d365ba16 188 *
ykuroda 0:13a5d365ba16 189 * \note For a vector, this returns just 1. For a matrix (non-vector), this is the major dimension
ykuroda 0:13a5d365ba16 190 * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of columns for a
ykuroda 0:13a5d365ba16 191 * column-major matrix, and the number of rows for a row-major matrix. */
ykuroda 0:13a5d365ba16 192 Index outerSize() const
ykuroda 0:13a5d365ba16 193 {
ykuroda 0:13a5d365ba16 194 return IsVectorAtCompileTime ? 1
ykuroda 0:13a5d365ba16 195 : int(IsRowMajor) ? this->rows() : this->cols();
ykuroda 0:13a5d365ba16 196 }
ykuroda 0:13a5d365ba16 197
ykuroda 0:13a5d365ba16 198 /** \returns the inner size.
ykuroda 0:13a5d365ba16 199 *
ykuroda 0:13a5d365ba16 200 * \note For a vector, this is just the size. For a matrix (non-vector), this is the minor dimension
ykuroda 0:13a5d365ba16 201 * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of rows for a
ykuroda 0:13a5d365ba16 202 * column-major matrix, and the number of columns for a row-major matrix. */
ykuroda 0:13a5d365ba16 203 Index innerSize() const
ykuroda 0:13a5d365ba16 204 {
ykuroda 0:13a5d365ba16 205 return IsVectorAtCompileTime ? this->size()
ykuroda 0:13a5d365ba16 206 : int(IsRowMajor) ? this->cols() : this->rows();
ykuroda 0:13a5d365ba16 207 }
ykuroda 0:13a5d365ba16 208
ykuroda 0:13a5d365ba16 209 /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are
ykuroda 0:13a5d365ba16 210 * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does
ykuroda 0:13a5d365ba16 211 * nothing else.
ykuroda 0:13a5d365ba16 212 */
ykuroda 0:13a5d365ba16 213 void resize(Index newSize)
ykuroda 0:13a5d365ba16 214 {
ykuroda 0:13a5d365ba16 215 EIGEN_ONLY_USED_FOR_DEBUG(newSize);
ykuroda 0:13a5d365ba16 216 eigen_assert(newSize == this->size()
ykuroda 0:13a5d365ba16 217 && "DenseBase::resize() does not actually allow to resize.");
ykuroda 0:13a5d365ba16 218 }
ykuroda 0:13a5d365ba16 219 /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are
ykuroda 0:13a5d365ba16 220 * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does
ykuroda 0:13a5d365ba16 221 * nothing else.
ykuroda 0:13a5d365ba16 222 */
ykuroda 0:13a5d365ba16 223 void resize(Index nbRows, Index nbCols)
ykuroda 0:13a5d365ba16 224 {
ykuroda 0:13a5d365ba16 225 EIGEN_ONLY_USED_FOR_DEBUG(nbRows);
ykuroda 0:13a5d365ba16 226 EIGEN_ONLY_USED_FOR_DEBUG(nbCols);
ykuroda 0:13a5d365ba16 227 eigen_assert(nbRows == this->rows() && nbCols == this->cols()
ykuroda 0:13a5d365ba16 228 && "DenseBase::resize() does not actually allow to resize.");
ykuroda 0:13a5d365ba16 229 }
ykuroda 0:13a5d365ba16 230
ykuroda 0:13a5d365ba16 231 #ifndef EIGEN_PARSED_BY_DOXYGEN
ykuroda 0:13a5d365ba16 232
ykuroda 0:13a5d365ba16 233 /** \internal Represents a matrix with all coefficients equal to one another*/
ykuroda 0:13a5d365ba16 234 typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
ykuroda 0:13a5d365ba16 235 /** \internal Represents a vector with linearly spaced coefficients that allows sequential access only. */
ykuroda 0:13a5d365ba16 236 typedef CwiseNullaryOp<internal::linspaced_op<Scalar,false>,Derived> SequentialLinSpacedReturnType;
ykuroda 0:13a5d365ba16 237 /** \internal Represents a vector with linearly spaced coefficients that allows random access. */
ykuroda 0:13a5d365ba16 238 typedef CwiseNullaryOp<internal::linspaced_op<Scalar,true>,Derived> RandomAccessLinSpacedReturnType;
ykuroda 0:13a5d365ba16 239 /** \internal the return type of MatrixBase::eigenvalues() */
ykuroda 0:13a5d365ba16 240 typedef Matrix<typename NumTraits<typename internal::traits<Derived>::Scalar>::Real, internal::traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
ykuroda 0:13a5d365ba16 241
ykuroda 0:13a5d365ba16 242 #endif // not EIGEN_PARSED_BY_DOXYGEN
ykuroda 0:13a5d365ba16 243
ykuroda 0:13a5d365ba16 244 /** Copies \a other into *this. \returns a reference to *this. */
ykuroda 0:13a5d365ba16 245 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 246 Derived& operator=(const DenseBase<OtherDerived>& other);
ykuroda 0:13a5d365ba16 247
ykuroda 0:13a5d365ba16 248 /** Special case of the template operator=, in order to prevent the compiler
ykuroda 0:13a5d365ba16 249 * from generating a default operator= (issue hit with g++ 4.1)
ykuroda 0:13a5d365ba16 250 */
ykuroda 0:13a5d365ba16 251 Derived& operator=(const DenseBase& other);
ykuroda 0:13a5d365ba16 252
ykuroda 0:13a5d365ba16 253 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 254 Derived& operator=(const EigenBase<OtherDerived> &other);
ykuroda 0:13a5d365ba16 255
ykuroda 0:13a5d365ba16 256 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 257 Derived& operator+=(const EigenBase<OtherDerived> &other);
ykuroda 0:13a5d365ba16 258
ykuroda 0:13a5d365ba16 259 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 260 Derived& operator-=(const EigenBase<OtherDerived> &other);
ykuroda 0:13a5d365ba16 261
ykuroda 0:13a5d365ba16 262 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 263 Derived& operator=(const ReturnByValue<OtherDerived>& func);
ykuroda 0:13a5d365ba16 264
ykuroda 0:13a5d365ba16 265 /** \internal Copies \a other into *this without evaluating other. \returns a reference to *this. */
ykuroda 0:13a5d365ba16 266 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 267 Derived& lazyAssign(const DenseBase<OtherDerived>& other);
ykuroda 0:13a5d365ba16 268
ykuroda 0:13a5d365ba16 269 /** \internal Evaluates \a other into *this. \returns a reference to *this. */
ykuroda 0:13a5d365ba16 270 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 271 Derived& lazyAssign(const ReturnByValue<OtherDerived>& other);
ykuroda 0:13a5d365ba16 272
ykuroda 0:13a5d365ba16 273 CommaInitializer<Derived> operator<< (const Scalar& s);
ykuroda 0:13a5d365ba16 274
ykuroda 0:13a5d365ba16 275 template<unsigned int Added,unsigned int Removed>
ykuroda 0:13a5d365ba16 276 const Flagged<Derived, Added, Removed> flagged() const;
ykuroda 0:13a5d365ba16 277
ykuroda 0:13a5d365ba16 278 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 279 CommaInitializer<Derived> operator<< (const DenseBase<OtherDerived>& other);
ykuroda 0:13a5d365ba16 280
ykuroda 0:13a5d365ba16 281 Eigen::Transpose<Derived> transpose();
ykuroda 0:13a5d365ba16 282 typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType;
ykuroda 0:13a5d365ba16 283 ConstTransposeReturnType transpose() const;
ykuroda 0:13a5d365ba16 284 void transposeInPlace();
ykuroda 0:13a5d365ba16 285 #ifndef EIGEN_NO_DEBUG
ykuroda 0:13a5d365ba16 286 protected:
ykuroda 0:13a5d365ba16 287 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 288 void checkTransposeAliasing(const OtherDerived& other) const;
ykuroda 0:13a5d365ba16 289 public:
ykuroda 0:13a5d365ba16 290 #endif
ykuroda 0:13a5d365ba16 291
ykuroda 0:13a5d365ba16 292
ykuroda 0:13a5d365ba16 293 static const ConstantReturnType
ykuroda 0:13a5d365ba16 294 Constant(Index rows, Index cols, const Scalar& value);
ykuroda 0:13a5d365ba16 295 static const ConstantReturnType
ykuroda 0:13a5d365ba16 296 Constant(Index size, const Scalar& value);
ykuroda 0:13a5d365ba16 297 static const ConstantReturnType
ykuroda 0:13a5d365ba16 298 Constant(const Scalar& value);
ykuroda 0:13a5d365ba16 299
ykuroda 0:13a5d365ba16 300 static const SequentialLinSpacedReturnType
ykuroda 0:13a5d365ba16 301 LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high);
ykuroda 0:13a5d365ba16 302 static const RandomAccessLinSpacedReturnType
ykuroda 0:13a5d365ba16 303 LinSpaced(Index size, const Scalar& low, const Scalar& high);
ykuroda 0:13a5d365ba16 304 static const SequentialLinSpacedReturnType
ykuroda 0:13a5d365ba16 305 LinSpaced(Sequential_t, const Scalar& low, const Scalar& high);
ykuroda 0:13a5d365ba16 306 static const RandomAccessLinSpacedReturnType
ykuroda 0:13a5d365ba16 307 LinSpaced(const Scalar& low, const Scalar& high);
ykuroda 0:13a5d365ba16 308
ykuroda 0:13a5d365ba16 309 template<typename CustomNullaryOp>
ykuroda 0:13a5d365ba16 310 static const CwiseNullaryOp<CustomNullaryOp, Derived>
ykuroda 0:13a5d365ba16 311 NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func);
ykuroda 0:13a5d365ba16 312 template<typename CustomNullaryOp>
ykuroda 0:13a5d365ba16 313 static const CwiseNullaryOp<CustomNullaryOp, Derived>
ykuroda 0:13a5d365ba16 314 NullaryExpr(Index size, const CustomNullaryOp& func);
ykuroda 0:13a5d365ba16 315 template<typename CustomNullaryOp>
ykuroda 0:13a5d365ba16 316 static const CwiseNullaryOp<CustomNullaryOp, Derived>
ykuroda 0:13a5d365ba16 317 NullaryExpr(const CustomNullaryOp& func);
ykuroda 0:13a5d365ba16 318
ykuroda 0:13a5d365ba16 319 static const ConstantReturnType Zero(Index rows, Index cols);
ykuroda 0:13a5d365ba16 320 static const ConstantReturnType Zero(Index size);
ykuroda 0:13a5d365ba16 321 static const ConstantReturnType Zero();
ykuroda 0:13a5d365ba16 322 static const ConstantReturnType Ones(Index rows, Index cols);
ykuroda 0:13a5d365ba16 323 static const ConstantReturnType Ones(Index size);
ykuroda 0:13a5d365ba16 324 static const ConstantReturnType Ones();
ykuroda 0:13a5d365ba16 325
ykuroda 0:13a5d365ba16 326 void fill(const Scalar& value);
ykuroda 0:13a5d365ba16 327 Derived& setConstant(const Scalar& value);
ykuroda 0:13a5d365ba16 328 Derived& setLinSpaced(Index size, const Scalar& low, const Scalar& high);
ykuroda 0:13a5d365ba16 329 Derived& setLinSpaced(const Scalar& low, const Scalar& high);
ykuroda 0:13a5d365ba16 330 Derived& setZero();
ykuroda 0:13a5d365ba16 331 Derived& setOnes();
ykuroda 0:13a5d365ba16 332 Derived& setRandom();
ykuroda 0:13a5d365ba16 333
ykuroda 0:13a5d365ba16 334 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 335 bool isApprox(const DenseBase<OtherDerived>& other,
ykuroda 0:13a5d365ba16 336 const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
ykuroda 0:13a5d365ba16 337 bool isMuchSmallerThan(const RealScalar& other,
ykuroda 0:13a5d365ba16 338 const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
ykuroda 0:13a5d365ba16 339 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 340 bool isMuchSmallerThan(const DenseBase<OtherDerived>& other,
ykuroda 0:13a5d365ba16 341 const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
ykuroda 0:13a5d365ba16 342
ykuroda 0:13a5d365ba16 343 bool isApproxToConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
ykuroda 0:13a5d365ba16 344 bool isConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
ykuroda 0:13a5d365ba16 345 bool isZero(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
ykuroda 0:13a5d365ba16 346 bool isOnes(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
ykuroda 0:13a5d365ba16 347
ykuroda 0:13a5d365ba16 348 inline bool hasNaN() const;
ykuroda 0:13a5d365ba16 349 inline bool allFinite() const;
ykuroda 0:13a5d365ba16 350
ykuroda 0:13a5d365ba16 351 inline Derived& operator*=(const Scalar& other);
ykuroda 0:13a5d365ba16 352 inline Derived& operator/=(const Scalar& other);
ykuroda 0:13a5d365ba16 353
ykuroda 0:13a5d365ba16 354 typedef typename internal::add_const_on_value_type<typename internal::eval<Derived>::type>::type EvalReturnType;
ykuroda 0:13a5d365ba16 355 /** \returns the matrix or vector obtained by evaluating this expression.
ykuroda 0:13a5d365ba16 356 *
ykuroda 0:13a5d365ba16 357 * Notice that in the case of a plain matrix or vector (not an expression) this function just returns
ykuroda 0:13a5d365ba16 358 * a const reference, in order to avoid a useless copy.
ykuroda 0:13a5d365ba16 359 */
ykuroda 0:13a5d365ba16 360 EIGEN_STRONG_INLINE EvalReturnType eval() const
ykuroda 0:13a5d365ba16 361 {
ykuroda 0:13a5d365ba16 362 // Even though MSVC does not honor strong inlining when the return type
ykuroda 0:13a5d365ba16 363 // is a dynamic matrix, we desperately need strong inlining for fixed
ykuroda 0:13a5d365ba16 364 // size types on MSVC.
ykuroda 0:13a5d365ba16 365 return typename internal::eval<Derived>::type(derived());
ykuroda 0:13a5d365ba16 366 }
ykuroda 0:13a5d365ba16 367
ykuroda 0:13a5d365ba16 368 /** swaps *this with the expression \a other.
ykuroda 0:13a5d365ba16 369 *
ykuroda 0:13a5d365ba16 370 */
ykuroda 0:13a5d365ba16 371 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 372 void swap(const DenseBase<OtherDerived>& other,
ykuroda 0:13a5d365ba16 373 int = OtherDerived::ThisConstantIsPrivateInPlainObjectBase)
ykuroda 0:13a5d365ba16 374 {
ykuroda 0:13a5d365ba16 375 SwapWrapper<Derived>(derived()).lazyAssign(other.derived());
ykuroda 0:13a5d365ba16 376 }
ykuroda 0:13a5d365ba16 377
ykuroda 0:13a5d365ba16 378 /** swaps *this with the matrix or array \a other.
ykuroda 0:13a5d365ba16 379 *
ykuroda 0:13a5d365ba16 380 */
ykuroda 0:13a5d365ba16 381 template<typename OtherDerived>
ykuroda 0:13a5d365ba16 382 void swap(PlainObjectBase<OtherDerived>& other)
ykuroda 0:13a5d365ba16 383 {
ykuroda 0:13a5d365ba16 384 SwapWrapper<Derived>(derived()).lazyAssign(other.derived());
ykuroda 0:13a5d365ba16 385 }
ykuroda 0:13a5d365ba16 386
ykuroda 0:13a5d365ba16 387
ykuroda 0:13a5d365ba16 388 inline const NestByValue<Derived> nestByValue() const;
ykuroda 0:13a5d365ba16 389 inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;
ykuroda 0:13a5d365ba16 390 inline ForceAlignedAccess<Derived> forceAlignedAccess();
ykuroda 0:13a5d365ba16 391 template<bool Enable> inline const typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf() const;
ykuroda 0:13a5d365ba16 392 template<bool Enable> inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf();
ykuroda 0:13a5d365ba16 393
ykuroda 0:13a5d365ba16 394 Scalar sum() const;
ykuroda 0:13a5d365ba16 395 Scalar mean() const;
ykuroda 0:13a5d365ba16 396 Scalar trace() const;
ykuroda 0:13a5d365ba16 397
ykuroda 0:13a5d365ba16 398 Scalar prod() const;
ykuroda 0:13a5d365ba16 399
ykuroda 0:13a5d365ba16 400 typename internal::traits<Derived>::Scalar minCoeff() const;
ykuroda 0:13a5d365ba16 401 typename internal::traits<Derived>::Scalar maxCoeff() const;
ykuroda 0:13a5d365ba16 402
ykuroda 0:13a5d365ba16 403 template<typename IndexType>
ykuroda 0:13a5d365ba16 404 typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col) const;
ykuroda 0:13a5d365ba16 405 template<typename IndexType>
ykuroda 0:13a5d365ba16 406 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col) const;
ykuroda 0:13a5d365ba16 407 template<typename IndexType>
ykuroda 0:13a5d365ba16 408 typename internal::traits<Derived>::Scalar minCoeff(IndexType* index) const;
ykuroda 0:13a5d365ba16 409 template<typename IndexType>
ykuroda 0:13a5d365ba16 410 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index) const;
ykuroda 0:13a5d365ba16 411
ykuroda 0:13a5d365ba16 412 template<typename BinaryOp>
ykuroda 0:13a5d365ba16 413 typename internal::result_of<BinaryOp(typename internal::traits<Derived>::Scalar)>::type
ykuroda 0:13a5d365ba16 414 redux(const BinaryOp& func) const;
ykuroda 0:13a5d365ba16 415
ykuroda 0:13a5d365ba16 416 template<typename Visitor>
ykuroda 0:13a5d365ba16 417 void visit(Visitor& func) const;
ykuroda 0:13a5d365ba16 418
ykuroda 0:13a5d365ba16 419 inline const WithFormat<Derived> format(const IOFormat& fmt) const;
ykuroda 0:13a5d365ba16 420
ykuroda 0:13a5d365ba16 421 /** \returns the unique coefficient of a 1x1 expression */
ykuroda 0:13a5d365ba16 422 CoeffReturnType value() const
ykuroda 0:13a5d365ba16 423 {
ykuroda 0:13a5d365ba16 424 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
ykuroda 0:13a5d365ba16 425 eigen_assert(this->rows() == 1 && this->cols() == 1);
ykuroda 0:13a5d365ba16 426 return derived().coeff(0,0);
ykuroda 0:13a5d365ba16 427 }
ykuroda 0:13a5d365ba16 428
ykuroda 0:13a5d365ba16 429 bool all(void) const;
ykuroda 0:13a5d365ba16 430 bool any(void) const;
ykuroda 0:13a5d365ba16 431 Index count() const;
ykuroda 0:13a5d365ba16 432
ykuroda 0:13a5d365ba16 433 typedef VectorwiseOp<Derived, Horizontal> RowwiseReturnType;
ykuroda 0:13a5d365ba16 434 typedef const VectorwiseOp<const Derived, Horizontal> ConstRowwiseReturnType;
ykuroda 0:13a5d365ba16 435 typedef VectorwiseOp<Derived, Vertical> ColwiseReturnType;
ykuroda 0:13a5d365ba16 436 typedef const VectorwiseOp<const Derived, Vertical> ConstColwiseReturnType;
ykuroda 0:13a5d365ba16 437
ykuroda 0:13a5d365ba16 438 ConstRowwiseReturnType rowwise() const;
ykuroda 0:13a5d365ba16 439 RowwiseReturnType rowwise();
ykuroda 0:13a5d365ba16 440 ConstColwiseReturnType colwise() const;
ykuroda 0:13a5d365ba16 441 ColwiseReturnType colwise();
ykuroda 0:13a5d365ba16 442
ykuroda 0:13a5d365ba16 443 static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index rows, Index cols);
ykuroda 0:13a5d365ba16 444 static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index size);
ykuroda 0:13a5d365ba16 445 static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random();
ykuroda 0:13a5d365ba16 446
ykuroda 0:13a5d365ba16 447 template<typename ThenDerived,typename ElseDerived>
ykuroda 0:13a5d365ba16 448 const Select<Derived,ThenDerived,ElseDerived>
ykuroda 0:13a5d365ba16 449 select(const DenseBase<ThenDerived>& thenMatrix,
ykuroda 0:13a5d365ba16 450 const DenseBase<ElseDerived>& elseMatrix) const;
ykuroda 0:13a5d365ba16 451
ykuroda 0:13a5d365ba16 452 template<typename ThenDerived>
ykuroda 0:13a5d365ba16 453 inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
ykuroda 0:13a5d365ba16 454 select(const DenseBase<ThenDerived>& thenMatrix, const typename ThenDerived::Scalar& elseScalar) const;
ykuroda 0:13a5d365ba16 455
ykuroda 0:13a5d365ba16 456 template<typename ElseDerived>
ykuroda 0:13a5d365ba16 457 inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
ykuroda 0:13a5d365ba16 458 select(const typename ElseDerived::Scalar& thenScalar, const DenseBase<ElseDerived>& elseMatrix) const;
ykuroda 0:13a5d365ba16 459
ykuroda 0:13a5d365ba16 460 template<int p> RealScalar lpNorm() const;
ykuroda 0:13a5d365ba16 461
ykuroda 0:13a5d365ba16 462 template<int RowFactor, int ColFactor>
ykuroda 0:13a5d365ba16 463 inline const Replicate<Derived,RowFactor,ColFactor> replicate() const;
ykuroda 0:13a5d365ba16 464
ykuroda 0:13a5d365ba16 465 typedef Replicate<Derived,Dynamic,Dynamic> ReplicateReturnType;
ykuroda 0:13a5d365ba16 466 inline const ReplicateReturnType replicate(Index rowFacor,Index colFactor) const;
ykuroda 0:13a5d365ba16 467
ykuroda 0:13a5d365ba16 468 typedef Reverse<Derived, BothDirections> ReverseReturnType;
ykuroda 0:13a5d365ba16 469 typedef const Reverse<const Derived, BothDirections> ConstReverseReturnType;
ykuroda 0:13a5d365ba16 470 ReverseReturnType reverse();
ykuroda 0:13a5d365ba16 471 ConstReverseReturnType reverse() const;
ykuroda 0:13a5d365ba16 472 void reverseInPlace();
ykuroda 0:13a5d365ba16 473
ykuroda 0:13a5d365ba16 474 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
ykuroda 0:13a5d365ba16 475 # include "../plugins/BlockMethods.h"
ykuroda 0:13a5d365ba16 476 # ifdef EIGEN_DENSEBASE_PLUGIN
ykuroda 0:13a5d365ba16 477 # include EIGEN_DENSEBASE_PLUGIN
ykuroda 0:13a5d365ba16 478 # endif
ykuroda 0:13a5d365ba16 479 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
ykuroda 0:13a5d365ba16 480
ykuroda 0:13a5d365ba16 481 #ifdef EIGEN2_SUPPORT
ykuroda 0:13a5d365ba16 482
ykuroda 0:13a5d365ba16 483 Block<Derived> corner(CornerType type, Index cRows, Index cCols);
ykuroda 0:13a5d365ba16 484 const Block<Derived> corner(CornerType type, Index cRows, Index cCols) const;
ykuroda 0:13a5d365ba16 485 template<int CRows, int CCols>
ykuroda 0:13a5d365ba16 486 Block<Derived, CRows, CCols> corner(CornerType type);
ykuroda 0:13a5d365ba16 487 template<int CRows, int CCols>
ykuroda 0:13a5d365ba16 488 const Block<Derived, CRows, CCols> corner(CornerType type) const;
ykuroda 0:13a5d365ba16 489
ykuroda 0:13a5d365ba16 490 #endif // EIGEN2_SUPPORT
ykuroda 0:13a5d365ba16 491
ykuroda 0:13a5d365ba16 492
ykuroda 0:13a5d365ba16 493 // disable the use of evalTo for dense objects with a nice compilation error
ykuroda 0:13a5d365ba16 494 template<typename Dest> inline void evalTo(Dest& ) const
ykuroda 0:13a5d365ba16 495 {
ykuroda 0:13a5d365ba16 496 EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
ykuroda 0:13a5d365ba16 497 }
ykuroda 0:13a5d365ba16 498
ykuroda 0:13a5d365ba16 499 protected:
ykuroda 0:13a5d365ba16 500 /** Default constructor. Do nothing. */
ykuroda 0:13a5d365ba16 501 DenseBase()
ykuroda 0:13a5d365ba16 502 {
ykuroda 0:13a5d365ba16 503 /* Just checks for self-consistency of the flags.
ykuroda 0:13a5d365ba16 504 * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down
ykuroda 0:13a5d365ba16 505 */
ykuroda 0:13a5d365ba16 506 #ifdef EIGEN_INTERNAL_DEBUGGING
ykuroda 0:13a5d365ba16 507 EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, int(IsRowMajor))
ykuroda 0:13a5d365ba16 508 && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, int(!IsRowMajor))),
ykuroda 0:13a5d365ba16 509 INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
ykuroda 0:13a5d365ba16 510 #endif
ykuroda 0:13a5d365ba16 511 }
ykuroda 0:13a5d365ba16 512
ykuroda 0:13a5d365ba16 513 private:
ykuroda 0:13a5d365ba16 514 explicit DenseBase(int);
ykuroda 0:13a5d365ba16 515 DenseBase(int,int);
ykuroda 0:13a5d365ba16 516 template<typename OtherDerived> explicit DenseBase(const DenseBase<OtherDerived>&);
ykuroda 0:13a5d365ba16 517 };
ykuroda 0:13a5d365ba16 518
ykuroda 0:13a5d365ba16 519 } // end namespace Eigen
ykuroda 0:13a5d365ba16 520
ykuroda 0:13a5d365ba16 521 #endif // EIGEN_DENSEBASE_H