aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/BenchSparseUtil.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-03-23 11:39:35 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-03-23 11:39:35 +0100
commit611fc1789434f6b335f42739ed0d99b39c686da1 (patch)
tree3270e6230468dfad9e4fe3dbee6a49cf1648755a /bench/BenchSparseUtil.h
parentec32d2c8079f2e52dc3f4503b32e76f4d0c9e88a (diff)
add support for ublas
Diffstat (limited to 'bench/BenchSparseUtil.h')
-rw-r--r--bench/BenchSparseUtil.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/bench/BenchSparseUtil.h b/bench/BenchSparseUtil.h
index ff836bffe..13981f6b7 100644
--- a/bench/BenchSparseUtil.h
+++ b/bench/BenchSparseUtil.h
@@ -26,7 +26,7 @@ typedef SparseMatrix<Scalar> EigenSparseMatrix;
void fillMatrix(float density, int rows, int cols, EigenSparseMatrix& dst)
{
- dst.reserve(rows*cols*density);
+ dst.reserve(double(rows)*cols*density);
for(int j = 0; j < cols; j++)
{
for(int i = 0; i < rows; i++)
@@ -122,22 +122,24 @@ void eiToCSparse(const EigenSparseMatrix& src, cs* &dst)
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/vector_of_vector.hpp>
#include <boost/numeric/ublas/operation.hpp>
-// #include <boost/numeric/ublas/sparse_prod.hpp>
-// using namespace boost;
-// using namespace boost::numeric;
-// using namespace boost::numeric::ublas;
+typedef boost::numeric::ublas::compressed_matrix<Scalar,boost::numeric::ublas::column_major> UBlasSparse;
-typedef boost::numeric::ublas::compressed_matrix<Scalar,boost::numeric::ublas::column_major> UblasMatrix;
-
-void eiToUblas(const EigenSparseMatrix& src, UblasMatrix& dst)
+void eiToUblas(const EigenSparseMatrix& src, UBlasSparse& dst)
{
+ dst.resize(src.rows(), src.cols(), false);
for (int j=0; j<src.cols(); ++j)
for (EigenSparseMatrix::InnerIterator it(src.derived(), j); it; ++it)
dst(it.index(),j) = it.value();
}
-
+template <typename EigenType, typename UblasType>
+void eiToUblasVec(const EigenType& src, UblasType& dst)
+{
+ dst.resize(src.size());
+ for (int j=0; j<src.size(); ++j)
+ dst[j] = src.coeff(j);
+}
#endif
#ifdef OSKI