27 #define COMP_PIVOT 100
44 G_message(
_(
"Starting direct gauss elimination solver"));
72 G_message(
_(
"Starting direct lu decomposition solver"));
82 #pragma omp for schedule(static) private(i)
83 for (i = 0; i < rows; i++) {
93 #pragma omp for schedule(static) private(i)
94 for (i = 0; i < rows; i++) {
128 G_message(
_(
"Starting cholesky decomposition solver"));
131 G_warning(
_(
"Unable to solve the linear equation system"));
159 for (k = 0; k < rows - 1; k++) {
160 #pragma omp parallel for schedule(static) private(i, j, tmpval) \
161 shared(k, A, b, rows)
162 for (i = k + 1; i < rows; i++) {
163 tmpval = A[i][k] / A[k][k];
164 b[i] =
b[i] - tmpval *
b[k];
165 for (j = k + 1; j < rows; j++) {
166 A[i][j] = A[i][j] - tmpval * A[k][j];
191 for (k = 0; k < rows - 1; k++) {
192 #pragma omp parallel for schedule(static) private(i, j) shared(k, A, rows)
193 for (i = k + 1; i < rows; i++) {
194 A[i][k] = A[i][k] / A[k][k];
195 for (j = k + 1; j < rows; j++) {
196 A[i][j] = A[i][j] - A[i][k] * A[k][j];
220 int i = 0, j = 0, k = 0;
233 for (k = 0; k < rows; k++) {
234 #pragma omp parallel for schedule(static) private(i, j, sum_2) shared(A, k) \
236 for (j = 0; j < k; j++) {
237 sum_1 += A[k][j] * A[k][j];
240 if (0 > (A[k][k] - sum_1)) {
241 G_warning(
"Matrix is not positive definite. break.");
244 A[k][k] = sqrt(A[k][k] - sum_1);
247 if ((k + bandwidth) > rows) {
251 colsize = k + bandwidth;
254 #pragma omp parallel for schedule(static) private(i, j, sum_2) \
255 shared(A, k, sum_1, colsize)
257 for (i = k + 1; i < colsize; i++) {
259 for (j = 0; j < k; j++) {
260 sum_2 += A[i][j] * A[k][j];
262 A[i][k] = (A[i][k] - sum_2) / A[k][k];
266 #pragma omp parallel for schedule(static) private(i, k) shared(A, rows)
267 for (k = 0; k < rows; k++) {
268 for (i = k + 1; i < rows; i++) {
290 for (i = rows - 1; i >= 0; i--) {
291 for (j = i + 1; j < rows; j++) {
292 b[i] =
b[i] - A[i][j] *
x[j];
294 x[i] = (
b[i]) / A[i][i];
316 for (i = 0; i < rows; i++) {
318 for (j = 0; j < i; j++) {
319 tmpval += A[i][j] *
x[j];
321 x[i] = (
b[i] - tmpval) / A[i][i];
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
void G_message(const char *,...) __attribute__((format(printf
double * G_alloc_vector(size_t)
Vector matrix memory allocation.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
int G_math_solver_lu(double **A, double *x, double *b, int rows)
The LU solver for quardatic matrices.
void G_math_lu_decomposition(double **A, double *b UNUSED, int rows)
lu decomposition
int G_math_solver_gauss(double **A, double *x, double *b, int rows)
The gauss elimination solver for quardatic matrices.
void G_math_forward_substitution(double **A, double *x, double *b, int rows)
forward substitution
int G_math_solver_cholesky(double **A, double *x, double *b, int bandwidth, int rows)
The choleksy decomposition solver for quardatic, symmetric positive definite matrices.
void G_math_backward_substitution(double **A, double *x, double *b, int rows)
backward substitution
void G_math_gauss_elimination(double **A, double *b, int rows)
Gauss elimination.
int G_math_cholesky_decomposition(double **A, int rows, int bandwidth)
cholesky decomposition for symmetric, positive definite matrices with bandwidth optimization