test_matrix.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 /* -------------------------------------------------------------------------- */
11 /* --- INCLUDES ------------------------------------------------------------- */
12 /* -------------------------------------------------------------------------- */
13 
15 
16 #include <iostream>
17 #include <sot/core/debug.hh>
19 using namespace std;
20 
21 #include <sot/core/sot.hh>
22 
23 #ifndef WIN32
24 #include <sys/time.h>
25 #else /*WIN32*/
27 #endif /*WIN32*/
28 
29 #define sotCHRONO1 \
30  gettimeofday(&t1, NULL); \
31  dt = ((t1.tv_sec - t0.tv_sec) * 1000. + \
32  (t1.tv_usec - t0.tv_usec + 0.) / 1000.); \
33  cout << "dt: " << dt
34 
35 int main(int, char **) {
36  sotDEBUGIN(15);
37 
38  struct timeval t0, t1;
39  double dt;
40 
41  dynamicgraph::Matrix P(40, 40);
42  dynamicgraph::Matrix J(6, 40);
43  dynamicgraph::Matrix JK(6, 40);
44  for (int i = 0; i < 40; ++i)
45  for (int j = 0; j < 40; ++j) P(i, j) = (rand() + 1.) / RAND_MAX;
46  for (int i = 0; i < J.rows(); ++i)
47  for (int j = 0; j < J.cols(); ++j) J(i, j) = (rand() + 1.) / RAND_MAX;
48 
49  int nbIter = 100000;
50  dt = 0;
51  gettimeofday(&t0, NULL);
52  for (int iter = 0; iter < nbIter; ++iter) {
53  gettimeofday(&t0, NULL);
54  // J.multiply(P,JK);
55  // prod(J.matrix,P.matrix,JK.matrix);
56  JK = J * P;
57  gettimeofday(&t1, NULL);
58  dt += ((double)(t1.tv_sec - t0.tv_sec) +
59  (double)(t1.tv_usec - t0.tv_usec) / 1000. / 1000.);
60  }
61  // sotCHRONO1 <<endl;
62  cout << dt / nbIter << endl;
63 
64  sotDEBUGOUT(15);
65  return 0;
66 }
utils-windows.hh
main
int main(int, char **)
Definition: test_matrix.cpp:35
J
J
i
int i
dynamicgraph::Matrix
Eigen::MatrixXd Matrix
feature-abstract.hh
debug.hh
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition: debug.hh:215
P
P
sot.hh
sotDEBUGIN
#define sotDEBUGIN(level)
Definition: debug.hh:214
linear-algebra.h
dynamicgraph::sot::double
double
Definition: fir-filter.cpp:49
test-parameter-server.dt
float dt
Definition: test-parameter-server.py:14
rand
def rand(n)


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:32