25 #ifndef EIGEN_SELFADJOINTMATRIX_H
26 #define EIGEN_SELFADJOINTMATRIX_H
47 template<
typename MatrixType,
unsigned int UpLo>
48 struct traits<SelfAdjointView<MatrixType, UpLo> > :
traits<MatrixType>
50 typedef typename nested<MatrixType>::type MatrixTypeNested;
51 typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
52 typedef MatrixType ExpressionType;
53 typedef typename MatrixType::PlainObject DenseMatrixType;
58 CoeffReadCost = MatrixTypeNestedCleaned::CoeffReadCost
63 template <
typename Lhs,
int LhsMode,
bool LhsIsVector,
64 typename Rhs,
int RhsMode,
bool RhsIsVector>
65 struct SelfadjointProductMatrix;
78 typedef typename internal::traits<SelfAdjointView>::Scalar
Scalar;
80 typedef typename MatrixType::Index
Index;
83 Mode = internal::traits<SelfAdjointView>::Mode
90 inline Index rows()
const {
return m_matrix.rows(); }
91 inline Index cols()
const {
return m_matrix.cols(); }
100 Base::check_coordinates_internal(row, col);
101 return m_matrix.coeff(row, col);
109 Base::check_coordinates_internal(row, col);
110 return m_matrix.const_cast_derived().coeffRef(row, col);
120 template<
typename OtherDerived>
121 SelfadjointProductMatrix<MatrixType,Mode,false,OtherDerived,0,OtherDerived::IsVectorAtCompileTime>
124 return SelfadjointProductMatrix
125 <MatrixType,Mode,
false,OtherDerived,0,OtherDerived::IsVectorAtCompileTime>
126 (m_matrix, rhs.derived());
130 template<
typename OtherDerived>
friend
131 SelfadjointProductMatrix<OtherDerived,0,OtherDerived::IsVectorAtCompileTime,MatrixType,Mode,false>
134 return SelfadjointProductMatrix
135 <OtherDerived,0,OtherDerived::IsVectorAtCompileTime,MatrixType,Mode,
false>
149 template<
typename DerivedU,
typename DerivedV>
162 template<
typename DerivedU>
180 #ifdef EIGEN2_SUPPORT
181 template<
typename OtherDerived>
187 m_matrix.const_cast_derived().template triangularView<UpLo>() = other;
188 m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.
adjoint();
191 template<
typename OtherMatrixType,
unsigned int OtherMode>
192 SelfAdjointView& operator=(
const TriangularView<OtherMatrixType, OtherMode>& other)
197 m_matrix.const_cast_derived().template triangularView<UpLo>() = other.toDenseMatrix();
198 m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.toDenseMatrix().adjoint();
219 template<
typename Derived1,
typename Derived2,
int UnrollCount,
bool ClearOpposite>
220 struct triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|Upper), UnrollCount, ClearOpposite>
223 col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
224 row = (UnrollCount-1) % Derived1::RowsAtCompileTime
227 static inline void run(Derived1 &dst,
const Derived2 &src)
229 triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|
Upper), UnrollCount-1, ClearOpposite>::run(dst, src);
238 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
239 struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper, 0, ClearOpposite>
241 static inline void run(Derived1 &,
const Derived2 &) {}
244 template<
typename Derived1,
typename Derived2,
int UnrollCount,
bool ClearOpposite>
245 struct triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|
Lower), UnrollCount, ClearOpposite>
248 col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
249 row = (UnrollCount-1) % Derived1::RowsAtCompileTime
252 static inline void run(Derived1 &dst,
const Derived2 &src)
254 triangular_assignment_selector<Derived1, Derived2, (SelfAdjoint|
Lower), UnrollCount-1, ClearOpposite>::run(dst, src);
263 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
264 struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|
Lower, 0, ClearOpposite>
266 static inline void run(Derived1 &,
const Derived2 &) {}
269 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
270 struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Upper,
Dynamic, ClearOpposite>
272 typedef typename Derived1::Index Index;
273 static inline void run(Derived1 &dst,
const Derived2 &src)
275 for(Index j = 0; j < dst.cols(); ++j)
277 for(Index i = 0; i < j; ++i)
279 dst.copyCoeff(i, j, src);
280 dst.coeffRef(j,i) =
conj(dst.coeff(i,j));
282 dst.copyCoeff(j, j, src);
287 template<
typename Derived1,
typename Derived2,
bool ClearOpposite>
288 struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|
Lower,
Dynamic, ClearOpposite>
290 static inline void run(Derived1 &dst,
const Derived2 &src)
292 typedef typename Derived1::Index Index;
293 for(Index i = 0; i < dst.rows(); ++i)
295 for(Index j = 0; j < i; ++j)
297 dst.copyCoeff(i, j, src);
298 dst.coeffRef(j,i) =
conj(dst.coeff(i,j));
300 dst.copyCoeff(i, i, src);
311 template<
typename Derived>
312 template<
unsigned int UpLo>
319 template<
typename Derived>
320 template<
unsigned int UpLo>
329 #endif // EIGEN_SELFADJOINTMATRIX_H