Timings on dot products of random vectors.
- Author
- Bradford Hovinen hovin.nosp@m.en@c.nosp@m.is.ud.nosp@m.el.e.nosp@m.du
Use of vectors meeting the LinBox dense and sparse vector archetypes is illustrated and their dot-product times are benchmarked.
Constructs random vectors and computes their dot product, giving the required time.
#include <iostream>
#include <linbox/vector/vector-domain.h>
typedef Givaro::Modular<uint32_t> Field;
int main (int argc, char **argv)
{
const int n = 10000000;
const double p = .001;
const int q = 32749;
commentator().
setMaxDepth (1);
commentator().
setReportStream (std::cout);
Field F (q); Field::RandIter gen(F);
factory1 >> v1 >> v2;
factory2 >> v3;
factory3 >> v4;
VectorDomain<Field> VD (F);
Field::Element res;
commentator().
start (
"dense/dense dot product (1)");
for (int i = 0; i < 1; i++)
VD.dot (res, v1, v2);
commentator().
stop (
"done");
commentator().
start (
"dense/sparse sequence dot product (1000)");
for (int i = 0; i < 1000; i++)
VD.dot (res, v1, v3);
commentator().
stop (
"done");
commentator().
start (
"dense/sparse parallel dot product (1000)");
for (int i = 0; i < 1000; i++)
VD.dot (res, v1, v4);
commentator().
stop (
"done");
return 0;
}