#include <cr.h>
Public Member Functions | |
void | add_entry (double e, long ri, long rci) |
void | addmat_cr (double c, comprow &cr) |
void | addresses (void) |
void | allocadr (long m) |
void | bicg (double *x, double *y, long ni, double err, long &ani, double &ares, double zero, long iv) |
void | bicg_new (double *x, double *y, long ni, double err, long &ani, double &ares, double zero, long iv) |
void | cg (double *x, double *y, long ni, double err, long &ani, double &ares, double zero, long iv) |
void | cg_cr_rev (double *x, double *y, long ni, double err, long &ani, double &ares, double limit, long iv) |
void | cg_new (double *x, double *y, long ni, double err, long &ani, double &ares, double zero, long iv) |
void | cg_prec (precond &pr, double *x, double *y, long ni, double err, long &ani, double &ares, double zero, long iv) |
void | changedecomp () |
comprow () | |
void | copy_cr (comprow &cr) |
void | crxcv_cv (compvect *cvi, compvect *cvo) |
long | decomp () |
double | estim_spect_radius () |
void | fill_data (long nsub, long *smadr, long *smci, double *sma) |
void | fillarray (gtopology *top) |
void | fillarray_elem (long *cn, long ndofe) |
double | give_entry (long ri, long rci) |
long | give_negm () |
void | initiate (gtopology *top, long ndof, long mespr) |
void | localize (matrix &b, long *cn) |
void | localized (double *b, long *cn, long nc) |
long | minimize (double limit) |
void | mtxv_cr (double *b, double *c) |
void | mv_cr15 (double *b, double *c) |
double | mv_cr15_rev (double *b, double *c) |
void | mxv_cr (double *b, double *c) |
void | mxv_cr_new (double *b, double *c) |
double | mxv_cr_new2 (double *b, double *c) |
double | mxv_cr_pom (double *b1, double *c1, double *b2, double *c2) |
void | nullmat () |
void | numcontr (gtopology *top) |
void | numcontr_elem (long *cn, long ndofe) |
void | printdiag (FILE *out) |
void | printmat (FILE *out) |
void | scalmat_cr (double c) |
void | select_submatrix (long *li, long nsub, densemat *smdm) |
void | select_submatrix (long *li, long nsub, comprow *smcr) |
void | sort_and_colindex (void) |
double * | status () |
~comprow () | |
Public Attributes | |
double * | a |
array containing nonzero entries of the matrix | |
long * | adr |
array containing addresses of the beginnings of rows | |
long * | adra |
auxiliary array containing addresses | |
long * | aux |
auxiliary array containing column indices | |
long * | ci |
array containing column indices | |
long | decompid |
decomposition indicator | |
double | limit |
threshold for entries rejection | |
long | n |
number of rows of the matrix | |
long | negm |
number of entries in the global matrix |
class comprow
serves for matrix storage called compressed rows compressed rows storage is available for real matrices only non-zero matrix entries are stored row by row
basic data double array a where matrix entries are stored long array ci where column indices of stored non-zero matrix entries are stored long array adr where the first row entries are stored long number n stands for number of rows (columns) of matrix long number negm stands for number of entries of matrix
basic relationships array a has negm components array ci has negm components array adr has n+1 components adr[n] is equal to negm
JK
Definition at line 34 of file cr.h.
comprow | ( | void | ) |
void add_entry | ( | double | e, | |
long | ri, | |||
long | rci | |||
) |
void addmat_cr | ( | double | c, | |
comprow & | cr | |||
) |
void addresses | ( | void | ) |
void allocadr | ( | long | m | ) |
void bicg | ( | double * | x, | |
double * | y, | |||
long | ni, | |||
double | err, | |||
long & | ani, | |||
double & | ares, | |||
double | zero, | |||
long | iv | |||
) |
function solves system of linear algebraic equations by bi-conjugate gradient method
x | - array containing solution | |
y | - array containing right hand side | |
ni | - maximum number of iterations | |
err | - required error (norm of residual vector) | |
ani | - number of performed iterations | |
ares | - attained error (norm of residual vector) | |
zero | - computer zero | |
iv | - initial values indicator |
iv=0 - initial vector is zero vector iv=1 - initial vector is taken from x array
JK, 16.8.2000/4.5.2002
Definition at line 1297 of file cr.cpp.
References mtxv_cr(), mxv_cr(), n, p, print_err(), and ss().
Referenced by gmatrix::solve_system().
void bicg_new | ( | double * | x, | |
double * | y, | |||
long | ni, | |||
double | err, | |||
long & | ani, | |||
double & | ares, | |||
double | zero, | |||
long | iv | |||
) |
function solves system of linear algebraic equations by bi-conjugate gradient method
x | - array containing solution | |
y | - array containing right hand side | |
ni | - maximum number of iterations | |
err | - required error (norm of residual vector) | |
ani | - number of performed iterations | |
ares | - attained error (norm of residual vector) | |
zero | - computer zero | |
iv | - initial values indicator |
iv=0 - initial vector is zero vector iv=1 - initial vector is taken from x array
modified multiplication,3 fussions 2003 IS
Definition at line 1577 of file cr.cpp.
References mxv_cr(), mxv_cr_pom(), n, p, print_err(), and ss().
void cg | ( | double * | x, | |
double * | y, | |||
long | ni, | |||
double | err, | |||
long & | ani, | |||
double & | ares, | |||
double | zero, | |||
long | iv | |||
) |
function solves system of linear algebraic equations by conjugate gradient method, matrix is stored as compressed rows
x | - vector of unknowns | |
y | - vector of right hand side | |
ni | - maximum number of iterations | |
err | - required error (norm of residual vector) | |
ani | - number of performed iterations | |
ares | - attained error (norm of residual vector) | |
zero | - computer zero | |
iv | - initial values indicator |
iv=0 - initial vector is zero vector iv=1 - initial vector is taken from x array
JK, 17.7.2001
Definition at line 968 of file cr.cpp.
References mxv_cr(), n, p, print_err(), and ss().
Referenced by aggregator::boss().
void cg_cr_rev | ( | double * | x, | |
double * | y, | |||
long | ni, | |||
double | err, | |||
long & | ani, | |||
double & | ares, | |||
double | limit, | |||
long | iv | |||
) |
funkce resi soustavu linearnich algebraickych rovnic metodou sdruzenych gradientu (podle Axelssona)
matice soustavy je ulozena v compresovane forme
a - matice soustavy x - vektor reseni y - vektor prave strany ci - pole sloupcovych indexu adr - pole adres prvnich prvku n - pocet neznamych ni - maximalni pocet iteraci err - maximalni pripustna chyba ani - pocet skutecne provedenych operaci ares - norma vektoru rezidui limit - konstanta pro testovani na nulu
IS, 10.5.2003
Definition at line 1469 of file cr.cpp.
References mv_cr15_rev(), n, and p.
void cg_new | ( | double * | x, | |
double * | y, | |||
long | ni, | |||
double | err, | |||
long & | ani, | |||
double & | ares, | |||
double | zero, | |||
long | iv | |||
) |
function solves system of linear algebraic equations by conjugate gradient method, matrix is stored as compressed rows
x | - vector of unknowns | |
y | - vector of right hand side | |
ni | - maximum number of iterations | |
err | - required error (norm of residual vector) | |
ani | - number of performed iterations | |
ares | - attained error (norm of residual vector) | |
zero | - computer zero | |
iv | - initial values indicator |
iv=0 - initial vector is zero vector iv=1 - initial vector is taken from x array 2 fussions + new multiplication 2003 IS
Definition at line 1197 of file cr.cpp.
References mxv_cr_new(), mxv_cr_new2(), n, p, and print_err().
void cg_prec | ( | precond & | pr, | |
double * | x, | |||
double * | y, | |||
long | ni, | |||
double | err, | |||
long & | ani, | |||
double & | ares, | |||
double | zero, | |||
long | iv | |||
) |
function solves system of linear algebraic equations by conjugate gradient method, matrix is stored as compressed rows
x | - vector of unknowns | |
y | - vector of right hand side | |
ni | - maximum number of iterations | |
err | - required error (norm of residual vector) | |
ani | - number of performed iterations | |
ares | - attained error (norm of residual vector) | |
zero | - computer zero | |
iv | - initial values indicator |
iv=0 - initial vector is zero vector iv=1 - initial vector is taken from x array
JK, 17.7.2001
Definition at line 1069 of file cr.cpp.
References h(), mxv_cr(), n, p, precond::preconditioning(), print_err(), and ss().
Referenced by gmatrix::solve_system().
void changedecomp | ( | ) |
void copy_cr | ( | comprow & | cr | ) |
function computes dot product of the ri-th row with sparse vector sv
cvi | - input compressed sparse vector | |
cvo | - output compressed sparse vector |
JK, 25.2.2007
Definition at line 1941 of file cr.cpp.
References a, compvect::a, adr, ci, compvect::ind, n, compvect::nz, compvect::ordering, print_err(), and compvect::setup_vector().
Referenced by aggregator::assemble_smoothed_prol2().
long decomp | ( | ) |
double estim_spect_radius | ( | ) |
function estimates spectral radius
the estimates are based on the Gershgorin circle theorem for details see G.H. Golub, C.F. Van Loan: Matrix computations. The Johns Hopkins University Press, 3rd edition, page 320, 1996
JK, 27.8.2008
Definition at line 2024 of file cr.cpp.
Referenced by gmatrix::estim_spect_radius().
void fill_data | ( | long | nsub, | |
long * | smadr, | |||
long * | smci, | |||
double * | sma | |||
) |
function fills new object by data
nsub | - number of rows of matrix | |
smadr | - array of addresses of first nonzero entries in rows | |
smci | - array of column indices | |
sma | - array of nenzero matrix entries |
JK, 19.2.2007
Definition at line 1699 of file cr.cpp.
References a, adr, ci, n, and negm.
Referenced by select_submatrix().
void fillarray | ( | gtopology * | top | ) |
function fills auxiliary array
top | - topology |
aux - auxiliary array containing column indices
JK, 22.6.2001
Definition at line 184 of file cr.cpp.
References fillarray_elem(), gtopology::give_code_numbers(), gtopology::give_ndofe(), and gtopology::ne.
Referenced by initiate().
void fillarray_elem | ( | long * | cn, | |
long | ndofe | |||
) |
function fills auxiliary array by one element
cn | - array containg code numbers of the element | |
ndofe | - number of DOFs on the element |
aux - auxiliary array containing column indices
JK, 22.6.2001
Definition at line 158 of file cr.cpp.
Referenced by fillarray().
double give_entry | ( | long | ri, | |
long | rci | |||
) |
long give_negm | ( | ) |
function returns number of stored matrix entries
JK, 16.8.2007
Definition at line 2010 of file cr.cpp.
References negm.
Referenced by gmatrix::give_negm().
void initiate | ( | gtopology * | top, | |
long | ndof, | |||
long | mespr | |||
) |
function initiates compressed rows storage
top | - pointer to general topology | |
ndof | - number of rows/columns of the matrix | |
mespr | - indicator of message printing |
JK
Definition at line 436 of file cr.cpp.
References addresses(), allocadr(), fillarray(), negm, nullmat(), numcontr(), sort_and_colindex(), and status().
Referenced by gmatrix::initiate().
void localize | ( | matrix & | b, | |
long * | cn | |||
) |
function localizes local matrix b to the global matrix matrix b is stored as dense matrix
b | - local matrix in row ordering | |
cn | - array containing code numbers of element |
JK, 25.6.2001
Definition at line 309 of file cr.cpp.
References a, adr, ci, ll, and matrix::m.
Referenced by gmatrix::localize().
void localized | ( | double * | b, | |
long * | cn, | |||
long | nc | |||
) |
function localizes local matrix b to the global matrix matrix b is stored as dense matrix
b | - local matrix in row ordering | |
cn | - array containing code numbers of element | |
n | - order of matrix b (number of rows or columns) |
JK, 25.6.2001
Definition at line 356 of file cr.cpp.
References a, adr, ci, and ll.
Referenced by gmatrix::localized().
long minimize | ( | double | limit | ) |
void mtxv_cr | ( | double * | b, | |
double * | c | |||
) |
void mv_cr15 | ( | double * | b, | |
double * | c | |||
) |
double mv_cr15_rev | ( | double * | b, | |
double * | c | |||
) |
funkce nasobi matici a s vektorem b, vysledek je vektor c matice a je ulozena v compressed row
prokladani dvou sousednich
vystup c - vysledny vektor vraci c*b
vstupy a - matice v compressed row b - vektor adr - pole adres prvnich prvku v radku ci - pole sloupcovych indexu n - rozmer matice a
15.4.2003
Definition at line 1390 of file cr.cpp.
Referenced by cg_cr_rev().
void mxv_cr | ( | double * | b, | |
double * | c | |||
) |
void mxv_cr_new | ( | double * | b, | |
double * | c | |||
) |
double mxv_cr_new2 | ( | double * | b, | |
double * | c | |||
) |
double mxv_cr_pom | ( | double * | b1, | |
double * | c1, | |||
double * | b2, | |||
double * | c2 | |||
) |
function multiplies matrix by vector b1, result is stored in vector c1 multiplies transposed matrix by vector b2, result is stored in vector c2 return c1*b2
b1,b2 | - input vectors | |
c1,c2 | - output vectors |
2003 IS
Definition at line 892 of file cr.cpp.
References a, adr, ci, n, and nullv().
Referenced by bicg_new().
void nullmat | ( | ) |
function fills the array of zeros
JK
Definition at line 95 of file cr.cpp.
Referenced by initiate().
void numcontr | ( | gtopology * | top | ) |
function evaluates number of contributions to the matrix
top | - topology |
JK, 22.6.2001
Definition at line 134 of file cr.cpp.
References gtopology::give_code_numbers(), gtopology::give_ndofe(), gtopology::ne, and numcontr_elem().
Referenced by initiate().
void numcontr_elem | ( | long * | cn, | |
long | ndofe | |||
) |
function evaluates number of contributions to the matrix from one element
cn | - array containing code numbers of the element | |
ndofe | - number of DOFs on the element |
JK, 22.6.2001
Definition at line 112 of file cr.cpp.
References adr.
Referenced by numcontr().
void printdiag | ( | FILE * | out | ) |
void printmat | ( | FILE * | out | ) |
void scalmat_cr | ( | double | c | ) |
void select_submatrix | ( | long * | li, | |
long | nsub, | |||
densemat * | smdm | |||
) |
function selects submatrix from the original matrix stored in the compressed row storage scheme, the submatrix is defined by indices
li | - list of indices of submatrix | |
nsub | - number of rows and columns of submatrix (it is also length of the array li) | |
smdm | - pointer to object of the class densemat which stores submatrix |
JK, 14.3.2007
Definition at line 1901 of file cr.cpp.
References a, densemat::a, adr, ci, and densemat::n.
void select_submatrix | ( | long * | li, | |
long | nsub, | |||
comprow * | smcr | |||
) |
function selects submatrix from the original matrix stored in the compressed row storage scheme, the submatrix is defined by indices
li | - list of indices of submatrix | |
nsub | - number of rows and columns of submatrix (it is also length of the array li) | |
smcr | - pointer to object of the class comprow which stores submatrix |
JK, 19.2.2007
Definition at line 1753 of file cr.cpp.
References a, adr, aux, ci, and fill_data().
Referenced by aggregator::local_matrices().
void sort_and_colindex | ( | void | ) |
double * status | ( | ) |
function returns status of array a
JK
Definition at line 85 of file cr.cpp.
References a.
Referenced by initiate().
double* a |
array containing nonzero entries of the matrix
Definition at line 109 of file cr.h.
Referenced by add_entry(), addmat_cr(), comprow(), copy_cr(), crxcv_cv(), estim_spect_radius(), fill_data(), give_entry(), boundparcongrad::ilu_mat_petsc(), boundparcongrad::initialize_diag_prec(), gmatrix::initiate(), localize(), localized(), minimize(), mtxv_cr(), mv_cr15(), mv_cr15_rev(), mxv_cr(), mxv_cr_new(), mxv_cr_new2(), mxv_cr_pom(), nullmat(), gmatrix::prepmat2(), printdiag(), printmat(), scalmat_cr(), select_submatrix(), sort_and_colindex(), status(), and ~comprow().
long* adr |
array containing addresses of the beginnings of rows
Definition at line 101 of file cr.h.
Referenced by add_entry(), addresses(), allocadr(), comprow(), copy_cr(), crxcv_cv(), estim_spect_radius(), fill_data(), give_entry(), boundparcongrad::ilu_mat_petsc(), boundparcongrad::initialize_diag_prec(), gmatrix::initiate(), aggregator::local_matrices(), localize(), localized(), minimize(), mtxv_cr(), mv_cr15(), mv_cr15_rev(), mxv_cr(), mxv_cr_new(), mxv_cr_new2(), mxv_cr_pom(), numcontr_elem(), gmatrix::prepmat2(), printdiag(), printmat(), select_submatrix(), sort_and_colindex(), and ~comprow().
long* adra |
auxiliary array containing addresses
Definition at line 103 of file cr.h.
Referenced by addresses(), allocadr(), comprow(), fillarray_elem(), minimize(), sort_and_colindex(), and ~comprow().
long* aux |
auxiliary array containing column indices
Definition at line 105 of file cr.h.
Referenced by addresses(), comprow(), fillarray_elem(), select_submatrix(), sort_and_colindex(), and ~comprow().
long* ci |
array containing column indices
Definition at line 107 of file cr.h.
Referenced by add_entry(), comprow(), copy_cr(), crxcv_cv(), fill_data(), give_entry(), boundparcongrad::ilu_mat_petsc(), boundparcongrad::initialize_diag_prec(), gmatrix::initiate(), localize(), localized(), minimize(), mtxv_cr(), mv_cr15(), mv_cr15_rev(), mxv_cr(), mxv_cr_new(), mxv_cr_new2(), mxv_cr_pom(), gmatrix::prepmat2(), printdiag(), printmat(), select_submatrix(), sort_and_colindex(), and ~comprow().
long decompid |
decomposition indicator
Definition at line 113 of file cr.h.
Referenced by changedecomp(), comprow(), decomp(), and gmatrix::prepmat().
double limit |
long n |
number of rows of the matrix
Definition at line 97 of file cr.h.
Referenced by addresses(), allocadr(), bicg(), bicg_new(), cg(), cg_cr_rev(), cg_new(), cg_prec(), comprow(), copy_cr(), crxcv_cv(), estim_spect_radius(), fill_data(), boundparcongrad::ilu_mat_petsc(), boundparcongrad::initialize_diag_prec(), aggregator::local_matrices(), minimize(), mtxv_cr(), mv_cr15(), mv_cr15_rev(), mxv_cr(), mxv_cr_new(), mxv_cr_new2(), mxv_cr_pom(), printdiag(), printmat(), and sort_and_colindex().
long negm |
number of entries in the global matrix
Definition at line 99 of file cr.h.
Referenced by addmat_cr(), comprow(), copy_cr(), fill_data(), give_negm(), initiate(), minimize(), nullmat(), gmatrix::prepmat(), printmat(), scalmat_cr(), and sort_and_colindex().