10#ifndef EIGEN_TRIANGULARMATRIXVECTOR_H
11#define EIGEN_TRIANGULARMATRIXVECTOR_H
17template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int StorageOrder,
int Version=Specialized>
20template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
30 const RhsScalar* _rhs,
Index rhsIncr, ResScalar* _res,
Index resIncr,
const RhsScalar& alpha);
33template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
36 const RhsScalar* _rhs,
Index rhsIncr,
ResScalar* _res,
Index resIncr,
const RhsScalar& alpha)
52 ResMap res(_res,rows);
60 for (
Index k=0; k<actualPanelWidth; ++k)
63 Index s = IsLower ? ((HasUnitDiag||HasZeroDiag) ? i+1 : i ) :
pi;
64 Index r = IsLower ? actualPanelWidth-k : k+1;
65 if ((!(HasUnitDiag||HasZeroDiag)) || (--r)>0)
66 res.segment(s,r) += (alpha * cjRhs.coeff(i)) * cjLhs.col(i).segment(s,r);
68 res.coeffRef(i) += alpha * cjRhs.coeff(i);
70 Index r = IsLower ? rows -
pi - actualPanelWidth :
pi;
73 Index s = IsLower ?
pi+actualPanelWidth : 0;
76 LhsMapper(&lhs.coeffRef(s,
pi), lhsStride),
77 RhsMapper(&rhs.coeffRef(
pi), rhsIncr),
78 &res.coeffRef(s), resIncr, alpha);
81 if((!IsLower) && cols>
size)
85 LhsMapper(&lhs.coeffRef(0,
size), lhsStride),
86 RhsMapper(&rhs.coeffRef(
size), rhsIncr),
87 _res, resIncr, alpha);
91template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
101 const RhsScalar* _rhs,
Index rhsIncr, ResScalar* _res,
Index resIncr,
const ResScalar& alpha);
104template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
111 Index rows = IsLower ? _rows : diagSize;
112 Index cols = IsLower ? diagSize : _cols;
119 const RhsMap rhs(_rhs,cols);
131 for (
Index k=0; k<actualPanelWidth; ++k)
134 Index s = IsLower ?
pi : ((HasUnitDiag||HasZeroDiag) ? i+1 : i);
135 Index r = IsLower ? k+1 : actualPanelWidth-k;
136 if ((!(HasUnitDiag||HasZeroDiag)) || (--r)>0)
137 res.coeffRef(i) += alpha * (cjLhs.row(i).segment(s,r).cwiseProduct(cjRhs.segment(s,r).transpose())).sum();
139 res.coeffRef(i) += alpha * cjRhs.coeff(i);
141 Index r = IsLower ?
pi : cols -
pi - actualPanelWidth;
144 Index s = IsLower ? 0 :
pi + actualPanelWidth;
147 LhsMapper(&lhs.coeffRef(
pi,s), lhsStride),
148 RhsMapper(&rhs.coeffRef(s), rhsIncr),
149 &res.coeffRef(
pi), resIncr, alpha);
152 if(IsLower && rows>diagSize)
156 LhsMapper(&lhs.coeffRef(diagSize,0), lhsStride),
157 RhsMapper(&rhs.coeffRef(0), rhsIncr),
158 &res.coeffRef(diagSize), resIncr, alpha);
166template<
int Mode,
int StorageOrder>
173template<
int Mode,
typename Lhs,
typename Rhs>
176 template<
typename Dest>
static void run(Dest& dst,
const Lhs &lhs,
const Rhs &rhs,
const typename Dest::Scalar& alpha)
178 eigen_assert(dst.rows()==lhs.rows() && dst.cols()==rhs.cols());
184template<
int Mode,
typename Lhs,
typename Rhs>
187 template<
typename Dest>
static void run(Dest& dst,
const Lhs &lhs,
const Rhs &rhs,
const typename Dest::Scalar& alpha)
189 eigen_assert(dst.rows()==lhs.rows() && dst.cols()==rhs.cols());
194 ::run(rhs.transpose(),lhs.transpose(), dstT, alpha);
206 template<
typename Lhs,
typename Rhs,
typename Dest>
207 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
209 typedef typename Lhs::Scalar LhsScalar;
210 typedef typename Rhs::Scalar RhsScalar;
211 typedef typename Dest::Scalar ResScalar;
212 typedef typename Dest::RealScalar RealScalar;
215 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
217 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
224 LhsScalar lhs_alpha = LhsBlasTraits::extractScalarFactor(lhs);
225 RhsScalar rhs_alpha = RhsBlasTraits::extractScalarFactor(rhs);
226 ResScalar actualAlpha = alpha * lhs_alpha * rhs_alpha;
231 EvalToDestAtCompileTime = Dest::InnerStrideAtCompileTime==1,
233 MightCannotUseDest = (Dest::InnerStrideAtCompileTime!=1) || ComplexByReal
238 bool alphaIsCompatible = (!ComplexByReal) || (
numext::imag(actualAlpha)==RealScalar(0));
239 bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
244 evalToDest ? dest.data() : static_dest.data());
248 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
250 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
252 if(!alphaIsCompatible)
254 MappedDest(actualDestPtr, dest.size()).setZero();
255 compatibleAlpha = RhsScalar(1);
258 MappedDest(actualDestPtr, dest.size()) = dest;
263 LhsScalar, LhsBlasTraits::NeedToConjugate,
264 RhsScalar, RhsBlasTraits::NeedToConjugate,
266 ::run(actualLhs.rows(),actualLhs.cols(),
267 actualLhs.data(),actualLhs.outerStride(),
268 actualRhs.data(),actualRhs.innerStride(),
269 actualDestPtr,1,compatibleAlpha);
273 if(!alphaIsCompatible)
274 dest += actualAlpha * MappedDest(actualDestPtr, dest.size());
276 dest = MappedDest(actualDestPtr, dest.size());
282 dest.head(diagSize) -= (lhs_alpha-LhsScalar(1))*rhs.head(diagSize);
289 template<
typename Lhs,
typename Rhs,
typename Dest>
290 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
292 typedef typename Lhs::Scalar LhsScalar;
293 typedef typename Rhs::Scalar RhsScalar;
294 typedef typename Dest::Scalar ResScalar;
297 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
299 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
305 LhsScalar lhs_alpha = LhsBlasTraits::extractScalarFactor(lhs);
306 RhsScalar rhs_alpha = RhsBlasTraits::extractScalarFactor(rhs);
307 ResScalar actualAlpha = alpha * lhs_alpha * rhs_alpha;
310 DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1
316 DirectlyUseRhs ?
const_cast<RhsScalar*
>(actualRhs.data()) : static_rhs.data());
320 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
322 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
329 LhsScalar, LhsBlasTraits::NeedToConjugate,
330 RhsScalar, RhsBlasTraits::NeedToConjugate,
332 ::run(actualLhs.
rows(),actualLhs.
cols(),
333 actualLhs.data(),actualLhs.outerStride(),
335 dest.data(),dest.innerStride(),
341 dest.head(diagSize) -= (lhs_alpha-LhsScalar(1))*rhs.head(diagSize);
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
Definition: CommonCwiseUnaryOps.h:109
#define EIGEN_PLAIN_ENUM_MIN(a, b)
Definition: Macros.h:1298
#define EIGEN_DONT_INLINE
Definition: Macros.h:950
#define eigen_assert(x)
Definition: Macros.h:1047
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:768
#define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH
Defines the maximal width of the blocks used in the triangular product and solver for vectors (level ...
Definition: Settings.h:38
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:96
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:107
Expression of the transpose of a matrix.
Definition: Transpose.h:54
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: Transpose.h:69
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Transpose.h:71
Definition: BlasUtil.h:389
@ UnitDiag
Matrix has ones on the diagonal; to be used in combination with Lower or Upper.
Definition: Constants.h:213
@ ZeroDiag
Matrix has zeros on the diagonal; to be used in combination with Lower or Upper.
Definition: Constants.h:215
@ Lower
View matrix as a lower triangular matrix.
Definition: Constants.h:209
@ Upper
View matrix as an upper triangular matrix.
Definition: Constants.h:211
@ AlignedMax
Definition: Constants.h:252
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:319
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:321
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:66
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50
static constexpr const unit_t< PI > pi(1)
Ratio of a circle's circumference to its diameter.
Holds information about the various numeric (i.e.
Definition: NumTraits.h:233
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:806
const T type
Definition: Meta.h:214
Definition: BlasUtil.h:403
const T & type
Definition: Meta.h:109
Definition: GeneralProduct.h:161
Definition: BlasUtil.h:40
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE To run(const From &x)
Definition: BlasUtil.h:43
Definition: GenericPacketMath.h:107
T type
Definition: Meta.h:126
Definition: ForwardDeclarations.h:17
static EIGEN_DONT_INLINE void run(Index _rows, Index _cols, const LhsScalar *_lhs, Index lhsStride, const RhsScalar *_rhs, Index rhsIncr, ResScalar *_res, Index resIncr, const ResScalar &alpha)
Definition: TriangularMatrixVector.h:106
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
Definition: TriangularMatrixVector.h:94
static EIGEN_DONT_INLINE void run(Index _rows, Index _cols, const LhsScalar *_lhs, Index lhsStride, const RhsScalar *_rhs, Index rhsIncr, ResScalar *_res, Index resIncr, const RhsScalar &alpha)
Definition: TriangularMatrixVector.h:35
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
Definition: TriangularMatrixVector.h:23
Definition: TriangularMatrixVector.h:18
static void run(Dest &dst, const Lhs &lhs, const Rhs &rhs, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:187
static void run(Dest &dst, const Lhs &lhs, const Rhs &rhs, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:176
Definition: ProductEvaluators.h:758
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:207
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixVector.h:290
Definition: TriangularMatrixVector.h:167