10 #ifndef EIGEN_SPARSEDENSEPRODUCT_H
11 #define EIGEN_SPARSEDENSEPRODUCT_H
29 template <
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
typename AlphaType,
31 bool ColPerCol = ((DenseRhsType::Flags &
RowMajorBit) == 0) || DenseRhsType::ColsAtCompileTime == 1>
34 template <
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
42 static void run(
const SparseLhsType& lhs,
const DenseRhsType& rhs, DenseResType&
res,
47 #ifdef EIGEN_HAS_OPENMP
51 for (
Index c = 0;
c < rhs.cols(); ++
c) {
52 #ifdef EIGEN_HAS_OPENMP
55 if (threads > 1 && lhsEval.nonZerosEstimate() > 20000) {
56 #pragma omp parallel for schedule(dynamic, (n + threads * 4 - 1) / (threads * 4)) num_threads(threads)
73 tmp_a += it.value() * rhs.coeff(it.index(),
col);
76 tmp_b += it.value() * rhs.coeff(it.index(),
col);
94 template <
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
typename AlphaType>
101 static void run(
const SparseLhsType& lhs,
const DenseRhsType& rhs, DenseResType&
res,
const AlphaType&
alpha) {
103 for (
Index c = 0;
c < rhs.cols(); ++
c) {
104 for (
Index j = 0;
j < lhs.outerSize(); ++
j) {
113 template <
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
121 static void run(
const SparseLhsType& lhs,
const DenseRhsType& rhs, DenseResType&
res,
126 #ifdef EIGEN_HAS_OPENMP
130 if (threads > 1 && lhsEval.nonZerosEstimate() * rhs.cols() > 20000) {
131 #pragma omp parallel for schedule(dynamic, (n + threads * 4 - 1) / (threads * 4)) num_threads(threads)
142 typename Res::RowXpr res_i(
res.row(
i));
147 template <
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
154 static void run(
const SparseLhsType& lhs,
const DenseRhsType& rhs, DenseResType&
res,
157 for (
Index j = 0;
j < lhs.outerSize(); ++
j) {
158 typename Rhs::ConstRowXpr rhs_j(rhs.row(
j));
164 template <
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
typename AlphaType>
166 const AlphaType&
alpha) {
174 template <
typename Lhs,
typename Rhs,
int ProductType>
179 template <
typename Dest>
183 LhsNested lhsNested(lhs);
184 RhsNested rhsNested(rhs);
189 template <
typename Lhs,
typename Rhs,
int ProductType>
193 template <
typename Lhs,
typename Rhs,
int ProductType>
198 template <
typename Dst>
203 LhsNested lhsNested(lhs);
204 RhsNested rhsNested(rhs);
212 template <
typename Lhs,
typename Rhs,
int ProductType>
216 template <
typename LhsT,
typename RhsT,
bool NeedToTranspose>
219 typedef std::conditional_t<NeedToTranspose, RhsT, LhsT>
Lhs1;
220 typedef std::conditional_t<NeedToTranspose, LhsT, RhsT>
ActualRhs;
225 typedef std::conditional_t<is_same<typename internal::traits<Lhs1>::StorageKind,
Sparse>
::value,
Lhs1,
228 typedef std::conditional_t<is_same<typename internal::traits<Lhs1>::StorageKind,
Sparse>
::value,
Lhs1 const&,
259 typename RhsEval::InnerIterator it(rhs,
outer);
260 if (it && it.index() == 0 && it.value() !=
Scalar(0))
return it.value();
288 template <
typename Lhs,
typename Rhs>
299 template <
typename Lhs,
typename Rhs>
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
Definition: StaticAssert.h:101
SCALAR Scalar
Definition: bench_gemm.cpp:45
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:202
Expression of a dense or sparse matrix with zero or too small values removed.
Definition: SparseView.h:45
Expression of the transpose of a matrix.
Definition: Transpose.h:56
Definition: SparseDenseProduct.h:240
EIGEN_STRONG_INLINE Index outer() const
Definition: SparseDenseProduct.h:248
Scalar m_factor
Definition: SparseDenseProduct.h:267
Scalar get(const RhsEval &rhs, Index outer, Sparse=Sparse())
Definition: SparseDenseProduct.h:258
EIGEN_STRONG_INLINE Scalar value() const
Definition: SparseDenseProduct.h:252
InnerIterator(const sparse_dense_outer_product_evaluator &xprEval, Index outer)
Definition: SparseDenseProduct.h:242
EIGEN_STRONG_INLINE Index col() const
Definition: SparseDenseProduct.h:250
bool m_empty
Definition: SparseDenseProduct.h:266
Scalar get(const RhsEval &rhs, Index outer, Dense=Dense()) const
Definition: SparseDenseProduct.h:256
EIGEN_STRONG_INLINE Index row() const
Definition: SparseDenseProduct.h:249
Index m_outer
Definition: SparseDenseProduct.h:265
@ DefaultProduct
Definition: Constants.h:503
@ OuterProduct
Definition: Constants.h:508
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int RowMajorBit
Definition: Constants.h:70
RealScalar alpha
Definition: level1_cplx_impl.h:151
@ Lhs
Definition: TensorContractionMapper.h:20
@ Rhs
Definition: TensorContractionMapper.h:20
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
void sparse_time_dense_product(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const AlphaType &alpha)
Definition: SparseDenseProduct.h:165
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
squared absolute value
Definition: GlobalFunctions.h:87
const int HugeCost
Definition: Constants.h:48
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
int nbThreads()
Definition: Parallelizer.h:54
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
int c
Definition: calibrate.py:100
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
Definition: Constants.h:540
Definition: Constants.h:519
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:1043
Definition: Constants.h:570
Definition: Constants.h:522
Definition: SparseUtil.h:152
Definition: CoreEvaluators.h:104
static void scaleAndAddTo(Dst &dst, const Lhs &lhs, const Rhs &rhs, const Scalar &alpha)
Definition: SparseDenseProduct.h:199
Product< Lhs, Rhs >::Scalar Scalar
Definition: SparseDenseProduct.h:196
static void scaleAndAddTo(Dest &dst, const Lhs &lhs, const Rhs &rhs, const Scalar &alpha)
Definition: SparseDenseProduct.h:180
Product< Lhs, Rhs >::Scalar Scalar
Definition: SparseDenseProduct.h:177
Definition: ProductEvaluators.h:341
Definition: ProductEvaluators.h:78
Definition: MoreMeta.h:202
Definition: XprHelper.h:533
XprType::PlainObject PlainObject
Definition: SparseDenseProduct.h:294
product_evaluator(const XprType &xpr)
Definition: SparseDenseProduct.h:296
sparse_dense_outer_product_evaluator< Lhs, Rhs, Lhs::IsRowMajor > Base
Definition: SparseDenseProduct.h:291
Product< Lhs, Rhs > XprType
Definition: SparseDenseProduct.h:293
Product< Lhs, Rhs > XprType
Definition: SparseDenseProduct.h:304
XprType::PlainObject PlainObject
Definition: SparseDenseProduct.h:305
product_evaluator(const XprType &xpr)
Definition: SparseDenseProduct.h:307
sparse_dense_outer_product_evaluator< Lhs, Rhs, Rhs::IsRowMajor > Base
Definition: SparseDenseProduct.h:302
Definition: ForwardDeclarations.h:221
Definition: SparseDenseProduct.h:217
evaluator< ActualLhs > m_lhsXprImpl
Definition: SparseDenseProduct.h:283
evaluator< ActualRhs > m_rhsXprImpl
Definition: SparseDenseProduct.h:284
ProdXprType::Scalar Scalar
Definition: SparseDenseProduct.h:235
std::conditional_t< is_same< typename internal::traits< Lhs1 >::StorageKind, Sparse >::value, Lhs1, SparseView< Lhs1 > > ActualLhs
Definition: SparseDenseProduct.h:227
sparse_dense_outer_product_evaluator(const Lhs1 &lhs, const ActualRhs &rhs)
Definition: SparseDenseProduct.h:270
sparse_dense_outer_product_evaluator(const ActualRhs &rhs, const Lhs1 &lhs)
Definition: SparseDenseProduct.h:276
std::conditional_t< is_same< typename internal::traits< Lhs1 >::StorageKind, Sparse >::value, Lhs1 const &, SparseView< Lhs1 > > LhsArg
Definition: SparseDenseProduct.h:230
evaluator< ActualRhs > RhsEval
Definition: SparseDenseProduct.h:233
std::conditional_t< NeedToTranspose, LhsT, RhsT > ActualRhs
Definition: SparseDenseProduct.h:220
const LhsArg m_lhs
Definition: SparseDenseProduct.h:282
@ CoeffReadCost
Definition: SparseDenseProduct.h:238
evaluator< ActualLhs >::InnerIterator LhsIterator
Definition: SparseDenseProduct.h:234
Product< LhsT, RhsT, DefaultProduct > ProdXprType
Definition: SparseDenseProduct.h:221
evaluator< ActualLhs > LhsEval
Definition: SparseDenseProduct.h:232
std::conditional_t< NeedToTranspose, RhsT, LhsT > Lhs1
Definition: SparseDenseProduct.h:219
LhsEval::InnerIterator LhsInnerIterator
Definition: SparseDenseProduct.h:100
evaluator< Lhs > LhsEval
Definition: SparseDenseProduct.h:99
internal::remove_all_t< DenseRhsType > Rhs
Definition: SparseDenseProduct.h:97
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const AlphaType &alpha)
Definition: SparseDenseProduct.h:101
internal::remove_all_t< DenseResType > Res
Definition: SparseDenseProduct.h:98
internal::remove_all_t< SparseLhsType > Lhs
Definition: SparseDenseProduct.h:96
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha)
Definition: SparseDenseProduct.h:154
internal::remove_all_t< SparseLhsType > Lhs
Definition: SparseDenseProduct.h:150
internal::remove_all_t< DenseResType > Res
Definition: SparseDenseProduct.h:152
internal::remove_all_t< DenseRhsType > Rhs
Definition: SparseDenseProduct.h:151
evaluator< Lhs >::InnerIterator LhsInnerIterator
Definition: SparseDenseProduct.h:153
evaluator< Lhs > LhsEval
Definition: SparseDenseProduct.h:41
internal::remove_all_t< DenseResType > Res
Definition: SparseDenseProduct.h:39
evaluator< Lhs >::InnerIterator LhsInnerIterator
Definition: SparseDenseProduct.h:40
internal::remove_all_t< SparseLhsType > Lhs
Definition: SparseDenseProduct.h:37
static void processRow(const LhsEval &lhsEval, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha, Index i, Index col)
Definition: SparseDenseProduct.h:66
internal::remove_all_t< DenseRhsType > Rhs
Definition: SparseDenseProduct.h:38
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha)
Definition: SparseDenseProduct.h:42
internal::remove_all_t< DenseRhsType > Rhs
Definition: SparseDenseProduct.h:117
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha)
Definition: SparseDenseProduct.h:121
evaluator< Lhs > LhsEval
Definition: SparseDenseProduct.h:119
internal::remove_all_t< SparseLhsType > Lhs
Definition: SparseDenseProduct.h:116
static void processRow(const LhsEval &lhsEval, const DenseRhsType &rhs, Res &res, const typename Res::Scalar &alpha, Index i)
Definition: SparseDenseProduct.h:140
internal::remove_all_t< DenseResType > Res
Definition: SparseDenseProduct.h:118
LhsEval::InnerIterator LhsInnerIterator
Definition: SparseDenseProduct.h:120
Definition: SparseDenseProduct.h:32
Definition: ForwardDeclarations.h:21
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
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