11 #ifndef EIGEN_TRIANGULARMATRIX_H    12 #define EIGEN_TRIANGULARMATRIX_H    18 template<
int S
ide, 
typename TriangularType, 
typename Rhs> 
struct triangular_solve_retval;
    49     inline Index 
rows()
 const { 
return derived().rows(); }
    50     inline Index 
cols()
 const { 
return derived().cols(); }
    51     inline Index 
outerStride()
 const { 
return derived().outerStride(); }
    52     inline Index 
innerStride()
 const { 
return derived().innerStride(); }
    54     inline Scalar 
coeff(Index 
row, Index 
col)
 const  { 
return derived().coeff(row,col); }
    55     inline Scalar& 
coeffRef(Index 
row, Index 
col) { 
return derived().coeffRef(row,col); }
    59     template<
typename Other>
    62       derived().coeffRef(row, col) = other.coeff(row, col);
    67       check_coordinates(row, col);
    68       return coeff(row,col);
    72       check_coordinates(row, col);
    73       return coeffRef(row,col);
    76     #ifndef EIGEN_PARSED_BY_DOXYGEN    77     inline const Derived& 
derived()
 const { 
return *
static_cast<const Derived*
>(
this); }
    78     inline Derived& 
derived() { 
return *
static_cast<Derived*
>(
this); }
    79     #endif // not EIGEN_PARSED_BY_DOXYGEN    81     template<
typename DenseDerived>
    83     template<
typename DenseDerived>
    88       DenseMatrixType res(rows(), cols());
    99       eigen_assert(col>=0 && col<cols() && row>=0 && row<rows());
   103                 || (mode==
Lower && col<=row)
   108     #ifdef EIGEN_INTERNAL_DEBUGGING   109     void check_coordinates_internal(Index 
row, Index 
col)
 const   111       check_coordinates(row, col);
   137 template<
typename MatrixType, 
unsigned int _Mode>
   148     CoeffReadCost = MatrixTypeNestedCleaned::CoeffReadCost
   153 template<
int Mode, 
bool LhsIsTriangular,
   154          typename Lhs, 
bool LhsIsVector,
   155          typename Rhs, 
bool RhsIsVector>
   178     using Base::evalToLazy;
   195     inline Index 
rows()
 const { 
return m_matrix.rows(); }
   196     inline Index 
cols()
 const { 
return m_matrix.cols(); }
   197     inline Index 
outerStride()
 const { 
return m_matrix.outerStride(); }
   198     inline Index 
innerStride()
 const { 
return m_matrix.innerStride(); }
   210     void fill(
const Scalar& value) { setConstant(value); }
   213     { 
return *
this = MatrixType::Constant(rows(), cols(), value); }
   224       Base::check_coordinates_internal(row, col);
   225       return m_matrix.coeff(row, col);
   233       Base::check_coordinates_internal(row, col);
   234       return m_matrix.const_cast_derived().coeffRef(row, col);
   238     MatrixTypeNestedCleaned& 
nestedExpression() { 
return *
const_cast<MatrixTypeNestedCleaned*
>(&m_matrix); }
   241     template<
typename OtherDerived>
   244     template<
typename OtherDerived>
   250     template<
typename OtherDerived>
   253     template<
typename OtherDerived>
   258     { 
return m_matrix.conjugate(); }
   261     { 
return m_matrix.conjugate(); }
   265     { 
return m_matrix.adjoint(); }
   271       return m_matrix.const_cast_derived().transpose();
   276       return m_matrix.transpose();
   280     template<
typename OtherDerived>
   285               <Mode,
true,MatrixType,
false,OtherDerived,OtherDerived::IsVectorAtCompileTime>
   286               (m_matrix, rhs.derived());
   290     template<
typename OtherDerived> 
friend   295               <Mode,
false,OtherDerived,OtherDerived::IsVectorAtCompileTime,MatrixType,
false>
   299     #ifdef EIGEN2_SUPPORT   300     template<
typename OtherDerived>
   301     struct eigen2_product_return_type
   304       typedef typename OtherDerived::PlainObject::DenseType OtherPlainObject;
   306       typedef typename ProdRetType::PlainObject type;
   308     template<
typename OtherDerived>
   309     const typename eigen2_product_return_type<OtherDerived>::type
   312       typename OtherDerived::PlainObject::DenseType rhsPlainObject;
   313       rhs.
evalTo(rhsPlainObject);
   314       return this->toDenseMatrix() * rhsPlainObject;
   316     template<
typename OtherMatrixType>
   321     template<
typename OtherDerived>
   324       return this->toDenseMatrix().isApprox(other, 
precision);
   326     #endif // EIGEN2_SUPPORT   328     template<
int S
ide, 
typename Other>
   332     template<
int S
ide, 
typename OtherDerived>
   335     template<
typename Other>
   338     { 
return solve<OnTheLeft>(other); }
   340     template<
typename OtherDerived>
   342     { 
return solveInPlace<OnTheLeft>(other); }
   355     template<
typename OtherDerived>
   361     template<
typename OtherDerived>
   375         return m_matrix.diagonal().prod();
   379     template<
typename ProductDerived, 
typename Lhs, 
typename Rhs>
   383       return assignProduct(other,1);
   386     template<
typename ProductDerived, 
typename Lhs, 
typename Rhs>
   389       return assignProduct(other,1);
   392     template<
typename ProductDerived, 
typename Lhs, 
typename Rhs>
   395       return assignProduct(other,-1);
   399     template<
typename ProductDerived>
   403       return assignProduct(other,other.
alpha());
   406     template<
typename ProductDerived>
   409       return assignProduct(other,other.
alpha());
   412     template<
typename ProductDerived>
   415       return assignProduct(other,-other.
alpha());
   420     template<
typename ProductDerived, 
typename Lhs, 
typename Rhs>
   432 template<
typename Derived1, 
typename Derived2, 
unsigned int Mode, 
int UnrollCount, 
bool ClearOpposite>
   436     col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
   437     row = (UnrollCount-1) % Derived1::RowsAtCompileTime
   440   typedef typename Derived1::Scalar 
Scalar;
   442   static inline void run(Derived1 &dst, 
const Derived2 &src)
   455       dst.copyCoeff(
row, 
col, src);
   456     else if(ClearOpposite)
   459         dst.coeffRef(
row, 
col) = Scalar(1);
   461         dst.coeffRef(
row, 
col) = Scalar(0);
   467 template<
typename Derived1, 
typename Derived2, 
unsigned int Mode, 
bool ClearOpposite>
   470   static inline void run(Derived1 &, 
const Derived2 &) {}
   473 template<
typename Derived1, 
typename Derived2, 
bool ClearOpposite>
   476   typedef typename Derived1::Index 
Index;
   477   typedef typename Derived1::Scalar 
Scalar;
   478   static inline void run(Derived1 &dst, 
const Derived2 &src)
   480     for(Index j = 0; j < dst.cols(); ++j)
   482       Index maxi = (std::min)(j, dst.rows()-1);
   483       for(Index i = 0; i <= maxi; ++i)
   484         dst.copyCoeff(i, j, src);
   486         for(Index i = maxi+1; i < dst.rows(); ++i)
   487           dst.coeffRef(i, j) = Scalar(0);
   492 template<
typename Derived1, 
typename Derived2, 
bool ClearOpposite>
   495   typedef typename Derived1::Index 
Index;
   496   static inline void run(Derived1 &dst, 
const Derived2 &src)
   498     for(Index j = 0; j < dst.cols(); ++j)
   500       for(Index i = j; i < dst.rows(); ++i)
   501         dst.copyCoeff(i, j, src);
   502       Index maxi = (std::min)(j, dst.rows());
   504         for(Index i = 0; i < maxi; ++i)
   505           dst.coeffRef(i, j) = 
static_cast<typename Derived1::Scalar
>(0);
   510 template<
typename Derived1, 
typename Derived2, 
bool ClearOpposite>
   513   typedef typename Derived1::Index 
Index;
   514   typedef typename Derived1::Scalar 
Scalar;
   515   static inline void run(Derived1 &dst, 
const Derived2 &src)
   517     for(Index j = 0; j < dst.cols(); ++j)
   519       Index maxi = (std::min)(j, dst.rows());
   520       for(Index i = 0; i < maxi; ++i)
   521         dst.copyCoeff(i, j, src);
   523         for(Index i = maxi; i < dst.rows(); ++i)
   524           dst.coeffRef(i, j) = Scalar(0);
   529 template<
typename Derived1, 
typename Derived2, 
bool ClearOpposite>
   532   typedef typename Derived1::Index 
Index;
   533   static inline void run(Derived1 &dst, 
const Derived2 &src)
   535     for(Index j = 0; j < dst.cols(); ++j)
   537       for(Index i = j+1; i < dst.rows(); ++i)
   538         dst.copyCoeff(i, j, src);
   539       Index maxi = (std::min)(j, dst.rows()-1);
   541         for(Index i = 0; i <= maxi; ++i)
   542           dst.coeffRef(i, j) = 
static_cast<typename Derived1::Scalar
>(0);
   547 template<
typename Derived1, 
typename Derived2, 
bool ClearOpposite>
   550   typedef typename Derived1::Index 
Index;
   551   static inline void run(Derived1 &dst, 
const Derived2 &src)
   553     for(Index j = 0; j < dst.cols(); ++j)
   555       Index maxi = (std::min)(j, dst.rows());
   556       for(Index i = 0; i < maxi; ++i)
   557         dst.copyCoeff(i, j, src);
   560         for(Index i = maxi+1; i < dst.rows(); ++i)
   561           dst.coeffRef(i, j) = 0;
   564     dst.diagonal().setOnes();
   567 template<
typename Derived1, 
typename Derived2, 
bool ClearOpposite>
   570   typedef typename Derived1::Index 
Index;
   571   static inline void run(Derived1 &dst, 
const Derived2 &src)
   573     for(Index j = 0; j < dst.cols(); ++j)
   575       Index maxi = (std::min)(j, dst.rows());
   576       for(Index i = maxi+1; i < dst.rows(); ++i)
   577         dst.copyCoeff(i, j, src);
   580         for(Index i = 0; i < maxi; ++i)
   581           dst.coeffRef(i, j) = 0;
   584     dst.diagonal().setOnes();
   591 template<
typename MatrixType, 
unsigned int Mode>
   592 template<
typename OtherDerived>
   599     other_evaluated.template triangularView<Mode>().lazyAssign(other.derived());
   600     lazyAssign(other_evaluated);
   603     lazyAssign(other.derived());
   608 template<
typename MatrixType, 
unsigned int Mode>
   609 template<
typename OtherDerived>
   613     unroll = MatrixType::SizeAtCompileTime != 
Dynamic   617   eigen_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols());
   620     <MatrixType, OtherDerived, int(Mode),
   621     unroll ? int(MatrixType::SizeAtCompileTime) : 
Dynamic,
   623     >::run(m_matrix.const_cast_derived(), other.derived());
   628 template<
typename MatrixType, 
unsigned int Mode>
   629 template<
typename OtherDerived>
   636     typename OtherDerived::DenseMatrixType other_evaluated(other.
rows(), other.
cols());
   637     other_evaluated.template triangularView<Mode>().lazyAssign(other.
derived().nestedExpression());
   638     lazyAssign(other_evaluated);
   641     lazyAssign(other.
derived().nestedExpression());
   645 template<
typename MatrixType, 
unsigned int Mode>
   646 template<
typename OtherDerived>
   650     unroll = MatrixType::SizeAtCompileTime != 
Dynamic   658     <MatrixType, OtherDerived, int(Mode),
   659     unroll ? int(MatrixType::SizeAtCompileTime) : 
Dynamic,
   661     >::run(m_matrix.const_cast_derived(), other.
derived().nestedExpression());
   670 template<
typename Derived>
   671 template<
typename DenseDerived>
   677     evalToLazy(other_evaluated);
   678     other.derived().
swap(other_evaluated);
   681     evalToLazy(other.derived());
   686 template<
typename Derived>
   687 template<
typename DenseDerived>
   691     unroll = DenseDerived::SizeAtCompileTime != 
Dynamic   696   other.derived().
resize(this->rows(), this->cols());
   700     unroll ? int(DenseDerived::SizeAtCompileTime) : 
Dynamic,
   702     >::run(other.derived(), derived().nestedExpression());
   713 #ifdef EIGEN2_SUPPORT   718 template<
typename MatrixType, 
unsigned int Mode>
   719 struct eigen2_part_return_type
   724 template<
typename MatrixType>
   725 struct eigen2_part_return_type<MatrixType, SelfAdjoint>
   732 template<
typename Derived>
   733 template<
unsigned int Mode>
   740 template<
typename Derived>
   741 template<
unsigned int Mode>
   759 template<
typename Derived>
   760 template<
unsigned int Mode>
   768 template<
typename Derived>
   769 template<
unsigned int Mode>
   781 template<
typename Derived>
   786   for(Index j = 0; j < cols(); ++j)
   788     Index maxi = (std::min)(j, rows()-1);
   789     for(Index i = 0; i <= maxi; ++i)
   792       if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
   795   RealScalar threshold = maxAbsOnUpperPart * prec;
   796   for(Index j = 0; j < cols(); ++j)
   797     for(Index i = j+1; i < rows(); ++i)
   798       if(
abs(coeff(i, j)) > threshold) 
return false;
   807 template<
typename Derived>
   812   for(Index j = 0; j < cols(); ++j)
   813     for(Index i = j; i < rows(); ++i)
   816       if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
   818   RealScalar threshold = maxAbsOnLowerPart * prec;
   819   for(Index j = 1; j < cols(); ++j)
   821     Index maxi = (std::min)(j, rows()-1);
   822     for(Index i = 0; i < maxi; ++i)
   823       if(
abs(coeff(i, j)) > threshold) 
return false;
   830 #endif // EIGEN_TRIANGULARMATRIX_H Expression of the product of two general matrices or vectors. 
const TriangularView< Transpose< MatrixType >, TransposeMode > transpose() const 
remove_reference< MatrixTypeNested >::type MatrixTypeNestedNonRef
internal::remove_all< typename MatrixType::ConjugateReturnType >::type MatrixConjugateReturnType
const TriangularView< MatrixConjugateReturnType, Mode > conjugate() const 
EIGEN_STRONG_INLINE TriangularView & operator=(const ScaledProduct< ProductDerived > &other)
#define EIGEN_STRONG_INLINE
const TriangularView< const typename MatrixType::AdjointReturnType, TransposeMode > adjoint() const 
TriangularView< Transpose< MatrixType >, TransposeMode > transpose()
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
DenseMatrixType toDenseMatrix() const 
void check_coordinates_internal(Index, Index) const 
EIGEN_STRONG_INLINE TriangularView & operator+=(const ProductBase< ProductDerived, Lhs, Rhs > &other)
MatrixTypeNestedCleaned & nestedExpression()
friend TriangularProduct< Mode, false, OtherDerived, OtherDerived::IsVectorAtCompileTime, MatrixType, false > operator*(const MatrixBase< OtherDerived > &lhs, const TriangularView &rhs)
EIGEN_STRONG_INLINE TriangularView & operator+=(const ScaledProduct< ProductDerived > &other)
Scalar & coeffRef(Index row, Index col)
MatrixType::PlainObject DenseMatrixType
const unsigned int DirectAccessBit
EIGEN_STRONG_INLINE void copyCoeff(Index row, Index col, Other &other)
bool isLowerTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const 
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
nested< MatrixType >::type MatrixTypeNested
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
const MatrixTypeNestedCleaned & nestedExpression() const 
MatrixTypeNested m_matrix
internal::traits< TriangularView >::MatrixTypeNestedCleaned MatrixTypeNestedCleaned
Base class for all dense matrices, vectors, and arrays. 
Scalar determinant() const 
const unsigned int PacketAccessBit
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
void resize(Index newSize)
DenseMatrixType DenseType
MatrixType ExpressionType
TriangularBase< TriangularView > Base
void swap(TriangularBase< OtherDerived > const &other)
TriangularView & operator-=(const DenseBase< Other > &other)
internal::traits< TriangularView >::Scalar Scalar
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const 
void solveInPlace(const MatrixBase< OtherDerived > &other) const 
internal::traits< Derived >::DenseMatrixType DenseMatrixType
static void run(Derived1 &dst, const Derived2 &src)
const unsigned int HereditaryBits
Index innerStride() const 
DenseMatrixType PlainObject
const internal::triangular_solve_retval< OnTheLeft, TriangularView, Other > solve(const MatrixBase< Other > &other) const 
TriangularView & operator*=(const typename internal::traits< MatrixType >::Scalar &other)
TriangularView(const MatrixType &matrix)
Index outerStride() const 
remove_all< MatrixTypeNested >::type MatrixTypeNestedCleaned
bool isApprox(const Scalar &x, const Scalar &y, typename NumTraits< Scalar >::Real precision=NumTraits< Scalar >::dummy_precision())
Scalar coeff(Index row, Index col) const 
Scalar & operator()(Index row, Index col)
internal::traits< TriangularView >::MatrixTypeNested MatrixTypeNested
Expression of a selfadjoint matrix from a triangular part of a dense matrix. 
static void run(Derived1 &dst, const Derived2 &src)
const Derived & derived() const 
TriangularView< MatrixConjugateReturnType, Mode > conjugate()
const unsigned int EvalBeforeAssigningBit
void evalTo(MatrixBase< DenseDerived > &other) const 
TriangularView & operator=(const TriangularBase< OtherDerived > &other)
Scalar operator()(Index row, Index col) const 
TriangularView & setZero()
EIGEN_STRONG_INLINE TriangularView & operator=(const ProductBase< ProductDerived, Lhs, Rhs > &other)
void evalTo(Dest &dst) const 
TriangularProduct< Mode, true, MatrixType, false, OtherDerived, OtherDerived::IsVectorAtCompileTime > operator*(const MatrixBase< OtherDerived > &rhs) const 
internal::traits< TriangularView >::DenseMatrixType DenseMatrixType
void lazyAssign(const TriangularBase< OtherDerived > &other)
static void run(Derived1 &dst, const Derived2 &src)
Scalar coeff(Index row, Index col) const 
TriangularView & setConstant(const Scalar &value)
NumTraits< Scalar >::Real RealScalar
Scalar & coeffRef(Index row, Index col)
EIGEN_STRONG_INLINE TriangularView & operator-=(const ProductBase< ProductDerived, Lhs, Rhs > &other)
static void run(Derived1 &dst, const Derived2 &src)
bool isUpperTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const 
Base class for triangular part in a matrix. 
const SelfAdjointView< MatrixTypeNestedNonRef, Mode > selfadjointView() const 
TriangularView & operator+=(const DenseBase< Other > &other)
EIGEN_STRONG_INLINE TriangularView & operator-=(const ScaledProduct< ProductDerived > &other)
TriangularView & operator/=(const typename internal::traits< MatrixType >::Scalar &other)
static void run(Derived1 &dst, const Derived2 &src)
internal::traits< Derived >::StorageKind StorageKind
internal::traits< Derived >::Index Index
Index innerStride() const 
static void run(Derived1 &dst, const Derived2 &src)
SelfAdjointView< MatrixTypeNestedNonRef, Mode > selfadjointView()
TriangularView & setOnes()
void swap(const DenseBase< OtherDerived > &other, int=OtherDerived::ThisConstantIsPrivateInPlainObjectBase)
Index outerStride() const 
const Scalar & alpha() const 
static void run(Derived1 &dst, const Derived2 &src)
void swap(MatrixBase< OtherDerived > const &other)
internal::traits< TriangularView >::Index Index
internal::traits< Derived >::Scalar Scalar
TriangularViewReturnType< Mode >::Type triangularView()
TriangularView & operator=(const TriangularView &other)
void fill(const Scalar &value)
Base class for all dense matrices, vectors, and expressions. 
const unsigned int LinearAccessBit
internal::traits< TriangularView >::StorageKind StorageKind
void check_coordinates(Index row, Index col) const 
#define EIGEN_UNROLLING_LIMIT
static void run(Derived1 &, const Derived2 &)
void evalToLazy(MatrixBase< DenseDerived > &other) const 
internal::traits< TriangularView >::MatrixTypeNestedNonRef MatrixTypeNestedNonRef