Timings on dot products of random vectors.
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);
Vector<Field>::Dense v1 (n), v2 (n);
Vector<Field>::SparseSeq v3;
Vector<Field>::SparsePar v4;
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;
}
Random dense vector stream.
Definition stream.h:229
Random sparse vector stream.
Definition stream.h:326
int main()
no command line args
Definition ex-fields-archetype.C:70
linbox base configuration file
A Givaro::Modular ring is a representations of Z/mZ.
Namespace in which all linbox code resides.
Definition alt-blackbox-block-container.h:4
Generation of sequences of random vectors.