[cleanup] I revert the sort call to QuickSort again since it's faster on my machine.

This commit is contained in:
Robert K 2014-12-05 14:48:16 +01:00
parent 1cd3dcadc6
commit 230447bea0

View File

@ -59,9 +59,9 @@ struct QuickSort< 0 >
template<typename Lhs, typename Rhs, typename ResultType> template<typename Lhs, typename Rhs, typename ResultType>
void fastSparseProduct(const Lhs& lhs, const Rhs& rhs, ResultType& res) void fastSparseProduct(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{ {
using namespace Eigen; // initialize result
typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix; res = ResultType(lhs.rows(), rhs.cols());
res = ColMajorMatrix(lhs.rows(), rhs.cols());
// if one of the matrices does not contain non zero elements // if one of the matrices does not contain non zero elements
// the result will only contain an empty matrix // the result will only contain an empty matrix
if( lhs.nonZeros() == 0 || rhs.nonZeros() == 0 ) if( lhs.nonZeros() == 0 || rhs.nonZeros() == 0 )
@ -76,8 +76,8 @@ void fastSparseProduct(const Lhs& lhs, const Rhs& rhs, ResultType& res)
eigen_assert(lhs.outerSize() == rhs.innerSize()); eigen_assert(lhs.outerSize() == rhs.innerSize());
std::vector<bool> mask(rows,false); std::vector<bool> mask(rows,false);
Matrix<Scalar,Dynamic,1> values(rows); Eigen::Matrix<Scalar,Eigen::Dynamic,1> values(rows);
Matrix<Index,Dynamic,1> indices(rows); Eigen::Matrix<Index, Eigen::Dynamic,1> indices(rows);
// estimate the number of non zero entries // estimate the number of non zero entries
// given a rhs column containing Y non zeros, we assume that the respective Y columns // given a rhs column containing Y non zeros, we assume that the respective Y columns
@ -122,8 +122,8 @@ void fastSparseProduct(const Lhs& lhs, const Rhs& rhs, ResultType& res)
if( nnz > 1 ) if( nnz > 1 )
{ {
// sort indices for sorted insertion to avoid later copying // sort indices for sorted insertion to avoid later copying
// QuickSort< 1 >::sort( indices.data(), indices.data()+nnz ); QuickSort< 1 >::sort( indices.data(), indices.data()+nnz );
std::sort( indices.data(), indices.data()+nnz ); //std::sort( indices.data(), indices.data()+nnz );
} }
res.startVec(j); res.startVec(j);