10 #ifndef EIGEN_TRIANGULARMATRIXVECTOR_H
11 #define EIGEN_TRIANGULARMATRIXVECTOR_H
14 #include "../InternalHeaderCheck.h"
20 template <
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
24 template <
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
27 static constexpr
bool IsLower = ((Mode &
Lower) ==
Lower);
32 const RhsScalar&
alpha);
35 template <
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
38 Index lhsStride,
const RhsScalar* rhs_,
40 const RhsScalar&
alpha) {
62 for (
Index k = 0;
k < actualPanelWidth; ++
k) {
64 Index s = IsLower ? ((HasUnitDiag || HasZeroDiag) ?
i + 1 :
i) :
pi;
65 Index r = IsLower ? actualPanelWidth -
k :
k + 1;
66 if ((!(HasUnitDiag || HasZeroDiag)) || (--
r) > 0)
67 res.segment(
s,
r) += (
alpha * cjRhs.coeff(
i)) * cjLhs.col(
i).segment(
s,
r);
68 if (HasUnitDiag)
res.coeffRef(
i) +=
alpha * cjRhs.coeff(
i);
72 Index s = IsLower ?
pi + actualPanelWidth : 0;
74 BuiltIn>
::run(
r, actualPanelWidth, LhsMapper(&lhs.coeffRef(
s,
pi), lhsStride),
75 RhsMapper(&rhs.coeffRef(
pi), rhsIncr), &
res.coeffRef(
s), resIncr,
81 rows,
cols -
size, LhsMapper(&lhs.coeffRef(0,
size), lhsStride), RhsMapper(&rhs.coeffRef(
size), rhsIncr), res_,
86 template <
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
89 static constexpr
bool IsLower = ((Mode &
Lower) ==
Lower);
97 template <
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
100 Index lhsStride,
const RhsScalar* rhs_,
113 const RhsMap rhs(rhs_,
cols);
122 for (
Index pi = 0;
pi < diagSize;
pi += PanelWidth) {
124 for (
Index k = 0;
k < actualPanelWidth; ++
k) {
126 Index s = IsLower ?
pi : ((HasUnitDiag || HasZeroDiag) ?
i + 1 :
i);
127 Index r = IsLower ?
k + 1 : actualPanelWidth -
k;
128 if ((!(HasUnitDiag || HasZeroDiag)) || (--
r) > 0)
129 res.coeffRef(
i) +=
alpha * (cjLhs.row(
i).segment(
s,
r).cwiseProduct(cjRhs.segment(
s,
r).transpose())).sum();
130 if (HasUnitDiag)
res.coeffRef(
i) +=
alpha * cjRhs.coeff(
i);
134 Index s = IsLower ? 0 :
pi + actualPanelWidth;
136 BuiltIn>
::run(actualPanelWidth,
r, LhsMapper(&lhs.coeffRef(
pi,
s), lhsStride),
137 RhsMapper(&rhs.coeffRef(
s), rhsIncr), &
res.coeffRef(
pi), resIncr,
141 if (IsLower &&
rows > diagSize) {
143 rows - diagSize,
cols, LhsMapper(&lhs.coeffRef(diagSize, 0), lhsStride), RhsMapper(&rhs.coeffRef(0), rhsIncr),
144 &
res.coeffRef(diagSize), resIncr,
alpha);
152 template <
int Mode,
int StorageOrder>
159 template <
int Mode,
typename Lhs,
typename Rhs>
161 template <
typename Dest>
163 eigen_assert(dst.rows() == lhs.rows() && dst.cols() == rhs.cols());
166 lhs, rhs, dst,
alpha);
170 template <
int Mode,
typename Lhs,
typename Rhs>
172 template <
typename Dest>
174 eigen_assert(dst.rows() == lhs.rows() && dst.cols() == rhs.cols());
180 lhs.transpose(), dstT,
193 template <
typename Lhs,
typename Rhs,
typename Dest>
200 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
202 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
210 LhsScalar lhs_alpha = LhsBlasTraits::extractScalarFactor(lhs);
211 RhsScalar rhs_alpha = RhsBlasTraits::extractScalarFactor(rhs);
212 ResScalar actualAlpha =
alpha * lhs_alpha * rhs_alpha;
216 constexpr
bool EvalToDestAtCompileTime = Dest::InnerStrideAtCompileTime == 1;
218 constexpr
bool MightCannotUseDest = (Dest::InnerStrideAtCompileTime != 1) || ComplexByReal;
224 bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
229 evalToDest ? dest.data() : static_dest.data());
232 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
233 constexpr
int Size = Dest::SizeAtCompileTime;
235 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
237 if (!alphaIsCompatible) {
238 MappedDest(actualDestPtr, dest.size()).setZero();
239 compatibleAlpha = RhsScalar(1);
241 MappedDest(actualDestPtr, dest.size()) = dest;
245 RhsBlasTraits::NeedToConjugate,
ColMajor>
::run(actualLhs.rows(),
248 actualLhs.outerStride(),
250 actualRhs.innerStride(),
255 if (!alphaIsCompatible)
256 dest += actualAlpha * MappedDest(actualDestPtr, dest.size());
258 dest = MappedDest(actualDestPtr, dest.size());
263 dest.head(diagSize) -= (lhs_alpha - LhsScalar(1)) * rhs.head(diagSize);
270 template <
typename Lhs,
typename Rhs,
typename Dest>
277 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
279 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
282 std::add_const_t<ActualLhsType> actualLhs = LhsBlasTraits::extract(lhs);
283 std::add_const_t<ActualRhsType> actualRhs = RhsBlasTraits::extract(rhs);
285 LhsScalar lhs_alpha = LhsBlasTraits::extractScalarFactor(lhs);
286 RhsScalar rhs_alpha = RhsBlasTraits::extractScalarFactor(rhs);
287 ResScalar actualAlpha =
alpha * lhs_alpha * rhs_alpha;
289 constexpr
bool DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime == 1;
291 const RhsScalar* actualRhsPtr = actualRhs.data();
295 ActualRhsTypeCleaned::MaxSizeAtCompileTime, !DirectlyUseRhs>
297 RhsScalar* buffer =
nullptr;
298 if (!DirectlyUseRhs) {
300 if (static_rhs.data() !=
nullptr) {
301 buffer = static_rhs.data();
304 Eigen::internal::check_size_for_overflow<RhsScalar>(actualRhs.size());
307 ? EIGEN_ALIGNED_ALLOCA(
sizeof(RhsScalar) * actualRhs.size())
313 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
314 constexpr
int Size = ActualRhsTypeCleaned::SizeAtCompileTime;
316 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
319 actualRhsPtr = buffer;
323 buffer, actualRhs.size(),
327 RhsBlasTraits::NeedToConjugate,
RowMajor>
::run(actualLhs.rows(),
330 actualLhs.outerStride(),
338 dest.head(diagSize) -= (lhs_alpha - LhsScalar(1)) * rhs.head(diagSize);
AnnoyingScalar imag(const AnnoyingScalar &)
Definition: AnnoyingScalar.h:132
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_STACK_ALLOCATION_LIMIT
Definition: Macros.h:56
#define EIGEN_DONT_INLINE
Definition: Macros.h:853
#define eigen_assert(x)
Definition: Macros.h:910
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:806
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
#define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH
Definition: Settings.h:37
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:93
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition: Stride.h:104
Expression of the transpose of a matrix.
Definition: Transpose.h:56
Definition: BlasUtil.h:443
#define min(a, b)
Definition: datatypes.h:22
@ UnitDiag
Definition: Constants.h:215
@ ZeroDiag
Definition: Constants.h:217
@ Lower
Definition: Constants.h:211
@ Upper
Definition: Constants.h:213
@ AlignedMax
Definition: Constants.h:254
@ Specialized
Definition: Constants.h:311
@ BuiltIn
Definition: Constants.h:311
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int RowMajorBit
Definition: Constants.h:70
RealScalar s
Definition: level1_cplx_impl.h:130
RealScalar alpha
Definition: level1_cplx_impl.h:151
char char char int int * k
Definition: level2_impl.h:374
@ Lhs
Definition: TensorContractionMapper.h:20
@ Rhs
Definition: TensorContractionMapper.h:20
std::conditional<!Cond, const T &, CwiseUnaryOp< scalar_conjugate_op< typename traits< T >::Scalar >, T > > conj_expr_if
Definition: SelfadjointRank2Update.h:52
EIGEN_DEVICE_FUNC void * aligned_malloc(std::size_t size)
Definition: Memory.h:199
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
typename add_const_on_value_type< T >::type add_const_on_value_type_t
Definition: Meta.h:274
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X &x)
Definition: Meta.h:592
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_one(const X &x)
Definition: Meta.h:601
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
const Mdouble pi
Definition: ExtendedMath.h:23
Definition: Eigen_Colamd.h:49
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:1043
Definition: BlasUtil.h:459
Definition: GeneralProduct.h:228
Definition: BlasUtil.h:42
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE To run(const From &x)
Definition: BlasUtil.h:46
Definition: GenericPacketMath.h:108
Definition: ForwardDeclarations.h:21
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
Definition: TriangularMatrixVector.h:88
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
Definition: TriangularMatrixVector.h:26
Definition: TriangularMatrixVector.h:22
static void run(Dest &dst, const Lhs &lhs, const Rhs &rhs, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:173
static void run(Dest &dst, const Lhs &lhs, const Rhs &rhs, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:162
Definition: ProductEvaluators.h:738
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:194
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:271
Definition: TriangularMatrixVector.h:153
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