11 #ifndef EIGEN_MATRIXBASE_H
12 #define EIGEN_MATRIXBASE_H
14 #include "./InternalHeaderCheck.h"
54 #ifndef EIGEN_PARSED_BY_DOXYGEN
56 typedef typename internal::traits<Derived>::StorageKind StorageKind;
57 typedef typename internal::traits<Derived>::StorageIndex
StorageIndex;
58 typedef typename internal::traits<Derived>::Scalar
Scalar;
59 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
63 using Base::RowsAtCompileTime;
64 using Base::ColsAtCompileTime;
65 using Base::SizeAtCompileTime;
66 using Base::MaxRowsAtCompileTime;
67 using Base::MaxColsAtCompileTime;
68 using Base::MaxSizeAtCompileTime;
69 using Base::IsVectorAtCompileTime;
73 using Base::const_cast_derived;
79 using Base::lazyAssign;
81 using Base::operator-;
82 using Base::operator+=;
83 using Base::operator-=;
84 using Base::operator*=;
85 using Base::operator/=;
87 typedef typename Base::CoeffReturnType CoeffReturnType;
89 typedef typename Base::RowXpr RowXpr;
90 typedef typename Base::ColXpr ColXpr;
95 #ifndef EIGEN_PARSED_BY_DOXYGEN
106 typedef typename Base::PlainObject PlainObject;
108 #ifndef EIGEN_PARSED_BY_DOXYGEN
112 typedef std::conditional_t<NumTraits<Scalar>::IsComplex,
114 ConstTransposeReturnType
122 internal::traits<Derived>::RowsAtCompileTime,
123 internal::traits<Derived>::ColsAtCompileTime> BasisReturnType;
126 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase
127 #define EIGEN_DOC_UNARY_ADDONS(X,Y)
128 # include "../plugins/CommonCwiseBinaryOps.h"
129 # include "../plugins/MatrixCwiseUnaryOps.h"
130 # include "../plugins/MatrixCwiseBinaryOps.h"
131 # ifdef EIGEN_MATRIXBASE_PLUGIN
132 # include EIGEN_MATRIXBASE_PLUGIN
134 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
135 #undef EIGEN_DOC_UNARY_ADDONS
140 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
146 template <
typename OtherDerived>
147 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
150 template <
typename OtherDerived>
154 template<
typename OtherDerived>
156 Derived&
operator=(
const ReturnByValue<OtherDerived>& other);
158 template<
typename OtherDerived>
159 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
161 template<
typename OtherDerived>
162 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
165 template<
typename OtherDerived>
170 template<
typename OtherDerived>
175 template<
typename OtherDerived>
178 template<
typename OtherDerived>
181 template<
typename OtherDerived>
184 template<
typename DiagonalDerived>
189 template<
typename OtherDerived>
195 EIGEN_DEVICE_FUNC RealScalar
norm()
const;
204 EIGEN_DEVICE_FUNC
const AdjointReturnType
adjoint()
const;
231 template<
unsigned int Mode>
233 typename TriangularViewReturnType<Mode>::Type triangularView();
234 template<
unsigned int Mode>
236 typename ConstTriangularViewReturnType<Mode>::Type triangularView()
const;
238 template<
unsigned int UpLo>
struct SelfAdjointViewReturnType {
typedef SelfAdjointView<Derived, UpLo> Type; };
239 template<
unsigned int UpLo>
struct ConstSelfAdjointViewReturnType {
typedef const SelfAdjointView<const Derived, UpLo> Type; };
241 template<
unsigned int UpLo>
243 typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
244 template<
unsigned int UpLo>
246 typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView()
const;
249 const typename NumTraits<Scalar>::Real& m_epsilon = NumTraits<Scalar>::dummy_precision())
const;
250 EIGEN_DEVICE_FUNC
static const IdentityReturnType
Identity();
253 EIGEN_DEVICE_FUNC
static const BasisReturnType
Unit(
Index i);
254 EIGEN_DEVICE_FUNC
static const BasisReturnType
UnitX();
255 EIGEN_DEVICE_FUNC
static const BasisReturnType
UnitY();
256 EIGEN_DEVICE_FUNC
static const BasisReturnType
UnitZ();
257 EIGEN_DEVICE_FUNC
static const BasisReturnType
UnitW();
260 const DiagonalWrapper<const Derived>
asDiagonal()
const;
261 const PermutationWrapper<const Derived> asPermutation()
const;
270 bool isIdentity(
const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
271 bool isDiagonal(
const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
273 bool isUpperTriangular(
const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
274 bool isLowerTriangular(
const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
276 template<
typename OtherDerived>
277 bool isOrthogonal(
const MatrixBase<OtherDerived>& other,
278 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
279 bool isUnitary(
const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
285 template<
typename OtherDerived>
287 {
return cwiseEqual(other).all(); }
293 template<
typename OtherDerived>
295 {
return cwiseNotEqual(other).any(); }
303 template<
bool Enable>
inline const Derived& forceAlignedAccessIf()
const {
return derived(); }
304 template<
bool Enable>
inline Derived& forceAlignedAccessIf() {
return derived(); }
308 template<
int p> EIGEN_DEVICE_FUNC RealScalar
lpNorm()
const;
310 EIGEN_DEVICE_FUNC MatrixBase<Derived>& matrix() {
return *
this; }
311 EIGEN_DEVICE_FUNC
const MatrixBase<Derived>& matrix()
const {
return *
this; }
330 template<
typename ResultType>
338 template<
typename ResultType>
367 template<
int Options = 0>
369 template<
int Options = 0>
373 template<
int Options = 0>
375 template<
int Options = 0>
381 #ifndef EIGEN_PARSED_BY_DOXYGEN
383 template<
typename OtherDerived>
struct cross_product_return_type {
388 template<
typename OtherDerived>
390 #ifndef EIGEN_PARSED_BY_DOXYGEN
391 inline typename cross_product_return_type<OtherDerived>::type
395 cross(
const MatrixBase<OtherDerived>& other)
const;
397 template<
typename OtherDerived>
399 inline PlainObject
cross3(
const MatrixBase<OtherDerived>& other)
const;
410 typedef Homogeneous<Derived, HomogeneousReturnTypeDirection> HomogeneousReturnType;
417 typedef Block<
const Derived,
418 internal::traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1,
419 internal::traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> ConstStartMinusOne;
420 typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(ConstStartMinusOne,
Scalar,quotient) HNormalizedReturnType;
422 inline const HNormalizedReturnType
hnormalized()
const;
428 template<
typename EssentialPart>
431 Scalar& tau, RealScalar& beta)
const;
432 template<
typename EssentialPart>
437 template<
typename EssentialPart>
445 template<
typename OtherScalar>
448 template<
typename OtherScalar>
454 template<
typename OtherDerived>
455 EIGEN_STRONG_INLINE
const typename SparseMatrixBase<OtherDerived>::template CwiseProductDenseReturnType<Derived>::Type
456 cwiseProduct(
const SparseMatrixBase<OtherDerived> &other)
const
458 return other.cwiseProduct(
derived());
463 typedef typename internal::stem_function<Scalar>::type StemFunction;
464 #define EIGEN_MATRIX_FUNCTION(ReturnType, Name, Description) \
466 const ReturnType<Derived> Name() const;
467 #define EIGEN_MATRIX_FUNCTION_1(ReturnType, Name, Description, Argument) \
469 const ReturnType<Derived> Name(Argument) const;
471 EIGEN_MATRIX_FUNCTION(MatrixExponentialReturnValue,
exp, exponential)
474 EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue,
cosh, hyperbolic cosine)
475 EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue,
sinh, hyperbolic sine)
476 #if EIGEN_HAS_CXX11_MATH
477 EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue,
atanh,
inverse hyperbolic cosine)
478 EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue,
acosh,
inverse hyperbolic cosine)
479 EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue,
asinh,
inverse hyperbolic sine)
481 EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue,
cos, cosine)
482 EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue,
sin, sine)
483 EIGEN_MATRIX_FUNCTION(MatrixSquareRootReturnValue,
sqrt,
square root)
484 EIGEN_MATRIX_FUNCTION(MatrixLogarithmReturnValue,
log, logarithm)
485 EIGEN_MATRIX_FUNCTION_1(MatrixPowerReturnValue,
pow, power to \c p, const RealScalar& p)
486 EIGEN_MATRIX_FUNCTION_1(MatrixComplexPowerReturnValue,
pow, power to \c p, const std::complex<RealScalar>& p)
490 EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(
MatrixBase)
495 template<typename OtherDerived> EIGEN_DEVICE_FUNC explicit
MatrixBase(const
MatrixBase<OtherDerived>&);
498 template<typename OtherDerived> Derived& operator+=(const
ArrayBase<OtherDerived>& )
499 {EIGEN_STATIC_ASSERT(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);
return *
this;}
502 {EIGEN_STATIC_ASSERT(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);
return *
this;}
517 template<
typename Derived>
518 template<
typename OtherDerived>
522 other.
derived().applyThisOnTheRight(derived());
531 template<
typename Derived>
532 template<
typename OtherDerived>
535 other.
derived().applyThisOnTheRight(derived());
543 template<
typename Derived>
544 template<
typename OtherDerived>
547 other.
derived().applyThisOnTheLeft(derived());
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:43
Expression of a mathematical vector or matrix as an array object.
Definition: ArrayWrapper.h:45
class Bidiagonal Divide and Conquer SVD
Definition: BDCSVD.h:97
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:107
Householder rank-revealing QR decomposition of a matrix with column-pivoting.
Definition: ColPivHouseholderQR.h:55
Complete orthogonal decomposition (COD) of a matrix.
Definition: CompleteOrthogonalDecomposition.h:54
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:63
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:58
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
@ SizeAtCompileTime
Definition: DenseBase.h:108
@ ColsAtCompileTime
Definition: DenseBase.h:101
@ RowsAtCompileTime
Definition: DenseBase.h:95
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
Definition: DenseBase.h:58
std::conditional_t< internal::is_same< typename internal::traits< Homogeneous< MatrixType, Direction_ > >::XprKind, MatrixXpr >::value, PlainMatrix, PlainArray > PlainObject
The plain matrix or array type corresponding to this expression.
Definition: DenseBase.h:204
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
Derived & derived()
Definition: EigenBase.h:48
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:69
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:67
Householder rank-revealing QR decomposition of a matrix with full pivoting.
Definition: FullPivHouseholderQR.h:64
LU decomposition of a matrix with complete pivoting, and related features.
Definition: FullPivLU.h:64
Householder QR decomposition of a matrix.
Definition: HouseholderQR.h:60
Expression of the inverse of another expression.
Definition: Inverse.h:46
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: JacobiSVD.h:514
Robust Cholesky decomposition of a matrix with pivoting.
Definition: LDLT.h:63
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
Definition: LLT.h:70
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
static const BasisReturnType UnitY()
Definition: CwiseNullaryOp.h:942
bool operator!=(const MatrixBase< OtherDerived > &other) const
Definition: MatrixBase.h:294
const MatrixFunctionReturnValue< Derived > sin() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise sine u...
void stableNormalize()
Definition: Dot.h:188
const LDLT< PlainObject > ldlt() const
Definition: LDLT.h:678
RealScalar operatorNorm() const
Computes the L2 operator norm.
Definition: MatrixBaseEigenvalues.h:122
Derived & operator-=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:164
void computeInverseWithCheck(ResultType &inverse, bool &invertible, const RealScalar &absDeterminantThreshold=NumTraits< Scalar >::dummy_precision()) const
Definition: InverseImpl.h:420
void makeHouseholder(EssentialPart &essential, Scalar &tau, RealScalar &beta) const
Definition: Householder.h:69
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:327
Derived & setIdentity()
Definition: CwiseNullaryOp.h:875
RealScalar norm() const
Definition: Dot.h:105
const MatrixFunctionReturnValue< Derived > matrixFunction(StemFunction f) const
Helper function for the unsupported MatrixFunctions module.
bool isLowerTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: TriangularMatrix.h:692
const FullPivLU< PlainObject > fullPivLu() const
Definition: FullPivLU.h:867
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition: NoAlias.h:104
DiagonalReturnType diagonal()
Definition: Diagonal.h:189
EigenvaluesReturnType eigenvalues() const
Computes the eigenvalues of a matrix.
Definition: MatrixBaseEigenvalues.h:69
RealScalar hypotNorm() const
Definition: StableNorm.h:243
const MatrixFunctionReturnValue< Derived > cos() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise cosine...
ArrayWrapper< Derived > array()
Definition: MatrixBase.h:315
Derived & operator=(const MatrixBase &other)
Definition: Assign.h:57
Derived & operator*=(const EigenBase< OtherDerived > &other)
Definition: MatrixBase.h:520
const PlainObject stableNormalized() const
Definition: Dot.h:164
void applyOnTheLeft(const EigenBase< OtherDerived > &other)
Definition: MatrixBase.h:545
RealScalar blueNorm() const
Definition: StableNorm.h:231
void applyOnTheRight(const EigenBase< OtherDerived > &other)
Definition: MatrixBase.h:533
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:818
const MatrixLogarithmReturnValue< Derived > log() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise logari...
void adjointInPlace()
Definition: Transpose.h:377
Scalar trace() const
Definition: Redux.h:510
const PlainObject normalized() const
Definition: Dot.h:121
const PartialPivLU< PlainObject > partialPivLu() const
Definition: PartialPivLU.h:599
const MatrixFunctionReturnValue< Derived > cosh() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise hyperb...
const MatrixExponentialReturnValue< Derived > exp() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise expone...
RealScalar lpNorm() const
Definition: Dot.h:264
const ArrayWrapper< const Derived > array() const
Definition: MatrixBase.h:318
const MatrixFunctionReturnValue< Derived > acosh() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise invers...
const Inverse< Derived > inverse() const
Definition: InverseImpl.h:350
Scalar determinant() const
Definition: Determinant.h:110
const MatrixPowerReturnValue< Derived > pow(const RealScalar &p) const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise power ...
void computeInverseAndDetWithCheck(ResultType &inverse, typename ResultType::Scalar &determinant, bool &invertible, const RealScalar &absDeterminantThreshold=NumTraits< Scalar >::dummy_precision()) const
Definition: InverseImpl.h:379
bool operator==(const MatrixBase< OtherDerived > &other) const
Definition: MatrixBase.h:286
const FullPivHouseholderQR< PlainObject > fullPivHouseholderQr() const
Definition: FullPivHouseholderQR.h:703
static const BasisReturnType UnitX()
Definition: CwiseNullaryOp.h:932
bool isUnitary(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:299
const MatrixFunctionReturnValue< Derived > asinh() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise invers...
void applyHouseholderOnTheLeft(const EssentialPart &essential, const Scalar &tau, Scalar *workspace)
Definition: Householder.h:118
const LLT< PlainObject > llt() const
Definition: LLT.h:537
bool isDiagonal(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: DiagonalMatrix.h:341
Derived & operator+=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:177
static const IdentityReturnType Identity()
Definition: CwiseNullaryOp.h:801
const HouseholderQR< PlainObject > householderQr() const
Definition: HouseholderQR.h:461
const MatrixFunctionReturnValue< Derived > sinh() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise hyperb...
static const BasisReturnType UnitZ()
Definition: CwiseNullaryOp.h:952
bool isUpperTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: TriangularMatrix.h:667
void applyHouseholderOnTheRight(const EssentialPart &essential, const Scalar &tau, Scalar *workspace)
Definition: Householder.h:156
Index diagonalSize() const
Definition: MatrixBase.h:104
RealScalar stableNorm() const
Definition: StableNorm.h:215
const MatrixFunctionReturnValue< Derived > atanh() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise invers...
static const BasisReturnType Unit(Index size, Index i)
Definition: CwiseNullaryOp.h:904
Derived & setUnit(Index i)
Set the coefficients of *this to the i-th unit (basis) vector.
Definition: CwiseNullaryOp.h:974
RealScalar squaredNorm() const
Definition: Dot.h:93
void normalize()
Definition: Dot.h:142
const Derived & forceAlignedAccess() const
Definition: MatrixBase.h:301
const MatrixSquareRootReturnValue< Derived > sqrt() const
This function requires the unsupported MatrixFunctions module. To compute the coefficient-wise square...
const ColPivHouseholderQR< PlainObject > colPivHouseholderQr() const
Definition: ColPivHouseholderQR.h:664
ScalarBinaryOpTraits< typename internal::traits< Derived >::Scalar, typename internal::traits< OtherDerived >::Scalar >::ReturnType dot(const MatrixBase< OtherDerived > &other) const
Definition: Dot.h:69
const Product< Derived, OtherDerived, LazyProduct > lazyProduct(const MatrixBase< OtherDerived > &other) const
Definition: GeneralProduct.h:444
const Product< Derived, OtherDerived > operator*(const MatrixBase< OtherDerived > &other) const
Definition: GeneralProduct.h:401
const CompleteOrthogonalDecomposition< PlainObject > completeOrthogonalDecomposition() const
Definition: CompleteOrthogonalDecomposition.h:627
void makeHouseholderInPlace(Scalar &tau, RealScalar &beta)
Definition: Householder.h:45
bool isOrthogonal(const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:280
static const BasisReturnType UnitW()
Definition: CwiseNullaryOp.h:962
const AdjointReturnType adjoint() const
Definition: Transpose.h:223
const PartialPivLU< PlainObject > lu() const
Definition: PartialPivLU.h:614
Derived & forceAlignedAccess()
Definition: MatrixBase.h:302
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Pseudo expression providing an operator = assuming no aliasing.
Definition: NoAlias.h:34
LU decomposition of a matrix with partial pivoting, and related features.
Definition: PartialPivLU.h:80
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:77
Expression of the transpose of a matrix.
Definition: Transpose.h:56
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:190
PlainObject cross(const MatrixBase< OtherDerived > &other) const
Definition: OrthoMethods.h:37
Matrix< Scalar, 3, 1 > eulerAngles(Index a0, Index a1, Index a2) const
Definition: EulerAngles.h:39
PlainObject unitOrthogonal(void) const
Definition: OrthoMethods.h:229
PlainObject cross3(const MatrixBase< OtherDerived > &other) const
Definition: OrthoMethods.h:85
const HNormalizedReturnType hnormalized() const
homogeneous normalization
Definition: Homogeneous.h:176
HomogeneousReturnType homogeneous() const
Definition: Homogeneous.h:134
const SparseView< Derived > sparseView(const Scalar &m_reference=Scalar(0), const typename NumTraits< Scalar >::Real &m_epsilon=NumTraits< Scalar >::dummy_precision()) const
Definition: SparseView.h:228
@ ColMajor
Definition: Constants.h:321
@ Horizontal
Definition: Constants.h:269
@ Vertical
Definition: Constants.h:266
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
const int Dynamic
Definition: Constants.h:24
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_square_op< typename Derived::Scalar >, const Derived > square(const Eigen::ArrayBase< Derived > &x)
Definition: EigenBase.h:32
Derived & derived()
Definition: EigenBase.h:48
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:774