2007-10-12 05:15:25 +00:00
// This file is part of Eigen, a lightweight C++ template library
2009-05-22 20:25:33 +02:00
// for linear algebra.
2007-09-05 10:42:15 +00:00
//
2009-06-28 21:27:37 +02:00
// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
2010-06-24 23:21:58 +02:00
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
2007-09-05 10:42:15 +00:00
//
2012-07-13 14:42:47 -04:00
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
2007-09-05 10:42:15 +00:00
2007-11-28 15:34:40 +00:00
# ifndef EIGEN_MATRIXBASE_H
# define EIGEN_MATRIXBASE_H
2007-09-05 10:42:15 +00:00
2021-09-10 19:12:26 +00:00
# include "./InternalHeaderCheck.h"
2012-04-15 11:06:28 +01:00
namespace Eigen {
2007-12-19 09:30:53 +00:00
/** \class MatrixBase
2010-07-06 13:10:08 +01:00
* \ ingroup Core_Module
2007-12-19 09:30:53 +00:00
*
2009-11-16 18:19:08 +01:00
* \ brief Base class for all dense matrices , vectors , and expressions
2007-12-19 09:30:53 +00:00
*
2010-01-04 19:00:16 +01:00
* This class is the base that is inherited by all matrix , vector , and related expression
* types . Most of the Eigen API is contained in this class , and its base classes . Other important
* classes for the Eigen API are Matrix , and VectorwiseOp .
2008-07-26 23:05:44 +00:00
*
2010-06-19 23:00:22 +02:00
* Note that some methods are defined in other modules such as the \ ref LU_Module LU module
* for all functions related to matrix inversions .
2007-12-19 09:30:53 +00:00
*
2011-02-13 22:50:57 +00:00
* \ tparam Derived is the derived type , e . g . a matrix type , or an expression , etc .
2007-12-19 09:30:53 +00:00
*
* When writing a function taking Eigen objects as argument , if you want your function
* to take as argument any matrix , vector , or expression , just let it take a
* MatrixBase argument . As an example , here is a function printFirstRow which , given
* a matrix , vector , or expression \ a x , prints the first row of \ a x .
*
* \ code
2008-03-10 17:23:11 +00:00
template < typename Derived >
void printFirstRow ( const Eigen : : MatrixBase < Derived > & x )
2007-12-19 09:30:53 +00:00
{
cout < < x . row ( 0 ) < < endl ;
}
* \ endcode
2010-08-22 18:28:19 +01:00
*
2011-02-13 22:50:57 +00:00
* This class can be extended with the help of the plugin mechanism described on the page
2016-08-30 11:10:08 +02:00
* \ ref TopicCustomizing_Plugins by defining the preprocessor symbol \ c EIGEN_MATRIXBASE_PLUGIN .
2011-02-13 22:50:57 +00:00
*
2015-12-30 16:45:44 +01:00
* \ sa \ blank \ ref TopicClassHierarchy
2007-12-19 09:30:53 +00:00
*/
2008-06-19 17:33:57 +00:00
template < typename Derived > class MatrixBase
2009-12-04 23:17:14 +01:00
: public DenseBase < Derived >
2007-09-05 10:42:15 +00:00
{
public :
2008-12-07 15:40:40 +00:00
# ifndef EIGEN_PARSED_BY_DOXYGEN
2009-11-17 16:04:19 +01:00
typedef MatrixBase StorageBaseType ;
2010-10-25 10:15:22 -04:00
typedef typename internal : : traits < Derived > : : StorageKind StorageKind ;
2015-02-13 18:57:41 +01:00
typedef typename internal : : traits < Derived > : : StorageIndex StorageIndex ;
2010-10-25 10:15:22 -04:00
typedef typename internal : : traits < Derived > : : Scalar Scalar ;
typedef typename internal : : packet_traits < Scalar > : : type PacketScalar ;
2010-05-30 16:00:58 -04:00
typedef typename NumTraits < Scalar > : : Real RealScalar ;
2010-06-03 08:41:11 +02:00
2009-12-04 23:17:14 +01:00
typedef DenseBase < Derived > Base ;
2009-12-16 19:18:40 +01:00
using Base : : RowsAtCompileTime ;
using Base : : ColsAtCompileTime ;
using Base : : SizeAtCompileTime ;
using Base : : MaxRowsAtCompileTime ;
using Base : : MaxColsAtCompileTime ;
using Base : : MaxSizeAtCompileTime ;
using Base : : IsVectorAtCompileTime ;
using Base : : Flags ;
2016-02-06 16:32:00 -08:00
2009-12-16 19:18:40 +01:00
using Base : : derived ;
using Base : : const_cast_derived ;
2009-12-04 23:17:14 +01:00
using Base : : rows ;
using Base : : cols ;
using Base : : size ;
using Base : : coeff ;
using Base : : coeffRef ;
2009-12-16 19:18:40 +01:00
using Base : : lazyAssign ;
2010-01-04 19:00:16 +01:00
using Base : : eval ;
2017-01-02 22:27:07 +01:00
using Base : : operator - ;
2009-12-16 19:18:40 +01:00
using Base : : operator + = ;
using Base : : operator - = ;
using Base : : operator * = ;
using Base : : operator / = ;
typedef typename Base : : CoeffReturnType CoeffReturnType ;
2010-12-22 17:45:37 -05:00
typedef typename Base : : ConstTransposeReturnType ConstTransposeReturnType ;
2010-01-04 19:00:16 +01:00
typedef typename Base : : RowXpr RowXpr ;
typedef typename Base : : ColXpr ColXpr ;
2008-12-07 15:40:40 +00:00
# endif // not EIGEN_PARSED_BY_DOXYGEN
2008-04-09 12:31:55 +00:00
2009-07-10 16:10:03 +02:00
2008-03-03 11:02:52 +00:00
2008-12-07 15:40:40 +00:00
# ifndef EIGEN_PARSED_BY_DOXYGEN
2008-07-19 13:03:23 +00:00
/** type of the equivalent square matrix */
2010-06-11 07:56:50 -04:00
typedef Matrix < Scalar , EIGEN_SIZE_MAX ( RowsAtCompileTime , ColsAtCompileTime ) ,
EIGEN_SIZE_MAX ( RowsAtCompileTime , ColsAtCompileTime ) > SquareMatrixType ;
2008-12-07 15:40:40 +00:00
# endif // not EIGEN_PARSED_BY_DOXYGEN
2008-07-19 13:03:23 +00:00
2009-05-10 16:24:39 +00:00
/** \returns the size of the main diagonal, which is min(rows(),cols()).
* \ sa rows ( ) , cols ( ) , SizeAtCompileTime . */
2013-07-31 15:30:50 +02:00
EIGEN_DEVICE_FUNC
2016-09-14 14:06:21 -07:00
inline Index diagonalSize ( ) const { return ( numext : : mini ) ( rows ( ) , cols ( ) ) ; }
2009-09-26 11:40:29 -04:00
2015-06-22 10:52:08 +02:00
typedef typename Base : : PlainObject PlainObject ;
2009-04-01 00:39:56 +00:00
2010-01-14 10:10:07 +01:00
# ifndef EIGEN_PARSED_BY_DOXYGEN
2008-12-18 20:36:25 +00:00
/** \internal Represents a matrix with all coefficients equal to one another*/
2015-06-22 10:52:08 +02:00
typedef CwiseNullaryOp < internal : : scalar_constant_op < Scalar > , PlainObject > ConstantReturnType ;
2008-07-29 16:33:07 +00:00
/** \internal the return type of MatrixBase::adjoint() */
2010-10-25 22:13:49 +02:00
typedef typename internal : : conditional < NumTraits < Scalar > : : IsComplex ,
2010-12-22 17:45:37 -05:00
CwiseUnaryOp < internal : : scalar_conjugate_op < Scalar > , ConstTransposeReturnType > ,
ConstTransposeReturnType
2010-10-25 22:13:49 +02:00
> : : type AdjointReturnType ;
2010-05-24 17:43:50 +01:00
/** \internal Return type of eigenvalues() */
2010-10-25 10:15:22 -04:00
typedef Matrix < std : : complex < RealScalar > , internal : : traits < Derived > : : ColsAtCompileTime , 1 , ColMajor > EigenvaluesReturnType ;
2008-07-29 16:33:07 +00:00
/** \internal the return type of identity */
2015-06-22 10:52:08 +02:00
typedef CwiseNullaryOp < internal : : scalar_identity_op < Scalar > , PlainObject > IdentityReturnType ;
2008-07-29 16:33:07 +00:00
/** \internal the return type of unit vectors */
2011-02-05 15:53:17 +01:00
typedef Block < const CwiseNullaryOp < internal : : scalar_identity_op < Scalar > , SquareMatrixType > ,
2010-10-25 10:15:22 -04:00
internal : : traits < Derived > : : RowsAtCompileTime ,
internal : : traits < Derived > : : ColsAtCompileTime > BasisReturnType ;
2008-12-07 15:40:40 +00:00
# endif // not EIGEN_PARSED_BY_DOXYGEN
2008-03-03 10:52:44 +00:00
2009-12-17 10:00:35 +01:00
# define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase
2016-09-16 10:40:50 +02:00
# define EIGEN_DOC_UNARY_ADDONS(X,Y)
2009-12-17 10:00:35 +01:00
# include ".. / plugins / CommonCwiseBinaryOps.h"
# include ".. / plugins / MatrixCwiseUnaryOps.h"
# include ".. / plugins / MatrixCwiseBinaryOps.h"
# ifdef EIGEN_MATRIXBASE_PLUGIN
# include EIGEN_MATRIXBASE_PLUGIN
# endif
# undef EIGEN_CURRENT_STORAGE_BASE_CLASS
2016-09-16 10:40:50 +02:00
# undef EIGEN_DOC_UNARY_ADDONS
2008-03-14 10:38:37 +00:00
2008-01-07 09:34:21 +00:00
/** Special case of the template operator=, in order to prevent the compiler
* from generating a default operator = ( issue hit with g + + 4.1 )
*/
2016-01-31 16:34:10 +01:00
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
2009-06-28 21:27:37 +02:00
Derived & operator = ( const MatrixBase & other ) ;
2008-03-04 12:34:58 +00:00
2010-06-14 23:02:49 +02:00
// We cannot inherit here via Base::operator= since it is causing
// trouble with MSVC.
template < typename OtherDerived >
2016-01-31 16:34:10 +01:00
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
2010-06-14 23:02:49 +02:00
Derived & operator = ( const DenseBase < OtherDerived > & other ) ;
2010-06-14 14:33:10 +02:00
template < typename OtherDerived >
2013-02-07 19:06:14 +01:00
EIGEN_DEVICE_FUNC
2010-06-14 23:02:49 +02:00
Derived & operator = ( const EigenBase < OtherDerived > & other ) ;
template < typename OtherDerived >
2013-02-07 19:06:14 +01:00
EIGEN_DEVICE_FUNC
2010-06-14 23:02:49 +02:00
Derived & operator = ( const ReturnByValue < OtherDerived > & other ) ;
2010-06-14 14:33:10 +02:00
2008-03-14 10:38:37 +00:00
template < typename OtherDerived >
2016-01-31 16:34:10 +01:00
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
2008-03-14 10:38:37 +00:00
Derived & operator + = ( const MatrixBase < OtherDerived > & other ) ;
template < typename OtherDerived >
2016-01-31 16:34:10 +01:00
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
2008-03-14 10:38:37 +00:00
Derived & operator - = ( const MatrixBase < OtherDerived > & other ) ;
2013-02-07 19:06:14 +01:00
template < typename OtherDerived >
EIGEN_DEVICE_FUNC
2013-11-07 16:38:14 +01:00
const Product < Derived , OtherDerived >
operator * ( const MatrixBase < OtherDerived > & other ) const ;
2010-02-09 14:34:31 +01:00
template < typename OtherDerived >
2016-02-06 16:32:00 -08:00
EIGEN_DEVICE_FUNC
2013-12-03 17:17:53 +01:00
const Product < Derived , OtherDerived , LazyProduct >
2010-02-09 14:34:31 +01:00
lazyProduct ( const MatrixBase < OtherDerived > & other ) const ;
2008-03-14 10:38:37 +00:00
template < typename OtherDerived >
2010-02-20 15:26:02 +01:00
Derived & operator * = ( const EigenBase < OtherDerived > & other ) ;
2009-09-16 14:35:42 +02:00
template < typename OtherDerived >
2010-02-20 15:26:02 +01:00
void applyOnTheLeft ( const EigenBase < OtherDerived > & other ) ;
2009-09-16 14:35:42 +02:00
template < typename OtherDerived >
2010-02-20 15:26:02 +01:00
void applyOnTheRight ( const EigenBase < OtherDerived > & other ) ;
2009-07-07 11:39:19 +02:00
2014-02-18 10:52:26 +01:00
template < typename DiagonalDerived >
EIGEN_DEVICE_FUNC
const Product < Derived , DiagonalDerived , LazyProduct >
operator * ( const DiagonalBase < DiagonalDerived > & diagonal ) const ;
2009-06-28 21:27:37 +02:00
2011-01-27 12:04:26 -05:00
template < typename OtherDerived >
2013-02-07 19:06:14 +01:00
EIGEN_DEVICE_FUNC
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 15:11:41 +02:00
typename ScalarBinaryOpTraits < typename internal : : traits < Derived > : : Scalar , typename internal : : traits < OtherDerived > : : Scalar > : : ReturnType
2011-01-27 12:04:26 -05:00
dot ( const MatrixBase < OtherDerived > & other ) const ;
2013-04-05 16:35:49 +02:00
EIGEN_DEVICE_FUNC RealScalar squaredNorm ( ) const ;
EIGEN_DEVICE_FUNC RealScalar norm ( ) const ;
2009-07-13 21:14:47 +02:00
RealScalar stableNorm ( ) const ;
RealScalar blueNorm ( ) const ;
2009-07-17 16:22:39 +02:00
RealScalar hypotNorm ( ) const ;
2013-04-05 16:35:49 +02:00
EIGEN_DEVICE_FUNC const PlainObject normalized ( ) const ;
2016-01-23 22:40:11 +01:00
EIGEN_DEVICE_FUNC const PlainObject stableNormalized ( ) const ;
2013-04-05 16:35:49 +02:00
EIGEN_DEVICE_FUNC void normalize ( ) ;
2016-01-23 22:40:11 +01:00
EIGEN_DEVICE_FUNC void stableNormalize ( ) ;
2008-03-14 10:38:37 +00:00
2013-04-05 16:35:49 +02:00
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint ( ) const ;
EIGEN_DEVICE_FUNC void adjointInPlace ( ) ;
2008-03-04 12:34:58 +00:00
2010-12-22 17:45:37 -05:00
typedef Diagonal < Derived > DiagonalReturnType ;
2013-07-31 15:30:50 +02:00
EIGEN_DEVICE_FUNC
2010-12-22 17:45:37 -05:00
DiagonalReturnType diagonal ( ) ;
2016-02-06 16:32:00 -08:00
2013-07-31 15:30:50 +02:00
typedef typename internal : : add_const < Diagonal < const Derived > > : : type ConstDiagonalReturnType ;
EIGEN_DEVICE_FUNC
2013-07-10 23:54:53 +02:00
ConstDiagonalReturnType diagonal ( ) const ;
2009-02-05 18:37:21 +00:00
2010-12-22 17:45:37 -05:00
template < int Index > struct DiagonalIndexReturnType { typedef Diagonal < Derived , Index > Type ; } ;
template < int Index > struct ConstDiagonalIndexReturnType { typedef const Diagonal < const Derived , Index > Type ; } ;
2009-06-10 11:20:30 +02:00
2016-02-06 16:32:00 -08:00
template < int Index >
2013-07-31 15:30:50 +02:00
EIGEN_DEVICE_FUNC
typename DiagonalIndexReturnType < Index > : : Type diagonal ( ) ;
template < int Index >
EIGEN_DEVICE_FUNC
typename ConstDiagonalIndexReturnType < Index > : : Type diagonal ( ) const ;
2016-02-06 16:32:00 -08:00
2014-11-28 14:39:47 +01:00
typedef Diagonal < Derived , DynamicIndex > DiagonalDynamicIndexReturnType ;
2014-12-02 14:35:31 +01:00
typedef typename internal : : add_const < Diagonal < const Derived , DynamicIndex > > : : type ConstDiagonalDynamicIndexReturnType ;
2010-12-22 17:45:37 -05:00
2013-07-31 15:30:50 +02:00
EIGEN_DEVICE_FUNC
2014-11-28 14:39:47 +01:00
DiagonalDynamicIndexReturnType diagonal ( Index index ) ;
2013-07-31 15:30:50 +02:00
EIGEN_DEVICE_FUNC
2014-11-28 14:39:47 +01:00
ConstDiagonalDynamicIndexReturnType diagonal ( Index index ) const ;
2009-06-10 11:20:30 +02:00
2010-12-22 17:45:37 -05:00
template < unsigned int Mode > struct TriangularViewReturnType { typedef TriangularView < Derived , Mode > Type ; } ;
template < unsigned int Mode > struct ConstTriangularViewReturnType { typedef const TriangularView < const Derived , Mode > Type ; } ;
2013-08-01 16:26:57 +02:00
template < unsigned int Mode >
EIGEN_DEVICE_FUNC
typename TriangularViewReturnType < Mode > : : Type triangularView ( ) ;
template < unsigned int Mode >
EIGEN_DEVICE_FUNC
typename ConstTriangularViewReturnType < Mode > : : Type triangularView ( ) const ;
2010-12-22 17:45:37 -05:00
template < unsigned int UpLo > struct SelfAdjointViewReturnType { typedef SelfAdjointView < Derived , UpLo > Type ; } ;
template < unsigned int UpLo > struct ConstSelfAdjointViewReturnType { typedef const SelfAdjointView < const Derived , UpLo > Type ; } ;
2008-03-03 10:52:44 +00:00
2016-02-06 16:32:00 -08:00
template < unsigned int UpLo >
2013-08-01 16:26:57 +02:00
EIGEN_DEVICE_FUNC
typename SelfAdjointViewReturnType < UpLo > : : Type selfadjointView ( ) ;
template < unsigned int UpLo >
EIGEN_DEVICE_FUNC
typename ConstSelfAdjointViewReturnType < UpLo > : : Type selfadjointView ( ) const ;
2008-06-02 20:08:37 +00:00
2010-06-15 10:26:12 +02:00
const SparseView < Derived > sparseView ( const Scalar & m_reference = Scalar ( 0 ) ,
2012-06-28 02:08:59 +02:00
const typename NumTraits < Scalar > : : Real & m_epsilon = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
2013-08-01 16:26:57 +02:00
EIGEN_DEVICE_FUNC static const IdentityReturnType Identity ( ) ;
EIGEN_DEVICE_FUNC static const IdentityReturnType Identity ( Index rows , Index cols ) ;
EIGEN_DEVICE_FUNC static const BasisReturnType Unit ( Index size , Index i ) ;
EIGEN_DEVICE_FUNC static const BasisReturnType Unit ( Index i ) ;
EIGEN_DEVICE_FUNC static const BasisReturnType UnitX ( ) ;
EIGEN_DEVICE_FUNC static const BasisReturnType UnitY ( ) ;
EIGEN_DEVICE_FUNC static const BasisReturnType UnitZ ( ) ;
EIGEN_DEVICE_FUNC static const BasisReturnType UnitW ( ) ;
2008-03-04 12:34:58 +00:00
2013-07-31 15:30:50 +02:00
EIGEN_DEVICE_FUNC
2011-01-23 21:53:28 -05:00
const DiagonalWrapper < const Derived > asDiagonal ( ) const ;
2011-01-26 16:33:23 +01:00
const PermutationWrapper < const Derived > asPermutation ( ) const ;
2008-03-14 10:38:37 +00:00
2013-08-01 16:26:57 +02:00
EIGEN_DEVICE_FUNC
2008-01-11 15:08:04 +00:00
Derived & setIdentity ( ) ;
2013-08-01 16:26:57 +02:00
EIGEN_DEVICE_FUNC
2010-05-30 16:00:58 -04:00
Derived & setIdentity ( Index rows , Index cols ) ;
2017-08-22 16:48:07 +02:00
EIGEN_DEVICE_FUNC Derived & setUnit ( Index i ) ;
EIGEN_DEVICE_FUNC Derived & setUnit ( Index newSize , Index i ) ;
2008-03-04 12:34:58 +00:00
2012-06-28 02:08:59 +02:00
bool isIdentity ( const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
bool isDiagonal ( const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
2008-02-29 14:35:14 +00:00
2012-06-28 02:08:59 +02:00
bool isUpperTriangular ( const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
bool isLowerTriangular ( const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
2008-05-27 05:47:30 +00:00
2007-09-26 14:06:14 +00:00
template < typename OtherDerived >
2008-06-24 15:13:00 +00:00
bool isOrthogonal ( const MatrixBase < OtherDerived > & other ,
2012-06-28 02:08:59 +02:00
const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
bool isUnitary ( const RealScalar & prec = NumTraits < Scalar > : : dummy_precision ( ) ) const ;
2008-05-22 14:51:25 +00:00
2009-12-17 10:00:35 +01:00
/** \returns true if each coefficients of \c *this and \a other are all exactly equal.
* \ warning When using floating point scalar values you probably should rather use a
* fuzzy comparison such as isApprox ( )
* \ sa isApprox ( ) , operator ! = */
2008-04-03 18:13:27 +00:00
template < typename OtherDerived >
2017-02-28 09:47:38 +01:00
EIGEN_DEVICE_FUNC inline bool operator = = ( const MatrixBase < OtherDerived > & other ) const
2009-11-18 18:15:19 +01:00
{ return cwiseEqual ( other ) . all ( ) ; }
2008-04-03 18:13:27 +00:00
2009-12-17 10:00:35 +01:00
/** \returns true if at least one pair of coefficients of \c *this and \a other are not exactly equal to each other.
* \ warning When using floating point scalar values you probably should rather use a
* fuzzy comparison such as isApprox ( )
* \ sa isApprox ( ) , operator = = */
2008-04-03 18:13:27 +00:00
template < typename OtherDerived >
2017-02-28 09:47:38 +01:00
EIGEN_DEVICE_FUNC inline bool operator ! = ( const MatrixBase < OtherDerived > & other ) const
2010-01-18 08:18:48 +01:00
{ return cwiseNotEqual ( other ) . any ( ) ; }
2008-04-03 18:13:27 +00:00
2017-08-17 11:51:22 +02:00
NoAlias < Derived , Eigen : : MatrixBase > EIGEN_DEVICE_FUNC noalias ( ) ;
2008-05-12 10:23:09 +00:00
2014-09-23 14:28:23 +02:00
// TODO forceAlignedAccess is temporarily disabled
2014-02-19 14:05:56 +01:00
// Need to find a nicer workaround.
inline const Derived & forceAlignedAccess ( ) const { return derived ( ) ; }
inline Derived & forceAlignedAccess ( ) { return derived ( ) ; }
template < bool Enable > inline const Derived & forceAlignedAccessIf ( ) const { return derived ( ) ; }
template < bool Enable > inline Derived & forceAlignedAccessIf ( ) { return derived ( ) ; }
2008-03-03 10:52:44 +00:00
2015-07-15 10:57:55 +02:00
EIGEN_DEVICE_FUNC Scalar trace ( ) const ;
2008-03-16 14:36:25 +00:00
2013-04-05 16:35:49 +02:00
template < int p > EIGEN_DEVICE_FUNC RealScalar lpNorm ( ) const ;
2009-03-10 11:55:50 +00:00
2013-04-05 16:35:49 +02:00
EIGEN_DEVICE_FUNC MatrixBase < Derived > & matrix ( ) { return * this ; }
EIGEN_DEVICE_FUNC const MatrixBase < Derived > & matrix ( ) const { return * this ; }
2010-01-21 17:55:09 +01:00
2012-12-24 13:33:22 +01:00
/** \returns an \link Eigen::ArrayBase Array \endlink expression of this matrix
2010-06-28 18:38:28 +01:00
* \ sa ArrayBase : : matrix ( ) */
2014-09-23 14:28:23 +02:00
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ArrayWrapper < Derived > array ( ) { return ArrayWrapper < Derived > ( derived ( ) ) ; }
2014-03-04 17:24:00 +01:00
/** \returns a const \link Eigen::ArrayBase Array \endlink expression of this matrix
* \ sa ArrayBase : : matrix ( ) */
2014-09-23 14:28:23 +02:00
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArrayWrapper < const Derived > array ( ) const { return ArrayWrapper < const Derived > ( derived ( ) ) ; }
2009-12-04 23:17:14 +01:00
2008-06-02 20:08:37 +00:00
/////////// LU module ///////////
2015-10-22 16:10:28 +02:00
inline const FullPivLU < PlainObject > fullPivLu ( ) const ;
inline const PartialPivLU < PlainObject > partialPivLu ( ) const ;
2011-01-25 10:02:36 -05:00
2015-10-22 16:10:28 +02:00
inline const PartialPivLU < PlainObject > lu ( ) const ;
2011-01-25 10:02:36 -05:00
2018-06-11 18:33:24 +02:00
EIGEN_DEVICE_FUNC
2015-10-22 16:10:28 +02:00
inline const Inverse < Derived > inverse ( ) const ;
2016-02-06 16:32:00 -08:00
2009-10-06 09:26:28 -04:00
template < typename ResultType >
2015-10-22 16:10:28 +02:00
inline void computeInverseAndDetWithCheck (
2009-10-26 11:18:23 -04:00
ResultType & inverse ,
typename ResultType : : Scalar & determinant ,
bool & invertible ,
2010-02-10 10:52:28 +01:00
const RealScalar & absDeterminantThreshold = NumTraits < Scalar > : : dummy_precision ( )
2009-10-26 11:18:23 -04:00
) const ;
2018-06-11 18:33:24 +02:00
2009-10-26 14:16:50 -04:00
template < typename ResultType >
2015-10-22 16:10:28 +02:00
inline void computeInverseWithCheck (
2009-10-26 14:16:50 -04:00
ResultType & inverse ,
bool & invertible ,
2010-02-10 10:52:28 +01:00
const RealScalar & absDeterminantThreshold = NumTraits < Scalar > : : dummy_precision ( )
2009-10-26 14:16:50 -04:00
) const ;
2018-06-11 18:33:24 +02:00
EIGEN_DEVICE_FUNC
2008-04-14 17:07:12 +00:00
Scalar determinant ( ) const ;
2008-04-14 08:20:24 +00:00
2008-07-19 22:59:05 +00:00
/////////// Cholesky module ///////////
2015-10-22 16:10:28 +02:00
inline const LLT < PlainObject > llt ( ) const ;
inline const LDLT < PlainObject > ldlt ( ) const ;
2008-06-02 20:08:37 +00:00
/////////// QR module ///////////
2015-10-22 16:10:28 +02:00
inline const HouseholderQR < PlainObject > householderQr ( ) const ;
inline const ColPivHouseholderQR < PlainObject > colPivHouseholderQr ( ) const ;
inline const FullPivHouseholderQR < PlainObject > fullPivHouseholderQr ( ) const ;
2016-02-06 16:32:00 -08:00
inline const CompleteOrthogonalDecomposition < PlainObject > completeOrthogonalDecomposition ( ) const ;
2015-10-22 16:10:28 +02:00
/////////// Eigenvalues module ///////////
2008-06-03 07:32:12 +00:00
2015-10-22 16:10:28 +02:00
inline EigenvaluesReturnType eigenvalues ( ) const ;
inline RealScalar operatorNorm ( ) const ;
2008-05-22 14:51:25 +00:00
2008-08-19 17:52:04 +00:00
/////////// SVD module ///////////
2021-11-30 18:45:54 +00:00
inline JacobiSVD < PlainObject > jacobiSvd ( unsigned int computationOptions = 0 ) const ;
inline BDCSVD < PlainObject > bdcSvd ( unsigned int computationOptions = 0 ) const ;
2010-10-17 09:40:52 -04:00
2008-06-03 07:32:12 +00:00
/////////// Geometry module ///////////
2011-01-27 11:33:37 +01:00
# ifndef EIGEN_PARSED_BY_DOXYGEN
/// \internal helper struct to form the return type of the cross product
template < typename OtherDerived > struct cross_product_return_type {
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 15:11:41 +02:00
typedef typename ScalarBinaryOpTraits < typename internal : : traits < Derived > : : Scalar , typename internal : : traits < OtherDerived > : : Scalar > : : ReturnType Scalar ;
2011-01-28 10:26:05 +01:00
typedef Matrix < Scalar , MatrixBase : : RowsAtCompileTime , MatrixBase : : ColsAtCompileTime > type ;
2011-01-27 11:33:37 +01:00
} ;
# endif // EIGEN_PARSED_BY_DOXYGEN
2008-06-03 07:32:12 +00:00
template < typename OtherDerived >
2013-08-01 16:26:57 +02:00
EIGEN_DEVICE_FUNC
2015-12-30 16:04:24 +01:00
# ifndef EIGEN_PARSED_BY_DOXYGEN
2015-10-22 16:10:28 +02:00
inline typename cross_product_return_type < OtherDerived > : : type
2015-12-30 16:04:24 +01:00
# else
inline PlainObject
# endif
2011-01-27 11:33:37 +01:00
cross ( const MatrixBase < OtherDerived > & other ) const ;
2016-02-06 16:32:00 -08:00
2009-03-11 14:20:36 +00:00
template < typename OtherDerived >
2013-08-01 16:26:57 +02:00
EIGEN_DEVICE_FUNC
2015-10-22 16:10:28 +02:00
inline PlainObject cross3 ( const MatrixBase < OtherDerived > & other ) const ;
2016-02-06 16:32:00 -08:00
2013-08-01 16:26:57 +02:00
EIGEN_DEVICE_FUNC
2015-10-22 16:10:28 +02:00
inline PlainObject unitOrthogonal ( void ) const ;
2016-02-06 16:32:00 -08:00
2016-10-12 16:35:17 +01:00
EIGEN_DEVICE_FUNC
2015-10-22 16:10:28 +02:00
inline Matrix < Scalar , 3 , 1 > eulerAngles ( Index a0 , Index a1 , Index a2 ) const ;
2016-02-06 16:32:00 -08:00
2011-01-24 11:21:58 -05:00
// put this as separate enum value to work around possible GCC 4.3 bug (?)
2015-06-08 15:40:51 +02:00
enum { HomogeneousReturnTypeDirection = ColsAtCompileTime = = 1 & & RowsAtCompileTime = = 1 ? ( ( internal : : traits < Derived > : : Flags & RowMajorBit ) = = RowMajorBit ? Horizontal : Vertical )
: ColsAtCompileTime = = 1 ? Vertical : Horizontal } ;
2011-01-24 11:21:58 -05:00
typedef Homogeneous < Derived , HomogeneousReturnTypeDirection > HomogeneousReturnType ;
2016-10-12 16:35:17 +01:00
EIGEN_DEVICE_FUNC
2015-10-22 16:10:28 +02:00
inline HomogeneousReturnType homogeneous ( ) const ;
2016-02-06 16:32:00 -08:00
2009-03-05 10:25:22 +00:00
enum {
SizeMinusOne = SizeAtCompileTime = = Dynamic ? Dynamic : SizeAtCompileTime - 1
} ;
2010-12-22 17:45:37 -05:00
typedef Block < const Derived ,
2010-10-25 10:15:22 -04:00
internal : : traits < Derived > : : ColsAtCompileTime = = 1 ? SizeMinusOne : 1 ,
2010-12-22 17:45:37 -05:00
internal : : traits < Derived > : : ColsAtCompileTime = = 1 ? 1 : SizeMinusOne > ConstStartMinusOne ;
2016-06-14 11:28:03 +02:00
typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE ( ConstStartMinusOne , Scalar , quotient ) HNormalizedReturnType ;
2016-10-12 16:35:17 +01:00
EIGEN_DEVICE_FUNC
2015-10-22 16:10:28 +02:00
inline const HNormalizedReturnType hnormalized ( ) const ;
2010-09-27 09:57:57 -04:00
2009-08-03 16:06:57 +02:00
////////// Householder module ///////////
2018-06-11 18:33:24 +02:00
EIGEN_DEVICE_FUNC
2009-11-10 21:22:20 -05:00
void makeHouseholderInPlace ( Scalar & tau , RealScalar & beta ) ;
2009-08-03 16:06:57 +02:00
template < typename EssentialPart >
2018-06-11 18:33:24 +02:00
EIGEN_DEVICE_FUNC
2009-11-10 21:22:20 -05:00
void makeHouseholder ( EssentialPart & essential ,
Scalar & tau , RealScalar & beta ) const ;
2009-08-03 16:06:57 +02:00
template < typename EssentialPart >
2018-06-11 18:33:24 +02:00
EIGEN_DEVICE_FUNC
2009-08-03 16:06:57 +02:00
void applyHouseholderOnTheLeft ( const EssentialPart & essential ,
2009-08-17 17:04:32 +02:00
const Scalar & tau ,
2009-08-16 19:22:15 +02:00
Scalar * workspace ) ;
2009-08-03 16:06:57 +02:00
template < typename EssentialPart >
2018-06-11 18:33:24 +02:00
EIGEN_DEVICE_FUNC
2009-08-03 16:06:57 +02:00
void applyHouseholderOnTheRight ( const EssentialPart & essential ,
2009-08-17 17:04:32 +02:00
const Scalar & tau ,
2009-08-16 19:22:15 +02:00
Scalar * workspace ) ;
2009-08-04 16:54:17 +02:00
2009-08-09 16:58:13 +02:00
///////// Jacobi module /////////
2009-09-02 15:04:10 +02:00
template < typename OtherScalar >
2017-08-17 11:51:22 +02:00
EIGEN_DEVICE_FUNC
2010-10-19 21:56:26 -04:00
void applyOnTheLeft ( Index p , Index q , const JacobiRotation < OtherScalar > & j ) ;
2009-09-02 15:04:10 +02:00
template < typename OtherScalar >
2017-08-17 11:51:22 +02:00
EIGEN_DEVICE_FUNC
2010-10-19 21:56:26 -04:00
void applyOnTheRight ( Index p , Index q , const JacobiRotation < OtherScalar > & j ) ;
2009-08-03 16:06:57 +02:00
2015-11-04 17:42:07 +01:00
///////// SparseCore module /////////
template < typename OtherDerived >
EIGEN_STRONG_INLINE const typename SparseMatrixBase < OtherDerived > : : template CwiseProductDenseReturnType < Derived > : : Type
cwiseProduct ( const SparseMatrixBase < OtherDerived > & other ) const
{
return other . cwiseProduct ( derived ( ) ) ;
}
2010-03-16 17:26:55 +00:00
///////// MatrixFunctions module /////////
2010-10-25 10:15:22 -04:00
typedef typename internal : : stem_function < Scalar > : : type StemFunction ;
2018-10-19 21:10:28 +02:00
# define EIGEN_MATRIX_FUNCTION(ReturnType, Name, Description) \
/** \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 . */ \
const ReturnType < Derived > Name ( ) const ;
# define EIGEN_MATRIX_FUNCTION_1(ReturnType, Name, Description, Argument) \
/** \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 . */ \
const ReturnType < Derived > Name ( Argument ) const ;
EIGEN_MATRIX_FUNCTION ( MatrixExponentialReturnValue , exp , exponential )
/** \brief Helper function for the <a href="unsupported/group__MatrixFunctions__Module.html"> unsupported MatrixFunctions module</a>.*/
2010-03-16 17:26:55 +00:00
const MatrixFunctionReturnValue < Derived > matrixFunction ( StemFunction f ) const ;
2018-10-19 21:10:28 +02:00
EIGEN_MATRIX_FUNCTION ( MatrixFunctionReturnValue , cosh , hyperbolic cosine )
EIGEN_MATRIX_FUNCTION ( MatrixFunctionReturnValue , sinh , hyperbolic sine )
2019-01-11 17:45:37 -08:00
# if EIGEN_HAS_CXX11_MATH
EIGEN_MATRIX_FUNCTION ( MatrixFunctionReturnValue , atanh , inverse hyperbolic cosine )
EIGEN_MATRIX_FUNCTION ( MatrixFunctionReturnValue , acosh , inverse hyperbolic cosine )
EIGEN_MATRIX_FUNCTION ( MatrixFunctionReturnValue , asinh , inverse hyperbolic sine )
# endif
2018-10-19 21:10:28 +02:00
EIGEN_MATRIX_FUNCTION ( MatrixFunctionReturnValue , cos , cosine )
EIGEN_MATRIX_FUNCTION ( MatrixFunctionReturnValue , sin , sine )
EIGEN_MATRIX_FUNCTION ( MatrixSquareRootReturnValue , sqrt , square root )
EIGEN_MATRIX_FUNCTION ( MatrixLogarithmReturnValue , log , logarithm )
EIGEN_MATRIX_FUNCTION_1 ( MatrixPowerReturnValue , pow , power to \ c p , const RealScalar & p )
EIGEN_MATRIX_FUNCTION_1 ( MatrixComplexPowerReturnValue , pow , power to \ c p , const std : : complex < RealScalar > & p )
2010-03-16 17:26:55 +00:00
2009-10-31 11:50:15 -04:00
protected :
2019-12-19 17:30:11 +01:00
EIGEN_DEFAULT_COPY_CONSTRUCTOR ( MatrixBase )
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR ( MatrixBase )
2009-11-16 18:19:08 +01:00
2009-10-31 11:50:15 -04:00
private :
2013-02-07 19:06:14 +01:00
EIGEN_DEVICE_FUNC explicit MatrixBase ( int ) ;
EIGEN_DEVICE_FUNC MatrixBase ( int , int ) ;
template < typename OtherDerived > EIGEN_DEVICE_FUNC explicit MatrixBase ( const MatrixBase < OtherDerived > & ) ;
2010-08-16 11:07:17 +02:00
protected :
// mixing arrays and matrices is not legal
2011-02-04 13:55:12 +01:00
template < typename OtherDerived > Derived & operator + = ( const ArrayBase < OtherDerived > & )
2012-01-31 13:05:44 +01:00
{ EIGEN_STATIC_ASSERT ( std : : ptrdiff_t ( sizeof ( typename OtherDerived : : Scalar ) ) = = - 1 , YOU_CANNOT_MIX_ARRAYS_AND_MATRICES ) ; return * this ; }
2010-08-16 11:07:17 +02:00
// mixing arrays and matrices is not legal
2011-02-04 13:55:12 +01:00
template < typename OtherDerived > Derived & operator - = ( const ArrayBase < OtherDerived > & )
2012-01-31 13:05:44 +01:00
{ EIGEN_STATIC_ASSERT ( std : : ptrdiff_t ( sizeof ( typename OtherDerived : : Scalar ) ) = = - 1 , YOU_CANNOT_MIX_ARRAYS_AND_MATRICES ) ; return * this ; }
2007-09-05 10:42:15 +00:00
} ;
2014-02-12 14:03:39 +00:00
/***************************************************************************
* Implementation of matrix base methods
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** replaces \c *this by \c *this * \a other.
*
* \ returns a reference to \ c * this
*
* Example : \ include MatrixBase_applyOnTheRight . cpp
* Output : \ verbinclude MatrixBase_applyOnTheRight . out
*/
template < typename Derived >
template < typename OtherDerived >
inline Derived &
MatrixBase < Derived > : : operator * = ( const EigenBase < OtherDerived > & other )
{
other . derived ( ) . applyThisOnTheRight ( derived ( ) ) ;
return derived ( ) ;
}
/** replaces \c *this by \c *this * \a other. It is equivalent to MatrixBase::operator*=().
*
* Example : \ include MatrixBase_applyOnTheRight . cpp
* Output : \ verbinclude MatrixBase_applyOnTheRight . out
*/
template < typename Derived >
template < typename OtherDerived >
inline void MatrixBase < Derived > : : applyOnTheRight ( const EigenBase < OtherDerived > & other )
{
other . derived ( ) . applyThisOnTheRight ( derived ( ) ) ;
}
/** replaces \c *this by \a other * \c *this.
*
* Example : \ include MatrixBase_applyOnTheLeft . cpp
* Output : \ verbinclude MatrixBase_applyOnTheLeft . out
*/
template < typename Derived >
template < typename OtherDerived >
inline void MatrixBase < Derived > : : applyOnTheLeft ( const EigenBase < OtherDerived > & other )
{
other . derived ( ) . applyThisOnTheLeft ( derived ( ) ) ;
}
2012-04-15 11:06:28 +01:00
} // end namespace Eigen
2007-11-28 15:34:40 +00:00
# endif // EIGEN_MATRIXBASE_H