public
Created

dot product profiling, see bottom of file for execution speeds

  • Download Gist
eigen profile.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#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
matrix profile.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
//#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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.