10 #ifndef EIGEN_SELFADJOINTMATRIX_H 11 #define EIGEN_SELFADJOINTMATRIX_H 14 #include "./InternalHeaderCheck.h" 35 template <
typename MatrixType,
unsigned int UpLo>
36 struct traits<SelfAdjointView<MatrixType, UpLo> > : traits<MatrixType> {
37 typedef typename ref_selector<MatrixType>::non_const_type MatrixTypeNested;
38 typedef remove_all_t<MatrixTypeNested> MatrixTypeNestedCleaned;
39 typedef MatrixType ExpressionType;
40 typedef typename MatrixType::PlainObject FullMatrixType;
43 FlagsLvalueBit = is_lvalue<MatrixType>::value ?
LvalueBit : 0,
44 Flags = MatrixTypeNestedCleaned::Flags & (HereditaryBits | FlagsLvalueBit) &
50 template <
typename MatrixType_,
unsigned int UpLo>
53 EIGEN_STATIC_ASSERT(UpLo ==
Lower || UpLo ==
Upper, SELFADJOINTVIEW_ACCEPTS_UPPER_AND_LOWER_MODE_ONLY)
55 typedef MatrixType_ MatrixType;
57 typedef typename internal::traits<SelfAdjointView>::MatrixTypeNested MatrixTypeNested;
58 typedef typename internal::traits<SelfAdjointView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;
59 typedef MatrixTypeNestedCleaned NestedExpression;
62 typedef typename internal::traits<SelfAdjointView>::Scalar
Scalar;
63 typedef typename MatrixType::StorageIndex StorageIndex;
64 typedef internal::remove_all_t<typename MatrixType::ConjugateReturnType> MatrixConjugateReturnType;
68 Mode = internal::traits<SelfAdjointView>::Mode,
69 Flags = internal::traits<SelfAdjointView>::Flags,
72 typedef typename MatrixType::PlainObject PlainObject;
74 EIGEN_DEVICE_FUNC
explicit inline SelfAdjointView(MatrixType& matrix) : m_matrix(matrix) {}
76 EIGEN_DEVICE_FUNC constexpr
Index rows() const noexcept {
return m_matrix.rows(); }
77 EIGEN_DEVICE_FUNC constexpr
Index cols() const noexcept {
return m_matrix.cols(); }
78 EIGEN_DEVICE_FUNC constexpr
Index outerStride() const noexcept {
return m_matrix.outerStride(); }
79 EIGEN_DEVICE_FUNC constexpr
Index innerStride() const noexcept {
return m_matrix.innerStride(); }
85 Base::check_coordinates_internal(row, col);
86 return m_matrix.coeff(row, col);
94 Base::check_coordinates_internal(row, col);
95 return m_matrix.coeffRef(row, col);
99 EIGEN_DEVICE_FUNC
const MatrixTypeNestedCleaned& _expression()
const {
return m_matrix; }
101 EIGEN_DEVICE_FUNC
const MatrixTypeNestedCleaned& nestedExpression()
const {
return m_matrix; }
102 EIGEN_DEVICE_FUNC MatrixTypeNestedCleaned& nestedExpression() {
return m_matrix; }
105 template <
typename OtherDerived>
111 template <
typename OtherDerived>
117 friend EIGEN_DEVICE_FUNC
const 120 return (s * mat.nestedExpression()).
template selfadjointView<UpLo>();
133 template <
typename DerivedU,
typename DerivedV>
134 EIGEN_DEVICE_FUNC SelfAdjointView&
rankUpdate(
const MatrixBase<DerivedU>& u,
const MatrixBase<DerivedV>& v,
147 template <
typename DerivedU>
148 EIGEN_DEVICE_FUNC SelfAdjointView&
rankUpdate(
const MatrixBase<DerivedU>& u,
const Scalar& alpha =
Scalar(1));
161 template <
unsigned int TriMode>
163 std::conditional_t<(TriMode & (Upper | Lower)) == (UpLo & (Upper | Lower)), TriangularView<MatrixType, TriMode>,
164 TriangularView<typename MatrixType::AdjointReturnType, TriMode> >
167 typename MatrixType::ConstTransposeReturnType>
170 typename MatrixType::AdjointReturnType>
187 EIGEN_DEVICE_FUNC
inline std::conditional_t<Cond, ConjugateReturnType, ConstSelfAdjointView>
conjugateIf()
const {
188 typedef std::conditional_t<Cond, ConjugateReturnType, ConstSelfAdjointView> ReturnType;
189 return ReturnType(m_matrix.template conjugateIf<Cond>());
198 template <
class Dummy =
int>
200 std::enable_if_t<Eigen::internal::is_lvalue<MatrixType>::value, Dummy*> =
nullptr) {
201 typename MatrixType::TransposeReturnType tmp(m_matrix);
216 EIGEN_DEVICE_FUNC
typename MatrixType::ConstDiagonalReturnType
diagonal()
const {
217 return typename MatrixType::ConstDiagonalReturnType(m_matrix);
236 MatrixTypeNested m_matrix;
255 template <
typename MatrixType,
unsigned int Mode>
257 typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;
258 typedef SelfAdjointShape Shape;
261 template <
int UpLo,
int SetOpposite,
typename DstEvaluatorTypeT,
typename SrcEvaluatorTypeT,
typename Functor,
263 class triangular_dense_assignment_kernel<UpLo,
SelfAdjoint, SetOpposite, DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor,
265 :
public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> {
267 typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> Base;
268 typedef typename Base::DstXprType DstXprType;
269 typedef typename Base::SrcXprType SrcXprType;
271 using Base::m_functor;
275 typedef typename Base::DstEvaluatorType DstEvaluatorType;
276 typedef typename Base::SrcEvaluatorType SrcEvaluatorType;
277 typedef typename Base::Scalar Scalar;
278 typedef typename Base::AssignmentTraits AssignmentTraits;
280 EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType& dst,
const SrcEvaluatorType& src,
281 const Functor& func, DstXprType& dstExpr)
282 : Base(dst, src, func, dstExpr) {}
284 EIGEN_DEVICE_FUNC
void assignCoeff(
Index row,
Index col) {
285 eigen_internal_assert(row != col);
286 Scalar tmp = m_src.coeff(row, col);
287 m_functor.assignCoeff(m_dst.coeffRef(row, col), tmp);
288 m_functor.assignCoeff(m_dst.coeffRef(col, row), numext::conj(tmp));
291 EIGEN_DEVICE_FUNC
void assignDiagonalCoeff(
Index id) { Base::assignCoeff(
id,
id); }
293 EIGEN_DEVICE_FUNC
void assignOppositeCoeff(
Index,
Index) { eigen_internal_assert(
false &&
"should never be called"); }
303 template <
typename Derived>
304 template <
unsigned int UpLo>
305 EIGEN_DEVICE_FUNC
typename MatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type
307 return typename ConstSelfAdjointViewReturnType<UpLo>::Type(derived());
320 template <
typename Derived>
321 template <
unsigned int UpLo>
324 return typename SelfAdjointViewReturnType<UpLo>::Type(derived());
329 #endif // EIGEN_SELFADJOINTMATRIX_H Robust Cholesky decomposition of a matrix with pivoting.
Definition: LDLT.h:63
const LDLT< PlainObject, UpLo > ldlt() const
Definition: LDLT.h:634
constexpr Derived & derived()
Definition: EigenBase.h:49
const Product< SelfAdjointView, OtherDerived > operator*(const MatrixBase< OtherDerived > &rhs) const
Definition: SelfAdjointView.h:106
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:198
std::conditional_t<(TriMode &(Upper|Lower))==(UpLo &(Upper|Lower)), TriangularView< MatrixType, TriMode >, TriangularView< typename MatrixType::AdjointReturnType, TriMode > > triangularView() const
Definition: SelfAdjointView.h:165
Base class for triangular part in a matrix.
Definition: TriangularMatrix.h:32
const unsigned int DirectAccessBit
Definition: Constants.h:159
MatrixType::ConstDiagonalReturnType diagonal() const
Definition: SelfAdjointView.h:216
const ConjugateReturnType conjugate() const
Definition: SelfAdjointView.h:179
const unsigned int LvalueBit
Definition: Constants.h:148
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
internal::traits< SelfAdjointView >::Scalar Scalar
The type of coefficients in this matrix.
Definition: SelfAdjointView.h:62
Matrix< RealScalar, internal::traits< MatrixType >::ColsAtCompileTime, 1 > EigenvaluesReturnType
Definition: SelfAdjointView.h:230
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
const unsigned int PacketAccessBit
Definition: Constants.h:97
const ConstTransposeReturnType transpose() const
Definition: SelfAdjointView.h:207
std::conditional_t< Cond, ConjugateReturnType, ConstSelfAdjointView > conjugateIf() const
Definition: SelfAdjointView.h:187
friend const Product< OtherDerived, SelfAdjointView > operator*(const MatrixBase< OtherDerived > &lhs, const SelfAdjointView &rhs)
Definition: SelfAdjointView.h:112
RealScalar operatorNorm() const
Computes the L2 operator norm.
Definition: MatrixBaseEigenvalues.h:136
Definition: Constants.h:211
const AdjointReturnType adjoint() const
Definition: SelfAdjointView.h:194
TransposeReturnType transpose(std::enable_if_t< Eigen::internal::is_lvalue< MatrixType >::value, Dummy *>=nullptr)
Definition: SelfAdjointView.h:199
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
Definition: LLT.h:70
Scalar coeff(Index row, Index col) const
Definition: SelfAdjointView.h:84
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
SelfAdjointView & rankUpdate(const MatrixBase< DerivedU > &u, const MatrixBase< DerivedV > &v, const Scalar &alpha=Scalar(1))
Expression of a selfadjoint matrix from a triangular part of a dense matrix.
Definition: SelfAdjointView.h:51
NumTraits< Scalar >::Real RealScalar
Definition: SelfAdjointView.h:228
Definition: Constants.h:213
Definition: Constants.h:227
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:166
EigenvaluesReturnType eigenvalues() const
Computes the eigenvalues of a matrix.
Definition: MatrixBaseEigenvalues.h:83
Scalar & coeffRef(Index row, Index col)
Definition: SelfAdjointView.h:92
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:186
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const unsigned int LinearAccessBit
Definition: Constants.h:133
const LLT< PlainObject, UpLo > llt() const
Definition: LLT.h:507