17 void csrcsc(
int OUTINDEX,
const int nrow,
const int ncol,
int job,
18 double *a,
int *ja,
int *ia,
19 double *ao,
int *jao,
int *iao) {
21 for (i=0; i<ncol+1; i++) {
25 for (i=0; i<nrow; i++) {
26 for (k=ia[i]; k<ia[i+1]; k++) {
31 for (i=0; i<ncol; i++) {
35 for (i=0; i<nrow; i++) {
36 for (k=ia[i]; k<ia[i+1]; k++) {
41 jao[iao[j]++] = i + OUTINDEX;
45 for (i=ncol; i>0; i--) {
46 iao[i] = iao[i-1] + OUTINDEX;
60 int nnz = A->
ia[nrows];
68 csrcsc(0, nrows, ncols, 1, A->
a, A->
ja, A->
ia, b, jb, ib);
69 csrcsc(0, ncols, nrows, 1, b, jb, ib, A->
a, A->
ja, A->
ia);
107 int nrows = A->
nrows;
108 int ncols = A->
ncols;
109 int nnz = A->
ia[nrows];
118 memcpy(B->
ia, A->
ia, (nrows+1)*
sizeof(
int));;
119 memcpy(B->
ja, A->
ja, nnz*
sizeof(
int));
120 memcpy(B->
a, A->
a, nnz*
sizeof(
double));
136 const int nnz = coo->
nnz;
140 const int nrows = coo->
nrows;
143 for (i=0; i<nrows+1; i++) {
146 for (i=0; i<nnz; i++) {
147 int row = coo->
ir[i] - cooidx;
150 for (i=0; i<nrows; i++) {
151 csr->
ia[i+1] += csr->
ia[i];
153 for (i=0; i<nnz; i++) {
154 int row = coo->
ir[i] - cooidx;
155 int col = coo->
jc[i] - cooidx;
156 double val = coo->
vv[i];
157 int k = csr->
ia[row];
162 for (i=nrows; i>0; i--) {
163 csr->
ia[i] = csr->
ia[i-1];
176 double dcsrinfnrm(
csrMat *A){
179 int nrows =A->
nrows, i, j;
183 for (i=0; i<nrows; i++) {
186 for (j=ia[i]; j<ia[i+1]; j++) {
199 void dcsrmv(
char trans,
int nrow,
int ncol,
double *a,
200 int *ia,
int *ja,
double *x,
double *y) {
218 r += x[*ja++]*(*a++);
237 y[*ja++] += xi*(*a++);
256 mkl_cspblas_dcsrgemv(&cN, &A->
nrows, A->
a, A->
ia, A->
ja, x, y);
272 if (*k > C->
ia[i] && C->
ja[(*k)-1] == A->
ja[*j]) {
275 map[(*j)] = (*k) - 1;
278 C->
a[(*k)-1] += t * A->
a[*j];
285 C->
ja[*k] = A->
ja[*j];
286 C->
a[*k] = t * A->
a[*j];
308 int *mapA,
int *mapB) {
309 int nnzA, nnzB, i, jA, jB, k;
322 for (i=0; i<A->
nrows; i++) {
325 for (jA=A->
ia[i], jB=B->
ia[i]; ; ) {
326 if (jA < A->ia[i+1] && jB < B->ia[i+1]) {
328 if (A->
ja[jA] <= B->
ja[jB]) {
335 }
else if (jA == A->
ia[i+1]) {
336 for (; jB < B->
ia[i+1]; ) {
342 for (; jA < A->
ia[i+1]; ) {
360 for (i=0; i<n; i++) {
361 A->
ia[i] = A->
ja[i] = i;
375 int i, row, col, nnz = A->
nnz;
377 for (i=0; i<nnz; i++) {
380 A->
vv[i] /= d[row] * d[col];
393 for (i=0; i<A->
nrows; i++) {
394 for (j=A->
ia[i]; j<A->ia[i+1]; j++) {
395 A->
a[j] /= d[i] * d[A->
ja[j]];
407 int i, j, nrows = B->
nrows;
408 for (i=0; i<nrows; i++) {
410 for (j=B->
ia[i]; j<B->ia[i+1]; j++) {
429 for (i = 0; i < A->
nrows; i++) {
430 for (j = A->
ia[i]; j < A->ia[i+1]; j++) {
440 for (i = 0; i < A->
nrows; i++) {
441 for (j = A->
ia[i]; j < A->ia[i+1]; j++) {
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
void triuCsr(csrMat *A, csrMat *U)
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 * ...
void free_coo(cooMat *coo)
memory deallocation for coo matrix
void diagScalCoo(cooMat *A, double *d)
void extrDiagCsr(csrMat *B, double *d)
void csr_resize(int nrow, int ncol, int nnz, csrMat *csr)
memory allocation for csr matrix
int cooMat_to_csrMat(int cooidx, cooMat *coo, csrMat *csr)
convert coo to csr
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 ...
void sortrow(csrMat *A)
Sort each row of a csr by increasing column order By double transposition.
void free_csr(csrMat *csr)
memory deallocation for csr matrix
This file contains function prototypes and constant definitions internally used in EVSL...
void diagScalCsr(csrMat *A, double *d)
int speye(int n, csrMat *A)
return an identity matrix of dimension n
#define Malloc(base, nmem, type)
sparse matrix format: the compressed sparse row (CSR) format, 0-based
Defs for blaslapack routines.
int matadd(double alp, double bet, csrMat *A, csrMat *B, csrMat *C, int *mapA, int *mapB)
matrix addition C = alp * A + bet * B
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 s...
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: wi...
#define Realloc(base, nmem, type)
sparse matrix format: the coordinate (COO) format, 0-based