Boost logo

Ublas :

From: Brian Budge (brian.budge_at_[hidden])
Date: 2006-08-18 12:59:50


One more note that I don't think anyone has touched on yet:

Why in the world are you using a sparse matrix on a 3x3? Unless you
have a very large data type (ie. not double), you'll almost definitely
see no gain from using a sparse representation, and it will be much
slower.

Ublas matrices are already much slower than other matrix libraries for
small fixed sizes (see many other threads about this), and your adding
sparsity on top of that, which will kill any remaining performance
cases.

Lastly, I believe you should (if you're not already doing so) compile
with -DNDEBUG.

  Brian

On 8/16/06, nobody <rrossi_at_[hidden]> wrote:
>
>
>
> Hi, i am not sure about how to improve the speed for your product (maybe
> defining a specialized axpy_prod), however the times you are speaking about
> are far too low for any comparison. Try to run the same example but so to
> have a total time of at least 1sec (better 10secs)
>
> greetings
>
> Riccardo
>
> On Wed, 16 Aug 2006 16:18:05 -0300, Fred wrote
>
> > Hi,
> >
> > Could you help to decrease time of prod when I use the typedef defined in
> the code below?
> >
> >
>
>
>
> #include <boost/timer.hpp>
> > #include <boost/numeric/ublas/matrix.hpp>
> > #include <boost/numeric/ublas/matrix_sparse.hpp>
> > #include <boost/numeric/ublas/matrix_proxy.hpp>
> > #include <boost/numeric/ublas/vector_sparse.hpp>
> > #include <boost/numeric/ublas/vector_proxy.hpp>
> > #include <boost/numeric/ublas/vector_of_vector.hpp>
> > #include <boost/numeric/ublas/operation.hpp>
> > #include <boost/numeric/ublas/io.hpp>
> >
> > int main () {
> > using namespace boost::numeric::ublas;
> >
> > typedef generalized_vector_of_vector< double, row_major,
> > boost::numeric::ublas::vector< compressed_vector<double> > >
> matrix;
> > typedef compressed_vector<double> vec_d;
> >
> > // typedef matrix<double> matrix;
> > // typedef vector<double> vec_d;
> >
> > boost::timer t1;
> > double t_final;
> >
> > matrix m(3,3);
> > vec_d v(3);
> > vec_d result;
> > for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
> > for (unsigned j = 0; j < m.size2 (); ++ j)
> > m (i, j) = 3 * i + j;
> > v (i) = i;
> > }
> >
> > std::cout << m << std::endl;
> > std::cout << v << std::endl;
> >
> > int counter = 0;
> > for(int n=0; n<20 ; ++n)
> > {
> > for(int i=0; i<200 ; ++i)
> > {
> > t1.restart();
> > result = prod(m, v);
> > t_final = t1.elapsed();
> >
> > if (t_final > 0.01)
> > {
> > std::cout << "time = " << t_final << std::endl;
> > counter++;
> > }
> > }
> > }
> > std::cout << "counter = " << counter << std::endl;
> > }
> > I don't understand why prod spends "0 sec" in some iterations and " 0.016
> sec" (in my computer) if variables are always the same...
> >
> > Thank you for your time!
> >
> > Frederico B. Teixeira
> > ---
> > UFMG, Brazil
> >
>
>
> --
> Open WebMail Project (http://openwebmail.org)
>
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>
>
>