Boost logo

Ublas :

From: Jeronimo Pellegrini (pellegrini_at_[hidden])
Date: 2006-06-28 08:11:51


Hello.

What is the best way to implement a three-dimensional sparse matrix
of doubles using uBLAS? I need fast access, but insertion can be
slow.

I tried something simlar to this:

#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>

#define cvector boost::numeric::ublas::compressed_vector
#define cmatrix boost::numeric::ublas::compressed_matrix

int main(void) {
        cmatrix<cvector<double> > m;
        m.resize(10,10);
        m(0,0).resize(3);
        m(0,0)(0) = 5.5;
}

But it doesn't compile because the return value when I get an element
from the matrix "m(0,0)" doesn't seem to be a "cvector<double>":

test.cpp:11: error: 'class boost::numeric::ublas::sparse_matrix_element<boost::numeric::ublas::compressed_matrix<boost::numeric::ublas::compressed_vector<double, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, boost::numeric::ublas::basic_row_major<unsigned int, int>, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<boost::numeric::ublas::compressed_vector<double, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, std::allocator<boost::numeric::ublas::compressed_vector<double, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > > > > >' has no member named 'resize'
test.cpp:13: error: no match for call to '(boost::numeric::ublas::sparse_matrix_element<boost::numeric::ublas::compressed_matrix<boost::numeric::ublas::compressed_vector<double, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, boost::numeric::ublas::basic_row_major<unsigned int, int>, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<boost::numeric::ublas::compressed_vector<double, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, std::allocator<boost::numeric::ublas::compressed_vector<double, 0u, boost::numeric::ublas::unbounded_array<unsigned int, std::allocator<unsigned int> >, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > > > > >) (int)'

This is with the uBLAS in Debian unstable (libboost-dev 1.33.1-4)

Also tried cvector<cvector<cvector<double> > >, and got similar
problems.

Is there a simple way to use three-dimensional sparse matrices with uBLAS?
(With slow insertion/fast access?)

Thanks a lot,
J.