handy macro
parent
e0e3875ff9
commit
ad0212354c
|
@ -23,74 +23,30 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
|
||||||
|
#define TEST(TITLE,STATEMENT) \
|
||||||
|
cout << TITLE << endl;\
|
||||||
|
timeLog = clock();\
|
||||||
|
for(int i = 0; i < n; i++)\
|
||||||
|
STATEMENT;\
|
||||||
|
timeLog2 = clock();\
|
||||||
|
seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;\
|
||||||
|
cout << seconds << " seconds" << endl;\
|
||||||
|
cout << ((double)n/seconds) << " calls/second" << endl;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int n = 300000;
|
int n = 300000; long timeLog, timeLog2; double seconds;
|
||||||
Vector v = Vector_(3,1.,0.,0.);
|
Vector v = Vector_(3,1.0,0.0,0.0);//0.1,0.2,-0.1);
|
||||||
Rot3 R = Rot3::rodriguez(0.1, 0.4, 0.2);
|
Rot3 R = Rot3::rodriguez(0.1, 0.4, 0.2), R2 = R.retract(v);
|
||||||
|
|
||||||
cout << "Rodriguez formula given axis angle" << endl;
|
TEST("Rodriguez formula given axis angle", Rot3::rodriguez(v,0.001))
|
||||||
long timeLog = clock();
|
TEST("Rodriguez formula given canonical coordinates", Rot3::rodriguez(v))
|
||||||
for(int i = 0; i < n; i++)
|
TEST("Expmap", R*Rot3::Expmap(v))
|
||||||
Rot3::rodriguez(v,0.001);
|
TEST("Logmap", Rot3::Logmap(R))
|
||||||
long timeLog2 = clock();
|
TEST("Retract", R.retract(v))
|
||||||
double seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
|
TEST("localCoordinates", R.localCoordinates(R2))
|
||||||
cout << seconds << " seconds" << endl;
|
TEST("Slow rotation matrix",Rot3::Rz(0.3)*Rot3::Ry(0.2)*Rot3::Rx(0.1))
|
||||||
cout << ((double)n/seconds) << " calls/second" << endl;
|
TEST("Fast Rotation matrix", Rot3::RzRyRx(0.1,0.2,0.3))
|
||||||
|
|
||||||
cout << "Rodriguez formula given canonical coordinates" << endl;
|
|
||||||
timeLog = clock();
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
Rot3::rodriguez(v);
|
|
||||||
timeLog2 = clock();
|
|
||||||
seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
|
|
||||||
cout << seconds << " seconds" << endl;
|
|
||||||
cout << ((double)n/seconds) << " calls/second" << endl;
|
|
||||||
|
|
||||||
cout << "Expmap" << endl;
|
|
||||||
timeLog = clock();
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
R*Rot3::Expmap(v);
|
|
||||||
timeLog2 = clock();
|
|
||||||
seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
|
|
||||||
cout << seconds << " seconds" << endl;
|
|
||||||
cout << ((double)n/seconds) << " calls/second" << endl;
|
|
||||||
|
|
||||||
cout << "Retract" << endl;
|
|
||||||
timeLog = clock();
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
R.retract(v);
|
|
||||||
timeLog2 = clock();
|
|
||||||
seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
|
|
||||||
cout << seconds << " seconds" << endl;
|
|
||||||
cout << ((double)n/seconds) << " calls/second" << endl;
|
|
||||||
|
|
||||||
cout << "localCoordinates" << endl;
|
|
||||||
timeLog = clock();
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
R.localCoordinates(R);
|
|
||||||
timeLog2 = clock();
|
|
||||||
seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
|
|
||||||
cout << seconds << " seconds" << endl;
|
|
||||||
cout << ((double)n/seconds) << " calls/second" << endl;
|
|
||||||
|
|
||||||
cout << "Slow rotation matrix" << endl;
|
|
||||||
timeLog = clock();
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
Rot3::Rz(0.3)*Rot3::Ry(0.2)*Rot3::Rx(0.1);
|
|
||||||
timeLog2 = clock();
|
|
||||||
seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
|
|
||||||
cout << seconds << " seconds" << endl;
|
|
||||||
cout << ((double)n/seconds) << " calls/second" << endl;
|
|
||||||
|
|
||||||
cout << "Fast Rotation matrix" << endl;
|
|
||||||
timeLog = clock();
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
Rot3::RzRyRx(0.1,0.2,0.3);
|
|
||||||
timeLog2 = clock();
|
|
||||||
seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
|
|
||||||
cout << seconds << " seconds" << endl;
|
|
||||||
cout << ((double)n/seconds) << " calls/second" << endl;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue