10 #ifndef EIGEN_CONSERVATIVESPARSESPARSEPRODUCT_H
11 #define EIGEN_CONSERVATIVESPARSESPARSEPRODUCT_H
20 template <
typename Lhs,
typename Rhs,
typename ResultType>
22 bool sortedInsertion =
false) {
36 std::memset(mask, 0,
sizeof(
bool) *
rows);
47 Index estimated_nnz_prod = lhsEval.nonZerosEstimate() + rhsEval.nonZerosEstimate();
50 res.reserve(
Index(estimated_nnz_prod));
56 RhsScalar
y = rhsIt.value();
60 LhsScalar
x = lhsIt.value();
70 if (!sortedInsertion) {
74 res.insertBackByOuterInnerUnordered(
j,
i) = values[
i];
88 if ((nnz < 200 && nnz < t200) || nnz *
numext::log2(
int(nnz)) <
t) {
89 if (nnz > 1) std::sort(indices, indices + nnz);
92 res.insertBackByOuterInner(
j,
i) = values[
i];
100 res.insertBackByOuterInner(
j,
i) = values[
i];
114 template <
class Source,
int Order>
117 template <
typename Lhs,
typename Rhs,
typename ResultType,
123 template <
typename Lhs,
typename Rhs,
typename ResultType>
135 if (lhs.rows() > rhs.cols()) {
136 using ColMajorMatrix =
typename sparse_eval<ColMajorMatrixAux, ResultType::RowsAtCompileTime,
137 ResultType::ColsAtCompileTime, ColMajorMatrixAux::Flags>
::type;
138 ColMajorMatrix resCol(lhs.rows(), rhs.cols());
140 internal::conservative_sparse_sparse_product_impl<Lhs, Rhs, ColMajorMatrix>(lhs, rhs, resCol,
true);
141 res = resCol.markAsRValue();
143 ColMajorMatrixAux resCol(lhs.rows(), rhs.cols());
145 internal::conservative_sparse_sparse_product_impl<Lhs, Rhs, ColMajorMatrixAux>(lhs, rhs, resCol,
false);
146 RowMajorMatrix resRow(resCol);
147 res = resRow.markAsRValue();
152 template <
typename Lhs,
typename Rhs,
typename ResultType>
157 RowMajorRhs rhsRow = rhs;
158 RowMajorRes resRow(lhs.rows(), rhs.cols());
159 internal::conservative_sparse_sparse_product_impl<RowMajorRhs, Lhs, RowMajorRes>(rhsRow, lhs, resRow);
164 template <
typename Lhs,
typename Rhs,
typename ResultType>
169 RowMajorLhs lhsRow = lhs;
170 RowMajorRes resRow(lhs.rows(), rhs.cols());
171 internal::conservative_sparse_sparse_product_impl<Rhs, RowMajorLhs, RowMajorRes>(rhs, lhsRow, resRow);
176 template <
typename Lhs,
typename Rhs,
typename ResultType>
180 RowMajorRes resRow(lhs.rows(), rhs.cols());
181 internal::conservative_sparse_sparse_product_impl<Rhs, Lhs, RowMajorRes>(rhs, lhs, resRow);
186 template <
typename Lhs,
typename Rhs,
typename ResultType>
192 ColMajorRes resCol(lhs.rows(), rhs.cols());
193 internal::conservative_sparse_sparse_product_impl<Lhs, Rhs, ColMajorRes>(lhs, rhs, resCol);
198 template <
typename Lhs,
typename Rhs,
typename ResultType>
203 ColMajorLhs lhsCol = lhs;
204 ColMajorRes resCol(lhs.rows(), rhs.cols());
205 internal::conservative_sparse_sparse_product_impl<ColMajorLhs, Rhs, ColMajorRes>(lhsCol, rhs, resCol);
210 template <
typename Lhs,
typename Rhs,
typename ResultType>
215 ColMajorRhs rhsCol = rhs;
216 ColMajorRes resCol(lhs.rows(), rhs.cols());
217 internal::conservative_sparse_sparse_product_impl<Lhs, ColMajorRhs, ColMajorRes>(lhs, rhsCol, resCol);
222 template <
typename Lhs,
typename Rhs,
typename ResultType>
227 RowMajorRes resRow(lhs.rows(), rhs.cols());
228 internal::conservative_sparse_sparse_product_impl<Rhs, Lhs, RowMajorRes>(rhs, lhs, resRow);
230 ColMajorRes resCol(resRow);
239 template <
typename Lhs,
typename Rhs,
typename ResultType>
251 RhsScalar
y = rhsIt.value();
255 LhsScalar
x = lhsIt.value();
266 template <
typename Lhs,
typename Rhs,
typename ResultType,
271 template <
typename Lhs,
typename Rhs,
typename ResultType>
274 internal::sparse_sparse_to_dense_product_impl<Lhs, Rhs, ResultType>(lhs, rhs,
res);
278 template <
typename Lhs,
typename Rhs,
typename ResultType>
282 ColMajorLhs lhsCol(lhs);
283 internal::sparse_sparse_to_dense_product_impl<ColMajorLhs, Rhs, ResultType>(lhsCol, rhs,
res);
287 template <
typename Lhs,
typename Rhs,
typename ResultType>
291 ColMajorRhs rhsCol(rhs);
292 internal::sparse_sparse_to_dense_product_impl<Lhs, ColMajorRhs, ResultType>(lhs, rhsCol,
res);
296 template <
typename Lhs,
typename Rhs,
typename ResultType>
300 internal::sparse_sparse_to_dense_product_impl<Rhs, Lhs, Transpose<ResultType>>(rhs, lhs, trRes);
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define eigen_assert(x)
Definition: Macros.h:910
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:806
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
A versatible sparse matrix representation.
Definition: SparseMatrix.h:121
Expression of the transpose of a matrix.
Definition: Transpose.h:56
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int RowMajorBit
Definition: Constants.h:70
char char char int int * k
Definition: level2_impl.h:374
static void conservative_sparse_sparse_product_impl(const Lhs &lhs, const Rhs &rhs, ResultType &res, bool sortedInsertion=false)
Definition: ConservativeSparseSparseProduct.h:21
@ Lhs
Definition: TensorContractionMapper.h:20
@ Rhs
Definition: TensorContractionMapper.h:20
const Scalar & y
Definition: RandomImpl.h:36
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
static void sparse_sparse_to_dense_product_impl(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:240
EIGEN_CONSTEXPR int log2(int x)
Definition: MathFunctions.h:1281
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:200
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:212
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:224
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:154
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:178
traits< remove_all_t< Lhs > >::Scalar Scalar
Definition: ConservativeSparseSparseProduct.h:188
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:190
Definition: ConservativeSparseSparseProduct.h:124
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:128
LhsCleaned::Scalar Scalar
Definition: ConservativeSparseSparseProduct.h:126
remove_all_t< Lhs > LhsCleaned
Definition: ConservativeSparseSparseProduct.h:125
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:166
Definition: ConservativeSparseSparseProduct.h:121
Definition: SparseUtil.h:110
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:289
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:273
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:280
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res)
Definition: ConservativeSparseSparseProduct.h:298
Definition: ConservativeSparseSparseProduct.h:269
Definition: ForwardDeclarations.h:21
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2