11 #ifndef EIGEN_TRIANGULARMATRIX_H    12 #define EIGEN_TRIANGULARMATRIX_H    18 template<
int S
ide, 
typename TriangularType, 
typename Rhs> 
struct triangular_solve_retval;
    59     inline Index rows()
 const { 
return derived().rows(); }
    61     inline Index cols()
 const { 
return derived().cols(); }
    82     template<
typename Other>
    86       derived().coeffRef(row, col) = other.coeff(row, col);
    92       check_coordinates(row, col);
    93       return coeff(row,col);
    98       check_coordinates(row, col);
    99       return coeffRef(row,col);
   102     #ifndef EIGEN_PARSED_BY_DOXYGEN   104     inline const Derived& 
derived()
 const { 
return *
static_cast<const Derived*
>(
this); }
   106     inline Derived& 
derived() { 
return *
static_cast<Derived*
>(
this); }
   107     #endif // not EIGEN_PARSED_BY_DOXYGEN   109     template<
typename DenseDerived>
   112     template<
typename DenseDerived>
   119       DenseMatrixType res(rows(), cols());
   130       eigen_assert(col>=0 && col<cols() && row>=0 && row<rows());
   134                 || (mode==
Lower && col<=row)
   139     #ifdef EIGEN_INTERNAL_DEBUGGING   142       check_coordinates(row, col);
   168 template<
typename MatrixType, 
unsigned int _Mode>
   187   : 
public TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind >
   213       IsVectorAtCompileTime = 
false   220     using Base::operator=;
   222     { 
return Base::operator=(other); }
   248     inline const AdjointReturnType 
adjoint()
 const   249     { 
return AdjointReturnType(m_matrix.adjoint()); }
   257       typename MatrixType::TransposeReturnType tmp(m_matrix);
   258       return TransposeReturnType(tmp);
   266       return ConstTransposeReturnType(m_matrix.transpose());
   269     template<
typename Other>
   277     template<
int S
ide, 
typename Other>
   281     { 
return Base::template solve<Side>(other); }
   316         return m_matrix.diagonal().prod();
   347     using Base::evalToLazy;
   367     template<
typename Other>
   374     template<
typename Other>
   390     void fill(
const Scalar& value) { setConstant(value); }
   394     { 
return *
this = MatrixType::Constant(derived().rows(), derived().cols(), value); }
   397     TriangularViewType& 
setZero() { 
return setConstant(Scalar(0)); }
   400     TriangularViewType& 
setOnes() { 
return setConstant(Scalar(1)); }
   408       Base::check_coordinates_internal(row, col);
   409       return derived().nestedExpression().coeff(row, col);
   419       Base::check_coordinates_internal(row, col);
   420       return derived().nestedExpression().coeffRef(row, col);
   424     template<
typename OtherDerived>
   429     template<
typename OtherDerived>
   433 #ifndef EIGEN_PARSED_BY_DOXYGEN   436     { 
return *
this = other.derived().nestedExpression(); }
   439     template<
typename OtherDerived>
   444     template<
typename OtherDerived>
   450     template<
typename OtherDerived>
   459     template<
typename OtherDerived> 
friend   488     template<
int S
ide, 
typename Other>
   500     template<
int S
ide, 
typename OtherDerived>
   504     template<
typename OtherDerived>
   507     { 
return solveInPlace<OnTheLeft>(other); }
   510     template<
typename OtherDerived>
   512 #ifdef EIGEN_PARSED_BY_DOXYGEN   524     template<
typename OtherDerived>
   532     template<
typename RhsType, 
typename DstType>
   537       this->solveInPlace(dst);
   540     template<
typename ProductType>
   542     EIGEN_STRONG_INLINE TriangularViewType& _assignProduct(
const ProductType& prod, 
const Scalar& alpha);
   550 template<
typename MatrixType, 
unsigned int Mode>
   551 template<
typename OtherDerived>
   560 template<
typename MatrixType, 
unsigned int Mode>
   561 template<
typename OtherDerived>
   569 template<
typename MatrixType, 
unsigned int Mode>
   570 template<
typename OtherDerived>
   579 template<
typename MatrixType, 
unsigned int Mode>
   580 template<
typename OtherDerived>
   593 template<
typename Derived>
   594 template<
typename DenseDerived>
   597   evalToLazy(other.derived());
   619 template<
typename Derived>
   620 template<
unsigned int Mode>
   628 template<
typename Derived>
   629 template<
unsigned int Mode>
   641 template<
typename Derived>
   645   for(
Index j = 0; j < cols(); ++j)
   647     Index maxi = numext::mini(j, rows()-1);
   648     for(
Index i = 0; i <= maxi; ++i)
   651       if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
   654   RealScalar threshold = maxAbsOnUpperPart * prec;
   655   for(
Index j = 0; j < cols(); ++j)
   656     for(
Index i = j+1; i < rows(); ++i)
   657       if(
numext::abs(coeff(i, j)) > threshold) 
return false;
   666 template<
typename Derived>
   670   for(
Index j = 0; j < cols(); ++j)
   671     for(
Index i = j; i < rows(); ++i)
   674       if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
   676   RealScalar threshold = maxAbsOnLowerPart * prec;
   677   for(
Index j = 1; j < cols(); ++j)
   679     Index maxi = numext::mini(j, rows()-1);
   680     for(
Index i = 0; i < maxi; ++i)
   681       if(
numext::abs(coeff(i, j)) > threshold) 
return false;
   699 template<
typename MatrixType, 
unsigned int Mode>
   706 template<
typename MatrixType, 
unsigned int Mode>
   708  : 
evaluator<typename internal::remove_all<MatrixType>::type>
   729 template<
int UpLo, 
int Mode, 
int SetOpposite, 
typename DstEvaluatorTypeT, 
typename SrcEvaluatorTypeT, 
typename Functor, 
int Version = Specialized>
   738   using Base::m_functor;
   748     : Base(dst, src, func, dstExpr)
   751 #ifdef EIGEN_INTERNAL_DEBUGGING   755     Base::assignCoeff(row,col);
   758   using Base::assignCoeff;
   763          if(Mode==
UnitDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(
id,
id), Scalar(1));
   764     else if(Mode==
ZeroDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(
id,
id), Scalar(0));
   765     else if(Mode==0)                       Base::assignCoeff(
id,
id);
   772       m_functor.assignCoeff(m_dst.coeffRef(row,col), Scalar(0));
   776 template<
int Mode, 
bool SetOpposite, 
typename DstXprType, 
typename SrcXprType, 
typename Functor>
   783   SrcEvaluatorType srcEvaluator(src);
   785   Index dstRows = src.rows();
   786   Index dstCols = src.cols();
   787   if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
   788     dst.resize(dstRows, dstCols);
   789   DstEvaluatorType dstEvaluator(dst);
   792                                               DstEvaluatorType,SrcEvaluatorType,Functor> Kernel;
   793   Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
   796       unroll = DstXprType::SizeAtCompileTime != 
Dynamic   797             && SrcEvaluatorType::CoeffReadCost < 
HugeCost   798             && DstXprType::SizeAtCompileTime * (DstEvaluatorType::CoeffReadCost+SrcEvaluatorType::CoeffReadCost) / 2 <= 
EIGEN_UNROLLING_LIMIT   804 template<
int Mode, 
bool SetOpposite, 
typename DstXprType, 
typename SrcXprType>
   816 template< 
typename DstXprType, 
typename SrcXprType, 
typename Functor>
   819   EIGEN_DEVICE_FUNC 
static void run(DstXprType &dst, 
const SrcXprType &src, 
const Functor &func)
   821     eigen_assert(
int(DstXprType::Mode) == 
int(SrcXprType::Mode));
   823     call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);  
   827 template< 
typename DstXprType, 
typename SrcXprType, 
typename Functor>
   830   EIGEN_DEVICE_FUNC 
static void run(DstXprType &dst, 
const SrcXprType &src, 
const Functor &func)
   832     call_triangular_assignment_loop<SrcXprType::Mode, (SrcXprType::Mode&SelfAdjoint)==0>(dst, src, func);  
   836 template< 
typename DstXprType, 
typename SrcXprType, 
typename Functor>
   839   EIGEN_DEVICE_FUNC 
static void run(DstXprType &dst, 
const SrcXprType &src, 
const Functor &func)
   841     call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);  
   846 template<
typename Kernel, 
unsigned int Mode, 
int UnrollCount, 
bool SetOpposite>
   854     col = (UnrollCount-1) / DstXprType::RowsAtCompileTime,
   855     row = (UnrollCount-1) % DstXprType::RowsAtCompileTime
   861   static inline void run(Kernel &kernel)
   866       kernel.assignDiagonalCoeff(
row);
   868       kernel.assignCoeff(
row,
col);
   870       kernel.assignOppositeCoeff(
row,
col);
   875 template<
typename Kernel, 
unsigned int Mode, 
bool SetOpposite>
   879   static inline void run(Kernel &) {}
   888 template<
typename Kernel, 
unsigned int Mode, 
bool SetOpposite>
   893   static inline void run(Kernel &kernel)
   895     for(
Index j = 0; j < kernel.cols(); ++j)
   897       Index maxi = numext::mini(j, kernel.rows());
   899       if (((Mode&
Lower) && SetOpposite) || (Mode&
Upper))
   902           if(Mode&
Upper) kernel.assignCoeff(i, j);
   903           else           kernel.assignOppositeCoeff(i, j);
   909         kernel.assignDiagonalCoeff(i++);
   911       if (((Mode&
Upper) && SetOpposite) || (Mode&Lower))
   913         for(; i < kernel.rows(); ++i)
   914           if(Mode&Lower) kernel.assignCoeff(i, j);
   915           else           kernel.assignOppositeCoeff(i, j);
   925 template<
typename Derived>
   926 template<
typename DenseDerived>
   929   other.derived().
resize(this->rows(), this->cols());
   936 template< 
typename DstXprType, 
typename Lhs, 
typename Rhs, 
typename Scalar>
   944     if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
   945       dst.resize(dstRows, dstCols);
   948     dst._assignProduct(src, 1);
   953 template< 
typename DstXprType, 
typename Lhs, 
typename Rhs, 
typename Scalar>
   959     dst._assignProduct(src, 1);
   964 template< 
typename DstXprType, 
typename Lhs, 
typename Rhs, 
typename Scalar>
   970     dst._assignProduct(src, -1);
   978 #endif // EIGEN_TRIANGULARMATRIX_H Base::DstEvaluatorType DstEvaluatorType
EIGEN_DEVICE_FUNC void assignOppositeCoeff(Index row, Index col)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
EIGEN_DEVICE_FUNC void evalToLazy(MatrixBase< DenseDerived > &other) const
#define EIGEN_STRONG_INLINE
Product< Lhs, Rhs, DefaultProduct > SrcXprType
remove_reference< MatrixTypeNested >::type MatrixTypeNestedNonRef
EIGEN_DEVICE_FUNC Scalar & coeffRef(Index row, Index col)
internal::remove_all< typename MatrixType::ConjugateReturnType >::type MatrixConjugateReturnType
SrcEvaluatorTypeT::XprType SrcXprType
Product< Lhs, Rhs, DefaultProduct > SrcXprType
Expression of the product of two arbitrary matrices or vectors. 
EIGEN_DEVICE_FUNC Scalar & coeffRef(Index row, Index col)
EIGEN_DEVICE_FUNC void swap(TriangularBase< OtherDerived > const &other)
EIGEN_DEVICE_FUNC DenseMatrixType toDenseMatrix() const
TriangularView< MatrixType, Mode > XprType
bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if< has_direct_access< T1 >::ret &&has_direct_access< T2 >::ret, T1 >::type *=0)
EIGEN_DEVICE_FUNC Scalar coeff(Index row, Index col) const
TriangularView< typename MatrixType::TransposeReturnType, TransposeMode > TransposeReturnType
TriangularView< _MatrixType, _Mode > TriangularViewType
Base class for triangular part in a matrix. 
const unsigned int DirectAccessBit
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col(). */. 
static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op< Scalar, typename SrcXprType::Scalar > &)
generic_dense_assignment_kernel< DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version > Base
const unsigned int LvalueBit
Base::AssignmentTraits AssignmentTraits
EIGEN_DEVICE_FUNC TriangularViewType & operator+=(const DenseBase< Other > &other)
EIGEN_DEVICE_FUNC Derived & const_cast_derived() const
DstEvaluatorType::Scalar Scalar
internal::traits< Derived >::FullMatrixType DenseMatrixType
EIGEN_DEVICE_FUNC const SelfAdjointView< MatrixTypeNestedNonRef, Mode > selfadjointView() const
EIGEN_DEVICE_FUNC TriangularViewType & setOnes()
TriangularView< const typename MatrixType::AdjointReturnType, TransposeMode > AdjointReturnType
DenseMatrixType PlainObject
glue_shapes< typename evaluator_traits< MatrixType >::Shape, TriangularShape >::type Shape
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_DEVICE_FUNC void resize(Index newSize)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _solve_impl(const RhsType &rhs, DstType &dst) const
EIGEN_DEVICE_FUNC TriangularViewType & operator/=(const typename internal::traits< MatrixType >::Scalar &other)
ref_selector< MatrixType >::non_const_type MatrixTypeNested
MatrixTypeNested m_matrix
EIGEN_DEVICE_FUNC Scalar operator()(Index row, Index col) const
EIGEN_DEVICE_FUNC void assignDiagonalCoeff(Index id)
Eigen::Index Index
The interface type of indices. 
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Base class for all dense matrices, vectors, and arrays. 
static EIGEN_DEVICE_FUNC void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
const unsigned int PacketAccessBit
EIGEN_DEVICE_FUNC Index rows() const
static EIGEN_DEVICE_FUNC void run(Kernel &kernel)
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
static EIGEN_DEVICE_FUNC void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
DenseMatrixType DenseType
friend EIGEN_DEVICE_FUNC const Product< OtherDerived, TriangularViewType > operator*(const MatrixBase< OtherDerived > &lhs, const TriangularViewImpl &rhs)
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
MatrixType ExpressionType
EIGEN_DEVICE_FUNC Index rows() const
EIGEN_DEVICE_FUNC Index outerStride() const
void resize(Index rows, Index cols)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
internal::traits< TriangularView >::Scalar Scalar
SrcEvaluatorTypeT SrcEvaluatorType
bool isUpperTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Product< Lhs, Rhs, DefaultProduct > SrcXprType
EIGEN_DEVICE_FUNC const Solve< TriangularView, Other > solve(const MatrixBase< Other > &other) const
TriangularView< const typename MatrixType::ConstTransposeReturnType, TransposeMode > ConstTransposeReturnType
const unsigned int HereditaryBits
EIGEN_DEVICE_FUNC TriangularViewType & setConstant(const Scalar &value)
EIGEN_DEVICE_FUNC TriangularViewType & operator*=(const typename internal::traits< MatrixType >::Scalar &other)
EIGEN_DEVICE_FUNC Index rows() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void copyCoeff(Index row, Index col, Other &other)
EIGEN_DEVICE_FUNC TriangularBase()
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< Scalar, typename SrcXprType::Scalar > &)
TriangularView< const MatrixConjugateReturnType, Mode > ConjugateReturnType
EIGEN_DEVICE_FUNC Index innerStride() const
EIGEN_DEVICE_FUNC void swap(MatrixBase< OtherDerived > const &other)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API. 
storage_kind_to_evaluator_kind< typename MatrixType::StorageKind >::Kind Kind
DstEvaluatorTypeT DstEvaluatorType
remove_all< MatrixTypeNested >::type MatrixTypeNestedCleaned
EIGEN_DEVICE_FUNC const Product< TriangularViewType, OtherDerived > operator*(const MatrixBase< OtherDerived > &rhs) const
TriangularViewImpl< _MatrixType, _Mode, typename internal::traits< _MatrixType >::StorageKind > Base
EIGEN_DEVICE_FUNC void solveInPlace(const MatrixBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_triangular_assignment_loop(DstXprType &dst, const SrcXprType &src, const Functor &func)
static EIGEN_DEVICE_FUNC void run(Kernel &)
EIGEN_DEVICE_FUNC TriangularViewReturnType< Mode >::Type triangularView()
internal::traits< TriangularView >::MatrixTypeNested MatrixTypeNested
Expression of a selfadjoint matrix from a triangular part of a dense matrix. 
Base::SrcEvaluatorType SrcEvaluatorType
EIGEN_DEVICE_FUNC Derived & derived()
evaluator< typename internal::remove_all< MatrixType >::type > Base
Base::SrcXprType SrcXprType
EIGEN_DEVICE_FUNC void evalTo(MatrixBase< DenseDerived > &other) const
internal::traits< TriangularView >::MatrixTypeNestedCleaned NestedExpression
EIGEN_DEVICE_FUNC const ConstTransposeReturnType transpose() const
EIGEN_DEVICE_FUNC Index cols() const
void check_coordinates(Index row, Index col) const
EIGEN_DEVICE_FUNC NestedExpression & nestedExpression()
DstEvaluatorType::XprType DstXprType
EIGEN_DEVICE_FUNC Scalar coeff(Index row, Index col) const
EIGEN_DEVICE_FUNC TriangularViewType & operator-=(const DenseBase< Other > &other)
EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType &dst, const SrcEvaluatorType &src, const Functor &func, DstXprType &dstExpr)
EIGEN_DEVICE_FUNC Index outerStride() const
DstEvaluatorTypeT::XprType DstXprType
Base::DstXprType DstXprType
EIGEN_DEVICE_FUNC Scalar & operator()(Index row, Index col)
bool isLowerTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
MatrixType::PlainObject FullMatrixType
static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op< Scalar, typename SrcXprType::Scalar > &)
MatrixType::PlainObject DenseMatrixType
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC Index cols() const
static EIGEN_DEVICE_FUNC void run(Kernel &kernel)
EIGEN_DEVICE_FUNC const ConjugateReturnType conjugate() const
Expression of a triangular part in a matrix. 
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). */. 
EIGEN_DEVICE_FUNC const NestedExpression & nestedExpression() const
Triangular2Triangular Kind
internal::traits< Derived >::StorageKind StorageKind
EIGEN_DEVICE_FUNC Scalar determinant() const
EIGEN_DEVICE_FUNC Index cols() const
EIGEN_DEVICE_FUNC Index innerStride() const
internal::traits< TriangularViewType >::StorageKind StorageKind
internal::conditional< NumTraits< Scalar >::IsComplex, const CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, const Derived >, const Derived &>::type ConjugateReturnType
Pseudo expression representing a solving operation. 
static EIGEN_DEVICE_FUNC void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
#define eigen_internal_assert(x)
internal::traits< Derived >::Scalar Scalar
Kernel::DstEvaluatorType DstEvaluatorType
EIGEN_DEVICE_FUNC TriangularViewType & operator=(const TriangularViewImpl &other)
EIGEN_DEVICE_FUNC void fill(const Scalar &value)
EIGEN_DEVICE_FUNC const Derived & derived() const
TriangularBase< TriangularViewType > Base
void check_coordinates_internal(Index, Index) const
unary_evaluator(const XprType &xpr)
TriangularView & operator=(const TriangularView &other)
Base class for all dense matrices, vectors, and expressions. 
EIGEN_DEVICE_FUNC TriangularView(MatrixType &matrix)
const unsigned int LinearAccessBit
EIGEN_DEVICE_FUNC SelfAdjointView< MatrixTypeNestedNonRef, Mode > selfadjointView()
internal::traits< TriangularView >::StorageKind StorageKind
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment(Dst &dst, const Src &src)
#define EIGEN_UNROLLING_LIMIT
#define EIGEN_UNUSED_VARIABLE(var)
EIGEN_DEVICE_FUNC TriangularViewType & setZero()
void swap(scoped_array< T > &a, scoped_array< T > &b)
internal::traits< Derived >::StorageIndex StorageIndex
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
internal::traits< TriangularView >::MatrixTypeNestedNonRef MatrixTypeNestedNonRef
internal::traits< TriangularViewType >::Scalar Scalar