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
33 template <
int Rows,
int Cols,
int Depth>
36 template <
int Size,
int MaxSize>
39 #ifndef EIGEN_GPU_COMPILE_PHASE
51 template <
typename Lhs,
typename Rhs>
76 #ifdef EIGEN_DEBUG_PRODUCT
93 template <
int M,
int N>
220 template <
int S
ide,
int StorageOrder,
bool BlasCompatible>
227 template <
typename Scalar,
int Size,
int MaxSize,
bool Cond>
230 template <
typename Scalar,
int Size,
int MaxSize>
238 template <
typename Scalar,
int Size>
243 template <
typename Scalar,
int Size,
int MaxSize>
245 #if EIGEN_MAX_STATIC_ALIGN_BYTES != 0
260 template <
int StorageOrder,
bool BlasCompatible>
262 template <
typename Lhs,
typename Rhs,
typename Dest>
273 template <
typename Lhs,
typename Rhs,
typename Dest>
280 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
282 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
287 ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
288 ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
293 typedef std::conditional_t<Dest::IsVectorAtCompileTime, Dest, typename Dest::ColXpr> ActualDest;
298 EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime == 1),
300 MightCannotUseDest = ((!EvalToDestAtCompileTime) || ComplexByReal) && (ActualDest::MaxSizeAtCompileTime != 0)
307 if (!MightCannotUseDest) {
311 RhsMapper, RhsBlasTraits::NeedToConjugate>
::run(actualLhs.rows(), actualLhs.cols(),
312 LhsMapper(actualLhs.data(),
313 actualLhs.outerStride()),
314 RhsMapper(actualRhs.data(),
315 actualRhs.innerStride()),
316 dest.data(), 1, compatibleAlpha);
323 const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
326 evalToDest ? dest.data() : static_dest.data());
329 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
330 constexpr
int Size = Dest::SizeAtCompileTime;
332 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
334 if (!alphaIsCompatible) {
335 MappedDest(actualDestPtr, dest.size()).setZero();
336 compatibleAlpha = RhsScalar(1);
338 MappedDest(actualDestPtr, dest.size()) = dest;
342 RhsMapper, RhsBlasTraits::NeedToConjugate>
::run(actualLhs.rows(), actualLhs.cols(),
343 LhsMapper(actualLhs.data(),
344 actualLhs.outerStride()),
345 RhsMapper(actualRhs.data(),
346 actualRhs.innerStride()),
347 actualDestPtr, 1, compatibleAlpha);
350 if (!alphaIsCompatible)
351 dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
353 dest = MappedDest(actualDestPtr, dest.size());
361 template <
typename Lhs,
typename Rhs,
typename Dest>
368 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
370 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
373 std::add_const_t<ActualLhsType> actualLhs = LhsBlasTraits::extract(lhs);
374 std::add_const_t<ActualRhsType> actualRhs = RhsBlasTraits::extract(rhs);
382 ActualRhsTypeCleaned::InnerStrideAtCompileTime == 1 || ActualRhsTypeCleaned::MaxSizeAtCompileTime == 0
386 ActualRhsTypeCleaned::MaxSizeAtCompileTime, !DirectlyUseRhs>
390 RhsScalar, actualRhsPtr, actualRhs.size(),
391 DirectlyUseRhs ?
const_cast<RhsScalar*
>(actualRhs.data()) : static_rhs.data());
393 if (!DirectlyUseRhs) {
394 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
395 constexpr
int Size = ActualRhsTypeCleaned::SizeAtCompileTime;
397 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
405 RhsMapper, RhsBlasTraits::NeedToConjugate>
::
406 run(actualLhs.rows(), actualLhs.cols(), LhsMapper(actualLhs.data(), actualLhs.outerStride()),
407 RhsMapper(actualRhsPtr, 1), dest.data(),
408 dest.col(0).innerStride(),
416 template <
typename Lhs,
typename Rhs,
typename Dest>
419 EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
430 template <
typename Lhs,
typename Rhs,
typename Dest>
433 EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
437 dest.coeffRef(
i) +=
alpha * (lhs.row(
i).cwiseProduct(actual_rhs.transpose())).sum();
453 template <
typename Derived>
454 template <
typename OtherDerived>
462 ProductIsValid = Derived::ColsAtCompileTime ==
Dynamic || OtherDerived::RowsAtCompileTime ==
Dynamic ||
463 int(Derived::ColsAtCompileTime) ==
int(OtherDerived::RowsAtCompileTime),
464 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
471 ProductIsValid || !(AreVectors && SameSizes),
472 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
474 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
476 #ifdef EIGEN_DEBUG_PRODUCT
494 template <
typename Derived>
495 template <
typename OtherDerived>
499 ProductIsValid = Derived::ColsAtCompileTime ==
Dynamic || OtherDerived::RowsAtCompileTime ==
Dynamic ||
500 int(Derived::ColsAtCompileTime) ==
int(OtherDerived::RowsAtCompileTime),
501 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
508 ProductIsValid || !(AreVectors && SameSizes),
509 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
511 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
Definition: AltiVec/PacketMath.h:21
AnnoyingScalar imag(const AnnoyingScalar &)
Definition: AnnoyingScalar.h:132
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define eigen_internal_assert(x)
Definition: Macros.h:916
#define EIGEN_DEBUG_VAR(x)
Definition: Macros.h:815
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
int data[]
Definition: Map_placement_new.cpp:1
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:806
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:66
int rows
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
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:52
EIGEN_DEVICE_FUNC const Product< Derived, OtherDerived, LazyProduct > lazyProduct(const MatrixBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC const Product< Derived, OtherDerived > operator*(const MatrixBase< OtherDerived > &other) const
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:202
Expression of the transpose of a matrix.
Definition: Transpose.h:56
Definition: BlasUtil.h:443
@ N
Definition: constructor.cpp:22
@ GemvProduct
Definition: Constants.h:510
@ InnerProduct
Definition: Constants.h:509
@ CoeffBasedProductMode
Definition: Constants.h:506
@ OuterProduct
Definition: Constants.h:508
@ GemmProduct
Definition: Constants.h:511
@ LazyCoeffBasedProductMode
Definition: Constants.h:507
@ AlignedMax
Definition: Constants.h:254
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
@ OnTheLeft
Definition: Constants.h:331
@ OnTheRight
Definition: Constants.h:333
Eigen::DenseIndex ret
Definition: level1_cplx_impl.h:43
RealScalar alpha
Definition: level1_cplx_impl.h:151
char char char int int * k
Definition: level2_impl.h:374
constexpr int plain_enum_min(A a, B b)
Definition: Meta.h:649
@ Lhs
Definition: TensorContractionMapper.h:20
@ Rhs
Definition: TensorContractionMapper.h:20
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE ResScalar combine_scalar_factors(const ResScalar &alpha, const Lhs &lhs, const Rhs &rhs)
Definition: BlasUtil.h:609
constexpr int min_size_prefer_fixed(A a, B b)
Definition: Meta.h:683
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X &x)
Definition: Meta.h:592
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
auto run(Kernel kernel, Args &&... args) -> decltype(kernel(args...))
Definition: gpu_test_helper.h:414
squared absolute value
Definition: GlobalFunctions.h:87
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
@ Small
Definition: GeneralProduct.h:19
@ Large
Definition: GeneralProduct.h:19
const int Dynamic
Definition: Constants.h:25
Definition: Eigen_Colamd.h:49
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: BlasUtil.h:459
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:263
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:417
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:274
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:431
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
Definition: GeneralProduct.h:362
Definition: GeneralProduct.h:221
EIGEN_STRONG_INLINE constexpr EIGEN_DEVICE_FUNC Scalar * data()
Definition: GeneralProduct.h:240
EIGEN_STRONG_INLINE constexpr EIGEN_DEVICE_FUNC Scalar * data()
Definition: GeneralProduct.h:232
internal::plain_array< Scalar, internal::min_size_prefer_fixed(Size, MaxSize)+EIGEN_MAX_ALIGN_BYTES, 0 > m_data
Definition: GeneralProduct.h:251
constexpr EIGEN_STRONG_INLINE Scalar * data()
Definition: GeneralProduct.h:252
Definition: GeneralProduct.h:228
Definition: BlasUtil.h:42
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE To run(const From &x)
Definition: BlasUtil.h:46
Definition: XprHelper.h:533
std::conditional_t< Evaluate, PlainObject, typename ref_selector< T >::type > type
Definition: XprHelper.h:549
Definition: GenericPacketMath.h:108
Definition: DenseStorage.h:54
Definition: GeneralProduct.h:37
Definition: GeneralProduct.h:34
Definition: GeneralProduct.h:52
@ value
Definition: GeneralProduct.h:75
@ ret
Definition: GeneralProduct.h:75
@ rows_select
Definition: GeneralProduct.h:68
@ cols_select
Definition: GeneralProduct.h:69
@ depth_select
Definition: GeneralProduct.h:70
remove_all_t< Rhs > Rhs_
Definition: GeneralProduct.h:54
product_type_selector< rows_select, cols_select, depth_select > selector
Definition: GeneralProduct.h:72
remove_all_t< Lhs > Lhs_
Definition: GeneralProduct.h:53
@ MaxDepth
Definition: GeneralProduct.h:60
@ Cols
Definition: GeneralProduct.h:59
@ MaxRows
Definition: GeneralProduct.h:56
@ Depth
Definition: GeneralProduct.h:61
@ MaxCols
Definition: GeneralProduct.h:58
@ Rows
Definition: GeneralProduct.h:57
Definition: ForwardDeclarations.h:21
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317