| 1 | /* ---------------------------------------------------------------------------- |
| 2 | |
| 3 | * GTSAM Copyright 2010, Georgia Tech Research Corporation, |
| 4 | * Atlanta, Georgia 30332-0415 |
| 5 | * All Rights Reserved |
| 6 | * Authors: Frank Dellaert, et al. (see THANKS for the full author list) |
| 7 | |
| 8 | * See LICENSE for the license information |
| 9 | |
| 10 | * -------------------------------------------------------------------------- */ |
| 11 | |
| 12 | /** |
| 13 | * @file timeCholesky.cpp |
| 14 | * @brief time Cholesky factorization |
| 15 | * @author Frank Dellaert |
| 16 | * @date March 4, 2016 |
| 17 | */ |
| 18 | |
| 19 | #include <gtsam/base/cholesky.h> |
| 20 | |
| 21 | #include <time.h> |
| 22 | #include <iostream> |
| 23 | #include <iomanip> // std::setprecision |
| 24 | |
| 25 | using namespace std; |
| 26 | using namespace gtsam; |
| 27 | |
| 28 | //#define TERNARY |
| 29 | |
| 30 | int main() { |
| 31 | |
| 32 | Matrix top = (Matrix(7,7) << |
| 33 | 4.0375, 3.4584, 3.5735, 2.4815, 2.1471, 2.7400, 2.2063, |
| 34 | 0., 4.7267, 3.8423, 2.3624, 2.8091, 2.9579, 2.5914, |
| 35 | 0., 0., 5.1600, 2.0797, 3.4690, 3.2419, 2.9992, |
| 36 | 0., 0., 0., 1.8786, 1.0535, 1.4250, 1.3347, |
| 37 | 0., 0., 0., 0., 3.0788, 2.6283, 2.3791, |
| 38 | 0., 0., 0., 0., 0., 2.9227, 2.4056, |
| 39 | 0., 0., 0., 0., 0., 0., 2.5776).finished(); |
| 40 | |
| 41 | Matrix ABC(100,100); |
| 42 | ABC.topLeftCorner<7,7>() = top; |
| 43 | cout << setprecision(3); |
| 44 | |
| 45 | size_t n = 100000; |
| 46 | for (size_t nFrontal = 1; nFrontal <= 7; nFrontal++) { |
| 47 | auto timeLog = clock(); |
| 48 | for (size_t i = 0; i < n; i++) { |
| 49 | Matrix RSL(ABC); |
| 50 | choleskyPartial(ABC&: RSL, nFrontal); |
| 51 | } |
| 52 | auto timeLog2 = clock(); |
| 53 | auto seconds = (double)(timeLog2 - timeLog) / CLOCKS_PER_SEC; |
| 54 | cout << "partialCholesky " << nFrontal << ": " ; |
| 55 | auto ms = ((double)seconds * 1000000 / n); |
| 56 | cout << ms << " ms, " << ms/nFrontal << " ms/dim" << endl; |
| 57 | } |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |