10 #ifndef EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H 11 #define EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H 19 template<
typename Lhs,
typename Rhs,
typename ResultType>
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()));
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);
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)
Namespace containing all symbols from the Eigen library.
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)
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
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)
NumTraits< Scalar >::Real RealScalar
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
ResultType::RealScalar RealScalar
static void run(const Lhs &lhs, const Rhs &rhs, ResultType &res, const RealScalar &tolerance)
ResultType::RealScalar RealScalar