apparently recursive determinant calculation takes 300ms
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Marius Eggert 2023-02-24 10:22:33 +01:00
parent 36fe0921de
commit 22bac9e7c0

View File

@ -10,6 +10,8 @@
#include <iostream> #include <iostream>
#include "fsfw/timemanager/Stopwatch.h"
using namespace Math; using namespace Math;
template <typename T1, typename T2 = T1> template <typename T1, typename T2 = T1>
@ -300,6 +302,7 @@ class MathOperations {
} }
static float matrixDeterminant(const T1 *inputMatrix, uint8_t size) { static float matrixDeterminant(const T1 *inputMatrix, uint8_t size) {
/* do not use this. takes 300ms */
float det = 0; float det = 0;
T1 matrix[size][size], submatrix[size - 1][size - 1]; T1 matrix[size][size], submatrix[size - 1][size - 1];
for (uint8_t row = 0; row < size; row++) { for (uint8_t row = 0; row < size; row++) {
@ -329,9 +332,11 @@ class MathOperations {
} }
static int inverseMatrix(const T1 *inputMatrix, T1 *inverse, uint8_t size) { static int inverseMatrix(const T1 *inputMatrix, T1 *inverse, uint8_t size) {
if (MathOperations<T1>::matrixDeterminant(inputMatrix, size) == 0) { // Stopwatch stopwatch;
return 1; // Matrix is singular and not invertible // if (MathOperations<T1>::matrixDeterminant(inputMatrix, size) == 0) {
} // return 1; // Matrix is singular and not invertible
// }
// stopwatch.stop(true);
T1 matrix[size][size], identity[size][size]; T1 matrix[size][size], identity[size][size];
// reformat array to matrix // reformat array to matrix
for (uint8_t row = 0; row < size; row++) { for (uint8_t row = 0; row < size; row++) {