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 nested<MatrixType>::type MatrixTypeNested;
36 typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
37 typedef MatrixType ExpressionType;
38 typedef typename MatrixType::PlainObject DenseMatrixType;
41 Flags = MatrixTypeNestedCleaned::Flags & (HereditaryBits)
43 CoeffReadCost = MatrixTypeNestedCleaned::CoeffReadCost
48 template <
typename Lhs,
int LhsMode,
bool LhsIsVector,
49 typename Rhs,
int RhsMode,
bool RhsIsVector>
50 struct SelfadjointProductMatrix;
54 :
public TriangularBase<SelfAdjointView<MatrixType, UpLo> >
58 typedef TriangularBase<SelfAdjointView> Base;
59 typedef typename internal::traits<SelfAdjointView>::MatrixTypeNested MatrixTypeNested;
60 typedef typename internal::traits<SelfAdjointView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;
63 typedef typename internal::traits<SelfAdjointView>::Scalar
Scalar;
65 typedef typename MatrixType::Index Index;
68 Mode = internal::traits<SelfAdjointView>::Mode
70 typedef typename MatrixType::PlainObject PlainObject;
75 inline Index rows()
const {
return m_matrix.rows(); }
76 inline Index cols()
const {
return m_matrix.cols(); }
77 inline Index outerStride()
const {
return m_matrix.outerStride(); }
78 inline Index innerStride()
const {
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.const_cast_derived().coeffRef(row, col);
99 const MatrixTypeNestedCleaned& _expression()
const {
return m_matrix; }
101 const MatrixTypeNestedCleaned& nestedExpression()
const {
return m_matrix; }
102 MatrixTypeNestedCleaned& nestedExpression() {
return *
const_cast<MatrixTypeNestedCleaned*
>(&m_matrix); }
105 template<
typename OtherDerived>
106 SelfadjointProductMatrix<MatrixType,Mode,false,OtherDerived,0,OtherDerived::IsVectorAtCompileTime>
109 return SelfadjointProductMatrix
110 <MatrixType,Mode,
false,OtherDerived,0,OtherDerived::IsVectorAtCompileTime>
111 (m_matrix, rhs.derived());
115 template<
typename OtherDerived>
friend
116 SelfadjointProductMatrix<OtherDerived,0,OtherDerived::IsVectorAtCompileTime,MatrixType,Mode,false>
119 return SelfadjointProductMatrix
120 <OtherDerived,0,OtherDerived::IsVectorAtCompileTime,MatrixType,Mode,
false>
121 (lhs.derived(),rhs.m_matrix);
134 template<
typename DerivedU,
typename DerivedV>
147 template<
typename DerivedU>
165 #ifdef EIGEN2_SUPPORT
166 template<
typename OtherDerived>
172 m_matrix.const_cast_derived().template triangularView<UpLo>() = other;
173 m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.
adjoint();
176 template<
typename OtherMatrixType,
unsigned int OtherMode>
177 SelfAdjointView& operator=(
const TriangularView<OtherMatrixType, OtherMode>& other)
182 m_matrix.const_cast_derived().template triangularView<UpLo>() = other.toDenseMatrix();
183 m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.toDenseMatrix().adjoint();
189 MatrixTypeNested m_matrix;
204 template<
typename Derived1,
typename Derived2,
int UnrollCount,
bool ClearOpposite>
205 struct triangular_assignment_selector<Derived1, Derived2, (
SelfAdjoint|
Upper), UnrollCount, ClearOpposite>
208 col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
209 row = (UnrollCount-1) % Derived1::RowsAtCompileTime
212 static inline void run(Derived1 &dst,
const Derived2 &src)
214 triangular_assignment_selector<Derived1, Derived2, (
SelfAdjoint|
Upper), UnrollCount-1, ClearOpposite>::run(dst, src);
217 dst.coeffRef(row, col) = numext::real(src.coeff(row, col));
219 dst.coeffRef(col, row) = numext::conj(dst.coeffRef(row, col) = src.coeff(row, col));
223 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
224 struct triangular_assignment_selector<Derived1, Derived2,
SelfAdjoint|
Upper, 0, ClearOpposite>
226 static inline void run(Derived1 &,
const Derived2 &) {}
229 template<
typename Derived1,
typename Derived2,
int UnrollCount,
bool ClearOpposite>
230 struct triangular_assignment_selector<Derived1, Derived2, (
SelfAdjoint|
Lower), UnrollCount, ClearOpposite>
233 col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
234 row = (UnrollCount-1) % Derived1::RowsAtCompileTime
237 static inline void run(Derived1 &dst,
const Derived2 &src)
239 triangular_assignment_selector<Derived1, Derived2, (
SelfAdjoint|
Lower), UnrollCount-1, ClearOpposite>::run(dst, src);
242 dst.coeffRef(row, col) = numext::real(src.coeff(row, col));
244 dst.coeffRef(col, row) = numext::conj(dst.coeffRef(row, col) = src.coeff(row, col));
248 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
249 struct triangular_assignment_selector<Derived1, Derived2,
SelfAdjoint|
Lower, 0, ClearOpposite>
251 static inline void run(Derived1 &,
const Derived2 &) {}
254 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
257 typedef typename Derived1::Index Index;
258 static inline void run(Derived1 &dst,
const Derived2 &src)
260 for(Index j = 0; j < dst.cols(); ++j)
262 for(Index i = 0; i < j; ++i)
264 dst.copyCoeff(i, j, src);
265 dst.coeffRef(j,i) = numext::conj(dst.coeff(i,j));
267 dst.copyCoeff(j, j, src);
272 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
275 static inline void run(Derived1 &dst,
const Derived2 &src)
277 typedef typename Derived1::Index Index;
278 for(Index i = 0; i < dst.rows(); ++i)
280 for(Index j = 0; j < i; ++j)
282 dst.copyCoeff(i, j, src);
283 dst.coeffRef(j,i) = numext::conj(dst.coeff(i,j));
285 dst.copyCoeff(i, i, src);
296 template<
typename Derived>
297 template<
unsigned int UpLo>
298 typename MatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type
299 MatrixBase<Derived>::selfadjointView()
const
304 template<
typename Derived>
305 template<
unsigned int UpLo>
306 typename MatrixBase<Derived>::template SelfAdjointViewReturnType<UpLo>::Type
307 MatrixBase<Derived>::selfadjointView()
314 #endif // EIGEN_SELFADJOINTMATRIX_H
Robust Cholesky decomposition of a matrix with pivoting.
Definition: LDLT.h:48
Definition: Constants.h:167
friend SelfadjointProductMatrix< OtherDerived, 0, OtherDerived::IsVectorAtCompileTime, MatrixType, Mode, false > operator*(const MatrixBase< OtherDerived > &lhs, const SelfAdjointView &rhs)
Definition: SelfAdjointView.h:117
Definition: Constants.h:181
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
const int Dynamic
Definition: Constants.h:21
const unsigned int PacketAccessBit
Definition: Constants.h:81
Definition: Constants.h:169
Scalar coeff(Index row, Index col) const
Definition: SelfAdjointView.h:83
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
Definition: LLT.h:50
const unsigned int LinearAccessBit
Definition: Constants.h:117
NumTraits< Scalar >::Real RealScalar
Definition: SelfAdjointView.h:158
SelfadjointProductMatrix< MatrixType, Mode, false, OtherDerived, 0, OtherDerived::IsVectorAtCompileTime > operator*(const MatrixBase< OtherDerived > &rhs) const
Definition: SelfAdjointView.h:107
Expression of a selfadjoint matrix from a triangular part of a dense matrix.
Definition: SelfAdjointView.h:53
Definition: Constants.h:179
Scalar & coeffRef(Index row, Index col)
Definition: SelfAdjointView.h:92
internal::traits< SelfAdjointView >::Scalar Scalar
The type of coefficients in this matrix.
Definition: SelfAdjointView.h:63
Definition: Constants.h:183
const unsigned int DirectAccessBit
Definition: Constants.h:142
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
const AdjointReturnType adjoint() const
Definition: Transpose.h:237
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Matrix< RealScalar, internal::traits< MatrixType >::ColsAtCompileTime, 1 > EigenvaluesReturnType
Definition: SelfAdjointView.h:160