Files | |
| file | eg_dmatrix.c |
| file | eg_dmatrix.ex.c |
This file shows some examples of the use of EGdMatrix_t structure and functions. as a test-set we use the Hilber Matrix wich is a matrix with coefficients . It is well known that the Hilbert matrix is extremmaly ill conditioned, and is very hard to invert, here are some values for it's determinant for different dimmensions .
| |
| file | eg_dmatrix.h |
| This file provide the user interface and function definitions for Dense Matrices. | |
Data Structures | |
| struct | EGdMatrix_t |
| structure to hold a dense matrix, we choose a row representation of the matrix, and we allow row and column permutations. All actual values in the matrix are stored in EGdMatrix_t::matval, and the rows in EGdMatrix_t::matrow. More... | |
Defines | |
| #define | EGdMatrixAddColMultiple(dmatrix, dest, ori, num) |
| Given a number 'num' and a two rows 'ori', 'dest', set columns 'dest' to 'dest' + 'ori' * 'num'. Note that the number MUST_NOT be stored in column 'dest', and note that columns 'ori' and 'dest' should be different. This is needed because of the way GNU_MP interface works. | |
| #define | EGdMatrixAddRowMultiple(dmatrix, dest, ori, num) |
| Given a number 'num' and a two rows 'ori', 'dest', set rows 'dest' to 'dest' + 'ori' * 'num'. Note that the number MUST_NOT be stored in row 'dest', and note that rows 'ori' and 'dest' should be different. This is needed because of the way GNU_MP interface works. | |
| #define | EGdMatrixClear(dmatrix) |
| Clear a dense matrix structure, i.e. free all internally allocated data of the structure. Note that no further use of the structure can be made unless it is re-initialized and set to a suitable size. | |
| #define | EGdMatrixDisplay(dmatrix, nat_order, out_file) |
| Display a given EGdMatrix_t structure contents. | |
| #define | EGdMatrixInit(dmatrix) memset(dmatrix,0,sizeof(EGdMatrix_t)) |
| Initialize (as a dense matrix of dimension 0x0) an EGdMatrix_t structure. | |
| #define | EGdMatrixMultiplyCol(dmatrix, col_ind, multiple) |
| Given a number and a column, multiply the complete column by the given number. Note that the number MUST_NOT be stored in the column being multiplied, this is because of the way GNU_MP interface works. | |
| #define | EGdMatrixMultiplyRow(dmatrix, row_ind, multiple) |
| Given a number and a row, multiply the complete row by the given number. Note that the number MUST_NOT be stored in the row being multiplied, this is because of the way GNU_MP interface works. | |
| #define | EGdMatrixSetDimension(dmatrix, new_nrows, new_ncols) |
| Set new dimensions for a dense matrix structure. | |
| #define | EGdMatrixSubColMultiple(dmatrix, dest, ori, num) |
| Given a number 'num' and a two rows 'ori', 'dest', set columns 'dest' to 'dest' - 'ori' * 'num'. Note that the number MUST_NOT be stored in column 'dest', and note that columns 'ori' and 'dest' should be different. This is needed because of the way GNU_MP interface works. | |
| #define | EGdMatrixSubRowMultiple(dmatrix, dest, ori, num) |
| Given a number 'num' and a two rows 'ori', 'dest', set rows 'dest' to 'dest' - 'ori' * 'num'. Note that the number MUST_NOT be stored in row 'dest', and note that rows 'ori' and 'dest' should be different. This is needed because of the way GNU_MP interface works. | |
| #define | HILBERT_TABLE_SIZE 9U |
| size of the table of eigenvalues of the hilbert matrix | |
Typedefs | |
| typedef EGdMatrix_t | EGdMatrix_t |
| structure to hold a dense matrix, we choose a row representation of the matrix, and we allow row and column permutations. All actual values in the matrix are stored in EGdMatrix_t::matval, and the rows in EGdMatrix_t::matrow. | |
Functions | |
| int | dmatrix_parseargs (int argc, char **argv, size_t *n, size_t *m) |
| parse the input argumenbts for the program | |
| void | dmatrix_usage (char *program) |
| display the usage message for this program | |
| int | EGdMatrixGaussianElimination (EGdMatrix_t *const dmatrix, const unsigned do_col_perm, const unsigned do_row_perm, unsigned *const rank, EGlpNum_t zero_tol, int *const status) |
| This function performs gaussian elimination to the given matrix, depending on the given options it may do row/columns permutations allong the way to improve numerical stabillity. | |
| int | main (int argc, char **argv) |
| main function | |
Variables | |
| static unsigned | dmatrix_hilbert_eigenvalues [HILBERT_TABLE_SIZE] |
| table containing 1/eigenvalues of the hilbert matrix. | |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ const size_t __EGdest = (dest);\ const size_t __EGori = (ori);\ size_t __EGdmj = __EGdm->row_sz;\ while(__EGdmj--) \ EGlpNumAddInnProdTo(__EGdm->matrow[__EGdmj][__EGdest],\ __EGdm->matrow[__EGdmj][__EGori],num);\ } while(0)
Definition at line 243 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ const size_t __EGdest = (dest);\ const size_t __EGori = (ori);\ size_t __EGdmj = __EGdm->col_sz;\ while(__EGdmj--) \ EGlpNumAddInnProdTo(__EGdm->matrow[__EGdest][__EGdmj],\ __EGdm->matrow[__EGori][__EGdmj],num);\ } while(0)
Definition at line 170 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ EGlpNumFreeArray(__EGdm->matval);\ EGfree(__EGdm->matrow);\ int_EGlpNumFreeArray(__EGdm->col_ord);\ int_EGlpNumFreeArray(__EGdm->row_ord);} while(0)
Definition at line 87 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ char* __EGdmstr = 0;\ size_t __EGdmi, __EGdmj;\ fprintf(out_file,"Matrix %p\nDimensions: %zd rows, %zd columns\n", (void*)__EGdm, __EGdm->row_sz, __EGdm->col_sz);\ if(nat_order){\ for(__EGdmi = 0 ; __EGdmi < __EGdm->row_sz ; __EGdmi++){\ for(__EGdmj = 0 ; __EGdmj < __EGdm->col_sz ; __EGdmj++){\ __EGdmstr = EGlpNumGetStr(__EGdm->matrow[__EGdmi][__EGdmj]);\ fprintf(out_file,"%10s ", __EGdmstr);\ EGfree(__EGdmstr);\ }\ fprintf(out_file,"\n");}\ } else {\ for(__EGdmi = 0 ; __EGdmi < __EGdm->row_sz ; __EGdmi++){\ for(__EGdmj = 0 ; __EGdmj < __EGdm->col_sz ; __EGdmj++){\ __EGdmstr = EGlpNumGetStr(__EGdm->matrow[__EGdm->row_ord[__EGdmi]][__EGdm->col_ord[__EGdmj]]);\ fprintf(out_file,"%10s ", __EGdmstr);\ EGfree(__EGdmstr);\ }\ fprintf(out_file,"\n");}\ }} while(0)
Definition at line 129 of file eg_dmatrix.h. |
|
|
Initialize (as a dense matrix of dimension 0x0) an EGdMatrix_t structure.
Definition at line 79 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ const size_t __EGdmi = (col_ind);\ size_t __EGdmj = __EGdm->row_sz;\ while(__EGdmj--) EGlpNumMultTo(__EGdm->matrow[__EGdmj][__EGdmi],multiple);\ } while(0)
Definition at line 292 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ const size_t __EGdmi = (row_ind);\ size_t __EGdmj = __EGdm->col_sz;\ while(__EGdmj--) EGlpNumMultTo(__EGdm->matrow[__EGdmi][__EGdmj],multiple);\ } while(0)
Definition at line 218 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ register unsigned __EGdmi;\ __EGdm->col_sz = (new_ncols);\ __EGdm->row_sz = (new_nrows);\ EGlpNumReallocArray(&(__EGdm->matval),__EGdm->col_sz * __EGdm->row_sz);\ EGrealloc(__EGdm->matrow,__EGdm->row_sz * sizeof(EGlpNum_t*));\ int_EGlpNumReallocArray(&(__EGdm->col_ord),__EGdm->col_sz);\ int_EGlpNumReallocArray(&(__EGdm->row_ord),__EGdm->row_sz);\ __EGdmi = __EGdm->col_sz;\ while(__EGdmi--) __EGdm->col_ord[__EGdmi] = __EGdmi;\ __EGdmi = __EGdm->row_sz;\ while(__EGdmi--) \ __EGdm->matrow[__EGdmi] = __EGdm->matval + (__EGdmi * __EGdm->col_sz);\ __EGdmi = __EGdm->row_sz;\ while(__EGdmi--) __EGdm->row_ord[__EGdmi] = __EGdmi;} while(0)
Definition at line 103 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ const size_t __EGdest = (dest);\ const size_t __EGori = (ori);\ size_t __EGdmj = __EGdm->row_sz;\ while(__EGdmj--) \ EGlpNumSubInnProdTo(__EGdm->matrow[__EGdmj][__EGdest],\ __EGdm->matrow[__EGdmj][__EGori],num);\ } while(0)
Definition at line 271 of file eg_dmatrix.h. |
|
|
Value: do{\ EGdMatrix_t*const __EGdm = (dmatrix);\ const size_t __EGdest = (dest);\ const size_t __EGori = (ori);\ size_t __EGdmj = __EGdm->col_sz;\ while(__EGdmj--) \ EGlpNumSubInnProdTo(__EGdm->matrow[__EGdest][__EGdmj],\ __EGdm->matrow[__EGori][__EGdmj],num);\ } while(0)
Definition at line 198 of file eg_dmatrix.h. |
|
|
size of the table of eigenvalues of the hilbert matrix
Definition at line 49 of file eg_dmatrix.ex.c. |
|
|
structure to hold a dense matrix, we choose a row representation of the matrix, and we allow row and column permutations. All actual values in the matrix are stored in EGdMatrix_t::matval, and the rows in EGdMatrix_t::matrow.
|
|
||||||||||||||||||||
|
parse the input argumenbts for the program
Definition at line 78 of file eg_dmatrix.ex.c. Here is the call graph for this function: ![]() |
|
|
display the usage message for this program
Definition at line 67 of file eg_dmatrix.ex.c. |
|
||||||||||||||||||||||||||||
|
This function performs gaussian elimination to the given matrix, depending on the given options it may do row/columns permutations allong the way to improve numerical stabillity.
Definition at line 26 of file eg_dmatrix.c. |
|
||||||||||||
|
main function
Definition at line 113 of file eg_dmatrix.ex.c. Here is the call graph for this function: ![]() |
|
|
Initial value: {
1,
12,
180,
2800,
44100,
698544,
11099088,
176679360,
2815827300
}
Definition at line 53 of file eg_dmatrix.ex.c. |
1.4.5