10#ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_H
11#define EIGEN_TRIANGULAR_MATRIX_MATRIX_H
44template <
typename Scalar,
typename Index,
45 int Mode,
bool LhsIsTriangular,
46 int LhsStorageOrder,
bool ConjugateLhs,
47 int RhsStorageOrder,
bool ConjugateRhs,
48 int ResStorageOrder,
int ResInnerStride,
52template <
typename Scalar,
typename Index,
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,
76 ::run(cols, rows, depth, rhs, rhsStride, lhs, lhsStride, res, resIncr, resStride, alpha, blocking);
81template <
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>
99 const Scalar* _lhs,
Index lhsStride,
100 const Scalar* _rhs,
Index rhsStride,
105template <
typename Scalar,
typename Index,
int Mode,
106 int LhsStorageOrder,
bool ConjugateLhs,
107 int RhsStorageOrder,
bool ConjugateRhs,
108 int ResInnerStride,
int Version>
110 LhsStorageOrder,ConjugateLhs,
111 RhsStorageOrder,ConjugateRhs,
ColMajor,ResInnerStride,Version>::run(
113 const Scalar* _lhs,
Index lhsStride,
114 const Scalar* _rhs,
Index rhsStride,
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);
138 std::size_t sizeA = kc*mc;
139 std::size_t sizeB = kc*cols;
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)
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);
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;
230 (blockA, lhs.getSubMapper(i2, actual_k2), actual_kc, actual_mc);
232 gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc,
233 actual_kc, cols, alpha, -1, -1, 0, 0);
240template <
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>
257 const Scalar* _lhs,
Index lhsStride,
258 const Scalar* _rhs,
Index rhsStride,
263template <
typename Scalar,
typename Index,
int Mode,
264 int LhsStorageOrder,
bool ConjugateLhs,
265 int RhsStorageOrder,
bool ConjugateRhs,
266 int ResInnerStride,
int Version>
268 LhsStorageOrder,ConjugateLhs,
269 RhsStorageOrder,ConjugateRhs,
ColMajor,ResInnerStride,Version>::run(
271 const Scalar* _lhs,
Index lhsStride,
272 const Scalar* _rhs,
Index rhsStride,
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);
293 std::size_t sizeA = kc*mc;
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)
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,
367 for (
Index i2=0; i2<rows; i2+=mc)
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,
404template<
int Mode,
bool LhsIsTriangular,
typename Lhs,
typename Rhs>
407 template<
typename Dest>
static void run(Dest& dst,
const Lhs &a_lhs,
const Rhs &a_rhs,
const typename Dest::Scalar& alpha)
409 typedef typename Lhs::Scalar LhsScalar;
410 typedef typename Rhs::Scalar RhsScalar;
411 typedef typename Dest::Scalar Scalar;
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);
#define EIGEN_PLAIN_ENUM_MAX(a, b)
Definition: Macros.h:1299
#define EIGEN_DONT_INLINE
Definition: Macros.h:950
#define EIGEN_STRONG_INLINE
Definition: Macros.h:927
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:768
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:180
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
Definition: Matrix.h:429
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,...
Definition: PlainObjectBase.h:175
EIGEN_DEVICE_FUNC Derived & setOnes(Index size)
Resizes to the given newSize, and sets all coefficients in this expression to one.
Definition: CwiseNullaryOp.h:714
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition: PlainObjectBase.h:247
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Resizes to the given size, and sets all coefficients in this expression to zero.
Definition: CwiseNullaryOp.h:562
Definition: BlasUtil.h:270
Definition: BlasUtil.h:389
Definition: GeneralBlockPanelKernel.h:419
Definition: GeneralMatrixMatrix.h:248
Definition: GeneralMatrixMatrix.h:252
RhsScalar * blockB()
Definition: GeneralMatrixMatrix.h:275
Index kc() const
Definition: GeneralMatrixMatrix.h:272
Index mc() const
Definition: GeneralMatrixMatrix.h:270
LhsScalar * blockA()
Definition: GeneralMatrixMatrix.h:274
@ 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
@ 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
static EIGEN_DEPRECATED const end_t end
Definition: IndexedViewHelper.h:181
Namespace containing all symbols from the Eigen library.
Definition: MatrixExponential.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
@ Specialized
Definition: Constants.h:310
Definition: Eigen_Colamd.h:50
static constexpr uint64_t k1
Definition: Hashing.h:171
static constexpr uint64_t k2
Definition: Hashing.h:172
const T type
Definition: Meta.h:214
Definition: BlasUtil.h:403
Definition: DenseStorage.h:25
Definition: GeneralBlockPanelKernel.h:1058
Definition: BlasUtil.h:28
Definition: BlasUtil.h:25
Definition: GenericPacketMath.h:107
Eigen::internal::product_triangular_matrix_matrix< Scalar, Index, Mode, false, LhsStorageOrder, ConjugateLhs, RhsStorageOrder, ConjugateRhs, ColMajor, ResInnerStride, Version >::Traits gebp_traits< Scalar, Scalar > Traits
Definition: TriangularMatrixMatrix.h:248
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)
Definition: TriangularMatrixMatrix.h:61
Eigen::internal::product_triangular_matrix_matrix< Scalar, Index, Mode, true, LhsStorageOrder, ConjugateLhs, RhsStorageOrder, ConjugateRhs, ColMajor, ResInnerStride, Version >::Traits gebp_traits< Scalar, Scalar > Traits
Definition: TriangularMatrixMatrix.h:90
Definition: TriangularMatrixMatrix.h:50
T type
Definition: Meta.h:126
Definition: ForwardDeclarations.h:17
static void run(Dest &dst, const Lhs &a_lhs, const Rhs &a_rhs, const typename Dest::Scalar &alpha)
Definition: TriangularMatrixMatrix.h:407
Definition: ProductEvaluators.h:758