Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
dot product profiling, see bottom of file for execution speeds
#include "include/eigen/dense"
int main() {
const unsigned max = 86800;
// long double v[max][2];
// long double d[2] = {3.14159e5, 82.31283e3};
Eigen::Matrix<long double, 2, 1> v[max];
Eigen::Matrix<long double, 2, 1> d;
d(0,0) = 3.14159e5;
d(1,0) = 82.31283e3;
unsigned n, i;
n=0;
while (n != max){
v[n](0,0) = 3452.2;
v[n++](1,0) = 3.1e2;
}
long double e;
for(i=0; i<100; ++i) {
n=0;
while (n != max) {
e = v[++n].dot(d);
}
}
return 0;
}
//this completed in ~4.045s
//#include "include/eigen/dense"
int main() {
const unsigned max = 86800;
long double v[max][2];
long double d[2] = {3.14159e5, 82.31283e3};
// Eigen::Matrix<long double, 2, 1> v[max];
// Eigen::Matrix<long double, 2, 1> d;
// d(0,0) = 3.14159e5;
// d(1,0) = 82.31283e3;
unsigned n, i;
n=0;
while (n != max){//initialize array of 2D arrays
v[n][0] = 3452.2;
v[n++][1] = 3.1e2;
}
long double e; //scalar to assign dot product to
for(i=0; i<100; ++i) {//find dot product of vector 'n' with vector 'd', 100x
n=0;
while (n != max) {
e = v[n][0] * d[0] + v[n][1] * d[1];
++n;
}
}
return 0;
}
//this completed in ~0.110s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.