Hi,
Could you help to decrease time of prod when I use the typedef defined in the code below?
#include <boost/timer.hpp>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...
#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;
}