Boost logo

Ublas :

From: Sourabh (sourabh_at_[hidden])
Date: 2007-03-06 23:03:56


#include <boost/timer.hpp>

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/operation.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>

#include "../matrix/config.h"

using namespace boost::numeric::ublas;

vector<double> othervector (20000);

void FillPathIncidenceVector (compressed_vector<double>& pathgatevector)
{
    unsigned factor = 20;
    for (unsigned i = 0; i < pathgatevector.size (); ++ i) {
        if (i % factor == 0) {
            pathgatevector(i) = i;
        }
    }
    for (unsigned i = 0; i < othervector.size (); ++i) {
        othervector (i) = i * 0.1;

    }

}

void
FillOmegas (vector<double>& omegas, compressed_vector<double>& pathgatevector)
{
    omegas.resize ((pathgatevector.nnz ()));
    compressed_vector<double>::const_iterator it = pathgatevector.begin ();
    for (unsigned i = 0; it != pathgatevector.end (); ++it, ++i) {
        omegas (i) = othervector(it.index ());
        //omegas (i) = it.index ();
       //<< choice between the above two statements.>>
        }

}

int main ( int argc, char* argv[])
{
    int iterations = atoi (argv[1]);
    int gatesperpath = atoi (argv[2]);
    boost::timer t;
    t.restart();
    compressed_vector<double> pathgatevector (gatesperpath * 20);
    FillPathIncidenceVector (pathgatevector);
    std::cout << t.elapsed () << std::endl;
    vector<double>omega;
    while (iterations--) {
        FillOmegas (omega, pathgatevector);
    }
    std::cout << t.elapsed() << std::endl;
}

On Tue, 6 Mar 2007, Gunter Winkler wrote:

> On Tuesday 06 March 2007 13:58, Sourabh wrote:
>
> > > > Just a strange thing, if I change the statement
> > > > densevector (i) = othervector (it.index ());
> > > >
> > > > to
> > > >
> > > > densevector (i) = (it.index ());
> > > >
> > > > time taken is increased. What could be the possible reason ?
>
> can you post a program that shows that behavior?
>
> mfg
> Gunter
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>

-- 
-- Sourabh