10#ifndef EIGEN_TRIANGULAR_SOLVER_VECTOR_H
11#define EIGEN_TRIANGULAR_SOLVER_VECTOR_H
14#include "../InternalHeaderCheck.h"
20template <
typename LhsScalar,
typename RhsScalar,
typename Index,
int Mode,
bool Conjugate,
int StorageOrder>
21struct triangular_solve_vector<LhsScalar, RhsScalar,
Index,
OnTheRight, Mode, Conjugate, StorageOrder> {
22 static void run(
Index size,
const LhsScalar* _lhs,
Index lhsStride, RhsScalar* rhs) {
30template <
typename LhsScalar,
typename RhsScalar,
typename Index,
int Mode,
bool Conjugate>
33 static void run(
Index size,
const LhsScalar* _lhs,
Index lhsStride, RhsScalar* rhs) {
34 typedef Map<const Matrix<LhsScalar, Dynamic, Dynamic, RowMajor>, 0, OuterStride<> > LhsMap;
35 const LhsMap lhs(_lhs, size, size, OuterStride<>(lhsStride));
37 typedef const_blas_data_mapper<LhsScalar, Index, RowMajor> LhsMapper;
38 typedef const_blas_data_mapper<RhsScalar, Index, ColMajor> RhsMapper;
40 std::conditional_t<Conjugate, const CwiseUnaryOp<typename internal::scalar_conjugate_op<LhsScalar>, LhsMap>,
43 static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;
44 for (
Index pi = IsLower ? 0 : size; IsLower ? pi < size : pi > 0; IsLower ? pi += PanelWidth : pi -= PanelWidth) {
45 Index actualPanelWidth = (std::min)(IsLower ? size - pi : pi, PanelWidth);
47 Index r = IsLower ? pi : size - pi;
52 Index startRow = IsLower ? pi : pi - actualPanelWidth;
53 Index startCol = IsLower ? 0 : pi;
55 general_matrix_vector_product<
Index, LhsScalar, LhsMapper,
RowMajor, Conjugate, RhsScalar, RhsMapper,
56 false>::run(actualPanelWidth, r,
57 LhsMapper(&lhs.coeffRef(startRow, startCol), lhsStride),
58 RhsMapper(rhs + startCol, 1), rhs + startRow, 1, RhsScalar(-1));
61 for (
Index k = 0; k < actualPanelWidth; ++k) {
62 Index i = IsLower ? pi + k : pi - k - 1;
63 Index s = IsLower ? pi : i + 1;
65 rhs[i] -= (cjLhs.row(i).segment(s, k).transpose().cwiseProduct(
66 Map<
const Matrix<RhsScalar, Dynamic, 1> >(rhs + s, k)))
69 if ((!(Mode &
UnitDiag)) && !is_identically_zero(rhs[i])) rhs[i] /= cjLhs(i, i);
76template <
typename LhsScalar,
typename RhsScalar,
typename Index,
int Mode,
bool Conjugate>
79 static void run(
Index size,
const LhsScalar* _lhs,
Index lhsStride, RhsScalar* rhs) {
80 typedef Map<const Matrix<LhsScalar, Dynamic, Dynamic, ColMajor>, 0, OuterStride<> > LhsMap;
81 const LhsMap lhs(_lhs, size, size, OuterStride<>(lhsStride));
82 typedef const_blas_data_mapper<LhsScalar, Index, ColMajor> LhsMapper;
83 typedef const_blas_data_mapper<RhsScalar, Index, ColMajor> RhsMapper;
84 std::conditional_t<Conjugate, const CwiseUnaryOp<typename internal::scalar_conjugate_op<LhsScalar>, LhsMap>,
87 static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;
89 for (
Index pi = IsLower ? 0 : size; IsLower ? pi < size : pi > 0; IsLower ? pi += PanelWidth : pi -= PanelWidth) {
90 Index actualPanelWidth = (std::min)(IsLower ? size - pi : pi, PanelWidth);
91 Index startBlock = IsLower ? pi : pi - actualPanelWidth;
92 Index endBlock = IsLower ? pi + actualPanelWidth : 0;
94 for (
Index k = 0; k < actualPanelWidth; ++k) {
95 Index i = IsLower ? pi + k : pi - k - 1;
96 if (!is_identically_zero(rhs[i])) {
97 if (!(Mode &
UnitDiag)) rhs[i] /= cjLhs.coeff(i, i);
99 Index r = actualPanelWidth - k - 1;
100 Index s = IsLower ? i + 1 : i - r;
101 if (r > 0) Map<Matrix<RhsScalar, Dynamic, 1> >(rhs + s, r) -= rhs[i] * cjLhs.col(i).segment(s, r);
104 Index r = IsLower ? size - endBlock : startBlock;
109 general_matrix_vector_product<
Index, LhsScalar, LhsMapper,
ColMajor, Conjugate, RhsScalar, RhsMapper,
110 false>::run(r, actualPanelWidth,
111 LhsMapper(&lhs.coeffRef(endBlock, startBlock), lhsStride),
112 RhsMapper(rhs + startBlock, 1), rhs + endBlock, 1, RhsScalar(-1));
@ UnitDiag
Definition Constants.h:215
@ Lower
Definition Constants.h:211
@ Upper
Definition Constants.h:213
@ ColMajor
Definition Constants.h:318
@ RowMajor
Definition Constants.h:320
@ OnTheLeft
Definition Constants.h:331
@ OnTheRight
Definition Constants.h:333
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82