10 #ifndef EIGEN_TRIANGULARMATRIXVECTOR_H 11 #define EIGEN_TRIANGULARMATRIXVECTOR_H 17 template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int StorageOrder,
int Version=Specialized>
20 template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
27 HasZeroDiag = (Mode &
ZeroDiag)==ZeroDiag
29 static EIGEN_DONT_INLINE
void run(
Index _rows,
Index _cols,
const LhsScalar* _lhs,
Index lhsStride,
30 const RhsScalar* _rhs,
Index rhsIncr, ResScalar* _res,
Index resIncr,
const RhsScalar& alpha);
33 template<
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)
38 static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;
39 Index size = (std::min)(_rows,_cols);
40 Index rows = IsLower ? _rows : (std::min)(_rows,_cols);
41 Index cols = IsLower ? (std::min)(_rows,_cols) : _cols;
52 ResMap res(_res,rows);
57 for (
Index pi=0; pi<size; pi+=PanelWidth)
59 Index actualPanelWidth = (std::min)(PanelWidth, size-pi);
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);
91 template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
98 HasZeroDiag = (Mode &
ZeroDiag)==ZeroDiag
100 static EIGEN_DONT_INLINE
void run(
Index _rows,
Index _cols,
const LhsScalar* _lhs,
Index lhsStride,
101 const RhsScalar* _rhs,
Index rhsIncr, ResScalar* _res,
Index resIncr,
const ResScalar& alpha);
104 template<
typename Index,
int Mode,
typename LhsScalar,
bool ConjLhs,
typename RhsScalar,
bool ConjRhs,
int Version>
107 const RhsScalar* _rhs,
Index rhsIncr, ResScalar* _res,
Index resIncr,
const ResScalar& alpha)
109 static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;
110 Index diagSize = (std::min)(_rows,_cols);
111 Index rows = IsLower ? _rows : diagSize;
112 Index cols = IsLower ? diagSize : _cols;
119 const RhsMap rhs(_rhs,cols);
128 for (
Index pi=0; pi<diagSize; pi+=PanelWidth)
130 Index actualPanelWidth = (std::min)(PanelWidth, diagSize-pi);
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);
166 template<
int Mode,
int StorageOrder>
173 template<
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());
184 template<
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 ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)
225 * RhsBlasTraits::extractScalarFactor(rhs);
230 EvalToDestAtCompileTime = Dest::InnerStrideAtCompileTime==1,
232 MightCannotUseDest = (Dest::InnerStrideAtCompileTime!=1) || ComplexByReal
237 bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0));
238 bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
242 ei_declare_aligned_stack_constructed_variable(ResScalar,actualDestPtr,dest.size(),
243 evalToDest ? dest.data() : static_dest.data());
247 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 248 Index size = dest.size();
249 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
251 if(!alphaIsCompatible)
253 MappedDest(actualDestPtr, dest.size()).setZero();
254 compatibleAlpha = RhsScalar(1);
257 MappedDest(actualDestPtr, dest.size()) = dest;
262 LhsScalar, LhsBlasTraits::NeedToConjugate,
263 RhsScalar, RhsBlasTraits::NeedToConjugate,
265 ::run(actualLhs.rows(),actualLhs.cols(),
266 actualLhs.data(),actualLhs.outerStride(),
267 actualRhs.data(),actualRhs.innerStride(),
268 actualDestPtr,1,compatibleAlpha);
272 if(!alphaIsCompatible)
273 dest += actualAlpha * MappedDest(actualDestPtr, dest.size());
275 dest = MappedDest(actualDestPtr, dest.size());
282 template<
typename Lhs,
typename Rhs,
typename Dest>
283 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
285 typedef typename Lhs::Scalar LhsScalar;
286 typedef typename Rhs::Scalar RhsScalar;
287 typedef typename Dest::Scalar ResScalar;
290 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
292 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
298 ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)
299 * RhsBlasTraits::extractScalarFactor(rhs);
302 DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1
307 ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,actualRhs.size(),
308 DirectlyUseRhs ?
const_cast<RhsScalar*
>(actualRhs.data()) : static_rhs.data());
312 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 313 Index size = actualRhs.size();
314 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
321 LhsScalar, LhsBlasTraits::NeedToConjugate,
322 RhsScalar, RhsBlasTraits::NeedToConjugate,
324 ::run(actualLhs.rows(),actualLhs.cols(),
325 actualLhs.data(),actualLhs.outerStride(),
327 dest.data(),dest.innerStride(),
336 #endif // EIGEN_TRIANGULARMATRIXVECTOR_H const StorageIndex & col() const
Definition: SparseUtil.h:167
Definition: BlasUtil.h:269
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:320
EIGEN_DEVICE_FUNC SegmentReturnType segment(Index start, Index n)
Definition: SparseMatrixBase.h:889
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:88
Expression of the transpose of a matrix.
Definition: Transpose.h:52
Definition: TriangularMatrixVector.h:167
const StorageIndex & row() const
Definition: SparseUtil.h:164
Definition: BlasUtil.h:126
Definition: TriangularMatrixVector.h:18
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:61
Definition: GenericPacketMath.h:96
View matrix as a lower triangular matrix.
Definition: Constants.h:204
Matrix has ones on the diagonal; to be used in combination with Lower or Upper.
Definition: Constants.h:208
Convenience specialization of Stride to specify only an inner stride See class Map for some examples...
Definition: Stride.h:90
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: ProductEvaluators.h:701
Definition: BlasUtil.h:256
Definition: GeneralProduct.h:146
View matrix as an upper triangular matrix.
Definition: Constants.h:206
Definition: BlasUtil.h:40
Matrix has zeros on the diagonal; to be used in combination with Lower or Upper.
Definition: Constants.h:210
Definition: BandTriangularSolver.h:13
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:322
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:757
Convenience specialization of Stride to specify only an outer stride See class Map for some examples...
Definition: Stride.h:101
Definition: ForwardDeclarations.h:17