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();
42 Index estimated_nnz_prod = lhs.nonZeros() + rhs.nonZeros();
45 if(ResultType::IsRowMajor)
46 res.resize(cols, rows);
48 res.resize(rows, cols);
50 res.reserve(estimated_nnz_prod);
51 double ratioColRes = double(estimated_nnz_prod)/double(lhs.rows()*rhs.cols());
52 for (Index j=0; j<cols; ++j)
57 tempVector.init(ratioColRes);
59 for (
typename Rhs::InnerIterator rhsIt(rhs, j); rhsIt; ++rhsIt)
63 Scalar x = rhsIt.value();
64 for (
typename Lhs::InnerIterator lhsIt(lhs, rhsIt.index()); lhsIt; ++lhsIt)
66 tempVector.coeffRef(lhsIt.index()) += lhsIt.value() * x;
71 res.insertBackByOuterInner(j,it.index()) = it.value();
76 template<
typename Lhs,
typename Rhs,
typename ResultType,
82 template<
typename Lhs,
typename Rhs,
typename ResultType>
88 static void run(
const Lhs& lhs,
const Rhs&
rhs, ResultType& res,
const RealScalar& tolerance)
91 internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,ResultType>(lhs,
rhs, _res, tolerance);
96 template<
typename Lhs,
typename Rhs,
typename ResultType>
100 static void run(
const Lhs& lhs,
const Rhs&
rhs, ResultType& res,
const RealScalar& tolerance)
104 SparseTemporaryType _res(res.rows(), res.cols());
105 internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,SparseTemporaryType>(lhs,
rhs, _res, tolerance);
110 template<
typename Lhs,
typename Rhs,
typename ResultType>
114 static void run(
const Lhs& lhs,
const Rhs&
rhs, ResultType& res,
const RealScalar& tolerance)
118 internal::sparse_sparse_product_with_pruning_impl<Rhs,Lhs,ResultType>(
rhs, lhs, _res, tolerance);
123 template<
typename Lhs,
typename Rhs,
typename ResultType>
127 static void run(
const Lhs& lhs,
const Rhs&
rhs, ResultType& res,
const RealScalar& tolerance)
130 ColMajorMatrix colLhs(lhs);
131 ColMajorMatrix colRhs(rhs);
132 internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrix,ColMajorMatrix,ResultType>(colLhs, colRhs, res, tolerance);
149 #endif // EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H
A versatible sparse matrix representation.
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)
iterative scaling algorithm to equilibrate rows and column norms in matrices
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)
ResultType::RealScalar RealScalar
void rhs(const real_t *x, real_t *f)
traits< typename remove_all< Lhs >::type >::Scalar Scalar
ResultType::RealScalar RealScalar