31 #define INIT_CHRONO(name) \ 32 struct timeval t0##_##name, t1##_##name; \ 34 #define START_CHRONO(name) \ 35 gettimeofday(&t0##_##name, NULL); \ 36 sotDEBUG(25) << "t0 " << #name << ": " << t0##_##name.tv_sec << " - " \ 37 << t0##_##name.tv_usec << std::endl 38 #define STOP_CHRONO(name, commentaire) \ 39 gettimeofday(&t1##_##name, NULL); \ 40 dt##_##name = ((double)(t1##_##name.tv_sec - t0##_##name.tv_sec) * 1000. + \ 41 (double)(t1##_##name.tv_usec - t0##_##name.tv_usec) / 1000.); \ 42 sotDEBUG(25) << "t1 " << #name << ": " << t1##_##name.tv_sec << " - " \ 43 << t1##_##name.tv_usec << std::endl; \ 44 sotDEBUG(1) << "Time spent " << #name " " commentaire << " = " \ 45 << dt##_##name << std::endl 127 int main(
int argc,
char **argv) {
133 if (argc > 1) r = atoi(argv[1]);
135 if (argc > 2) c = atoi(argv[2]);
136 static const int BENCH = 100;
144 unsigned int nbzeros = 0;
145 for (
unsigned int j = 0; j <
c; ++j) {
146 if ((
rand() + 1.) / RAND_MAX > .8) {
147 for (
unsigned int i = 0;
i <
r; ++
i) M(
i, j) = 0.;
150 for (
unsigned int i = 0;
i <
r; ++
i)
151 M(
i, j) = (
rand() + 1.) / RAND_MAX * 2 - 1;
153 for (
unsigned int i = 0;
i <
r; ++
i)
154 for (
unsigned int j = 0; j <
c; ++j)
158 sotDEBUG(15) <<
"M1 = " << M1 << endl;
159 sotDEBUG(5) <<
"Nb zeros = " << nbzeros << endl;
166 sotDEBUG(15) <<
"Minv = " << Minv << endl;
171 cout << dt_inv << endl;
195 std::list<unsigned int> nonzeros;
198 for (
int ib = 0; ib < BENCH; ++ib) {
200 unsigned int parc = 0;
203 for (
unsigned int j = 0; j <
c; ++j) {
205 for (
unsigned int i = 0;
i <
r; ++
i) sumsq += M(
i, j) * M(
i, j);
207 nonzeros.push_back(j);
212 Mcreuse.resize(r, parc);
218 for (std::list<unsigned int>::iterator iter = nonzeros.begin();
219 iter != nonzeros.end(); ++iter) {
220 for (
unsigned int i = 0;
i <
r; ++
i) {
221 Mcreuse(
i, parc) = M(
i, *iter);
227 Mcreuseinv.resize(Mcreuse.cols(),
r);
231 for (std::list<unsigned int>::iterator iter = nonzeros.begin();
232 iter != nonzeros.end(); ++iter) {
233 for (
unsigned int i = 0;
i <
r; ++
i) Minv(*iter,
i) = Mcreuseinv(parc,
i);
251 unsigned int parc = 0;
252 for (
unsigned int j = 0; j <
c; ++j) {
254 for (
unsigned int i = 0;
i <
r; ++
i) sumsq += M(
i, j) * M(
i, j);
256 nonzeros.push_back(j);
263 for (std::list<unsigned int>::iterator iter = nonzeros.begin();
264 iter != nonzeros.end(); ++iter) {
265 for (
unsigned int i = 0;
i <
r; ++
i) {
266 Mcreuse(
i, parc) = M(
i, *iter);
273 for (
int ib = 0; ib < BENCH; ++ib) {
280 for (std::list<unsigned int>::iterator iter = nonzeros.begin();
281 iter != nonzeros.end(); ++iter) {
282 for (
unsigned int i = 0;
i <
r; ++
i) Minv(*iter,
i) = Mcreuseinv(parc,
i);
#define INIT_CHRONO(name)
#define sotDEBUG_ENABLE(level)
#define START_CHRONO(name)
#define STOP_CHRONO(name, commentaire)
static void openFile(const char *filename=DEBUG_FILENAME_DEFAULT)
void pseudoInverse(Matrix &_inputMatrix, Matrix &_inverseMatrix, const double threshold=1e-6)
int main(int argc, char **argv)