10 #ifndef EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H 11 #define EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H 15 template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjLhs,
bool ConjRhs>
28 template<
typename LhsScalar,
typename RhsScalar,
typename Index,
int mr,
int nr,
bool ConjLhs,
bool ConjRhs,
int UpLo>
32 template <
typename Index,
33 typename LhsScalar,
int LhsStorageOrder,
bool ConjugateLhs,
34 typename RhsScalar,
int RhsStorageOrder,
bool ConjugateRhs,
35 int ResStorageOrder,
int UpLo,
int Version =
Specialized>
39 template <
typename Index,
typename LhsScalar,
int LhsStorageOrder,
bool ConjugateLhs,
40 typename RhsScalar,
int RhsStorageOrder,
bool ConjugateRhs,
int UpLo,
int Version>
45 const RhsScalar* rhs,
Index rhsStride, ResScalar* res,
Index resStride,
52 ::run(size,depth,rhs,rhsStride,lhs,lhsStride,res,resStride,alpha,blocking);
56 template <
typename Index,
typename LhsScalar,
int LhsStorageOrder,
bool ConjugateLhs,
57 typename RhsScalar,
int RhsStorageOrder,
bool ConjugateRhs,
int UpLo,
int Version>
62 const RhsScalar* _rhs,
Index rhsStride, ResScalar* _res,
Index resStride,
70 LhsMapper lhs(_lhs,lhsStride);
71 RhsMapper rhs(_rhs,rhsStride);
72 ResMapper res(_res, resStride);
75 Index mc = (std::min)(size,blocking.
mc());
79 mc = (mc/Traits::nr)*Traits::nr;
81 std::size_t sizeA = kc*mc;
82 std::size_t sizeB = kc*
size;
92 for(
Index k2=0; k2<depth; k2+=kc)
94 const Index actual_kc = (std::min)(k2+kc,depth)-k2;
97 pack_rhs(blockB, rhs.getSubMapper(k2,0), actual_kc,
size);
101 const Index actual_mc = (std::min)(i2+mc,size)-i2;
103 pack_lhs(blockA, lhs.getSubMapper(i2, k2), actual_kc, actual_mc);
110 gebp(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc,
111 (std::min)(size,i2), alpha, -1, -1, 0, 0);
114 sybb(_res+resStride*i2 + i2, resStride, blockA, blockB + actual_kc*i2, actual_mc, actual_kc, alpha);
118 Index j2 = i2+actual_mc;
119 gebp(res.getSubMapper(i2, j2), blockA, blockB+actual_kc*j2, actual_mc,
120 actual_kc, (
std::max)(
Index(0), size-j2), alpha, -1, -1, 0, 0);
136 template<
typename LhsScalar,
typename RhsScalar,
typename Index,
int mr,
int nr,
bool ConjLhs,
bool ConjRhs,
int UpLo>
148 ResMapper res(_res, resStride);
157 Index actualBlockSize = std::min<Index>(BlockSize,size - j);
158 const RhsScalar* actual_b = blockB+j*depth;
161 gebp_kernel(res.getSubMapper(0, j), blockA, actual_b, j, depth, actualBlockSize, alpha,
169 gebp_kernel(ResMapper(buffer.
data(), BlockSize), blockA+depth*i, actual_b, actualBlockSize, depth, actualBlockSize, alpha,
172 for(
Index j1=0; j1<actualBlockSize; ++j1)
174 ResScalar* r = &res(i, j + j1);
176 UpLo==
Lower ? i1<actualBlockSize : i1<=j1; ++i1)
177 r[i1] += buffer(i1,j1);
183 Index i = j+actualBlockSize;
184 gebp_kernel(res.getSubMapper(i, j), blockA+depth*i, actual_b, size-i,
185 depth, actualBlockSize, alpha, -1, -1, 0, 0);
195 template<
typename MatrixType,
typename ProductType,
int UpLo,
bool IsOuterProduct>
199 template<
typename MatrixType,
typename ProductType,
int UpLo>
202 static void run(MatrixType& mat,
const ProductType& prod,
const typename MatrixType::Scalar& alpha,
bool beta)
204 typedef typename MatrixType::Scalar Scalar;
208 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhs;
214 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhs;
218 Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs().derived()) * RhsBlasTraits::extractScalarFactor(prod.rhs().derived());
221 mat.template triangularView<UpLo>().
setZero();
225 UseLhsDirectly = _ActualLhs::InnerStrideAtCompileTime==1,
226 UseRhsDirectly = _ActualRhs::InnerStrideAtCompileTime==1
231 (UseLhsDirectly ?
const_cast<Scalar*
>(actualLhs.data()) : static_lhs.data()));
236 (UseRhsDirectly ?
const_cast<Scalar*
>(actualRhs.data()) : static_rhs.data()));
242 RhsBlasTraits::NeedToConjugate && NumTraits<Scalar>::IsComplex>
243 ::run(actualLhs.size(), mat.data(), mat.outerStride(), actualLhsPtr, actualRhsPtr, actualAlpha);
247 template<
typename MatrixType,
typename ProductType,
int UpLo>
250 static void run(MatrixType& mat,
const ProductType& prod,
const typename MatrixType::Scalar& alpha,
bool beta)
254 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhs;
260 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhs;
264 typename ProductType::Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs().derived()) * RhsBlasTraits::extractScalarFactor(prod.rhs().derived());
267 mat.template triangularView<UpLo>().
setZero();
271 LhsIsRowMajor = _ActualLhs::Flags&
RowMajorBit ? 1 : 0,
272 RhsIsRowMajor = _ActualRhs::Flags&RowMajorBit ? 1 : 0,
279 Index depth = actualLhs.cols();
282 MatrixType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime, _ActualRhs::MaxColsAtCompileTime> BlockingType;
284 BlockingType blocking(size, size, depth, 1,
false);
287 typename Lhs::Scalar, LhsIsRowMajor ?
RowMajor :
ColMajor, LhsBlasTraits::NeedToConjugate,
288 typename Rhs::Scalar, RhsIsRowMajor ?
RowMajor :
ColMajor, RhsBlasTraits::NeedToConjugate,
291 &actualLhs.coeffRef(SkipDiag&&(UpLo&
Lower)==Lower ? 1 : 0,0), actualLhs.outerStride(),
292 &actualRhs.coeffRef(0,SkipDiag&&(UpLo&
Upper)==Upper ? 1 : 0), actualRhs.outerStride(),
293 mat.data() + (SkipDiag ? (bool(IsRowMajor) != ((UpLo&
Lower)==Lower) ? 1 : mat.outerStride() ) : 0), mat.outerStride(), actualAlpha, blocking);
297 template<
typename MatrixType,
unsigned int UpLo>
298 template<
typename ProductType>
302 eigen_assert(derived().nestedExpression().rows() == prod.rows() && derived().cols() == prod.cols());
311 #endif // EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H
#define EIGEN_STRONG_INLINE
EIGEN_DEVICE_FUNC Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setZero(Index size)
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
Traits::ResScalar ResScalar
A matrix or vector expression mapping an existing array of data.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
const unsigned int RowMajorBit
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() max(const half &a, const half &b)
static EIGEN_STRONG_INLINE void run(Index size, Index depth, const LhsScalar *lhs, Index lhsStride, const RhsScalar *rhs, Index rhsStride, ResScalar *res, Index resStride, const ResScalar &alpha, level3_blocking< RhsScalar, LhsScalar > &blocking)
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
static EIGEN_STRONG_INLINE void run(Index size, Index depth, const LhsScalar *_lhs, Index lhsStride, const RhsScalar *_rhs, Index rhsStride, ResScalar *_res, Index resStride, const ResScalar &alpha, level3_blocking< LhsScalar, RhsScalar > &blocking)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
static void run(MatrixType &mat, const ProductType &prod, const typename MatrixType::Scalar &alpha, bool beta)
gebp_traits< LhsScalar, RhsScalar, ConjLhs, ConjRhs > Traits
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
void operator()(ResScalar *_res, Index resStride, const LhsScalar *blockA, const RhsScalar *blockB, Index size, Index depth, const ResScalar &alpha)
Expression of a triangular part in a matrix.
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
static void run(MatrixType &mat, const ProductType &prod, const typename MatrixType::Scalar &alpha, bool beta)
The matrix class, also used for vectors and row-vectors.
void run(Expr &expr, Dev &dev)