10 #ifndef EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H
11 #define EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H
19 template<
typename Lhs,
typename Rhs,
typename ResultType>
29 Index rows = lhs.innerSize();
30 Index cols = rhs.outerSize();
38 if(ResultType::IsRowMajor)
39 res.resize(cols, rows);
41 res.resize(rows, cols);
52 Index estimated_nnz_prod = lhsEval.nonZerosEstimate() + rhsEval.nonZerosEstimate();
54 res.reserve(estimated_nnz_prod);
55 double ratioColRes = double(estimated_nnz_prod)/(double(lhs.rows())*double(rhs.cols()));
56 for (
Index j=0; j<cols; ++j)
61 tempVector.
init(ratioColRes);
67 RhsScalar x = rhsIt.value();
70 tempVector.
coeffRef(lhsIt.index()) += lhsIt.value() * x;
75 res.insertBackByOuterInner(j,it.index()) = it.value();
80 template<
typename Lhs,
typename Rhs,
typename ResultType,
86 template<
typename Lhs,
typename Rhs,
typename ResultType>
91 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
94 internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,ResultType>(lhs, rhs, _res, tolerance);
99 template<
typename Lhs,
typename Rhs,
typename ResultType>
103 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
107 SparseTemporaryType _res(res.rows(), res.cols());
108 internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,SparseTemporaryType>(lhs, rhs, _res, tolerance);
113 template<
typename Lhs,
typename Rhs,
typename ResultType>
117 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
121 internal::sparse_sparse_product_with_pruning_impl<Rhs,Lhs,ResultType>(rhs, lhs, _res, tolerance);
126 template<
typename Lhs,
typename Rhs,
typename ResultType>
130 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
134 ColMajorMatrixLhs colLhs(lhs);
135 ColMajorMatrixRhs colRhs(rhs);
136 internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrixLhs,ColMajorMatrixRhs,ResultType>(colLhs, colRhs, res, tolerance);
146 template<
typename Lhs,
typename Rhs,
typename ResultType>
150 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
153 RowMajorMatrixLhs rowLhs(lhs);
158 template<
typename Lhs,
typename Rhs,
typename ResultType>
162 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
165 RowMajorMatrixRhs rowRhs(rhs);
170 template<
typename Lhs,
typename Rhs,
typename ResultType>
174 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
177 ColMajorMatrixRhs colRhs(rhs);
178 internal::sparse_sparse_product_with_pruning_impl<Lhs,ColMajorMatrixRhs,ResultType>(lhs, colRhs, res, tolerance);
182 template<
typename Lhs,
typename Rhs,
typename ResultType>
186 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType& res,
const RealScalar& tolerance)
189 ColMajorMatrixLhs colLhs(lhs);
190 internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrixLhs,Rhs,ResultType>(colLhs, rhs, res, tolerance);
#define eigen_assert(x)
Definition: Macros.h:1037
A versatible sparse matrix representation.
Definition: SparseMatrix.h:98
Definition: AmbiVector.h:285
Definition: AmbiVector.h:24
void restart()
Definition: AmbiVector.h:164
void init(double estimatedDensity)
Definition: AmbiVector.h:138
Scalar & coeffRef(Index i)
Definition: AmbiVector.h:187
void setZero()
Definition: AmbiVector.h:171
@ ColMajor
Definition: Constants.h:319
@ RowMajor
Definition: Constants.h:321
const unsigned int RowMajorBit
Definition: Constants.h:66
static void sparse_sparse_product_with_pruning_impl(const Lhs &lhs, const Rhs &rhs, ResultType &res, const typename ResultType::RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:20
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Flags
Special flags for archives.
Definition: cereal.hpp:185
Definition: document.h:416
T type
Definition: Meta.h:126
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:103
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:102
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:117
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:116
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:130
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:129
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:174
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:173
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:150
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:149
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:89
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:91
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:186
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:185
ResultType::RealScalar RealScalar
Definition: SparseSparseProductWithPruning.h:161
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
Definition: SparseSparseProductWithPruning.h:162
Definition: SparseSparseProductWithPruning.h:84