11#ifndef EIGEN_TRIANGULARMATRIX_H
12#define EIGEN_TRIANGULARMATRIX_H
15#include "./InternalHeaderCheck.h"
21template <
int S
ide,
typename TriangularType,
typename Rhs>
22struct triangular_solve_retval;
31template <
typename Derived>
35 Mode = internal::traits<Derived>::Mode,
36 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
37 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
38 MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
39 MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
46 MaxSizeAtCompileTime = internal::size_at_compile_time(internal::traits<Derived>::MaxRowsAtCompileTime,
47 internal::traits<Derived>::MaxColsAtCompileTime)
50 typedef typename internal::traits<Derived>::Scalar
Scalar;
51 typedef typename internal::traits<Derived>::StorageKind StorageKind;
52 typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
53 typedef typename internal::traits<Derived>::FullMatrixType DenseMatrixType;
54 typedef DenseMatrixType DenseType;
55 typedef Derived
const& Nested;
61 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index rows() const EIGEN_NOEXCEPT {
return derived().rows(); }
62 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index cols() const EIGEN_NOEXCEPT {
return derived().cols(); }
63 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index outerStride() const EIGEN_NOEXCEPT {
return derived().outerStride(); }
64 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index innerStride() const EIGEN_NOEXCEPT {
return derived().innerStride(); }
67 EIGEN_DEVICE_FUNC
void resize(
Index rows,
Index cols) {
68 EIGEN_UNUSED_VARIABLE(rows);
69 EIGEN_UNUSED_VARIABLE(cols);
70 eigen_assert(rows == this->rows() && cols == this->cols());
73 EIGEN_DEVICE_FUNC
inline Scalar coeff(
Index row,
Index col)
const {
return derived().coeff(row, col); }
74 EIGEN_DEVICE_FUNC
inline Scalar& coeffRef(
Index row,
Index col) {
return derived().coeffRef(row, col); }
78 template <
typename Other>
80 derived().coeffRef(row, col) = other.coeff(row, col);
84 check_coordinates(row, col);
85 return coeff(row, col);
87 EIGEN_DEVICE_FUNC
inline Scalar& operator()(Index row, Index col) {
88 check_coordinates(row, col);
89 return coeffRef(row, col);
92#ifndef EIGEN_PARSED_BY_DOXYGEN
93 EIGEN_DEVICE_FUNC
inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
94 EIGEN_DEVICE_FUNC
inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
97 template <
typename DenseDerived>
99 template <
typename DenseDerived>
102 EIGEN_DEVICE_FUNC DenseMatrixType toDenseMatrix()
const {
103 DenseMatrixType res(rows(), cols());
109 void check_coordinates(
Index row,
Index col)
const {
110 EIGEN_ONLY_USED_FOR_DEBUG(row);
111 EIGEN_ONLY_USED_FOR_DEBUG(col);
112 eigen_assert(col >= 0 && col < cols() && row >= 0 && row < rows());
114 EIGEN_ONLY_USED_FOR_DEBUG(mode);
115 eigen_assert((mode ==
Upper && col >= row) || (mode ==
Lower && col <= row) ||
120#ifdef EIGEN_INTERNAL_DEBUGGING
121 void check_coordinates_internal(Index row, Index col)
const { check_coordinates(row, col); }
123 void check_coordinates_internal(
Index,
Index)
const {}
146template <
typename MatrixType,
unsigned int Mode_>
147struct traits<TriangularView<MatrixType, Mode_>> : traits<MatrixType> {
148 typedef typename ref_selector<MatrixType>::non_const_type MatrixTypeNested;
149 typedef std::remove_reference_t<MatrixTypeNested> MatrixTypeNestedNonRef;
150 typedef remove_all_t<MatrixTypeNested> MatrixTypeNestedCleaned;
151 typedef typename MatrixType::PlainObject FullMatrixType;
152 typedef MatrixType ExpressionType;
155 FlagsLvalueBit = is_lvalue<MatrixType>::value ?
LvalueBit : 0,
156 Flags = (MatrixTypeNestedCleaned::Flags & (HereditaryBits | FlagsLvalueBit) &
162template <
typename MatrixType_,
unsigned int Mode_,
typename StorageKind>
163class TriangularViewImpl;
165template <
typename MatrixType_,
unsigned int Mode_>
167 :
public TriangularViewImpl<MatrixType_, Mode_, typename internal::traits<MatrixType_>::StorageKind> {
169 typedef TriangularViewImpl<MatrixType_, Mode_, typename internal::traits<MatrixType_>::StorageKind> Base;
170 typedef typename internal::traits<TriangularView>::Scalar Scalar;
171 typedef MatrixType_ MatrixType;
174 typedef typename internal::traits<TriangularView>::MatrixTypeNested MatrixTypeNested;
175 typedef typename internal::traits<TriangularView>::MatrixTypeNestedNonRef MatrixTypeNestedNonRef;
177 typedef internal::remove_all_t<typename MatrixType::ConjugateReturnType> MatrixConjugateReturnType;
178 typedef TriangularView<std::add_const_t<MatrixType>, Mode_> ConstTriangularView;
181 typedef typename internal::traits<TriangularView>::StorageKind StorageKind;
182 typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned NestedExpression;
186 Flags = internal::traits<TriangularView>::Flags,
189 IsVectorAtCompileTime =
false
192 EIGEN_DEVICE_FUNC
explicit inline TriangularView(MatrixType& matrix) : m_matrix(matrix) {}
194 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(TriangularView)
197 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline
Index rows() const EIGEN_NOEXCEPT {
return m_matrix.rows(); }
199 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index cols() const EIGEN_NOEXCEPT {
return m_matrix.cols(); }
209 EIGEN_DEVICE_FUNC
inline const ConjugateReturnType
conjugate()
const {
210 return ConjugateReturnType(m_matrix.conjugate());
217 EIGEN_DEVICE_FUNC
inline std::conditional_t<Cond, ConjugateReturnType, ConstTriangularView>
conjugateIf()
const {
218 typedef std::conditional_t<Cond, ConjugateReturnType, ConstTriangularView>
ReturnType;
224 EIGEN_DEVICE_FUNC
inline const AdjointReturnType
adjoint()
const {
return AdjointReturnType(m_matrix.adjoint()); }
228 template <
class Dummy =
int>
230 std::enable_if_t<Eigen::internal::is_lvalue<MatrixType>::value, Dummy*> =
nullptr) {
231 typename MatrixType::TransposeReturnType tmp(m_matrix);
232 return TransposeReturnType(tmp);
237 EIGEN_DEVICE_FUNC
inline const ConstTransposeReturnType
transpose()
const {
238 return ConstTransposeReturnType(m_matrix.transpose());
241 template <
typename Other>
248 template <
int S
ide,
typename Other>
249 EIGEN_DEVICE_FUNC
inline const internal::triangular_solve_retval<Side, TriangularView, Other> solve(
250 const MatrixBase<Other>& other)
const {
251 return Base::template solve<Side>(other);
262 EIGEN_STATIC_ASSERT((Mode & (
UnitDiag |
ZeroDiag)) == 0, PROGRAMMING_ERROR);
280 return m_matrix.diagonal().prod();
284 MatrixTypeNested m_matrix;
296template <
typename MatrixType_,
unsigned int Mode_>
297class TriangularViewImpl<MatrixType_, Mode_,
Dense> :
public TriangularBase<TriangularView<MatrixType_, Mode_>> {
301 typedef TriangularBase<TriangularViewType> Base;
302 typedef typename internal::traits<TriangularViewType>::Scalar Scalar;
304 typedef MatrixType_ MatrixType;
305 typedef typename MatrixType::PlainObject DenseMatrixType;
306 typedef DenseMatrixType PlainObject;
312 typedef typename internal::traits<TriangularViewType>::StorageKind StorageKind;
314 enum { Mode = Mode_, Flags = internal::traits<TriangularViewType>::Flags };
324 template <
typename Other>
326 internal::call_assignment_no_alias(
derived(), other.derived(),
327 internal::add_assign_op<Scalar, typename Other::Scalar>());
331 template <
typename Other>
333 internal::call_assignment_no_alias(
derived(), other.derived(),
334 internal::sub_assign_op<Scalar, typename Other::Scalar>());
339 EIGEN_DEVICE_FUNC TriangularViewType&
operator*=(
const typename internal::traits<MatrixType>::Scalar& other) {
340 return *
this =
derived().nestedExpression() * other;
343 EIGEN_DEVICE_FUNC TriangularViewType&
operator/=(
const typename internal::traits<MatrixType>::Scalar& other) {
344 return *
this =
derived().nestedExpression() / other;
350 EIGEN_DEVICE_FUNC TriangularViewType&
setConstant(
const Scalar& value) {
351 return *
this = MatrixType::Constant(
derived().rows(),
derived().cols(), value);
362 Base::check_coordinates_internal(row, col);
363 return derived().nestedExpression().coeff(row, col);
370 EIGEN_STATIC_ASSERT_LVALUE(TriangularViewType);
371 Base::check_coordinates_internal(row, col);
372 return derived().nestedExpression().coeffRef(row, col);
376 template <
typename OtherDerived>
377 EIGEN_DEVICE_FUNC TriangularViewType&
operator=(
const TriangularBase<OtherDerived>& other);
380 template <
typename OtherDerived>
383#ifndef EIGEN_PARSED_BY_DOXYGEN
384 EIGEN_DEVICE_FUNC TriangularViewType&
operator=(
const TriangularViewImpl& other) {
385 return *
this = other.derived().nestedExpression();
388 template <
typename OtherDerived>
392 template <
typename OtherDerived>
398 template <
typename OtherDerived>
405 template <
typename OtherDerived>
434 template <
int S
ide,
typename Other>
435 inline const internal::triangular_solve_retval<Side, TriangularViewType, Other>
solve(
447 template <
int S
ide,
typename OtherDerived>
450 template <
typename OtherDerived>
456 template <
typename OtherDerived>
458#ifdef EIGEN_PARSED_BY_DOXYGEN
460 swap(TriangularBase<OtherDerived>& other)
463 swap(TriangularBase<OtherDerived>
const& other)
466 EIGEN_STATIC_ASSERT_LVALUE(OtherDerived);
467 call_assignment(
derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
471 template <
typename OtherDerived>
474 EIGEN_STATIC_ASSERT_LVALUE(OtherDerived);
475 call_assignment(
derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
478 template <
typename RhsType,
typename DstType>
479 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _solve_impl(
const RhsType& rhs, DstType& dst)
const {
480 if (!internal::is_same_dense(dst, rhs)) dst = rhs;
481 this->solveInPlace(dst);
484 template <
typename ProductType>
485 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TriangularViewType& _assignProduct(
const ProductType& prod,
const Scalar& alpha,
489 EIGEN_DEFAULT_COPY_CONSTRUCTOR(TriangularViewImpl)
490 EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(TriangularViewImpl)
497#ifndef EIGEN_PARSED_BY_DOXYGEN
499template <
typename MatrixType,
unsigned int Mode>
500template <
typename OtherDerived>
503 internal::call_assignment_no_alias(derived(), other.derived(),
504 internal::assign_op<Scalar, typename OtherDerived::Scalar>());
509template <
typename MatrixType,
unsigned int Mode>
510template <
typename OtherDerived>
511EIGEN_DEVICE_FUNC
void TriangularViewImpl<MatrixType, Mode, Dense>::lazyAssign(
const MatrixBase<OtherDerived>& other) {
512 internal::call_assignment_no_alias(derived(), other.template triangularView<Mode>());
515template <
typename MatrixType,
unsigned int Mode>
516template <
typename OtherDerived>
519 eigen_assert(Mode ==
int(OtherDerived::Mode));
520 internal::call_assignment(derived(), other.derived());
524template <
typename MatrixType,
unsigned int Mode>
525template <
typename OtherDerived>
526EIGEN_DEVICE_FUNC
void TriangularViewImpl<MatrixType, Mode, Dense>::lazyAssign(
528 eigen_assert(Mode ==
int(OtherDerived::Mode));
529 internal::call_assignment_no_alias(derived(), other.derived());
539template <
typename Derived>
540template <
typename DenseDerived>
564template <
typename Derived>
565template <
unsigned int Mode>
567MatrixBase<Derived>::triangularView() {
568 return typename TriangularViewReturnType<Mode>::Type(derived());
572template <
typename Derived>
573template <
unsigned int Mode>
575MatrixBase<Derived>::triangularView()
const {
576 return typename ConstTriangularViewReturnType<Mode>::Type(derived());
584template <
typename Derived>
586 RealScalar maxAbsOnUpperPart =
static_cast<RealScalar
>(-1);
587 for (
Index j = 0; j < cols(); ++j) {
588 Index maxi = numext::mini(j, rows() - 1);
589 for (
Index i = 0; i <= maxi; ++i) {
590 RealScalar absValue = numext::abs(coeff(i, j));
591 if (absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
594 RealScalar threshold = maxAbsOnUpperPart * prec;
595 for (
Index j = 0; j < cols(); ++j)
596 for (
Index i = j + 1; i < rows(); ++i)
597 if (numext::abs(coeff(i, j)) > threshold)
return false;
606template <
typename Derived>
608 RealScalar maxAbsOnLowerPart =
static_cast<RealScalar
>(-1);
609 for (
Index j = 0; j < cols(); ++j)
610 for (
Index i = j; i < rows(); ++i) {
611 RealScalar absValue = numext::abs(coeff(i, j));
612 if (absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
614 RealScalar threshold = maxAbsOnLowerPart * prec;
615 for (
Index j = 1; j < cols(); ++j) {
616 Index maxi = numext::mini(j, rows() - 1);
617 for (
Index i = 0; i < maxi; ++i)
618 if (numext::abs(coeff(i, j)) > threshold)
return false;
635template <
typename MatrixType,
unsigned int Mode>
637 typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;
638 typedef typename glue_shapes<typename evaluator_traits<MatrixType>::Shape, TriangularShape>::type Shape;
641template <
typename MatrixType,
unsigned int Mode>
642struct unary_evaluator<TriangularView<MatrixType, Mode>, IndexBased> : evaluator<internal::remove_all_t<MatrixType>> {
643 typedef TriangularView<MatrixType, Mode> XprType;
644 typedef evaluator<internal::remove_all_t<MatrixType>> Base;
645 EIGEN_DEVICE_FUNC unary_evaluator(
const XprType& xpr) : Base(xpr.nestedExpression()) {}
649struct Triangular2Triangular {};
650struct Triangular2Dense {};
651struct Dense2Triangular {};
653template <
typename Kernel,
unsigned int Mode,
int UnrollCount,
bool ClearOpposite>
654struct triangular_assignment_loop;
661template <
int UpLo,
int Mode,
int SetOpposite,
typename DstEvaluatorTypeT,
typename SrcEvaluatorTypeT,
typename Functor,
662 int Version = Specialized>
663class triangular_dense_assignment_kernel
664 :
public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> {
666 typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> Base;
667 typedef typename Base::DstXprType DstXprType;
668 typedef typename Base::SrcXprType SrcXprType;
670 using Base::m_functor;
674 typedef typename Base::DstEvaluatorType DstEvaluatorType;
675 typedef typename Base::SrcEvaluatorType SrcEvaluatorType;
676 typedef typename Base::Scalar Scalar;
677 typedef typename Base::AssignmentTraits AssignmentTraits;
679 EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType& dst,
const SrcEvaluatorType& src,
680 const Functor& func, DstXprType& dstExpr)
681 : Base(dst, src, func, dstExpr) {}
683#ifdef EIGEN_INTERNAL_DEBUGGING
684 EIGEN_DEVICE_FUNC
void assignCoeff(
Index row,
Index col) {
685 eigen_internal_assert(row != col);
686 Base::assignCoeff(row, col);
689 using Base::assignCoeff;
692 EIGEN_DEVICE_FUNC
void assignDiagonalCoeff(
Index id) {
693 if (Mode ==
UnitDiag && SetOpposite)
694 m_functor.assignCoeff(m_dst.coeffRef(
id,
id), Scalar(1));
695 else if (Mode ==
ZeroDiag && SetOpposite)
696 m_functor.assignCoeff(m_dst.coeffRef(
id,
id), Scalar(0));
698 Base::assignCoeff(
id,
id);
701 EIGEN_DEVICE_FUNC
void assignOppositeCoeff(
Index row,
Index col) {
702 eigen_internal_assert(row != col);
703 if (SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(row, col), Scalar(0));
707template <
int Mode,
bool SetOpposite,
typename DstXprType,
typename SrcXprType,
typename Functor>
708EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void call_triangular_assignment_loop(DstXprType& dst,
const SrcXprType& src,
709 const Functor& func) {
710 typedef evaluator<DstXprType> DstEvaluatorType;
711 typedef evaluator<SrcXprType> SrcEvaluatorType;
713 SrcEvaluatorType srcEvaluator(src);
715 Index dstRows = src.rows();
716 Index dstCols = src.cols();
717 if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols);
718 DstEvaluatorType dstEvaluator(dst);
721 SetOpposite, DstEvaluatorType, SrcEvaluatorType, Functor>
723 Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
726 unroll = DstXprType::SizeAtCompileTime !=
Dynamic && SrcEvaluatorType::CoeffReadCost <
HugeCost &&
727 DstXprType::SizeAtCompileTime *
728 (int(DstEvaluatorType::CoeffReadCost) + int(SrcEvaluatorType::CoeffReadCost)) / 2 <=
729 EIGEN_UNROLLING_LIMIT
732 triangular_assignment_loop<Kernel, Mode, unroll ? int(DstXprType::SizeAtCompileTime) :
Dynamic, SetOpposite>::run(
736template <
int Mode,
bool SetOpposite,
typename DstXprType,
typename SrcXprType>
737EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void call_triangular_assignment_loop(DstXprType& dst,
const SrcXprType& src) {
738 call_triangular_assignment_loop<Mode, SetOpposite>(
739 dst, src, internal::assign_op<typename DstXprType::Scalar, typename SrcXprType::Scalar>());
743struct AssignmentKind<TriangularShape, TriangularShape> {
744 typedef Triangular2Triangular Kind;
747struct AssignmentKind<DenseShape, TriangularShape> {
748 typedef Triangular2Dense Kind;
751struct AssignmentKind<TriangularShape, DenseShape> {
752 typedef Dense2Triangular Kind;
755template <
typename DstXprType,
typename SrcXprType,
typename Functor>
756struct Assignment<DstXprType, SrcXprType, Functor, Triangular2Triangular> {
757 EIGEN_DEVICE_FUNC
static void run(DstXprType& dst,
const SrcXprType& src,
const Functor& func) {
758 eigen_assert(
int(DstXprType::Mode) ==
int(SrcXprType::Mode));
760 call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);
764template <
typename DstXprType,
typename SrcXprType,
typename Functor>
765struct Assignment<DstXprType, SrcXprType, Functor, Triangular2Dense> {
766 EIGEN_DEVICE_FUNC
static void run(DstXprType& dst,
const SrcXprType& src,
const Functor& func) {
767 call_triangular_assignment_loop<SrcXprType::Mode, (int(SrcXprType::Mode) & int(SelfAdjoint)) == 0>(dst, src, func);
771template <
typename DstXprType,
typename SrcXprType,
typename Functor>
772struct Assignment<DstXprType, SrcXprType, Functor, Dense2Triangular> {
773 EIGEN_DEVICE_FUNC
static void run(DstXprType& dst,
const SrcXprType& src,
const Functor& func) {
774 call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);
778template <
typename Kernel,
unsigned int Mode,
int UnrollCount,
bool SetOpposite>
779struct triangular_assignment_loop {
781 typedef typename Kernel::DstEvaluatorType DstEvaluatorType;
782 typedef typename DstEvaluatorType::XprType DstXprType;
785 col = (UnrollCount - 1) / DstXprType::RowsAtCompileTime,
786 row = (UnrollCount - 1) % DstXprType::RowsAtCompileTime
789 typedef typename Kernel::Scalar Scalar;
791 EIGEN_DEVICE_FUNC
static inline void run(Kernel& kernel) {
792 triangular_assignment_loop<Kernel, Mode, UnrollCount - 1, SetOpposite>::run(kernel);
795 kernel.assignDiagonalCoeff(row);
796 else if (((Mode &
Lower) && row > col) || ((Mode &
Upper) && row < col))
797 kernel.assignCoeff(row, col);
798 else if (SetOpposite)
799 kernel.assignOppositeCoeff(row, col);
804template <
typename Kernel,
unsigned int Mode,
bool SetOpposite>
805struct triangular_assignment_loop<Kernel, Mode, 0, SetOpposite> {
806 EIGEN_DEVICE_FUNC
static inline void run(Kernel&) {}
812template <
typename Kernel,
unsigned int Mode,
bool SetOpposite>
813struct triangular_assignment_loop<Kernel, Mode,
Dynamic, SetOpposite> {
814 typedef typename Kernel::Scalar Scalar;
815 EIGEN_DEVICE_FUNC
static inline void run(Kernel& kernel) {
816 for (
Index j = 0; j < kernel.cols(); ++j) {
817 Index maxi = numext::mini(j, kernel.rows());
819 if (((Mode &
Lower) && SetOpposite) || (Mode &
Upper)) {
820 for (; i < maxi; ++i)
822 kernel.assignCoeff(i, j);
824 kernel.assignOppositeCoeff(i, j);
828 if (i < kernel.rows())
829 kernel.assignDiagonalCoeff(i++);
831 if (((Mode &
Upper) && SetOpposite) || (Mode &
Lower)) {
832 for (; i < kernel.rows(); ++i)
834 kernel.assignCoeff(i, j);
836 kernel.assignOppositeCoeff(i, j);
846template <
typename Derived>
847template <
typename DenseDerived>
849 other.derived().
resize(this->rows(), this->cols());
850 internal::call_triangular_assignment_loop<Derived::Mode,
852 other.derived(),
derived().nestedExpression());
858template <
typename DstXprType,
typename Lhs,
typename Rhs,
typename Scalar>
859struct Assignment<DstXprType,
Product<Lhs, Rhs, DefaultProduct>,
860 internal::assign_op<Scalar, typename Product<Lhs, Rhs, DefaultProduct>::Scalar>, Dense2Triangular> {
862 static void run(DstXprType& dst,
const SrcXprType& src,
863 const internal::assign_op<Scalar, typename SrcXprType::Scalar>&) {
864 Index dstRows = src.rows();
865 Index dstCols = src.cols();
866 if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols);
868 dst._assignProduct(src,
Scalar(1),
false);
873template <
typename DstXprType,
typename Lhs,
typename Rhs,
typename Scalar>
874struct Assignment<DstXprType, Product<Lhs, Rhs, DefaultProduct>,
875 internal::add_assign_op<Scalar, typename Product<Lhs, Rhs, DefaultProduct>::Scalar>,
877 typedef Product<Lhs, Rhs, DefaultProduct> SrcXprType;
878 static void run(DstXprType& dst,
const SrcXprType& src,
879 const internal::add_assign_op<Scalar, typename SrcXprType::Scalar>&) {
880 dst._assignProduct(src, Scalar(1),
true);
885template <
typename DstXprType,
typename Lhs,
typename Rhs,
typename Scalar>
886struct Assignment<DstXprType, Product<Lhs, Rhs, DefaultProduct>,
887 internal::sub_assign_op<Scalar, typename Product<Lhs, Rhs, DefaultProduct>::Scalar>,
889 typedef Product<Lhs, Rhs, DefaultProduct> SrcXprType;
890 static void run(DstXprType& dst,
const SrcXprType& src,
891 const internal::sub_assign_op<Scalar, typename SrcXprType::Scalar>&) {
892 dst._assignProduct(src, Scalar(-1),
true);
Base class for all dense matrices, vectors, and arrays.
Definition ForwardDeclarations.h:59
void resize(Index newSize)
Definition DenseBase.h:228
Base class for all dense matrices, vectors, and expressions.
Definition ForwardDeclarations.h:73
bool isLowerTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition TriangularMatrix.h:607
bool isUpperTriangular(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition TriangularMatrix.h:585
Expression of a selfadjoint matrix from a triangular part of a dense matrix.
Definition ForwardDeclarations.h:173
Pseudo expression representing a solving operation.
Definition ForwardDeclarations.h:112
Base class for triangular part in a matrix.
Definition ForwardDeclarations.h:169
void copyCoeff(Index row, Index col, Other &other)
Definition TriangularMatrix.h:79
void evalTo(MatrixBase< DenseDerived > &other) const
Definition TriangularMatrix.h:541
void evalToLazy(MatrixBase< DenseDerived > &other) const
Definition TriangularMatrix.h:848
@ SizeAtCompileTime
Definition TriangularMatrix.h:41
Scalar coeff(Index row, Index col) const
Definition TriangularMatrix.h:361
TriangularViewType & setConstant(const Scalar &value)
Definition TriangularMatrix.h:350
void fill(const Scalar &value)
Definition TriangularMatrix.h:348
TriangularViewType & operator*=(const typename internal::traits< MatrixType >::Scalar &other)
Definition TriangularMatrix.h:339
TriangularViewType & operator+=(const DenseBase< Other > &other)
Definition TriangularMatrix.h:325
TriangularViewType & operator/=(const typename internal::traits< MatrixType >::Scalar &other)
Definition TriangularMatrix.h:343
Index outerStride() const
Definition TriangularMatrix.h:318
TriangularViewType & operator-=(const DenseBase< Other > &other)
Definition TriangularMatrix.h:332
TriangularViewType & setZero()
Definition TriangularMatrix.h:354
friend const Product< OtherDerived, TriangularViewType > operator*(const MatrixBase< OtherDerived > &lhs, const TriangularViewImpl &rhs)
Definition TriangularMatrix.h:406
TriangularViewType & operator=(const TriangularBase< OtherDerived > &other)
Scalar & coeffRef(Index row, Index col)
Definition TriangularMatrix.h:369
TriangularViewType & setOnes()
Definition TriangularMatrix.h:356
EIGEN_DEPRECATED void swap(MatrixBase< OtherDerived > const &other)
Definition TriangularMatrix.h:473
TriangularViewType & operator=(const MatrixBase< OtherDerived > &other)
Index innerStride() const
Definition TriangularMatrix.h:321
const Product< TriangularViewType, OtherDerived > operator*(const MatrixBase< OtherDerived > &rhs) const
Definition TriangularMatrix.h:399
const internal::triangular_solve_retval< Side, TriangularViewType, Other > solve(const MatrixBase< Other > &other) const
void solveInPlace(const MatrixBase< OtherDerived > &other) const
void swap(TriangularBase< OtherDerived > &other)
Definition TriangularMatrix.h:460
Expression of a triangular part in a matrix.
Definition ForwardDeclarations.h:171
SelfAdjointView< MatrixTypeNestedNonRef, Mode > selfadjointView()
Definition TriangularMatrix.h:261
TransposeReturnType transpose(std::enable_if_t< Eigen::internal::is_lvalue< MatrixType >::value, Dummy * >=nullptr)
Definition TriangularMatrix.h:229
std::conditional_t< Cond, ConjugateReturnType, ConstTriangularView > conjugateIf() const
Definition TriangularMatrix.h:217
const AdjointReturnType adjoint() const
Definition TriangularMatrix.h:224
NestedExpression & nestedExpression()
Definition TriangularMatrix.h:205
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition TriangularMatrix.h:199
Scalar determinant() const
Definition TriangularMatrix.h:274
const NestedExpression & nestedExpression() const
Definition TriangularMatrix.h:202
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition TriangularMatrix.h:197
const ConstTransposeReturnType transpose() const
Definition TriangularMatrix.h:237
const ConjugateReturnType conjugate() const
Definition TriangularMatrix.h:209
@ StrictlyLower
Definition Constants.h:223
@ UnitDiag
Definition Constants.h:215
@ StrictlyUpper
Definition Constants.h:225
@ UnitLower
Definition Constants.h:219
@ ZeroDiag
Definition Constants.h:217
@ SelfAdjoint
Definition Constants.h:227
@ UnitUpper
Definition Constants.h:221
@ Lower
Definition Constants.h:211
@ Upper
Definition Constants.h:213
const unsigned int PacketAccessBit
Definition Constants.h:97
const unsigned int LinearAccessBit
Definition Constants.h:133
const unsigned int DirectAccessBit
Definition Constants.h:159
const unsigned int LvalueBit
Definition Constants.h:148
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
std::enable_if_t< std::is_base_of< DenseBase< std::decay_t< DerivedA > >, std::decay_t< DerivedA > >::value &&std::is_base_of< DenseBase< std::decay_t< DerivedB > >, std::decay_t< DerivedB > >::value, void > swap(DerivedA &&a, DerivedB &&b)
Definition DenseBase.h:655
const int HugeCost
Definition Constants.h:48
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:25
Definition Constants.h:519
Definition ForwardDeclarations.h:57
constexpr Derived & derived()
Definition EigenBase.h:49
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:43