comprow Class Reference

#include <cr.h>

List of all members.

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

Detailed Description

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.


Constructor & Destructor Documentation

comprow ( void   ) 

Definition at line 9 of file cr.cpp.

References a, adr, adra, aux, ci, decompid, limit, n, and negm.

~comprow ( void   ) 

Definition at line 29 of file cr.cpp.

References a, adr, adra, aux, and ci.


Member Function Documentation

void add_entry ( double  e,
long  ri,
long  rci 
)

function adds required matrix entry

Parameters:
e - matrix entry
ri,ci - row and column indices

JK, 24.7.2005

Definition at line 603 of file cr.cpp.

References a, adr, and ci.

Referenced by gmatrix::add_entry().

void addmat_cr ( double  c,
comprow cr 
)

function adds multiplied matrix stored in cr by coefficient c to actual matrix

Parameters:
c - multiplicative coefficient
cr - another compressed row storage

JK

Definition at line 927 of file cr.cpp.

References a, and negm.

void addresses ( void   ) 

function computes addresses of the first entries in the rows

JK, 22.6.2001

Definition at line 202 of file cr.cpp.

References adr, adra, aux, memset(), and n.

Referenced by initiate().

void allocadr ( long  m  ) 

function allocates array containing addresses of the first entries in rows function also allocates auxiliary array

Parameters:
m - number of unknowns in solved problem

JK

Definition at line 70 of file cr.cpp.

References adr, adra, memset(), and n.

Referenced by initiate().

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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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 (  ) 

function changes indicator of decomposition (factorization) of matrix

JK

Definition at line 56 of file cr.cpp.

References decompid.

void copy_cr ( comprow cr  ) 

function copies data to additional storage

Parameters:
cr - additional storage (it is filled)

JK, 29.9.2006

Definition at line 1657 of file cr.cpp.

References a, adr, ci, n, and negm.

void crxcv_cv ( compvect cvi,
compvect cvo 
)

function computes dot product of the ri-th row with sparse vector sv

Parameters:
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 (  ) 

function returns indicator of decomposition (factorization) of matrix

JK

Definition at line 46 of file cr.cpp.

References decompid.

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.

References a, adr, and n.

Referenced by gmatrix::estim_spect_radius().

void fill_data ( long  nsub,
long *  smadr,
long *  smci,
double *  sma 
)

function fills new object by data

Parameters:
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

Parameters:
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

Parameters:
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.

References adra, and aux.

Referenced by fillarray().

double give_entry ( long  ri,
long  rci 
)

function returns required matrix entry

Parameters:
ri,ci - row and column indices

JK, 24.7.2005

Definition at line 579 of file cr.cpp.

References a, adr, and ci.

Referenced by gmatrix::give_entry().

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

Parameters:
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

Parameters:
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

Parameters:
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  ) 

function rejects zero entries from the global matrix function returns number of rejected entries

Parameters:
limit - threshold for rejection

JK, 25.6.2001

Definition at line 401 of file cr.cpp.

References a, adr, adra, ci, n, and negm.

void mtxv_cr ( double *  b,
double *  c 
)

function multiplies transposed matrix by vector b, result is stored in vector c

Parameters:
b - input vector
c - output vector

JK, 16.8.2000/4.5.2002

Definition at line 789 of file cr.cpp.

References a, adr, ci, n, and nullv().

Referenced by bicg().

void mv_cr15 ( double *  b,
double *  c 
)

Definition at line 805 of file cr.cpp.

References a, adr, ci, and n.

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.

References a, adr, ci, and n.

Referenced by cg_cr_rev().

void mxv_cr ( double *  b,
double *  c 
)

function multiplies matrix by vector

Parameters:
b - array containing vector b
c - array containing resulting vector c = A.b

JK

Definition at line 624 of file cr.cpp.

References a, adr, ci, and n.

Referenced by bicg(), bicg_new(), cg(), and cg_prec().

void mxv_cr_new ( double *  b,
double *  c 
)

function multiplies matrix by vector

Parameters:
b - array containing vector b
c - array containing resulting vector c = A.b interleaving of 2 adjacent rows 2003 IS

Definition at line 651 of file cr.cpp.

References a, adr, ci, and n.

Referenced by cg_new().

double mxv_cr_new2 ( double *  b,
double *  c 
)

function multiplies matrix by vector =vector2 return vector2 * vector

Parameters:
b - array containing vector b
c - array containing resulting vector c = A.b interleaving of 2 adjacent rows 2003 IS

Definition at line 718 of file cr.cpp.

References a, adr, ci, and n.

Referenced by cg_new().

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

Parameters:
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.

References a, and negm.

Referenced by initiate().

void numcontr ( gtopology top  ) 

function evaluates number of contributions to the matrix

Parameters:
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

Parameters:
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  ) 

function prints diagonal entries of matrix stored in the compressed row storage scheme

Parameters:
out - output stream

JK, 17.3.2007

Definition at line 555 of file cr.cpp.

References a, adr, ci, and n.

Referenced by gmatrix::printdiag().

void printmat ( FILE *  out  ) 

function prints matrix into output file

Parameters:
out - output stream

JK

Definition at line 459 of file cr.cpp.

References a, adr, ci, n, negm, and p.

Referenced by gmatrix::printmat().

void scalmat_cr ( double  c  ) 

function multiplies matrix by coefficient c

Parameters:
c - multiplicative coefficient

JK

Definition at line 942 of file cr.cpp.

References a, and negm.

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

Parameters:
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

Parameters:
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   ) 

function sortes array aux function also allocates array for matrix storage

JK, 22.6.2001

Definition at line 229 of file cr.cpp.

References a, adr, adra, aux, ci, memset(), n, and negm.

Referenced by initiate().

double * status (  ) 

function returns status of array a

JK

Definition at line 85 of file cr.cpp.

References a.

Referenced by initiate().


Member Data Documentation

double* a
long* adr
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
long decompid

decomposition indicator

Definition at line 113 of file cr.h.

Referenced by changedecomp(), comprow(), decomp(), and gmatrix::prepmat().

double limit

threshold for entries rejection

Definition at line 111 of file cr.h.

Referenced by comprow().

long n
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().


The documentation for this class was generated from the following files:

Generated by  doxygen 1.6.2