43 for (k = n-1, U += n * (n - 1); k >= 0; U -= n, k--) {
44 if (*(U + k) == 0.0)
return -1;
46 for (i = k + 1; i < n; i++) x[k] -= x[i] * *(U + i);
94 for (k = 1, L += n; k < n; L += n, k++)
95 for (i = 0, x[k] = B[k]; i <
k; i++) x[k] -= x[i] * *(L + i);
156 float *p_k, *p_row, *p_col;
163 for (k = 0, p_k = A; k < n; p_k += n, k++) {
164 for (j = k; j < n; j++) {
165 for (p = 0, p_col = A; p <
k; p_col += n, p++)
166 *(p_k + j) -= *(p_k + p) * *(p_col + j);
168 if ( *(p_k + k) == 0.0 )
return -1;
169 for (i = k+1, p_row = p_k + n; i < n; p_row += n, i++) {
170 for (p = 0, p_col = A; p <
k; p_col += n, p++)
171 *(p_row + k) -= *(p_row + p) * *(p_col + k);
172 *(p_row +
k) /= *(p_k + k);
237 float resultColumn[4];
239 for (i = 0; i < 4; ++i)
243 if (res != 0)
return res;
244 for (j = 0; j < 4; ++j)
245 *(invA + i + j * 4) = resultColumn[j];
254 int fun(
float *
A,
float *invA,
float *b,
float *
x,
float *I)
258 if (res != 0)
return res;
265 if (res != 0)
return res;
int fun(float *A, float *invA, float *b, float *x, float *I)
int invertMatrix(float *LU, float *invA, float *I)
int Upper_Triangular_Solve(float *U, float B[], float x[], int n)
static const uint32_t k[]
x
Return the smallest n such that 2^n >= _x.
int Doolittle_LU_Decomposition(float *A, int n)
void Unit_Lower_Triangular_Solve(float *L, float B[], float x[], int n)
int Doolittle_LU_Solve(float *LU, float B[], float x[], int n)