Created
December 12, 2012 04:22
-
-
Save pmelanson/4264844 to your computer and use it in GitHub Desktop.
dot product profiling, see bottom of file for execution speeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#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