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>
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>
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,
127 LhsMapper lhs(_lhs,lhsStride);
128 RhsMapper rhs(_rhs,rhsStride);
129 ResMapper
res(_res, resStride, resIncr);
153 triangularBuffer.diagonal().
setZero();
155 triangularBuffer.diagonal().
setOnes();
162 IsLower ? k2>0 : k2<
depth;
163 IsLower ? k2-=kc : 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)
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;
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);
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);
217 lengthTarget, actualPanelWidth,
cols,
alpha,
218 actualPanelWidth, actual_kc, 0, blockBOffset);
224 Index start = IsLower ? k2 : 0;
230 (blockA, lhs.getSubMapper(i2, actual_k2), actual_kc, 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>
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,
286 LhsMapper lhs(_lhs,lhsStride);
287 RhsMapper rhs(_rhs,rhsStride);
288 ResMapper
res(_res, resStride, resIncr);
303 triangularBuffer.diagonal().
setZero();
305 triangularBuffer.diagonal().
setOnes();
313 IsLower ? k2<depth : k2>0;
314 IsLower ? k2+=kc : 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;
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,
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;
382 blockA, blockB+j2*actual_kc,
383 actual_mc, panelLength, actualPanelWidth,
385 actual_kc, actual_kc,
386 blockOffset, blockOffset);
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))
457 dst.topRows(diagSize) -= ((lhs_alpha-LhsScalar(1))*a_rhs).topRows(diagSize);
459 else if ((!LhsIsTriangular) && rhs_alpha!=RhsScalar(1))
462 dst.leftCols(diagSize) -= (rhs_alpha-RhsScalar(1))*a_lhs.leftCols(diagSize);
472 #endif // EIGEN_TRIANGULAR_MATRIX_MATRIX_H