MatrixBase.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
  5. // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
  6. //
  7. // This Source Code Form is subject to the terms of the Mozilla
  8. // Public License v. 2.0. If a copy of the MPL was not distributed
  9. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  10. #ifndef EIGEN_MATRIXBASE_H
  11. #define EIGEN_MATRIXBASE_H
  12. namespace Eigen {
  13. /** \class MatrixBase
  14. * \ingroup Core_Module
  15. *
  16. * \brief Base class for all dense matrices, vectors, and expressions
  17. *
  18. * This class is the base that is inherited by all matrix, vector, and related expression
  19. * types. Most of the Eigen API is contained in this class, and its base classes. Other important
  20. * classes for the Eigen API are Matrix, and VectorwiseOp.
  21. *
  22. * Note that some methods are defined in other modules such as the \ref LU_Module LU module
  23. * for all functions related to matrix inversions.
  24. *
  25. * \tparam Derived is the derived type, e.g. a matrix type, or an expression, etc.
  26. *
  27. * When writing a function taking Eigen objects as argument, if you want your function
  28. * to take as argument any matrix, vector, or expression, just let it take a
  29. * MatrixBase argument. As an example, here is a function printFirstRow which, given
  30. * a matrix, vector, or expression \a x, prints the first row of \a x.
  31. *
  32. * \code
  33. template<typename Derived>
  34. void printFirstRow(const Eigen::MatrixBase<Derived>& x)
  35. {
  36. cout << x.row(0) << endl;
  37. }
  38. * \endcode
  39. *
  40. * This class can be extended with the help of the plugin mechanism described on the page
  41. * \ref TopicCustomizing_Plugins by defining the preprocessor symbol \c EIGEN_MATRIXBASE_PLUGIN.
  42. *
  43. * \sa \blank \ref TopicClassHierarchy
  44. */
  45. template<typename Derived> class MatrixBase
  46. : public DenseBase<Derived>
  47. {
  48. public:
  49. #ifndef EIGEN_PARSED_BY_DOXYGEN
  50. typedef MatrixBase StorageBaseType;
  51. typedef typename internal::traits<Derived>::StorageKind StorageKind;
  52. typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
  53. typedef typename internal::traits<Derived>::Scalar Scalar;
  54. typedef typename internal::packet_traits<Scalar>::type PacketScalar;
  55. typedef typename NumTraits<Scalar>::Real RealScalar;
  56. typedef DenseBase<Derived> Base;
  57. using Base::RowsAtCompileTime;
  58. using Base::ColsAtCompileTime;
  59. using Base::SizeAtCompileTime;
  60. using Base::MaxRowsAtCompileTime;
  61. using Base::MaxColsAtCompileTime;
  62. using Base::MaxSizeAtCompileTime;
  63. using Base::IsVectorAtCompileTime;
  64. using Base::Flags;
  65. using Base::derived;
  66. using Base::const_cast_derived;
  67. using Base::rows;
  68. using Base::cols;
  69. using Base::size;
  70. using Base::coeff;
  71. using Base::coeffRef;
  72. using Base::lazyAssign;
  73. using Base::eval;
  74. using Base::operator+=;
  75. using Base::operator-=;
  76. using Base::operator*=;
  77. using Base::operator/=;
  78. typedef typename Base::CoeffReturnType CoeffReturnType;
  79. typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType;
  80. typedef typename Base::RowXpr RowXpr;
  81. typedef typename Base::ColXpr ColXpr;
  82. #endif // not EIGEN_PARSED_BY_DOXYGEN
  83. #ifndef EIGEN_PARSED_BY_DOXYGEN
  84. /** type of the equivalent square matrix */
  85. typedef Matrix<Scalar,EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime),
  86. EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
  87. #endif // not EIGEN_PARSED_BY_DOXYGEN
  88. /** \returns the size of the main diagonal, which is min(rows(),cols()).
  89. * \sa rows(), cols(), SizeAtCompileTime. */
  90. EIGEN_DEVICE_FUNC
  91. inline Index diagonalSize() const { return (numext::mini)(rows(),cols()); }
  92. typedef typename Base::PlainObject PlainObject;
  93. #ifndef EIGEN_PARSED_BY_DOXYGEN
  94. /** \internal Represents a matrix with all coefficients equal to one another*/
  95. typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;
  96. /** \internal the return type of MatrixBase::adjoint() */
  97. typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
  98. CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,
  99. ConstTransposeReturnType
  100. >::type AdjointReturnType;
  101. /** \internal Return type of eigenvalues() */
  102. typedef Matrix<std::complex<RealScalar>, internal::traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType;
  103. /** \internal the return type of identity */
  104. typedef CwiseNullaryOp<internal::scalar_identity_op<Scalar>,PlainObject> IdentityReturnType;
  105. /** \internal the return type of unit vectors */
  106. typedef Block<const CwiseNullaryOp<internal::scalar_identity_op<Scalar>, SquareMatrixType>,
  107. internal::traits<Derived>::RowsAtCompileTime,
  108. internal::traits<Derived>::ColsAtCompileTime> BasisReturnType;
  109. #endif // not EIGEN_PARSED_BY_DOXYGEN
  110. #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase
  111. #define EIGEN_DOC_UNARY_ADDONS(X,Y)
  112. # include "../plugins/CommonCwiseUnaryOps.h"
  113. # include "../plugins/CommonCwiseBinaryOps.h"
  114. # include "../plugins/MatrixCwiseUnaryOps.h"
  115. # include "../plugins/MatrixCwiseBinaryOps.h"
  116. # ifdef EIGEN_MATRIXBASE_PLUGIN
  117. # include EIGEN_MATRIXBASE_PLUGIN
  118. # endif
  119. #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
  120. #undef EIGEN_DOC_UNARY_ADDONS
  121. /** Special case of the template operator=, in order to prevent the compiler
  122. * from generating a default operator= (issue hit with g++ 4.1)
  123. */
  124. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
  125. Derived& operator=(const MatrixBase& other);
  126. // We cannot inherit here via Base::operator= since it is causing
  127. // trouble with MSVC.
  128. template <typename OtherDerived>
  129. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
  130. Derived& operator=(const DenseBase<OtherDerived>& other);
  131. template <typename OtherDerived>
  132. EIGEN_DEVICE_FUNC
  133. Derived& operator=(const EigenBase<OtherDerived>& other);
  134. template<typename OtherDerived>
  135. EIGEN_DEVICE_FUNC
  136. Derived& operator=(const ReturnByValue<OtherDerived>& other);
  137. template<typename OtherDerived>
  138. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
  139. Derived& operator+=(const MatrixBase<OtherDerived>& other);
  140. template<typename OtherDerived>
  141. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
  142. Derived& operator-=(const MatrixBase<OtherDerived>& other);
  143. template<typename OtherDerived>
  144. EIGEN_DEVICE_FUNC
  145. const Product<Derived,OtherDerived>
  146. operator*(const MatrixBase<OtherDerived> &other) const;
  147. template<typename OtherDerived>
  148. EIGEN_DEVICE_FUNC
  149. const Product<Derived,OtherDerived,LazyProduct>
  150. lazyProduct(const MatrixBase<OtherDerived> &other) const;
  151. template<typename OtherDerived>
  152. Derived& operator*=(const EigenBase<OtherDerived>& other);
  153. template<typename OtherDerived>
  154. void applyOnTheLeft(const EigenBase<OtherDerived>& other);
  155. template<typename OtherDerived>
  156. void applyOnTheRight(const EigenBase<OtherDerived>& other);
  157. template<typename DiagonalDerived>
  158. EIGEN_DEVICE_FUNC
  159. const Product<Derived, DiagonalDerived, LazyProduct>
  160. operator*(const DiagonalBase<DiagonalDerived> &diagonal) const;
  161. template<typename OtherDerived>
  162. EIGEN_DEVICE_FUNC
  163. typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType
  164. dot(const MatrixBase<OtherDerived>& other) const;
  165. EIGEN_DEVICE_FUNC RealScalar squaredNorm() const;
  166. EIGEN_DEVICE_FUNC RealScalar norm() const;
  167. RealScalar stableNorm() const;
  168. RealScalar blueNorm() const;
  169. RealScalar hypotNorm() const;
  170. EIGEN_DEVICE_FUNC const PlainObject normalized() const;
  171. EIGEN_DEVICE_FUNC const PlainObject stableNormalized() const;
  172. EIGEN_DEVICE_FUNC void normalize();
  173. EIGEN_DEVICE_FUNC void stableNormalize();
  174. EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const;
  175. EIGEN_DEVICE_FUNC void adjointInPlace();
  176. typedef Diagonal<Derived> DiagonalReturnType;
  177. EIGEN_DEVICE_FUNC
  178. DiagonalReturnType diagonal();
  179. typedef typename internal::add_const<Diagonal<const Derived> >::type ConstDiagonalReturnType;
  180. EIGEN_DEVICE_FUNC
  181. ConstDiagonalReturnType diagonal() const;
  182. template<int Index> struct DiagonalIndexReturnType { typedef Diagonal<Derived,Index> Type; };
  183. template<int Index> struct ConstDiagonalIndexReturnType { typedef const Diagonal<const Derived,Index> Type; };
  184. template<int Index>
  185. EIGEN_DEVICE_FUNC
  186. typename DiagonalIndexReturnType<Index>::Type diagonal();
  187. template<int Index>
  188. EIGEN_DEVICE_FUNC
  189. typename ConstDiagonalIndexReturnType<Index>::Type diagonal() const;
  190. typedef Diagonal<Derived,DynamicIndex> DiagonalDynamicIndexReturnType;
  191. typedef typename internal::add_const<Diagonal<const Derived,DynamicIndex> >::type ConstDiagonalDynamicIndexReturnType;
  192. EIGEN_DEVICE_FUNC
  193. DiagonalDynamicIndexReturnType diagonal(Index index);
  194. EIGEN_DEVICE_FUNC
  195. ConstDiagonalDynamicIndexReturnType diagonal(Index index) const;
  196. template<unsigned int Mode> struct TriangularViewReturnType { typedef TriangularView<Derived, Mode> Type; };
  197. template<unsigned int Mode> struct ConstTriangularViewReturnType { typedef const TriangularView<const Derived, Mode> Type; };
  198. template<unsigned int Mode>
  199. EIGEN_DEVICE_FUNC
  200. typename TriangularViewReturnType<Mode>::Type triangularView();
  201. template<unsigned int Mode>
  202. EIGEN_DEVICE_FUNC
  203. typename ConstTriangularViewReturnType<Mode>::Type triangularView() const;
  204. template<unsigned int UpLo> struct SelfAdjointViewReturnType { typedef SelfAdjointView<Derived, UpLo> Type; };
  205. template<unsigned int UpLo> struct ConstSelfAdjointViewReturnType { typedef const SelfAdjointView<const Derived, UpLo> Type; };
  206. template<unsigned int UpLo>
  207. EIGEN_DEVICE_FUNC
  208. typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
  209. template<unsigned int UpLo>
  210. EIGEN_DEVICE_FUNC
  211. typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView() const;
  212. const SparseView<Derived> sparseView(const Scalar& m_reference = Scalar(0),
  213. const typename NumTraits<Scalar>::Real& m_epsilon = NumTraits<Scalar>::dummy_precision()) const;
  214. EIGEN_DEVICE_FUNC static const IdentityReturnType Identity();
  215. EIGEN_DEVICE_FUNC static const IdentityReturnType Identity(Index rows, Index cols);
  216. EIGEN_DEVICE_FUNC static const BasisReturnType Unit(Index size, Index i);
  217. EIGEN_DEVICE_FUNC static const BasisReturnType Unit(Index i);
  218. EIGEN_DEVICE_FUNC static const BasisReturnType UnitX();
  219. EIGEN_DEVICE_FUNC static const BasisReturnType UnitY();
  220. EIGEN_DEVICE_FUNC static const BasisReturnType UnitZ();
  221. EIGEN_DEVICE_FUNC static const BasisReturnType UnitW();
  222. EIGEN_DEVICE_FUNC
  223. const DiagonalWrapper<const Derived> asDiagonal() const;
  224. const PermutationWrapper<const Derived> asPermutation() const;
  225. EIGEN_DEVICE_FUNC
  226. Derived& setIdentity();
  227. EIGEN_DEVICE_FUNC
  228. Derived& setIdentity(Index rows, Index cols);
  229. bool isIdentity(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
  230. bool isDiagonal(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
  231. bool isUpperTriangular(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
  232. bool isLowerTriangular(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
  233. template<typename OtherDerived>
  234. bool isOrthogonal(const MatrixBase<OtherDerived>& other,
  235. const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
  236. bool isUnitary(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
  237. /** \returns true if each coefficients of \c *this and \a other are all exactly equal.
  238. * \warning When using floating point scalar values you probably should rather use a
  239. * fuzzy comparison such as isApprox()
  240. * \sa isApprox(), operator!= */
  241. template<typename OtherDerived>
  242. EIGEN_DEVICE_FUNC inline bool operator==(const MatrixBase<OtherDerived>& other) const
  243. { return cwiseEqual(other).all(); }
  244. /** \returns true if at least one pair of coefficients of \c *this and \a other are not exactly equal to each other.
  245. * \warning When using floating point scalar values you probably should rather use a
  246. * fuzzy comparison such as isApprox()
  247. * \sa isApprox(), operator== */
  248. template<typename OtherDerived>
  249. EIGEN_DEVICE_FUNC inline bool operator!=(const MatrixBase<OtherDerived>& other) const
  250. { return cwiseNotEqual(other).any(); }
  251. NoAlias<Derived,Eigen::MatrixBase > noalias();
  252. // TODO forceAlignedAccess is temporarily disabled
  253. // Need to find a nicer workaround.
  254. inline const Derived& forceAlignedAccess() const { return derived(); }
  255. inline Derived& forceAlignedAccess() { return derived(); }
  256. template<bool Enable> inline const Derived& forceAlignedAccessIf() const { return derived(); }
  257. template<bool Enable> inline Derived& forceAlignedAccessIf() { return derived(); }
  258. EIGEN_DEVICE_FUNC Scalar trace() const;
  259. template<int p> EIGEN_DEVICE_FUNC RealScalar lpNorm() const;
  260. EIGEN_DEVICE_FUNC MatrixBase<Derived>& matrix() { return *this; }
  261. EIGEN_DEVICE_FUNC const MatrixBase<Derived>& matrix() const { return *this; }
  262. /** \returns an \link Eigen::ArrayBase Array \endlink expression of this matrix
  263. * \sa ArrayBase::matrix() */
  264. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ArrayWrapper<Derived> array() { return ArrayWrapper<Derived>(derived()); }
  265. /** \returns a const \link Eigen::ArrayBase Array \endlink expression of this matrix
  266. * \sa ArrayBase::matrix() */
  267. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArrayWrapper<const Derived> array() const { return ArrayWrapper<const Derived>(derived()); }
  268. /////////// LU module ///////////
  269. inline const FullPivLU<PlainObject> fullPivLu() const;
  270. inline const PartialPivLU<PlainObject> partialPivLu() const;
  271. inline const PartialPivLU<PlainObject> lu() const;
  272. inline const Inverse<Derived> inverse() const;
  273. template<typename ResultType>
  274. inline void computeInverseAndDetWithCheck(
  275. ResultType& inverse,
  276. typename ResultType::Scalar& determinant,
  277. bool& invertible,
  278. const RealScalar& absDeterminantThreshold = NumTraits<Scalar>::dummy_precision()
  279. ) const;
  280. template<typename ResultType>
  281. inline void computeInverseWithCheck(
  282. ResultType& inverse,
  283. bool& invertible,
  284. const RealScalar& absDeterminantThreshold = NumTraits<Scalar>::dummy_precision()
  285. ) const;
  286. Scalar determinant() const;
  287. /////////// Cholesky module ///////////
  288. inline const LLT<PlainObject> llt() const;
  289. inline const LDLT<PlainObject> ldlt() const;
  290. /////////// QR module ///////////
  291. inline const HouseholderQR<PlainObject> householderQr() const;
  292. inline const ColPivHouseholderQR<PlainObject> colPivHouseholderQr() const;
  293. inline const FullPivHouseholderQR<PlainObject> fullPivHouseholderQr() const;
  294. inline const CompleteOrthogonalDecomposition<PlainObject> completeOrthogonalDecomposition() const;
  295. /////////// Eigenvalues module ///////////
  296. inline EigenvaluesReturnType eigenvalues() const;
  297. inline RealScalar operatorNorm() const;
  298. /////////// SVD module ///////////
  299. inline JacobiSVD<PlainObject> jacobiSvd(unsigned int computationOptions = 0) const;
  300. inline BDCSVD<PlainObject> bdcSvd(unsigned int computationOptions = 0) const;
  301. /////////// Geometry module ///////////
  302. #ifndef EIGEN_PARSED_BY_DOXYGEN
  303. /// \internal helper struct to form the return type of the cross product
  304. template<typename OtherDerived> struct cross_product_return_type {
  305. typedef typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType Scalar;
  306. typedef Matrix<Scalar,MatrixBase::RowsAtCompileTime,MatrixBase::ColsAtCompileTime> type;
  307. };
  308. #endif // EIGEN_PARSED_BY_DOXYGEN
  309. template<typename OtherDerived>
  310. EIGEN_DEVICE_FUNC
  311. #ifndef EIGEN_PARSED_BY_DOXYGEN
  312. inline typename cross_product_return_type<OtherDerived>::type
  313. #else
  314. inline PlainObject
  315. #endif
  316. cross(const MatrixBase<OtherDerived>& other) const;
  317. template<typename OtherDerived>
  318. EIGEN_DEVICE_FUNC
  319. inline PlainObject cross3(const MatrixBase<OtherDerived>& other) const;
  320. EIGEN_DEVICE_FUNC
  321. inline PlainObject unitOrthogonal(void) const;
  322. EIGEN_DEVICE_FUNC
  323. inline Matrix<Scalar,3,1> eulerAngles(Index a0, Index a1, Index a2) const;
  324. // put this as separate enum value to work around possible GCC 4.3 bug (?)
  325. enum { HomogeneousReturnTypeDirection = ColsAtCompileTime==1&&RowsAtCompileTime==1 ? ((internal::traits<Derived>::Flags&RowMajorBit)==RowMajorBit ? Horizontal : Vertical)
  326. : ColsAtCompileTime==1 ? Vertical : Horizontal };
  327. typedef Homogeneous<Derived, HomogeneousReturnTypeDirection> HomogeneousReturnType;
  328. EIGEN_DEVICE_FUNC
  329. inline HomogeneousReturnType homogeneous() const;
  330. enum {
  331. SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1
  332. };
  333. typedef Block<const Derived,
  334. internal::traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1,
  335. internal::traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> ConstStartMinusOne;
  336. typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(ConstStartMinusOne,Scalar,quotient) HNormalizedReturnType;
  337. EIGEN_DEVICE_FUNC
  338. inline const HNormalizedReturnType hnormalized() const;
  339. ////////// Householder module ///////////
  340. void makeHouseholderInPlace(Scalar& tau, RealScalar& beta);
  341. template<typename EssentialPart>
  342. void makeHouseholder(EssentialPart& essential,
  343. Scalar& tau, RealScalar& beta) const;
  344. template<typename EssentialPart>
  345. void applyHouseholderOnTheLeft(const EssentialPart& essential,
  346. const Scalar& tau,
  347. Scalar* workspace);
  348. template<typename EssentialPart>
  349. void applyHouseholderOnTheRight(const EssentialPart& essential,
  350. const Scalar& tau,
  351. Scalar* workspace);
  352. ///////// Jacobi module /////////
  353. template<typename OtherScalar>
  354. void applyOnTheLeft(Index p, Index q, const JacobiRotation<OtherScalar>& j);
  355. template<typename OtherScalar>
  356. void applyOnTheRight(Index p, Index q, const JacobiRotation<OtherScalar>& j);
  357. ///////// SparseCore module /////////
  358. template<typename OtherDerived>
  359. EIGEN_STRONG_INLINE const typename SparseMatrixBase<OtherDerived>::template CwiseProductDenseReturnType<Derived>::Type
  360. cwiseProduct(const SparseMatrixBase<OtherDerived> &other) const
  361. {
  362. return other.cwiseProduct(derived());
  363. }
  364. ///////// MatrixFunctions module /////////
  365. typedef typename internal::stem_function<Scalar>::type StemFunction;
  366. #define EIGEN_MATRIX_FUNCTION(ReturnType, Name, Description) \
  367. /** \returns an expression of the matrix Description of \c *this. \brief This function requires the <a href="unsupported/group__MatrixFunctions__Module.html"> unsupported MatrixFunctions module</a>. To compute the coefficient-wise Description use ArrayBase::##Name . */ \
  368. const ReturnType<Derived> Name() const;
  369. #define EIGEN_MATRIX_FUNCTION_1(ReturnType, Name, Description, Argument) \
  370. /** \returns an expression of the matrix Description of \c *this. \brief This function requires the <a href="unsupported/group__MatrixFunctions__Module.html"> unsupported MatrixFunctions module</a>. To compute the coefficient-wise Description use ArrayBase::##Name . */ \
  371. const ReturnType<Derived> Name(Argument) const;
  372. EIGEN_MATRIX_FUNCTION(MatrixExponentialReturnValue, exp, exponential)
  373. /** \brief Helper function for the <a href="unsupported/group__MatrixFunctions__Module.html"> unsupported MatrixFunctions module</a>.*/
  374. const MatrixFunctionReturnValue<Derived> matrixFunction(StemFunction f) const;
  375. EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, cosh, hyperbolic cosine)
  376. EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, sinh, hyperbolic sine)
  377. EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, cos, cosine)
  378. EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, sin, sine)
  379. EIGEN_MATRIX_FUNCTION(MatrixSquareRootReturnValue, sqrt, square root)
  380. EIGEN_MATRIX_FUNCTION(MatrixLogarithmReturnValue, log, logarithm)
  381. EIGEN_MATRIX_FUNCTION_1(MatrixPowerReturnValue, pow, power to \c p, const RealScalar& p)
  382. EIGEN_MATRIX_FUNCTION_1(MatrixComplexPowerReturnValue, pow, power to \c p, const std::complex<RealScalar>& p)
  383. protected:
  384. EIGEN_DEFAULT_COPY_CONSTRUCTOR(MatrixBase)
  385. EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(MatrixBase)
  386. private:
  387. EIGEN_DEVICE_FUNC explicit MatrixBase(int);
  388. EIGEN_DEVICE_FUNC MatrixBase(int,int);
  389. template<typename OtherDerived> EIGEN_DEVICE_FUNC explicit MatrixBase(const MatrixBase<OtherDerived>&);
  390. protected:
  391. // mixing arrays and matrices is not legal
  392. template<typename OtherDerived> Derived& operator+=(const ArrayBase<OtherDerived>& )
  393. {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
  394. // mixing arrays and matrices is not legal
  395. template<typename OtherDerived> Derived& operator-=(const ArrayBase<OtherDerived>& )
  396. {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
  397. };
  398. /***************************************************************************
  399. * Implementation of matrix base methods
  400. ***************************************************************************/
  401. /** replaces \c *this by \c *this * \a other.
  402. *
  403. * \returns a reference to \c *this
  404. *
  405. * Example: \include MatrixBase_applyOnTheRight.cpp
  406. * Output: \verbinclude MatrixBase_applyOnTheRight.out
  407. */
  408. template<typename Derived>
  409. template<typename OtherDerived>
  410. inline Derived&
  411. MatrixBase<Derived>::operator*=(const EigenBase<OtherDerived> &other)
  412. {
  413. other.derived().applyThisOnTheRight(derived());
  414. return derived();
  415. }
  416. /** replaces \c *this by \c *this * \a other. It is equivalent to MatrixBase::operator*=().
  417. *
  418. * Example: \include MatrixBase_applyOnTheRight.cpp
  419. * Output: \verbinclude MatrixBase_applyOnTheRight.out
  420. */
  421. template<typename Derived>
  422. template<typename OtherDerived>
  423. inline void MatrixBase<Derived>::applyOnTheRight(const EigenBase<OtherDerived> &other)
  424. {
  425. other.derived().applyThisOnTheRight(derived());
  426. }
  427. /** replaces \c *this by \a other * \c *this.
  428. *
  429. * Example: \include MatrixBase_applyOnTheLeft.cpp
  430. * Output: \verbinclude MatrixBase_applyOnTheLeft.out
  431. */
  432. template<typename Derived>
  433. template<typename OtherDerived>
  434. inline void MatrixBase<Derived>::applyOnTheLeft(const EigenBase<OtherDerived> &other)
  435. {
  436. other.derived().applyThisOnTheLeft(derived());
  437. }
  438. } // end namespace Eigen
  439. #endif // EIGEN_MATRIXBASE_H