22 const uint n = ioA.GetCols();
23 const uint m = ioB.GetCols();
31 memset(ipiv, 0, n *
sizeof(
int));
33 for (
uint i = 0; i < n; ++i)
36 uint pivot_row = i, pivot_col = i;
39 float largest_element = 0.0f;
40 for (
uint j = 0; j < n; ++j)
42 for (
uint k = 0; k < n; ++k)
46 float element = abs(ioA(j, k));
47 if (element >= largest_element)
49 largest_element = element;
64 if (pivot_row != pivot_col)
66 for (
uint j = 0; j < n; ++j)
67 std::swap(ioA(pivot_row, j), ioA(pivot_col, j));
68 for (
uint j = 0; j < m; ++j)
69 std::swap(ioB(pivot_row, j), ioB(pivot_col, j));
73 float diagonal_element = ioA(pivot_col, pivot_col);
74 if (abs(diagonal_element) < inTolerance)
78 for (
uint j = 0; j < n; ++j)
79 ioA(pivot_col, j) /= diagonal_element;
80 for (
uint j = 0; j < m; ++j)
81 ioB(pivot_col, j) /= diagonal_element;
82 ioA(pivot_col, pivot_col) = 1.0f;
86 for (
uint j = 0; j < n; ++j)
89 float element = ioA(j, pivot_col);
90 for (
uint k = 0; k < n; ++k)
91 ioA(j, k) -= ioA(pivot_col, k) * element;
92 for (
uint k = 0; k < m; ++k)
93 ioB(j, k) -= ioB(pivot_col, k) * element;
94 ioA(j, pivot_col) = 0.0f;
JPH_NAMESPACE_BEGIN bool GaussianElimination(MatrixA &ioA, MatrixB &ioB, float inTolerance=1.0e-16f)
Definition GaussianElimination.h:19