11#ifndef EIGEN_GENERAL_PRODUCT_H
12#define EIGEN_GENERAL_PRODUCT_H
26#ifndef EIGEN_GEMM_TO_COEFFBASED_THRESHOLD
28#define EIGEN_GEMM_TO_COEFFBASED_THRESHOLD 20
38 #ifndef EIGEN_GPU_COMPILE_PHASE
39 is_large = MaxSize ==
Dynamic ||
74 typedef product_type_selector<rows_select, cols_select, depth_select> selector;
81#ifdef EIGEN_DEBUG_PRODUCT
154template<
int S
ide,
int StorageOrder,
bool BlasCompatible>
163template<
typename Scalar,
int Size,
int MaxSize>
169template<
typename Scalar,
int Size>
175template<
typename Scalar,
int Size,
int MaxSize>
182 #if EIGEN_MAX_STATIC_ALIGN_BYTES!=0
190 return ForceAlignment
198template<
int StorageOrder,
bool BlasCompatible>
201 template<
typename Lhs,
typename Rhs,
typename Dest>
202 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
207 ::run(rhs.transpose(), lhs.transpose(), destT, alpha);
213 template<
typename Lhs,
typename Rhs,
typename Dest>
214 static inline void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
216 typedef typename Lhs::Scalar LhsScalar;
217 typedef typename Rhs::Scalar RhsScalar;
218 typedef typename Dest::Scalar ResScalar;
219 typedef typename Dest::RealScalar RealScalar;
222 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
224 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
228 ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
229 ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
239 EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime==1),
241 MightCannotUseDest = ((!EvalToDestAtCompileTime) || ComplexByReal) && (ActualDest::MaxSizeAtCompileTime!=0)
248 if(!MightCannotUseDest)
253 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
254 actualLhs.rows(), actualLhs.cols(),
255 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
256 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
264 const bool alphaIsCompatible = (!ComplexByReal) || (
numext::imag(actualAlpha)==RealScalar(0));
265 const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
268 evalToDest ? dest.data() : static_dest.data());
272 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
274 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
276 if(!alphaIsCompatible)
278 MappedDest(actualDestPtr, dest.size()).setZero();
279 compatibleAlpha = RhsScalar(1);
282 MappedDest(actualDestPtr, dest.size()) = dest;
286 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
287 actualLhs.rows(), actualLhs.cols(),
288 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
289 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
295 if(!alphaIsCompatible)
296 dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
298 dest = MappedDest(actualDestPtr, dest.size());
306 template<
typename Lhs,
typename Rhs,
typename Dest>
307 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
309 typedef typename Lhs::Scalar LhsScalar;
310 typedef typename Rhs::Scalar RhsScalar;
311 typedef typename Dest::Scalar ResScalar;
314 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
316 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
327 DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1 || ActualRhsTypeCleaned::MaxSizeAtCompileTime==0
333 DirectlyUseRhs ?
const_cast<RhsScalar*
>(actualRhs.data()) : static_rhs.data());
337 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
339 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
347 <
Index,LhsScalar,LhsMapper,
RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
349 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
350 RhsMapper(actualRhsPtr, 1),
351 dest.data(), dest.col(0).innerStride(),
358 template<
typename Lhs,
typename Rhs,
typename Dest>
359 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
366 dest += (alpha*actual_rhs.coeff(k)) * lhs.col(k);
372 template<
typename Lhs,
typename Rhs,
typename Dest>
373 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
377 const Index rows = dest.rows();
378 for(
Index i=0; i<rows; ++i)
379 dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
395template<
typename Derived>
396template<
typename OtherDerived>
398const Product<Derived, OtherDerived>
406 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic
407 || OtherDerived::RowsAtCompileTime==
Dynamic
408 || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
409 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
416 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
418 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
420#ifdef EIGEN_DEBUG_PRODUCT
438template<
typename Derived>
439template<
typename OtherDerived>
445 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic
446 || OtherDerived::RowsAtCompileTime==
Dynamic
447 || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
448 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
455 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
457 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
Definition: PacketMath.h:18
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
Definition: CommonCwiseUnaryOps.h:109
#define EIGEN_PLAIN_ENUM_MIN(a, b)
Definition: Macros.h:1298
#define eigen_internal_assert(x)
Definition: Macros.h:1053
#define EIGEN_DEBUG_VAR(x)
Definition: Macros.h:908
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define EIGEN_STRONG_INLINE
Definition: Macros.h:927
#define EIGEN_SIZE_MIN_PREFER_FIXED(a, b)
Definition: Macros.h:1312
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:768
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:174
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:127
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
EIGEN_DEVICE_FUNC const Product< Derived, OtherDerived > operator*(const MatrixBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC const Product< Derived, OtherDerived, LazyProduct > lazyProduct(const MatrixBase< OtherDerived > &other) const
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:75
Expression of the transpose of a matrix.
Definition: Transpose.h:54
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: Transpose.h:69
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Transpose.h:71
Definition: BlasUtil.h:389
@ AlignedMax
Definition: Constants.h:252
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:319
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:321
@ OnTheLeft
Apply transformation on the left.
Definition: Constants.h:332
@ OnTheRight
Apply transformation on the right.
Definition: Constants.h:334
std::size_t UIntPtr
Definition: Meta.h:92
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE ResScalar combine_scalar_factors(const ResScalar &alpha, const Lhs &lhs, const Rhs &rhs)
Definition: BlasUtil.h:568
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
Namespace containing all symbols from the Eigen library.
Definition: Core:141
@ GemvProduct
Definition: Constants.h:500
@ InnerProduct
Definition: Constants.h:500
@ CoeffBasedProductMode
Definition: Constants.h:500
@ OuterProduct
Definition: Constants.h:500
@ GemmProduct
Definition: Constants.h:500
@ LazyCoeffBasedProductMode
Definition: Constants.h:500
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
@ Small
Definition: GeneralProduct.h:18
@ Large
Definition: GeneralProduct.h:17
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition: Constants.h:22
Definition: Eigen_Colamd.h:50
Holds information about the various numeric (i.e.
Definition: NumTraits.h:233
Definition: BlasUtil.h:403
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:202
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:359
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:214
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:373
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:307
Definition: GeneralProduct.h:155
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Scalar * data()
Definition: GeneralProduct.h:172
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Scalar * data()
Definition: GeneralProduct.h:166
EIGEN_STRONG_INLINE Scalar * data()
Definition: GeneralProduct.h:189
Definition: GeneralProduct.h:161
Definition: BlasUtil.h:40
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE To run(const From &x)
Definition: BlasUtil.h:43
Definition: XprHelper.h:458
Definition: GenericPacketMath.h:107
Definition: DenseStorage.h:45
T array[Size]
Definition: DenseStorage.h:46
Definition: GeneralProduct.h:36
Definition: GeneralProduct.h:33
Definition: GeneralProduct.h:52
@ ret
Definition: GeneralProduct.h:79
remove_all< Lhs >::type _Lhs
Definition: GeneralProduct.h:53
remove_all< Rhs >::type _Rhs
Definition: GeneralProduct.h:54
@ MaxDepth
Definition: GeneralProduct.h:60
@ Cols
Definition: GeneralProduct.h:59
@ MaxRows
Definition: GeneralProduct.h:56
@ Depth
Definition: GeneralProduct.h:62
@ MaxCols
Definition: GeneralProduct.h:58
@ Rows
Definition: GeneralProduct.h:57
T type
Definition: Meta.h:126
Definition: ForwardDeclarations.h:17
Definition: format.h:1552