10 #ifndef EIGEN_SPARSETRIANGULARSOLVER_H
11 #define EIGEN_SPARSETRIANGULARSOLVER_H
20 template <
typename Lhs,
typename Rhs,
int Mode,
28 template <
typename Lhs,
typename Rhs,
int Mode>
36 for (
Index i = 0;
i < lhs.rows(); ++
i) {
42 lastIndex = it.index();
43 if (lastIndex ==
i)
break;
50 other.coeffRef(
i,
col) =
tmp / lastVal;
58 template <
typename Lhs,
typename Rhs,
int Mode>
66 for (
Index i = lhs.rows() - 1;
i >= 0; --
i) {
70 while (it && it.index() <
i) ++it;
75 }
else if (it && it.index() ==
i)
78 tmp -= it.value() * other.coeff(it.index(),
col);
91 template <
typename Lhs,
typename Rhs,
int Mode>
99 for (
Index i = 0;
i < lhs.cols(); ++
i) {
104 while (it && it.index() <
i) ++it;
109 if (it && it.index() ==
i) ++it;
110 for (; it; ++it) other.coeffRef(it.index(),
col) -=
tmp * it.value();
118 template <
typename Lhs,
typename Rhs,
int Mode>
126 for (
Index i = lhs.cols() - 1;
i >= 0; --
i) {
133 while (it && it.index() !=
i) ++it;
135 other.coeffRef(
i,
col) /= it.value();
138 for (; it && it.index() <
i; ++it) other.coeffRef(it.index(),
col) -=
tmp * it.value();
147 #ifndef EIGEN_PARSED_BY_DOXYGEN
149 template <
typename ExpressionType,
unsigned int Mode>
150 template <
typename OtherDerived>
151 void TriangularViewImpl<ExpressionType, Mode, Sparse>::solveInPlace(MatrixBase<OtherDerived>& other)
const {
159 OtherCopy otherCopy(other.derived());
161 internal::sparse_solve_triangular_selector<ExpressionType, std::remove_reference_t<OtherCopy>, Mode>
::run(
162 derived().nestedExpression(), otherCopy);
164 if (
copy) other = otherCopy;
172 template <
typename Lhs,
typename Rhs,
int Mode,
180 template <
typename Lhs,
typename Rhs,
int Mode,
int UpLo>
186 const bool IsLower = (UpLo ==
Lower);
190 Rhs res(other.rows(), other.cols());
191 res.reserve(other.nonZeros());
195 tempVector.
init(.99 );
198 for (
typename Rhs::InnerIterator rhsIt(other,
col); rhsIt; ++rhsIt) {
199 tempVector.
coeffRef(rhsIt.index()) = rhsIt.value();
202 for (
Index i = IsLower ? 0 : lhs.cols() - 1; IsLower ?
i < lhs.cols() :
i >= 0;
i += IsLower ? 1 : -1) {
207 typename Lhs::InnerIterator it(lhs,
i);
213 ci /= lhs.coeff(
i,
i);
217 if (it.index() ==
i) ++it;
218 for (; it; ++it) tempVector.
coeffRef(it.index()) -= ci * it.value();
220 for (; it && it.index() <
i; ++it) tempVector.
coeffRef(it.index()) -= ci * it.value();
232 res.insert(it.index(),
col) = it.value();
237 other =
res.markAsRValue();
243 #ifndef EIGEN_PARSED_BY_DOXYGEN
244 template <
typename ExpressionType,
unsigned int Mode>
245 template <
typename OtherDerived>
246 void TriangularViewImpl<ExpressionType, Mode, Sparse>::solveInPlace(SparseMatrixBase<OtherDerived>& other)
const {
257 derived().nestedExpression(), other.derived());
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define eigen_assert(x)
Definition: Macros.h:910
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:217
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:198
Definition: AmbiVector.h:251
Definition: AmbiVector.h:26
Scalar & coeffRef(Index i)
Definition: AmbiVector.h:171
void setZero()
Definition: AmbiVector.h:160
void init(double estimatedDensity)
Definition: AmbiVector.h:130
void restart()
Definition: AmbiVector.h:154
void setBounds(Index start, Index end)
Definition: AmbiVector.h:43
@ UnitDiag
Definition: Constants.h:215
@ ZeroDiag
Definition: Constants.h:217
@ Lower
Definition: Constants.h:211
@ Upper
Definition: Constants.h:213
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int RowMajorBit
Definition: Constants.h:70
EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:32
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
@ Lhs
Definition: TensorContractionMapper.h:20
@ Rhs
Definition: TensorContractionMapper.h:20
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X &x)
Definition: Meta.h:592
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
auto run(Kernel kernel, Args &&... args) -> decltype(kernel(args...))
Definition: gpu_test_helper.h:414
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:95
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:96
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:94
Rhs::Scalar Scalar
Definition: TriangularSolver.h:93
Rhs::Scalar Scalar
Definition: TriangularSolver.h:30
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:31
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:33
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:32
Rhs::Scalar Scalar
Definition: TriangularSolver.h:120
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:123
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:121
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:122
evaluator< Lhs >::InnerIterator LhsIterator
Definition: TriangularSolver.h:62
Rhs::Scalar Scalar
Definition: TriangularSolver.h:60
evaluator< Lhs > LhsEval
Definition: TriangularSolver.h:61
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:63
Definition: TriangularSolver.h:25
Definition: TriangularSolver.h:181
promote_index_type< typename traits< Lhs >::StorageIndex, typename traits< Rhs >::StorageIndex >::type StorageIndex
Definition: TriangularSolver.h:184
Rhs::Scalar Scalar
Definition: TriangularSolver.h:182
static void run(const Lhs &lhs, Rhs &other)
Definition: TriangularSolver.h:185
Definition: TriangularSolver.h:177
Definition: ForwardDeclarations.h:21
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317