19 #include "grass/N_pde.h"
33 G_debug(4,
"Allocate memory for a sparse vector with %i cols\n", cols);
38 spvector->
index = (
int *)G_calloc(cols,
sizeof(
int));
39 spvector->
values = (
double *)G_calloc(cols,
sizeof(
double));
205 "Allocate memory for a sparse linear equation system with %i rows\n",
209 "Allocate memory for a regular linear equation system with %i rows\n",
215 les->
x = (
double *)G_calloc(cols,
sizeof(
double));
216 for (i = 0; i <
cols; i++)
222 les->
b = (
double *)G_calloc(cols,
sizeof(
double));
223 for (i = 0; i <
cols; i++)
241 les->
A = (
double **)G_calloc(rows,
sizeof(
double *));
242 for (i = 0; i < rows; i++) {
243 les->
A[i] = (
double *)G_calloc(cols,
sizeof(
double));
271 if (les->
rows > row) {
273 "Add sparse vector %p to the sparse linear equation system at row %i\n",
275 les->
Asp[row] = spvector;
318 for (i = 0; i < les->
rows; i++) {
319 for (j = 0; j < les->
cols; j++) {
321 for (k = 0; k < les->
Asp[i]->
cols; k++) {
323 fprintf(stdout,
"%4.5f ", les->
Asp[i]->
values[k]);
328 fprintf(stdout,
"%4.5f ", 0.0);
331 fprintf(stdout,
" * %4.5f", les->
x[i]);
333 fprintf(stdout,
" = %4.5f ", les->
b[i]);
335 fprintf(stdout,
"\n");
340 for (i = 0; i < les->
rows; i++) {
341 for (j = 0; j < les->
cols; j++) {
342 fprintf(stdout,
"%4.5f ", les->
A[i][j]);
345 fprintf(stdout,
" * %4.5f", les->
x[i]);
347 fprintf(stdout,
" = %4.5f ", les->
b[i]);
349 fprintf(stdout,
"\n");
392 G_debug(2,
"Releasing memory of a sparse linear equation system\n");
394 G_debug(2,
"Releasing memory of a regular linear equation system\n");
406 for (i = 0; i < les->
rows; i++)
416 for (i = 0; i < les->
rows; i++)
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.
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.
The row vector of the sparse matrix.
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...
void N_free_spvector(N_spvector *spvector)
Release the memory of the sparse vector.
N_spvector * N_alloc_spvector(int cols)
Allocate memory for a sparse vector.
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
int N_add_spvector_to_les(N_les *les, N_spvector *spvector, int row)
Adds a sparse vector to a sparse linear equation system at position row.