|
Ublas : |
Subject: Re: [ublas] a problem with compressed matrices
From: Ungermann, Jörn (j.ungermann_at_[hidden])
Date: 2011-08-22 07:36:28
Dear Tarek(?),
matrix-matrix multiplication is currently not optimized. I supplied some
patches to remedy this, but they haven't been looked at, yet.
There is even a further product, you might want to look at "sparse_prod".
All three functions - prod, axpy_prod and sparse_prod - use different
algorithms for performing the multiplication, the performance of which
heavily depends on the type of supplied matrices (especially
compressed/dense and majority).
I try out these algorithms and some improved versions of mine in an older
email of mine at
http://lists.boost.org/MailArchives/ublas/2010/03/4091.php
My results showed that axpy_prod should be faster than prod, but I didn't
look at *completely* empty matrices.
In the end, you need to try these functions for real data and see, what
works best.
In the end, it is doubtful, if it is sensible to calculate such a product
between compressed_matrices naively; writing out the results into a
non-initialized compressed_matrix is ridiculously expensive, either way,
unless you have *very* sparse matrices. Usually it is best to either
manually compute the product using a priori information about the structure
of the result, or at least determine that structure in a first step to
initialize that matrix before computing the product.
Regards,
Joern
> -----Original Message-----
> From: ublas-bounces_at_[hidden] [mailto:ublas-
> bounces_at_[hidden]] On Behalf Of Tarek
> Sent: Samstag, 20. August 2011 16:27
> To: ublas_at_[hidden]
> Subject: [ublas] a problem with compressed matrices
>
> I noticed that the function axpy_prod() in ublas has a problem when
> used in
> release mode with compressed sparse matrices, see yourself:
>
> #define BOOST_UBLAS_NDEBUG
> #include <boost/numeric/ublas/matrix_sparse.hpp>
> #include <boost/numeric/ublas/operation.hpp>
>
> namespace ublas = boost::numeric::ublas;
> #include <boost/timer.hpp>
> int main()
> {
> boost::timer t;
> t.restart();
>
> ublas::compressed_matrix<double> m1(700,700,0);
> ublas::compressed_matrix<double> m2(700,700,0);
> ublas::compressed_matrix<double> r(700,700,0);
> //r= prod(m1,m2);
> ublas::axpy_prod(m1,m2,r,true);
> std::cout << "Matrix mult. took " <<t.elapsed()<< "
> s" << std::endl;
>
> return 0;
> }
>
>
> The error I get in Xcode is: error: invalid use of incomplete type
> 'struct
> boost::numeric::ublas::zero_matrix >'
>
> I noticed also that prod() is faster than axpy_prod for both dense and
> sparse matrices contrary to what is advertised!! You can check that too
> in
> the same code. Actually it seems to me that the matrix is not treated
> as
> sparse at all, since multiplication of all-zero sparse matrices should
> take
> no time. In debug mode, it takes 20 second on my computer !!
>
> --
> View this message in context: http://boost.2283326.n4.nabble.com/a-
> problem-with-compressed-matrices-tp3757133p3757133.html
> Sent from the Boost - uBLAS mailing list archive at Nabble.com.
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: j.ungermann_at_[hidden]