20 #include "grass/N_pde.h"
21 #include "grass/gmath.h"
186 "Allocate memory for a sparse linear equation system with %i rows\n",
190 "Allocate memory for a regular linear equation system with %i rows\n",
196 les->
x = (
double *)G_calloc(cols,
sizeof(
double));
197 for (i = 0; i <
cols; i++)
203 les->
b = (
double *)G_calloc(cols,
sizeof(
double));
204 for (i = 0; i <
cols; i++)
258 for (i = 0; i < les->
rows; i++) {
259 for (j = 0; j < les->
cols; j++) {
261 for (k = 0; k < les->
Asp[i]->cols; k++) {
262 if (les->
Asp[i]->index[k] == j) {
263 fprintf(stdout,
"%4.5f ", les->
Asp[i]->values[k]);
268 fprintf(stdout,
"%4.5f ", 0.0);
271 fprintf(stdout,
" * %4.5f", les->
x[i]);
273 fprintf(stdout,
" = %4.5f ", les->
b[i]);
275 fprintf(stdout,
"\n");
280 for (i = 0; i < les->
rows; i++) {
281 for (j = 0; j < les->
cols; j++) {
282 fprintf(stdout,
"%4.5f ", les->
A[i][j]);
285 fprintf(stdout,
" * %4.5f", les->
x[i]);
287 fprintf(stdout,
" = %4.5f ", les->
b[i]);
289 fprintf(stdout,
"\n");
309 G_debug(2,
"Releasing memory of a sparse linear equation system\n");
311 G_debug(2,
"Releasing memory of a regular linear equation system\n");
N_les * N_alloc_nquad_les_Ax(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A and vector x...
void G_free(void *buf)
Free allocated memory.
N_les * N_alloc_nquad_les(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A...
N_les * N_alloc_les_Ax_b(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A, vector x and vector b.
double ** G_alloc_matrix(int rows, int cols)
Matrix memory allocation.
N_les * N_alloc_les(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A, vector x and vector b.
N_les * N_alloc_nquad_les_A(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A...
G_math_spvector ** G_math_alloc_spmatrix(int rows)
Allocate memory for a sparse matrix.
void G_free_matrix(double **m)
Matrix memory deallocation.
void G_math_free_spmatrix(G_math_spvector **spmatrix, int rows)
Release the memory of the sparse matrix.
N_les * N_alloc_les_param(int cols, int rows, int type, int parts)
Allocate memory for a quadratic or not quadratic linear equation system.
N_les * N_alloc_les_A(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A.
N_les * N_alloc_nquad_les_Ax_b(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A...
int G_debug(int level, const char *msg,...)
Print debugging message.
N_les * N_alloc_les_Ax(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A and vector x...
void N_free_les(N_les *les)
Release the memory of the linear equation system.
The linear equation system (les) structure.
void N_print_les(N_les *les)
prints the linear equation system to stdout