EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
spmat.c File Reference

Sparse matrix routines. More...

#include <string.h>
#include "def.h"
#include "blaslapack.h"
#include "struct.h"
#include "internal_proto.h"

Go to the source code of this file.

Functions

void csrcsc (int OUTINDEX, const int nrow, const int ncol, int job, double *a, int *ja, int *ia, double *ao, int *jao, int *iao)
 convert csr to csc Assume input csr is 0-based index output csc 0/1 index specified by OUTINDEX * More...
 
void sortrow (csrMat *A)
 Sort each row of a csr by increasing column order By double transposition. More...
 
void csr_resize (int nrow, int ncol, int nnz, csrMat *csr)
 memory allocation for csr matrix More...
 
void free_csr (csrMat *csr)
 memory deallocation for csr matrix More...
 
void csr_copy (csrMat *A, csrMat *B, int allocB)
 copy a csr matrix A into B alloB: 0: will not allocate memory for B (have been alloced outside) 1: will allocate memory for B (same size as A) More...
 
void free_coo (cooMat *coo)
 memory deallocation for coo matrix More...
 
int cooMat_to_csrMat (int cooidx, cooMat *coo, csrMat *csr)
 convert coo to csr More...
 
void dcsrmv (char trans, int nrow, int ncol, double *a, int *ia, int *ja, double *x, double *y)
 csr matrix matvec or transpose matvec, (ia, ja, a) form More...
 
void matvec_csr (double *x, double *y, void *data)
 matvec for a CSR matrix, y = A*x. void *data points to csrMat, compatible form with EVSLMatvec (see struct.h) More...
 
void matadd_insert (double t, csrMat *A, csrMat *C, int i, int *k, int *j, int *map)
 inline function used by matadd insert an element pointed by j of A (times t) to location k in C (row i) More...
 
int matadd (double alp, double bet, csrMat *A, csrMat *B, csrMat *C, int *mapA, int *mapB)
 matrix addition C = alp * A + bet * B More...
 
int speye (int n, csrMat *A)
 return an identity matrix of dimension n More...
 
void diagScalCoo (cooMat *A, double *d)
 
void diagScalCsr (csrMat *A, double *d)
 
void extrDiagCsr (csrMat *B, double *d)
 
void triuCsr (csrMat *A, csrMat *U)
 

Detailed Description

Sparse matrix routines.

Definition in file spmat.c.

Function Documentation

int cooMat_to_csrMat ( int  cooidx,
cooMat coo,
csrMat csr 
)

convert coo to csr

Definition at line 135 of file spmat.c.

References _csrMat::a, csr_resize(), _csrMat::ia, _cooMat::ir, _csrMat::ja, _cooMat::jc, _cooMat::ncols, _cooMat::nnz, _cooMat::nrows, sortrow(), and _cooMat::vv.

Referenced by evsl_coo2csr(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void csr_copy ( csrMat A,
csrMat B,
int  allocB 
)

copy a csr matrix A into B alloB: 0: will not allocate memory for B (have been alloced outside) 1: will allocate memory for B (same size as A)

Definition at line 106 of file spmat.c.

References _csrMat::a, csr_resize(), _csrMat::ia, _csrMat::ja, _csrMat::ncols, and _csrMat::nrows.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void csr_resize ( int  nrow,
int  ncol,
int  nnz,
csrMat csr 
)

memory allocation for csr matrix

Definition at line 79 of file spmat.c.

References _csrMat::a, _csrMat::ia, _csrMat::ja, Malloc, _csrMat::ncols, _csrMat::nrows, and _csrMat::owndata.

Referenced by cooMat_to_csrMat(), csr_copy(), matadd(), speye(), and triuCsr().

Here is the caller graph for this function:

void csrcsc ( int  OUTINDEX,
const int  nrow,
const int  ncol,
int  job,
double *  a,
int *  ja,
int *  ia,
double *  ao,
int *  jao,
int *  iao 
)

convert csr to csc Assume input csr is 0-based index output csc 0/1 index specified by OUTINDEX *

Definition at line 17 of file spmat.c.

Referenced by driver(), and sortrow().

Here is the caller graph for this function:

void dcsrmv ( char  trans,
int  nrow,
int  ncol,
double *  a,
int *  ia,
int *  ja,
double *  x,
double *  y 
)

csr matrix matvec or transpose matvec, (ia, ja, a) form

Definition at line 199 of file spmat.c.

Referenced by matvec_csr().

Here is the caller graph for this function:

void diagScalCoo ( cooMat A,
double *  d 
)

Definition at line 374 of file spmat.c.

References _cooMat::ir, _cooMat::jc, _cooMat::nnz, and _cooMat::vv.

void diagScalCsr ( csrMat A,
double *  d 
)

Definition at line 390 of file spmat.c.

References _csrMat::a, _csrMat::ia, _csrMat::ja, and _csrMat::nrows.

Referenced by main().

Here is the caller graph for this function:

void extrDiagCsr ( csrMat B,
double *  d 
)

Definition at line 406 of file spmat.c.

References _csrMat::a, _csrMat::ia, _csrMat::ja, and _csrMat::nrows.

Referenced by main().

Here is the caller graph for this function:

void free_coo ( cooMat coo)

memory deallocation for coo matrix

Definition at line 126 of file spmat.c.

References _cooMat::ir, _cooMat::jc, and _cooMat::vv.

Referenced by main().

Here is the caller graph for this function:

void free_csr ( csrMat csr)

memory deallocation for csr matrix

Definition at line 91 of file spmat.c.

References _csrMat::a, _csrMat::ia, _csrMat::ja, and _csrMat::owndata.

Referenced by evsl_free_csr(), main(), and SetupASIGMABSolDirect().

Here is the caller graph for this function:

int matadd ( double  alp,
double  bet,
csrMat A,
csrMat B,
csrMat C,
int *  mapA,
int *  mapB 
)

matrix addition C = alp * A + bet * B

Parameters
[in]alp
[in]bet
[in]A
[in]B
[out]C
Warning
the nz pattern of C will be union of those of A and B. no cancellation will be considered
A and B MUST be sorted, on output C will be sorted as well
Parameters
[out]mapA(of size nnzA or null), mapB (of size nnzB or null) if not null, on output mapA contains the location of each nonzero of A in the CSR matrix C, i.e. mapA[i] is the position of the corresponding entry in C.ja and C.a for entry in A.ja[i] and A.a[i]
[out]mapBthe same as mapA

Definition at line 307 of file spmat.c.

References _csrMat::a, csr_resize(), _csrMat::ia, _csrMat::ja, matadd_insert(), _csrMat::ncols, _csrMat::nrows, and Realloc.

Referenced by SetupASIGMABSolDirect().

Here is the call graph for this function:

Here is the caller graph for this function:

void matadd_insert ( double  t,
csrMat A,
csrMat C,
int  i,
int *  k,
int *  j,
int *  map 
)
inline

inline function used by matadd insert an element pointed by j of A (times t) to location k in C (row i)

Definition at line 266 of file spmat.c.

References _csrMat::a, _csrMat::ia, and _csrMat::ja.

Referenced by matadd().

Here is the caller graph for this function:

void matvec_csr ( double *  x,
double *  y,
void *  data 
)

matvec for a CSR matrix, y = A*x. void *data points to csrMat, compatible form with EVSLMatvec (see struct.h)

Definition at line 247 of file spmat.c.

References _csrMat::a, dcsrmv(), _csrMat::ia, _csrMat::ja, _csrMat::ncols, and _csrMat::nrows.

Referenced by SetAMatrix(), and SetBMatrix().

Here is the call graph for this function:

Here is the caller graph for this function:

void sortrow ( csrMat A)

Sort each row of a csr by increasing column order By double transposition.

Definition at line 56 of file spmat.c.

References _csrMat::a, csrcsc(), _csrMat::ia, _csrMat::ja, Malloc, _csrMat::ncols, and _csrMat::nrows.

Referenced by cooMat_to_csrMat().

Here is the call graph for this function:

Here is the caller graph for this function:

int speye ( int  n,
csrMat A 
)

return an identity matrix of dimension n

Definition at line 357 of file spmat.c.

References _csrMat::a, csr_resize(), _csrMat::ia, and _csrMat::ja.

Referenced by SetupASIGMABSolDirect().

Here is the call graph for this function:

Here is the caller graph for this function:

void triuCsr ( csrMat A,
csrMat U 
)

Definition at line 424 of file spmat.c.

References _csrMat::a, CHKERR, csr_resize(), EVSL_Int, EVSL_Unsigned, _csrMat::ia, _csrMat::ja, _csrMat::ncols, and _csrMat::nrows.

Here is the call graph for this function: