10 #ifndef EIGEN_SELFADJOINTMATRIX_H
11 #define EIGEN_SELFADJOINTMATRIX_H
32 template<
typename MatrixType,
unsigned int UpLo>
33 struct traits<SelfAdjointView<MatrixType, UpLo> > : traits<MatrixType>
35 typedef typename ref_selector<MatrixType>::non_const_type MatrixTypeNested;
36 typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
37 typedef MatrixType ExpressionType;
38 typedef typename MatrixType::PlainObject FullMatrixType;
41 FlagsLvalueBit = is_lvalue<MatrixType>::value ?
LvalueBit : 0,
42 Flags = MatrixTypeNestedCleaned::Flags & (HereditaryBits|FlagsLvalueBit)
54 typedef _MatrixType MatrixType;
56 typedef typename internal::traits<SelfAdjointView>::MatrixTypeNested MatrixTypeNested;
57 typedef typename internal::traits<SelfAdjointView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;
58 typedef MatrixTypeNestedCleaned NestedExpression;
61 typedef typename internal::traits<SelfAdjointView>::Scalar
Scalar;
62 typedef typename MatrixType::StorageIndex StorageIndex;
65 Mode = internal::traits<SelfAdjointView>::Mode,
66 Flags = internal::traits<SelfAdjointView>::Flags
68 typedef typename MatrixType::PlainObject PlainObject;
75 inline Index rows()
const {
return m_matrix.rows(); }
77 inline Index cols()
const {
return m_matrix.cols(); }
79 inline Index outerStride()
const {
return m_matrix.outerStride(); }
81 inline Index innerStride()
const {
return m_matrix.innerStride(); }
89 Base::check_coordinates_internal(row, col);
90 return m_matrix.coeff(row, col);
100 Base::check_coordinates_internal(row, col);
101 return m_matrix.coeffRef(row, col);
106 const MatrixTypeNestedCleaned& _expression()
const {
return m_matrix; }
109 const MatrixTypeNestedCleaned& nestedExpression()
const {
return m_matrix; }
111 MatrixTypeNestedCleaned& nestedExpression() {
return m_matrix; }
114 template<
typename OtherDerived>
116 const Product<SelfAdjointView,OtherDerived>
123 template<
typename OtherDerived>
friend
131 friend EIGEN_DEVICE_FUNC
135 return (s*mat.nestedExpression()).template selfadjointView<UpLo>();
148 template<
typename DerivedU,
typename DerivedV>
162 template<
typename DerivedU>
176 template<
unsigned int TriMode>
183 typename internal::conditional<(TriMode&(
Upper|
Lower))==(UpLo&(
Upper|
Lower)), MatrixType&,
typename MatrixType::ConstTransposeReturnType>::type tmp1(m_matrix);
184 typename internal::conditional<(TriMode&(
Upper|
Lower))==(UpLo&(
Upper|
Lower)), MatrixType&,
typename MatrixType::AdjointReturnType>::type tmp2(tmp1);
196 typename MatrixType::ConstDiagonalReturnType
diagonal()
const
198 return typename MatrixType::ConstDiagonalReturnType(m_matrix);
219 MatrixTypeNested m_matrix;
237 template<
typename MatrixType,
unsigned int Mode>
240 typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;
241 typedef SelfAdjointShape Shape;
244 template<
int UpLo,
int SetOpposite,
typename DstEvaluatorTypeT,
typename SrcEvaluatorTypeT,
typename Functor,
int Version>
245 class triangular_dense_assignment_kernel<UpLo,
SelfAdjoint,SetOpposite,DstEvaluatorTypeT,SrcEvaluatorTypeT,Functor,Version>
246 :
public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version>
249 typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> Base;
250 typedef typename Base::DstXprType DstXprType;
251 typedef typename Base::SrcXprType SrcXprType;
254 using Base::m_functor;
257 typedef typename Base::DstEvaluatorType DstEvaluatorType;
258 typedef typename Base::SrcEvaluatorType SrcEvaluatorType;
259 typedef typename Base::Scalar Scalar;
260 typedef typename Base::AssignmentTraits AssignmentTraits;
263 EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType &dst,
const SrcEvaluatorType &src,
const Functor &func, DstXprType& dstExpr)
264 : Base(dst, src, func, dstExpr)
267 EIGEN_DEVICE_FUNC
void assignCoeff(
Index row,
Index col)
269 eigen_internal_assert(row!=col);
270 Scalar tmp = m_src.coeff(row,col);
271 m_functor.assignCoeff(m_dst.coeffRef(row,col), tmp);
272 m_functor.assignCoeff(m_dst.coeffRef(col,row), numext::conj(tmp));
275 EIGEN_DEVICE_FUNC
void assignDiagonalCoeff(
Index id)
277 Base::assignCoeff(
id,
id);
280 EIGEN_DEVICE_FUNC
void assignOppositeCoeff(
Index,
Index)
281 { eigen_internal_assert(
false &&
"should never be called"); }
290 template<
typename Derived>
291 template<
unsigned int UpLo>
292 typename MatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type
293 MatrixBase<Derived>::selfadjointView()
const
295 return typename ConstSelfAdjointViewReturnType<UpLo>::Type(derived());
298 template<
typename Derived>
299 template<
unsigned int UpLo>
300 typename MatrixBase<Derived>::template SelfAdjointViewReturnType<UpLo>::Type
301 MatrixBase<Derived>::selfadjointView()
303 return typename SelfAdjointViewReturnType<UpLo>::Type(derived());
Derived & derived()
Definition: EigenBase.h:44
Robust Cholesky decomposition of a matrix with pivoting.
Definition: LDLT.h:51
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
Definition: LLT.h:53
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:180
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:75
Expression of a selfadjoint matrix from a triangular part of a dense matrix.
Definition: SelfAdjointView.h:51
RealScalar operatorNorm() const
Computes the L2 operator norm.
Definition: MatrixBaseEigenvalues.h:153
SelfAdjointView & rankUpdate(const MatrixBase< DerivedU > &u, const MatrixBase< DerivedV > &v, const Scalar &alpha=Scalar(1))
const LLT< PlainObject, UpLo > llt() const
Definition: LLT.h:527
const LDLT< PlainObject, UpLo > ldlt() const
Definition: LDLT.h:651
Matrix< RealScalar, internal::traits< MatrixType >::ColsAtCompileTime, 1 > EigenvaluesReturnType
Definition: SelfAdjointView.h:211
MatrixType::ConstDiagonalReturnType diagonal() const
Definition: SelfAdjointView.h:196
Scalar coeff(Index row, Index col) const
Definition: SelfAdjointView.h:87
friend const Product< OtherDerived, SelfAdjointView > operator*(const MatrixBase< OtherDerived > &lhs, const SelfAdjointView &rhs)
Definition: SelfAdjointView.h:126
internal::conditional<(TriMode &(Upper|Lower))==(UpLo &(Upper|Lower)), TriangularView< MatrixType, TriMode >, TriangularView< typename MatrixType::AdjointReturnType, TriMode > >::type triangularView() const
Definition: SelfAdjointView.h:181
Scalar & coeffRef(Index row, Index col)
Definition: SelfAdjointView.h:97
SelfAdjointView & rankUpdate(const MatrixBase< DerivedU > &u, const Scalar &alpha=Scalar(1))
EigenvaluesReturnType eigenvalues() const
Computes the eigenvalues of a matrix.
Definition: MatrixBaseEigenvalues.h:89
const Product< SelfAdjointView, OtherDerived > operator*(const MatrixBase< OtherDerived > &rhs) const
Definition: SelfAdjointView.h:117
internal::traits< SelfAdjointView >::Scalar Scalar
The type of coefficients in this matrix.
Definition: SelfAdjointView.h:61
NumTraits< Scalar >::Real RealScalar
Definition: SelfAdjointView.h:209
Base class for triangular part in a matrix.
Definition: TriangularMatrix.h:28
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:188
@ SelfAdjoint
Definition: Constants.h:220
@ Lower
Definition: Constants.h:204
@ Upper
Definition: Constants.h:206
const unsigned int PacketAccessBit
Definition: Constants.h:89
const unsigned int LinearAccessBit
Definition: Constants.h:125
const unsigned int DirectAccessBit
Definition: Constants.h:150
const unsigned int LvalueBit
Definition: Constants.h:139
Namespace containing all symbols from the Eigen library.
Definition: Core:287
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:37
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:151