Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
BlaSparseUtil.c File Reference

Routines for sparse matrix operations. More...

#include <math.h>
#include <time.h>
#include "fasp.h"
#include "fasp_functs.h"

Go to the source code of this file.

Functions

void fasp_sparse_abybms_ (INT *ia, INT *ja, INT *ib, INT *jb, INT *nap, INT *map, INT *mbp, INT *ic, INT *jc)
 Multiplication of two sparse matrices: calculating the nonzero structure of the result if jc is not null. If jc is null only finds num of nonzeroes. More...
 
void fasp_sparse_abyb_ (INT *ia, INT *ja, REAL *a, INT *ib, INT *jb, REAL *b, INT *nap, INT *map, INT *mbp, INT *ic, INT *jc, REAL *c)
 Multiplication of two sparse matrices. More...
 
void fasp_sparse_iit_ (INT *ia, INT *ja, INT *na, INT *ma, INT *iat, INT *jat)
 Transpose a boolean matrix (only given by ia, ja) More...
 
void fasp_sparse_aat_ (INT *ia, INT *ja, REAL *a, INT *na, INT *ma, INT *iat, INT *jat, REAL *at)
 Transpose a boolean matrix (only given by ia, ja) More...
 
void fasp_sparse_aplbms_ (INT *ia, INT *ja, INT *ib, INT *jb, INT *nab, INT *mab, INT *ic, INT *jc)
 Addition of two sparse matrices: calculating the nonzero structure of the result if jc is not null. if jc is null only finds num of nonzeroes. More...
 
void fasp_sparse_aplusb_ (INT *ia, INT *ja, REAL *a, INT *ib, INT *jb, REAL *b, INT *nab, INT *mab, INT *ic, INT *jc, REAL *c)
 Addition of two sparse matrices. More...
 
void fasp_sparse_rapms_ (INT *ir, INT *jr, INT *ia, INT *ja, INT *ip, INT *jp, INT *nin, INT *ncin, INT *iac, INT *jac, INT *maxrout)
 Calculates the nonzero structure of R*A*P, if jac is not null. If jac is null only finds num of nonzeroes. More...
 
void fasp_sparse_wtams_ (INT *jw, INT *ia, INT *ja, INT *nwp, INT *map, INT *jv, INT *nvp, INT *icp)
 Finds the nonzeroes in the result of v^t = w^t A, where w is a sparse vector and A is sparse matrix. jv is an integer array containing the indices of the nonzero elements in the result. More...
 
void fasp_sparse_wta_ (INT *jw, REAL *w, INT *ia, INT *ja, REAL *a, INT *nwp, INT *map, INT *jv, REAL *v, INT *nvp)
 Calculate v^t = w^t A, where w is a sparse vector and A is sparse matrix. v is an array of dimension = number of columns in A. More...
 
void fasp_sparse_ytxbig_ (INT *jy, REAL *y, INT *nyp, REAL *x, REAL *s)
 Calculates s = y^t x. y-sparse, x - no. More...
 
void fasp_sparse_ytx_ (INT *jy, REAL *y, INT *jx, REAL *x, INT *nyp, INT *nxp, INT *icp, REAL *s)
 Calculates s = y^t x. y is sparse, x is sparse. More...
 
void fasp_sparse_rapcmp_ (INT *ir, INT *jr, REAL *r, INT *ia, INT *ja, REAL *a, INT *ipt, INT *jpt, REAL *pt, INT *nin, INT *ncin, INT *iac, INT *jac, REAL *ac, INT *idummy)
 Calculates R*A*P after the nonzero structure of the result is known. iac,jac,ac have to be allocated before call to this function. More...
 
ivector fasp_sparse_mis (dCSRmat *A)
 Get the maximal independet set of a CSR matrix. More...
 

Detailed Description

Routines for sparse matrix operations.

Note
Most algorithms work as follows: (a) Boolean operations (to determine the nonzero structure); (b) Numerical part, where the result is calculated.
Parameter notation :I: is input; :O: is output; :IO: is both
This file contains Level-1 (Bla) functions. It requires: AuxMemory.c

Copyright (C) 2010–Present by the FASP team. All rights reserved.

Released under the terms of the GNU Lesser General Public License 3.0 or later.

Definition in file BlaSparseUtil.c.

Function Documentation

◆ fasp_sparse_aat_()

void fasp_sparse_aat_ ( INT ia,
INT ja,
REAL a,
INT na,
INT ma,
INT iat,
INT jat,
REAL at 
)

Transpose a boolean matrix (only given by ia, ja)

Parameters
iaarray of row pointers (as usual in CSR)
jaarray of column indices
aarray of entries of teh input
nanumber of rows of A
manumber of cols of A
iatarray of row pointers in the result
jatarray of column indices
atarray of entries of the result

Definition at line 273 of file BlaSparseUtil.c.

◆ fasp_sparse_abyb_()

void fasp_sparse_abyb_ ( INT ia,
INT ja,
REAL a,
INT ib,
INT jb,
REAL b,
INT nap,
INT map,
INT mbp,
INT ic,
INT jc,
REAL c 
)

Multiplication of two sparse matrices.

Parameters
iaarray of row pointers 1st multiplicand
jaarray of column indices 1st multiplicand
aentries of the 1st multiplicand
ibarray of row pointers 2nd multiplicand
jbarray of column indices 2nd multiplicand
bentries of the 2nd multiplicand
icarray of row pointers in c=a*b
jcarray of column indices in c=a*b
centries of the result: c= a*b
napnumber of rows in the 1st multiplicand
mapnumber of columns in the 1st multiplicand
mbpnumber of columns in the 2nd multiplicand

Modified by Chensong Zhang on 09/11/2012

Definition at line 127 of file BlaSparseUtil.c.

◆ fasp_sparse_abybms_()

void fasp_sparse_abybms_ ( INT ia,
INT ja,
INT ib,
INT jb,
INT nap,
INT map,
INT mbp,
INT ic,
INT jc 
)

Multiplication of two sparse matrices: calculating the nonzero structure of the result if jc is not null. If jc is null only finds num of nonzeroes.

Parameters
iaarray of row pointers 1st multiplicand
jaarray of column indices 1st multiplicand
ibarray of row pointers 2nd multiplicand
jbarray of column indices 2nd multiplicand
napnumber of rows of A
mapnumber of cols of A
mbpnumber of cols of b
icarray of row pointers in the result (this is also computed here again, so that we can have a stand alone call of this routine, if for some reason the number of nonzeros in the result is known)
jcarray of column indices in the result c=a*b

Modified by Chensong Zhang on 09/11/2012

Definition at line 52 of file BlaSparseUtil.c.

◆ fasp_sparse_aplbms_()

void void fasp_sparse_aplbms_ ( INT ia,
INT ja,
INT ib,
INT jb,
INT nab,
INT mab,
INT ic,
INT jc 
)

Addition of two sparse matrices: calculating the nonzero structure of the result if jc is not null. if jc is null only finds num of nonzeroes.

Parameters
iaarray of row pointers 1st summand
jaarray of column indices 1st summand
ibarray of row pointers 2nd summand
jbarray of column indices 2nd summand
nabnumber of rows
mabnumber of cols
icarray of row pointers in the result (this is also computed here again, so that we can have a stand alone call of this routine, if for some reason the number of nonzeros in the result is known)
jcarray of column indices in the result c=a+b

Definition at line 359 of file BlaSparseUtil.c.

◆ fasp_sparse_aplusb_()

void fasp_sparse_aplusb_ ( INT ia,
INT ja,
REAL a,
INT ib,
INT jb,
REAL b,
INT nab,
INT mab,
INT ic,
INT jc,
REAL c 
)

Addition of two sparse matrices.

Parameters
iaarray of row pointers 1st summand
jaarray of column indices 1st summand
aentries of the 1st summand
ibarray of row pointers 2nd summand
jbarray of column indices 2nd summand
bentries of the 2nd summand
nabnumber of rows
mabnumber of cols
icarray of row pointers in c=a+b
jcarray of column indices in c=a+b
centries of the result: c=a+b

Definition at line 431 of file BlaSparseUtil.c.

◆ fasp_sparse_iit_()

void fasp_sparse_iit_ ( INT ia,
INT ja,
INT na,
INT ma,
INT iat,
INT jat 
)

Transpose a boolean matrix (only given by ia, ja)

Parameters
iaarray of row pointers (as usual in CSR)
jaarray of column indices
nanumber of rows
manumber of cols
iatarray of row pointers in the result
jatarray of column indices

Definition at line 197 of file BlaSparseUtil.c.

◆ fasp_sparse_mis()

ivector fasp_sparse_mis ( dCSRmat A)

Get the maximal independet set of a CSR matrix.

Parameters
Apointer to the matrix
Note
Only use the sparsity of A, index starts from 1 (fortran)!!

Definition at line 907 of file BlaSparseUtil.c.

◆ fasp_sparse_rapcmp_()

void fasp_sparse_rapcmp_ ( INT ir,
INT jr,
REAL r,
INT ia,
INT ja,
REAL a,
INT ipt,
INT jpt,
REAL pt,
INT nin,
INT ncin,
INT iac,
INT jac,
REAL ac,
INT idummy 
)

Calculates R*A*P after the nonzero structure of the result is known. iac,jac,ac have to be allocated before call to this function.

Note
:I: is input :O: is output :IO: is both
Parameters
ir:I: array of row pointers for R
jr:I: array of column indices for R
r:I: entries of R
ia:I: array of row pointers for A
ja:I: array of column indices for A
a:I: entries of A
ipt:I: array of row pointers for P
jpt:I: array of column indices for P
pt:I: entries of P
nin:I: number of rows in R
ncin:I: number of rows in
iac:O: array of row pointers for P
jac:O: array of column indices for P
ac:O: entries of P
idummynot changed
Note
Compute R*A*P for known nonzero structure of the result the result is stored in iac,jac,ac!

Definition at line 787 of file BlaSparseUtil.c.

◆ fasp_sparse_rapms_()

void fasp_sparse_rapms_ ( INT ir,
INT jr,
INT ia,
INT ja,
INT ip,
INT jp,
INT nin,
INT ncin,
INT iac,
INT jac,
INT maxrout 
)

Calculates the nonzero structure of R*A*P, if jac is not null. If jac is null only finds num of nonzeroes.

Note
:I: is input :O: is output :IO: is both
Parameters
ir:I: array of row pointers for R
jr:I: array of column indices for R
ia:I: array of row pointers for A
ja:I: array of column indices for A
ip:I: array of row pointers for P
jp:I: array of column indices for P
nin:I: number of rows in R
ncin:I: number of columns in R
iac:O: array of row pointers for Ac
jac:O: array of column indices for Ac
maxrout:O: the maximum nonzeroes per row for R
Note
Computes the sparsity pattern of R*A*P. maxrout is output and is the maximum nonzeroes per row for r. On output we also have is iac (if jac is null) and jac (if jac entry is not null). R is (nc,n) A is (n,n) and P is (n,nc)!

Modified by Chensong Zhang on 09/11/2012

Definition at line 515 of file BlaSparseUtil.c.

◆ fasp_sparse_wta_()

void fasp_sparse_wta_ ( INT jw,
REAL w,
INT ia,
INT ja,
REAL a,
INT nwp,
INT map,
INT jv,
REAL v,
INT nvp 
)

Calculate v^t = w^t A, where w is a sparse vector and A is sparse matrix. v is an array of dimension = number of columns in A.

Note
:I: is input :O: is output :IO: is both
Parameters
jw:I: indices such that w[jw] is nonzero
w:I: the values of w
ia:I: array of row pointers for A
ja:I: array of column indices for A
a:I: entries of A
nwp:I: number of nonzeroes in w (the length of w)
map:I: number of columns in A
jv:O: indices such that v[jv] is nonzero
v:O: the result v^t=w^t A
nvp:I: number of nonzeroes in v

Definition at line 648 of file BlaSparseUtil.c.

◆ fasp_sparse_wtams_()

void fasp_sparse_wtams_ ( INT jw,
INT ia,
INT ja,
INT nwp,
INT map,
INT jv,
INT nvp,
INT icp 
)

Finds the nonzeroes in the result of v^t = w^t A, where w is a sparse vector and A is sparse matrix. jv is an integer array containing the indices of the nonzero elements in the result.

:I: is input :O: is output :IO: is both

Parameters
jw:I: indices such that w[jw] is nonzero
ia:I: array of row pointers for A
ja:I: array of column indices for A
nwp:I: number of nonzeroes in w (the length of w)
map:I: number of columns in A
jv:O: indices such that v[jv] is nonzero
nvp:I: number of nonzeroes in v
icp:IO: is a working array of length (*map) which on output satisfies icp[jv[k]-1]=k; Values of icp[] at positions * other than (jv[k]-1) remain unchanged.

Modified by Chensong Zhang on 09/11/2012

Definition at line 596 of file BlaSparseUtil.c.

◆ fasp_sparse_ytx_()

void fasp_sparse_ytx_ ( INT jy,
REAL y,
INT jx,
REAL x,
INT nyp,
INT nxp,
INT icp,
REAL s 
)

Calculates s = y^t x. y is sparse, x is sparse.

Note
:I: is input :O: is output :IO: is both
Parameters
jy:I: indices such that y[jy] is nonzero
y:I: is a sparse vector.
nyp:I: number of nonzeroes in y
jx:I: indices such that x[jx] is nonzero
x:I: is a sparse vector.
nxp:I: number of nonzeroes in x
icp???
s:O: s = y^t x.

Definition at line 733 of file BlaSparseUtil.c.

◆ fasp_sparse_ytxbig_()

void fasp_sparse_ytxbig_ ( INT jy,
REAL y,
INT nyp,
REAL x,
REAL s 
)

Calculates s = y^t x. y-sparse, x - no.

Note
:I: is input :O: is output :IO: is both
Parameters
jy:I: indices such that y[jy] is nonzero
y:I: is a sparse vector
nyp:I: number of nonzeroes in v
x:I: also a vector assumed to have entry for any j=jy[i]-1; for i=1:nyp. This means that x here does not have to be sparse
s:O: s = y^t x

Definition at line 699 of file BlaSparseUtil.c.