11 #ifndef EIGEN_TRIANGULARMATRIX_H 12 #define EIGEN_TRIANGULARMATRIX_H 18 template<
int S
ide,
typename TriangularType,
typename Rhs>
struct triangular_solve_retval;
83 template<
typename Other>
87 derived().coeffRef(row, col) = other.coeff(row, col);
93 check_coordinates(row, col);
94 return coeff(row,col);
99 check_coordinates(row, col);
100 return coeffRef(row,col);
103 #ifndef EIGEN_PARSED_BY_DOXYGEN 105 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
107 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
108 #endif // not EIGEN_PARSED_BY_DOXYGEN 110 template<
typename DenseDerived>
113 template<
typename DenseDerived>
135 || (mode==
Lower && col<=row)
140 #ifdef EIGEN_INTERNAL_DEBUGGING 143 check_coordinates(row, col);
169 template<
typename MatrixType,
unsigned int _Mode>
188 :
public TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind >
215 IsVectorAtCompileTime =
false 254 return ReturnType(m_matrix.template conjugateIf<Cond>());
260 inline const AdjointReturnType
adjoint()
const 261 {
return AdjointReturnType(m_matrix.adjoint()); }
269 typename MatrixType::TransposeReturnType tmp(m_matrix);
270 return TransposeReturnType(tmp);
278 return ConstTransposeReturnType(m_matrix.transpose());
281 template<
typename Other>
289 template<
int S
ide,
typename Other>
293 {
return Base::template solve<Side>(
other); }
328 return m_matrix.diagonal().prod();
359 using Base::evalToLazy;
379 template<
typename Other>
386 template<
typename Other>
406 {
return *
this = MatrixType::Constant(derived().
rows(), derived().
cols(), value); }
420 Base::check_coordinates_internal(row, col);
421 return derived().nestedExpression().coeff(row, col);
431 Base::check_coordinates_internal(row, col);
432 return derived().nestedExpression().coeffRef(row, col);
436 template<
typename OtherDerived>
441 template<
typename OtherDerived>
445 #ifndef EIGEN_PARSED_BY_DOXYGEN 448 {
return *
this = other.derived().nestedExpression(); }
450 template<
typename OtherDerived>
455 template<
typename OtherDerived>
462 template<
typename OtherDerived>
471 template<
typename OtherDerived>
friend 502 template<
int S
ide,
typename Other>
515 template<
int S
ide,
typename OtherDerived>
519 template<
typename OtherDerived>
522 {
return solveInPlace<OnTheLeft>(
other); }
525 template<
typename OtherDerived>
527 #ifdef EIGEN_PARSED_BY_DOXYGEN 538 template<
typename OtherDerived>
547 template<
typename RhsType,
typename DstType>
552 this->solveInPlace(dst);
555 template<
typename ProductType>
568 #ifndef EIGEN_PARSED_BY_DOXYGEN 570 template<
typename MatrixType,
unsigned int Mode>
571 template<
typename OtherDerived>
580 template<
typename MatrixType,
unsigned int Mode>
581 template<
typename OtherDerived>
589 template<
typename MatrixType,
unsigned int Mode>
590 template<
typename OtherDerived>
599 template<
typename MatrixType,
unsigned int Mode>
600 template<
typename OtherDerived>
614 template<
typename Derived>
615 template<
typename DenseDerived>
618 evalToLazy(other.derived());
640 template<
typename Derived>
641 template<
unsigned int Mode>
650 template<
typename Derived>
651 template<
unsigned int Mode>
664 template<
typename Derived>
674 if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
677 RealScalar threshold = maxAbsOnUpperPart * prec;
689 template<
typename Derived>
697 if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
699 RealScalar threshold = maxAbsOnLowerPart * prec;
722 template<
typename MatrixType,
unsigned int Mode>
729 template<
typename MatrixType,
unsigned int Mode>
731 :
evaluator<typename internal::remove_all<MatrixType>::type>
753 template<
int UpLo,
int Mode,
int SetOpposite,
typename DstEvaluatorTypeT,
typename SrcEvaluatorTypeT,
typename Functor,
int Version = Specialized>
762 using Base::m_functor;
772 : Base(dst, src, func, dstExpr)
775 #ifdef EIGEN_INTERNAL_DEBUGGING 779 Base::assignCoeff(row,col);
782 using Base::assignCoeff;
787 if(Mode==
UnitDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(
id,
id),
Scalar(1));
788 else if(Mode==
ZeroDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(
id,
id),
Scalar(0));
789 else if(Mode==0) Base::assignCoeff(
id,
id);
796 m_functor.assignCoeff(m_dst.coeffRef(row,col),
Scalar(0));
800 template<
int Mode,
bool SetOpposite,
typename DstXprType,
typename SrcXprType,
typename Functor>
807 SrcEvaluatorType srcEvaluator(src);
809 Index dstRows = src.rows();
810 Index dstCols = src.cols();
811 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
812 dst.resize(dstRows, dstCols);
813 DstEvaluatorType dstEvaluator(dst);
816 DstEvaluatorType,SrcEvaluatorType,
Functor> Kernel;
817 Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
820 unroll = DstXprType::SizeAtCompileTime !=
Dynamic 821 && SrcEvaluatorType::CoeffReadCost <
HugeCost 822 && DstXprType::SizeAtCompileTime * (
int(DstEvaluatorType::CoeffReadCost) +
int(SrcEvaluatorType::CoeffReadCost)) / 2 <=
EIGEN_UNROLLING_LIMIT 828 template<
int Mode,
bool SetOpposite,
typename DstXprType,
typename SrcXprType>
840 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
845 eigen_assert(
int(DstXprType::Mode) ==
int(SrcXprType::Mode));
847 call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src,
func);
851 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
856 call_triangular_assignment_loop<SrcXprType::Mode, (int(SrcXprType::Mode) & int(SelfAdjoint)) == 0>(dst, src,
func);
860 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
865 call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src,
func);
870 template<
typename Kernel,
unsigned int Mode,
int UnrollCount,
bool SetOpposite>
878 col = (UnrollCount-1) / DstXprType::RowsAtCompileTime,
879 row = (UnrollCount-1) % DstXprType::RowsAtCompileTime
885 static inline void run(Kernel &kernel)
890 kernel.assignDiagonalCoeff(
row);
892 kernel.assignCoeff(
row,
col);
894 kernel.assignOppositeCoeff(
row,
col);
899 template<
typename Kernel,
unsigned int Mode,
bool SetOpposite>
903 static inline void run(Kernel &) {}
912 template<
typename Kernel,
unsigned int Mode,
bool SetOpposite>
917 static inline void run(Kernel &kernel)
919 for(
Index j = 0;
j < kernel.cols(); ++
j)
923 if (((Mode&
Lower) && SetOpposite) || (Mode&
Upper))
926 if(Mode&
Upper) kernel.assignCoeff(i,
j);
927 else kernel.assignOppositeCoeff(i,
j);
933 kernel.assignDiagonalCoeff(i++);
935 if (((Mode&
Upper) && SetOpposite) || (Mode&Lower))
937 for(; i < kernel.rows(); ++
i)
938 if(Mode&Lower) kernel.assignCoeff(i,
j);
939 else kernel.assignOppositeCoeff(i,
j);
949 template<
typename Derived>
950 template<
typename DenseDerived>
960 template<
typename DstXprType,
typename Lhs,
typename Rhs,
typename Scalar>
968 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
969 dst.resize(dstRows, dstCols);
971 dst._assignProduct(src,
Scalar(1),
false);
976 template<
typename DstXprType,
typename Lhs,
typename Rhs,
typename Scalar>
982 dst._assignProduct(src,
Scalar(1),
true);
987 template<
typename DstXprType,
typename Lhs,
typename Rhs,
typename Scalar>
993 dst._assignProduct(src,
Scalar(-1),
true);
1001 #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 internal::conditional< Cond, ConjugateReturnType, ConstTriangularView >::type conjugateIf() const
EIGEN_DEVICE_FUNC void swap(TriangularBase< OtherDerived > const &other)
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC DenseMatrixType toDenseMatrix() const
TriangularView< MatrixType, Mode > XprType
EIGEN_DEVICE_FUNC Scalar coeff(Index row, Index col) const
TriangularView< typename MatrixType::TransposeReturnType, TransposeMode > TransposeReturnType
TriangularView< _MatrixType, _Mode > TriangularViewType
EIGEN_DEPRECATED EIGEN_DEVICE_FUNC void swap(MatrixBase< OtherDerived > const &other)
Base class for triangular part in a matrix.
const unsigned int DirectAccessBit
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
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
internal::traits< Derived >::FullMatrixType DenseMatrixType
EIGEN_DEVICE_FUNC const SelfAdjointView< MatrixTypeNestedNonRef, Mode > selfadjointView() const
Namespace containing all symbols from the Eigen library.
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_ALWAYS_INLINE T maxi(const T &x, const T &y)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _solve_impl(const RhsType &rhs, DstType &dst) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC TriangularViewType & operator/=(const typename internal::traits< MatrixType >::Scalar &other)
ref_selector< MatrixType >::non_const_type MatrixTypeNested
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
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
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
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
MatrixType ExpressionType
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
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 EIGEN_ALWAYS_INLINE internal::enable_if< NumTraits< T >::IsSigned||NumTraits< T >::IsComplex, typename NumTraits< T >::Real >::type abs(const T &x)
EIGEN_DEVICE_FUNC TriangularViewType & operator*=(const typename internal::traits< MatrixType >::Scalar &other)
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
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
TriangularView< typename internal::add_const< MatrixType >::type, _Mode > ConstTriangularView
EIGEN_DEVICE_FUNC Index innerStride() const
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.
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
EIGEN_DEVICE_FUNC bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if< possibly_same_dense< T1, T2 >::value >::type *=0)
Base::SrcEvaluatorType SrcEvaluatorType
EIGEN_DEVICE_FUNC Derived & derived()
evaluator< typename internal::remove_all< MatrixType >::type > Base
Base::SrcXprType SrcXprType
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
EIGEN_DEVICE_FUNC void evalTo(MatrixBase< DenseDerived > &other) const
EIGEN_DEVICE_FUNC void resize(Index rows, Index cols)
internal::traits< TriangularView >::MatrixTypeNestedCleaned NestedExpression
EIGEN_DEVICE_FUNC const ConstTransposeReturnType transpose() const
EIGEN_DEVICE_FUNC unary_evaluator(const XprType &xpr)
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
#define EIGEN_DEVICE_FUNC
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
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
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
static EIGEN_DEVICE_FUNC void run(Kernel &kernel)
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived)
EIGEN_DEVICE_FUNC const ConjugateReturnType conjugate() const
Expression of a triangular part in a matrix.
EIGEN_DEVICE_FUNC const NestedExpression & nestedExpression() const
Triangular2Triangular Kind
internal::traits< Derived >::StorageKind StorageKind
EIGEN_DEVICE_FUNC Scalar determinant() const
static const DiscreteKey mode(modeKey, 2)
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)
Generic expression where a coefficient-wise unary operator is applied to an expression.
internal::traits< Derived >::Scalar Scalar
Kernel::DstEvaluatorType DstEvaluatorType
EIGEN_DEVICE_FUNC TriangularViewType & operator=(const TriangularViewImpl &other)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
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
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
const Product< Lhs, Rhs > prod(const Lhs &lhs, const Rhs &rhs)
internal::traits< TriangularViewType >::Scalar Scalar