10 #ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_H 11 #define EIGEN_TRIANGULAR_MATRIX_MATRIX_H 45 int Mode,
bool LhsIsTriangular,
46 int LhsStorageOrder,
bool ConjugateLhs,
47 int RhsStorageOrder,
bool ConjugateRhs,
48 int ResStorageOrder,
int ResInnerStride,
53 int Mode,
bool LhsIsTriangular,
54 int LhsStorageOrder,
bool ConjugateLhs,
55 int RhsStorageOrder,
bool ConjugateRhs,
56 int ResInnerStride,
int Version>
58 LhsStorageOrder,ConjugateLhs,
59 RhsStorageOrder,ConjugateRhs,
RowMajor,ResInnerStride,Version>
63 const Scalar* lhs, Index lhsStride,
64 const Scalar* rhs, Index rhsStride,
65 Scalar*
res, Index resIncr, Index resStride,
73 LhsStorageOrder==RowMajor ?
ColMajor : RowMajor,
76 ::
run(cols, rows, depth, rhs, rhsStride, lhs, lhsStride, res, resIncr, resStride, alpha, blocking);
81 template <
typename Scalar,
typename Index,
int Mode,
82 int LhsStorageOrder,
bool ConjugateLhs,
83 int RhsStorageOrder,
bool ConjugateRhs,
84 int ResInnerStride,
int Version>
86 LhsStorageOrder,ConjugateLhs,
87 RhsStorageOrder,ConjugateRhs,
ColMajor,ResInnerStride,Version>
98 Index _rows, Index _cols, Index _depth,
99 const Scalar* _lhs, Index lhsStride,
100 const Scalar* _rhs, Index rhsStride,
101 Scalar*
res, Index resIncr, Index resStride,
105 template <
typename Scalar,
typename Index,
int Mode,
106 int LhsStorageOrder,
bool ConjugateLhs,
107 int RhsStorageOrder,
bool ConjugateRhs,
108 int ResInnerStride,
int Version>
110 LhsStorageOrder,ConjugateLhs,
112 Index _rows, Index _cols, Index _depth,
113 const Scalar* _lhs, Index lhsStride,
114 const Scalar* _rhs, Index rhsStride,
115 Scalar* _res, Index resIncr, Index resStride,
119 Index diagSize = (
std::min)(_rows,_depth);
120 Index
rows = IsLower ? _rows : diagSize;
121 Index
depth = IsLower ? diagSize : _depth;
127 LhsMapper lhs(_lhs,lhsStride);
128 RhsMapper rhs(_rhs,rhsStride);
129 ResMapper
res(_res, resStride, resIncr);
131 Index kc = blocking.
kc();
153 triangularBuffer.diagonal().
setZero();
155 triangularBuffer.diagonal().
setOnes();
161 for(Index k2=IsLower ? depth : 0;
162 IsLower ? k2>0 : k2<
depth;
163 IsLower ? k2-=kc : k2+=kc)
165 Index actual_kc = (
std::min)(IsLower ? k2 : depth-k2, kc);
166 Index actual_k2 = IsLower ? k2-actual_kc : k2;
169 if((!IsLower)&&(k2<rows)&&(k2+actual_kc>
rows))
172 k2 = k2+actual_kc-kc;
175 pack_rhs(blockB, rhs.getSubMapper(actual_k2,0), actual_kc,
cols);
183 if(IsLower || actual_k2<rows)
186 for (Index k1=0; k1<actual_kc; k1+=panelWidth)
188 Index actualPanelWidth = std::min<Index>(actual_kc-k1, panelWidth);
189 Index lengthTarget = IsLower ? actual_kc-k1-actualPanelWidth : k1;
190 Index startBlock = actual_k2+k1;
191 Index blockBOffset = k1;
196 for (Index k=0;k<actualPanelWidth;++k)
199 triangularBuffer.
coeffRef(k,k) = lhs(startBlock+k,startBlock+k);
200 for (Index
i=IsLower ? k+1 : 0; IsLower ?
i<actualPanelWidth :
i<k; ++
i)
201 triangularBuffer.
coeffRef(
i,k) = lhs(startBlock+
i,startBlock+k);
203 pack_lhs(blockA, LhsMapper(triangularBuffer.
data(), triangularBuffer.
outerStride()), actualPanelWidth, actualPanelWidth);
205 gebp_kernel(res.getSubMapper(startBlock, 0), blockA, blockB,
206 actualPanelWidth, actualPanelWidth,
cols,
alpha,
207 actualPanelWidth, actual_kc, 0, blockBOffset);
212 Index startTarget = IsLower ? actual_k2+k1+actualPanelWidth : actual_k2;
214 pack_lhs(blockA, lhs.getSubMapper(startTarget,startBlock), actualPanelWidth, lengthTarget);
216 gebp_kernel(res.getSubMapper(startTarget, 0), blockA, blockB,
217 lengthTarget, actualPanelWidth,
cols,
alpha,
218 actualPanelWidth, actual_kc, 0, blockBOffset);
224 Index start = IsLower ? k2 : 0;
226 for(Index i2=start; i2<
end; i2+=mc)
228 const Index actual_mc = (
std::min)(i2+mc,end)-i2;
230 (blockA, lhs.getSubMapper(i2, actual_k2), actual_kc, actual_mc);
232 gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc,
240 template <
typename Scalar,
typename Index,
int Mode,
241 int LhsStorageOrder,
bool ConjugateLhs,
242 int RhsStorageOrder,
bool ConjugateRhs,
243 int ResInnerStride,
int Version>
245 LhsStorageOrder,ConjugateLhs,
246 RhsStorageOrder,ConjugateRhs,ColMajor,ResInnerStride,Version>
256 Index _rows, Index _cols, Index _depth,
257 const Scalar* _lhs, Index lhsStride,
258 const Scalar* _rhs, Index rhsStride,
259 Scalar*
res, Index resIncr, Index resStride,
263 template <
typename Scalar,
typename Index,
int Mode,
264 int LhsStorageOrder,
bool ConjugateLhs,
265 int RhsStorageOrder,
bool ConjugateRhs,
266 int ResInnerStride,
int Version>
268 LhsStorageOrder,ConjugateLhs,
270 Index _rows, Index _cols, Index _depth,
271 const Scalar* _lhs, Index lhsStride,
272 const Scalar* _rhs, Index rhsStride,
273 Scalar* _res, Index resIncr, Index resStride,
278 Index diagSize = (
std::min)(_cols,_depth);
280 Index
depth = IsLower ? _depth : diagSize;
281 Index
cols = IsLower ? diagSize : _cols;
286 LhsMapper lhs(_lhs,lhsStride);
287 RhsMapper rhs(_rhs,rhsStride);
288 ResMapper
res(_res, resStride, resIncr);
290 Index kc = blocking.
kc();
303 triangularBuffer.diagonal().
setZero();
305 triangularBuffer.diagonal().
setOnes();
312 for(Index k2=IsLower ? 0 : depth;
313 IsLower ? k2<depth : k2>0;
314 IsLower ? k2+=kc : k2-=kc)
316 Index actual_kc = (
std::min)(IsLower ? depth-k2 : k2, kc);
317 Index actual_k2 = IsLower ? k2 : k2-actual_kc;
320 if(IsLower && (k2<cols) && (actual_k2+actual_kc>
cols))
323 k2 = actual_k2 + actual_kc - kc;
327 Index rs = IsLower ? (
std::min)(cols,actual_k2) : cols - k2;
329 Index ts = (IsLower && actual_k2>=
cols) ? 0 : actual_kc;
331 Scalar* geb = blockB+ts*ts;
332 geb = geb + internal::first_aligned<PacketBytes>(geb,PacketBytes/
sizeof(
Scalar));
334 pack_rhs(geb, rhs.getSubMapper(actual_k2,IsLower ? 0 : k2), actual_kc, rs);
339 for (Index j2=0; j2<actual_kc; j2+=SmallPanelWidth)
341 Index actualPanelWidth = std::min<Index>(actual_kc-j2, SmallPanelWidth);
342 Index actual_j2 = actual_k2 + j2;
343 Index panelOffset = IsLower ? j2+actualPanelWidth : 0;
344 Index panelLength = IsLower ? actual_kc-j2-actualPanelWidth : j2;
346 pack_rhs_panel(blockB+j2*actual_kc,
347 rhs.getSubMapper(actual_k2+panelOffset, actual_j2),
348 panelLength, actualPanelWidth,
349 actual_kc, panelOffset);
352 for (Index
j=0;
j<actualPanelWidth;++
j)
355 triangularBuffer.
coeffRef(
j,
j) = rhs(actual_j2+
j,actual_j2+
j);
356 for (Index k=IsLower ?
j+1 : 0; IsLower ? k<actualPanelWidth : k<
j; ++k)
357 triangularBuffer.
coeffRef(k,j) = rhs(actual_j2+k,actual_j2+j);
360 pack_rhs_panel(blockB+j2*actual_kc,
362 actualPanelWidth, actualPanelWidth,
367 for (Index i2=0; i2<
rows; i2+=mc)
369 const Index actual_mc = (
std::min)(mc,rows-i2);
370 pack_lhs(blockA, lhs.getSubMapper(i2, actual_k2), actual_kc, actual_mc);
375 for (Index j2=0; j2<actual_kc; j2+=SmallPanelWidth)
377 Index actualPanelWidth = std::min<Index>(actual_kc-j2, SmallPanelWidth);
378 Index panelLength = IsLower ? actual_kc-j2 : j2+actualPanelWidth;
379 Index blockOffset = IsLower ? j2 : 0;
381 gebp_kernel(res.getSubMapper(i2, actual_k2 + j2),
382 blockA, blockB+j2*actual_kc,
383 actual_mc, panelLength, actualPanelWidth,
385 actual_kc, actual_kc,
386 blockOffset, blockOffset);
389 gebp_kernel(res.getSubMapper(i2, IsLower ? 0 : k2),
390 blockA, geb, actual_mc, actual_kc, rs,
404 template<
int Mode,
bool LhsIsTriangular,
typename Lhs,
typename Rhs>
414 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
417 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
423 LhsScalar lhs_alpha = LhsBlasTraits::extractScalarFactor(a_lhs);
424 RhsScalar rhs_alpha = RhsBlasTraits::extractScalarFactor(a_rhs);
425 Scalar actualAlpha = alpha * lhs_alpha * rhs_alpha;
428 Lhs::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime, Lhs::MaxColsAtCompileTime,4> BlockingType;
431 Index stripedRows = ((!LhsIsTriangular) || (IsLower)) ? lhs.rows() : (
std::min)(lhs.rows(),lhs.cols());
432 Index stripedCols = ((LhsIsTriangular) || (!IsLower)) ? rhs.cols() : (
std::min)(rhs.cols(),rhs.rows());
433 Index stripedDepth = LhsIsTriangular ? ((!IsLower) ? lhs.cols() : (
std::min)(lhs.cols(),lhs.rows()))
434 : ((IsLower) ? rhs.rows() : (
std::min)(rhs.rows(),rhs.cols()));
436 BlockingType blocking(stripedRows, stripedCols, stripedDepth, 1,
false);
439 Mode, LhsIsTriangular,
444 stripedRows, stripedCols, stripedDepth,
445 &lhs.coeffRef(0,0), lhs.outerStride(),
446 &rhs.coeffRef(0,0), rhs.outerStride(),
447 &dst.coeffRef(0,0), dst.innerStride(), dst.outerStride(),
448 actualAlpha, blocking
454 if (LhsIsTriangular && lhs_alpha!=LhsScalar(1))
456 Index diagSize = (
std::min)(lhs.rows(),lhs.cols());
457 dst.topRows(diagSize) -= ((lhs_alpha-LhsScalar(1))*a_rhs).topRows(diagSize);
459 else if ((!LhsIsTriangular) && rhs_alpha!=RhsScalar(1))
461 Index diagSize = (
std::min)(rhs.rows(),rhs.cols());
462 dst.leftCols(diagSize) -= (rhs_alpha-RhsScalar(1))*a_lhs.leftCols(diagSize);
472 #endif // EIGEN_TRIANGULAR_MATRIX_MATRIX_H
#define EIGEN_STRONG_INLINE
EIGEN_DEVICE_FUNC Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setZero(Index size)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
#define EIGEN_PLAIN_ENUM_MAX(a, b)
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setOnes(Index size)
const unsigned int RowMajorBit
#define EIGEN_DONT_INLINE
Eigen::internal::product_triangular_matrix_matrix< Scalar, Index, Mode, LhsIsTriangular, LhsStorageOrder, ConjugateLhs, RhsStorageOrder, ConjugateRhs, RowMajor, ResInnerStride, Version >::run static EIGEN_STRONG_INLINE void run(Index rows, Index cols, Index depth, const Scalar *lhs, Index lhsStride, const Scalar *rhs, Index rhsStride, Scalar *res, Index resIncr, Index resStride, const Scalar &alpha, level3_blocking< Scalar, Scalar > &blocking)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Eigen::internal::product_triangular_matrix_matrix< Scalar, Index, Mode, true, LhsStorageOrder, ConjugateLhs, RhsStorageOrder, ConjugateRhs, ColMajor, ResInnerStride, Version >::Traits gebp_traits< Scalar, Scalar > Traits
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::internal::product_triangular_matrix_matrix< Scalar, Index, Mode, false, LhsStorageOrder, ConjugateLhs, RhsStorageOrder, ConjugateRhs, ColMajor, ResInnerStride, Version >::Traits gebp_traits< Scalar, Scalar > Traits
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
static EIGEN_DEPRECATED const end_t end
static void run(Dest &dst, const Lhs &a_lhs, const Rhs &a_rhs, const typename Dest::Scalar &alpha)
The matrix class, also used for vectors and row-vectors.