10 #ifndef EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H 11 #define EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H 19 template<
typename Lhs,
typename Rhs,
typename ResultType>
28 Index rows = lhs.innerSize();
29 Index cols = rhs.outerSize();
37 if(ResultType::IsRowMajor)
38 res.resize(cols, rows);
40 res.resize(rows, cols);
51 Index estimated_nnz_prod = lhsEval.nonZerosEstimate() + rhsEval.nonZerosEstimate();
53 res.reserve(estimated_nnz_prod);
54 double ratioColRes = double(estimated_nnz_prod)/(double(lhs.rows())*
double(rhs.cols()));
55 for (
Index j=0; j<cols; ++j)
60 tempVector.init(ratioColRes);
66 Scalar x = rhsIt.value();
69 tempVector.coeffRef(lhsIt.index()) += lhsIt.value() * x;
74 res.insertBackByOuterInner(j,it.index()) = it.value();
79 template<
typename Lhs,
typename Rhs,
typename ResultType,
85 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);
198 #endif // EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H
A versatible sparse matrix representation.
ResultType::RealScalar RealScalar
ResultType::RealScalar RealScalar
static void sparse_sparse_product_with_pruning_impl(const Lhs &lhs, const Rhs &rhs, ResultType &res, const typename ResultType::RealScalar &tolerance)
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
ResultType::RealScalar RealScalar
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
const unsigned int RowMajorBit
ResultType::RealScalar RealScalar
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
ResultType::RealScalar RealScalar
ResultType::RealScalar RealScalar
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
traits< typename remove_all< Lhs >::type >::Scalar Scalar
ResultType::RealScalar RealScalar
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
ResultType::RealScalar RealScalar