9 for (
int i=0; i<n; i++) {
11 for (
int j=0; j<i; j++) {
12 out[i] -= L[i][j]*out[j];
20 for (
int i=n-1; i>=0; i--) {
22 for (
int j=i+1; j<n; j++) {
23 out[i] -= U[i][j]*out[j];
35 for (i=0; i<n; i++) p[i] = i;
50 if ( !(fabs(m) > 0.0) ) {
51 printf(
"\nLINALG FAILURE: the matrix is singular\n\n");
72 A[j][k] -= A[j][i]*A[i][k];
76void ode_solve_LU (
double **LU,
int *p,
double *b,
int n,
double *out) {
103 double *c = T[0] + 1;
109 for (
int i=1; i<n; i++) {
111 z = b[i] - a[i-1]*temp[i];
112 out[i] = (r[i] - a[i-1]*out[i-1])/z;
114 for (
int i=n-2; i>=0; i--)
115 out[i] -= temp[i+1]*out[i+1];
void ode_solve_LU(double **LU, int *p, double *b, int n, double *out)
Solves a matrix equation where the matrix has already be crout LU decomposed.
void ode_back_sub(double **U, double *b, int n, double *out)
Backward substitution.
void ode_solve_A(double **A, double *b, int n, double *out)
Solves a matrix equation A x = b with crout LU decomposition.
void ode_crout_LU(double **A, int n, int *p)
Crout LU decomposition.
void ode_crout_forw_sub(double **L, double *b, int *p, int n, double *out)
Crout forward substitution.
void ode_solve_tridiag(double **T, double *r, double *temp, int n, double *out)
Solves a tridiagonal matrix equation.