00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_MATRIXBASE_H
00027 #define EIGEN_MATRIXBASE_H
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 template<typename Derived> class MatrixBase
00059 : public DenseBase<Derived>
00060 {
00061 public:
00062 #ifndef EIGEN_PARSED_BY_DOXYGEN
00063 typedef MatrixBase StorageBaseType;
00064 typedef typename internal::traits<Derived>::StorageKind StorageKind;
00065 typedef typename internal::traits<Derived>::Index Index;
00066 typedef typename internal::traits<Derived>::Scalar Scalar;
00067 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
00068 typedef typename NumTraits<Scalar>::Real RealScalar;
00069
00070 typedef DenseBase<Derived> Base;
00071 using Base::RowsAtCompileTime;
00072 using Base::ColsAtCompileTime;
00073 using Base::SizeAtCompileTime;
00074 using Base::MaxRowsAtCompileTime;
00075 using Base::MaxColsAtCompileTime;
00076 using Base::MaxSizeAtCompileTime;
00077 using Base::IsVectorAtCompileTime;
00078 using Base::Flags;
00079 using Base::CoeffReadCost;
00080
00081 using Base::derived;
00082 using Base::const_cast_derived;
00083 using Base::rows;
00084 using Base::cols;
00085 using Base::size;
00086 using Base::coeff;
00087 using Base::coeffRef;
00088 using Base::lazyAssign;
00089 using Base::eval;
00090 using Base::operator+=;
00091 using Base::operator-=;
00092 using Base::operator*=;
00093 using Base::operator/=;
00094
00095 typedef typename Base::CoeffReturnType CoeffReturnType;
00096 typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType;
00097 typedef typename Base::RowXpr RowXpr;
00098 typedef typename Base::ColXpr ColXpr;
00099 #endif // not EIGEN_PARSED_BY_DOXYGEN
00100
00101
00102
00103 #ifndef EIGEN_PARSED_BY_DOXYGEN
00104
00105 typedef Matrix<Scalar,EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime),
00106 EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
00107 #endif // not EIGEN_PARSED_BY_DOXYGEN
00108
00109
00110
00111 inline Index diagonalSize() const { return std::min(rows(),cols()); }
00112
00113
00114
00115
00116
00117
00118
00119 typedef Matrix<typename internal::traits<Derived>::Scalar,
00120 internal::traits<Derived>::RowsAtCompileTime,
00121 internal::traits<Derived>::ColsAtCompileTime,
00122 AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
00123 internal::traits<Derived>::MaxRowsAtCompileTime,
00124 internal::traits<Derived>::MaxColsAtCompileTime
00125 > PlainObject;
00126
00127 #ifndef EIGEN_PARSED_BY_DOXYGEN
00128
00129 typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
00130
00131 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00132 CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,
00133 ConstTransposeReturnType
00134 >::type AdjointReturnType;
00135
00136 typedef Matrix<std::complex<RealScalar>, internal::traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType;
00137
00138 typedef CwiseNullaryOp<internal::scalar_identity_op<Scalar>,Derived> IdentityReturnType;
00139
00140 typedef Block<CwiseNullaryOp<internal::scalar_identity_op<Scalar>, SquareMatrixType>,
00141 internal::traits<Derived>::RowsAtCompileTime,
00142 internal::traits<Derived>::ColsAtCompileTime> BasisReturnType;
00143 #endif // not EIGEN_PARSED_BY_DOXYGEN
00144
00145 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase
00146 # include "../plugins/CommonCwiseUnaryOps.h"
00147 # include "../plugins/CommonCwiseBinaryOps.h"
00148 # include "../plugins/MatrixCwiseUnaryOps.h"
00149 # include "../plugins/MatrixCwiseBinaryOps.h"
00150 # ifdef EIGEN_MATRIXBASE_PLUGIN
00151 # include EIGEN_MATRIXBASE_PLUGIN
00152 # endif
00153 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
00154
00155
00156
00157
00158 Derived& operator=(const MatrixBase& other);
00159
00160
00161
00162
00163 template <typename OtherDerived>
00164 Derived& operator=(const DenseBase<OtherDerived>& other);
00165
00166 template <typename OtherDerived>
00167 Derived& operator=(const EigenBase<OtherDerived>& other);
00168
00169 template<typename OtherDerived>
00170 Derived& operator=(const ReturnByValue<OtherDerived>& other);
00171
00172 #ifndef EIGEN_PARSED_BY_DOXYGEN
00173 template<typename ProductDerived, typename Lhs, typename Rhs>
00174 Derived& lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other);
00175 #endif // not EIGEN_PARSED_BY_DOXYGEN
00176
00177 template<typename OtherDerived>
00178 Derived& operator+=(const MatrixBase<OtherDerived>& other);
00179 template<typename OtherDerived>
00180 Derived& operator-=(const MatrixBase<OtherDerived>& other);
00181
00182 template<typename OtherDerived>
00183 const typename ProductReturnType<Derived,OtherDerived>::Type
00184 operator*(const MatrixBase<OtherDerived> &other) const;
00185
00186 template<typename OtherDerived>
00187 const typename LazyProductReturnType<Derived,OtherDerived>::Type
00188 lazyProduct(const MatrixBase<OtherDerived> &other) const;
00189
00190 template<typename OtherDerived>
00191 Derived& operator*=(const EigenBase<OtherDerived>& other);
00192
00193 template<typename OtherDerived>
00194 void applyOnTheLeft(const EigenBase<OtherDerived>& other);
00195
00196 template<typename OtherDerived>
00197 void applyOnTheRight(const EigenBase<OtherDerived>& other);
00198
00199 template<typename DiagonalDerived>
00200 const DiagonalProduct<Derived, DiagonalDerived, OnTheRight>
00201 operator*(const DiagonalBase<DiagonalDerived> &diagonal) const;
00202
00203 template<typename OtherDerived>
00204 Scalar dot(const MatrixBase<OtherDerived>& other) const;
00205 RealScalar squaredNorm() const;
00206 RealScalar norm() const;
00207 RealScalar stableNorm() const;
00208 RealScalar blueNorm() const;
00209 RealScalar hypotNorm() const;
00210 const PlainObject normalized() const;
00211 void normalize();
00212
00213 const AdjointReturnType adjoint() const;
00214 void adjointInPlace();
00215
00216 typedef Diagonal<Derived> DiagonalReturnType;
00217 DiagonalReturnType diagonal();
00218 typedef const Diagonal<const Derived> ConstDiagonalReturnType;
00219 ConstDiagonalReturnType diagonal() const;
00220
00221 template<int Index> struct DiagonalIndexReturnType { typedef Diagonal<Derived,Index> Type; };
00222 template<int Index> struct ConstDiagonalIndexReturnType { typedef const Diagonal<const Derived,Index> Type; };
00223
00224 template<int Index> typename DiagonalIndexReturnType<Index>::Type diagonal();
00225 template<int Index> typename ConstDiagonalIndexReturnType<Index>::Type diagonal() const;
00226
00227
00228 typename MatrixBase::template DiagonalIndexReturnType<Dynamic>::Type diagonal(Index index);
00229 typename MatrixBase::template ConstDiagonalIndexReturnType<Dynamic>::Type diagonal(Index index) const;
00230
00231 template<unsigned int Mode> TriangularView<Derived, Mode> part();
00232 template<unsigned int Mode> const TriangularView<Derived, Mode> part() const;
00233
00234 template<unsigned int Mode> struct TriangularViewReturnType { typedef TriangularView<Derived, Mode> Type; };
00235 template<unsigned int Mode> struct ConstTriangularViewReturnType { typedef const TriangularView<const Derived, Mode> Type; };
00236
00237 template<unsigned int Mode> typename TriangularViewReturnType<Mode>::Type triangularView();
00238 template<unsigned int Mode> typename ConstTriangularViewReturnType<Mode>::Type triangularView() const;
00239
00240 template<unsigned int UpLo> struct SelfAdjointViewReturnType { typedef SelfAdjointView<Derived, UpLo> Type; };
00241 template<unsigned int UpLo> struct ConstSelfAdjointViewReturnType { typedef const SelfAdjointView<const Derived, UpLo> Type; };
00242
00243 template<unsigned int UpLo> typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
00244 template<unsigned int UpLo> typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView() const;
00245
00246 const SparseView<Derived> sparseView(const Scalar& m_reference = Scalar(0),
00247 typename NumTraits<Scalar>::Real m_epsilon = NumTraits<Scalar>::dummy_precision()) const;
00248 static const IdentityReturnType Identity();
00249 static const IdentityReturnType Identity(Index rows, Index cols);
00250 static const BasisReturnType Unit(Index size, Index i);
00251 static const BasisReturnType Unit(Index i);
00252 static const BasisReturnType UnitX();
00253 static const BasisReturnType UnitY();
00254 static const BasisReturnType UnitZ();
00255 static const BasisReturnType UnitW();
00256
00257 const DiagonalWrapper<Derived> asDiagonal() const;
00258
00259 Derived& setIdentity();
00260 Derived& setIdentity(Index rows, Index cols);
00261
00262 bool isIdentity(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00263 bool isDiagonal(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00264
00265 bool isUpperTriangular(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00266 bool isLowerTriangular(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00267
00268 template<typename OtherDerived>
00269 bool isOrthogonal(const MatrixBase<OtherDerived>& other,
00270 RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00271 bool isUnitary(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00272
00273
00274
00275
00276
00277 template<typename OtherDerived>
00278 inline bool operator==(const MatrixBase<OtherDerived>& other) const
00279 { return cwiseEqual(other).all(); }
00280
00281
00282
00283
00284
00285 template<typename OtherDerived>
00286 inline bool operator!=(const MatrixBase<OtherDerived>& other) const
00287 { return cwiseNotEqual(other).any(); }
00288
00289 NoAlias<Derived,Eigen::MatrixBase > noalias();
00290
00291 inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;
00292 inline ForceAlignedAccess<Derived> forceAlignedAccess();
00293 template<bool Enable> inline typename internal::add_const_on_value_type<typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type>::type forceAlignedAccessIf() const;
00294 template<bool Enable> inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf();
00295
00296 Scalar trace() const;
00297
00298
00299
00300 template<int p> RealScalar lpNorm() const;
00301
00302 MatrixBase<Derived>& matrix() { return *this; }
00303 const MatrixBase<Derived>& matrix() const { return *this; }
00304
00305
00306
00307 ArrayWrapper<Derived> array() { return derived(); }
00308 const ArrayWrapper<Derived> array() const { return derived(); }
00309
00310
00311
00312 const FullPivLU<PlainObject> fullPivLu() const;
00313 const PartialPivLU<PlainObject> partialPivLu() const;
00314 const PartialPivLU<PlainObject> lu() const;
00315 const internal::inverse_impl<Derived> inverse() const;
00316 template<typename ResultType>
00317 void computeInverseAndDetWithCheck(
00318 ResultType& inverse,
00319 typename ResultType::Scalar& determinant,
00320 bool& invertible,
00321 const RealScalar& absDeterminantThreshold = NumTraits<Scalar>::dummy_precision()
00322 ) const;
00323 template<typename ResultType>
00324 void computeInverseWithCheck(
00325 ResultType& inverse,
00326 bool& invertible,
00327 const RealScalar& absDeterminantThreshold = NumTraits<Scalar>::dummy_precision()
00328 ) const;
00329 Scalar determinant() const;
00330
00331
00332
00333 const LLT<PlainObject> llt() const;
00334 const LDLT<PlainObject> ldlt() const;
00335
00336
00337
00338 const HouseholderQR<PlainObject> householderQr() const;
00339 const ColPivHouseholderQR<PlainObject> colPivHouseholderQr() const;
00340 const FullPivHouseholderQR<PlainObject> fullPivHouseholderQr() const;
00341
00342 EigenvaluesReturnType eigenvalues() const;
00343 RealScalar operatorNorm() const;
00344
00345
00346
00347 JacobiSVD<PlainObject> jacobiSvd(unsigned int computationOptions = 0) const;
00348
00349
00350
00351 template<typename OtherDerived>
00352 PlainObject cross(const MatrixBase<OtherDerived>& other) const;
00353 template<typename OtherDerived>
00354 PlainObject cross3(const MatrixBase<OtherDerived>& other) const;
00355 PlainObject unitOrthogonal(void) const;
00356 Matrix<Scalar,3,1> eulerAngles(Index a0, Index a1, Index a2) const;
00357 ScalarMultipleReturnType operator*(const UniformScaling<Scalar>& s) const;
00358 enum {
00359 SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1
00360 };
00361 typedef Block<const Derived,
00362 internal::traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1,
00363 internal::traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> ConstStartMinusOne;
00364 typedef CwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>,
00365 ConstStartMinusOne > HNormalizedReturnType;
00366
00367 const HNormalizedReturnType hnormalized() const;
00368
00369
00370 enum { HomogeneousReturnTypeDirection = ColsAtCompileTime==1?Vertical:Horizontal };
00371 typedef Homogeneous<Derived, HomogeneousReturnTypeDirection> HomogeneousReturnType;
00372
00373 HomogeneousReturnType homogeneous() const;
00374
00375
00376
00377 void makeHouseholderInPlace(Scalar& tau, RealScalar& beta);
00378 template<typename EssentialPart>
00379 void makeHouseholder(EssentialPart& essential,
00380 Scalar& tau, RealScalar& beta) const;
00381 template<typename EssentialPart>
00382 void applyHouseholderOnTheLeft(const EssentialPart& essential,
00383 const Scalar& tau,
00384 Scalar* workspace);
00385 template<typename EssentialPart>
00386 void applyHouseholderOnTheRight(const EssentialPart& essential,
00387 const Scalar& tau,
00388 Scalar* workspace);
00389
00390
00391
00392 template<typename OtherScalar>
00393 void applyOnTheLeft(Index p, Index q, const JacobiRotation<OtherScalar>& j);
00394 template<typename OtherScalar>
00395 void applyOnTheRight(Index p, Index q, const JacobiRotation<OtherScalar>& j);
00396
00397
00398
00399 typedef typename internal::stem_function<Scalar>::type StemFunction;
00400 const MatrixExponentialReturnValue<Derived> exp() const;
00401 const MatrixFunctionReturnValue<Derived> matrixFunction(StemFunction f) const;
00402 const MatrixFunctionReturnValue<Derived> cosh() const;
00403 const MatrixFunctionReturnValue<Derived> sinh() const;
00404 const MatrixFunctionReturnValue<Derived> cos() const;
00405 const MatrixFunctionReturnValue<Derived> sin() const;
00406
00407 #ifdef EIGEN2_SUPPORT
00408 template<typename ProductDerived, typename Lhs, typename Rhs>
00409 Derived& operator+=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
00410 EvalBeforeAssigningBit>& other);
00411
00412 template<typename ProductDerived, typename Lhs, typename Rhs>
00413 Derived& operator-=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
00414 EvalBeforeAssigningBit>& other);
00415
00416
00417
00418 template<typename OtherDerived>
00419 Derived& lazyAssign(const Flagged<OtherDerived, 0, EvalBeforeAssigningBit>& other)
00420 { return lazyAssign(other._expression()); }
00421
00422 template<unsigned int Added>
00423 const Flagged<Derived, Added, 0> marked() const;
00424 const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const;
00425
00426 inline const Cwise<Derived> cwise() const;
00427 inline Cwise<Derived> cwise();
00428
00429 VectorBlock<Derived> start(Index size);
00430 const VectorBlock<Derived> start(Index size) const;
00431 VectorBlock<Derived> end(Index size);
00432 const VectorBlock<Derived> end(Index size) const;
00433 template<int Size> VectorBlock<Derived,Size> start();
00434 template<int Size> const VectorBlock<Derived,Size> start() const;
00435 template<int Size> VectorBlock<Derived,Size> end();
00436 template<int Size> const VectorBlock<Derived,Size> end() const;
00437
00438 Minor<Derived> minor(Index row, Index col);
00439 const Minor<Derived> minor(Index row, Index col) const;
00440 #endif
00441
00442 protected:
00443 MatrixBase() : Base() {}
00444
00445 private:
00446 explicit MatrixBase(int);
00447 MatrixBase(int,int);
00448 template<typename OtherDerived> explicit MatrixBase(const MatrixBase<OtherDerived>&);
00449 protected:
00450
00451 template<typename OtherDerived> Derived& operator+=(const ArrayBase<OtherDerived>& array)
00452 {EIGEN_STATIC_ASSERT(sizeof(typename OtherDerived::Scalar)==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);}
00453
00454 template<typename OtherDerived> Derived& operator-=(const ArrayBase<OtherDerived>& array)
00455 {EIGEN_STATIC_ASSERT(sizeof(typename OtherDerived::Scalar)==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);}
00456 };
00457
00458 #endif // EIGEN_MATRIXBASE_H