Blame thirdparty/superlu/SuperLU_4.1/TESTING/sp_zconvert.c
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*
|
|
kusano |
7d535a |
* -- SuperLU routine (version 2.0) --
|
|
kusano |
7d535a |
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
|
|
kusano |
7d535a |
* and Lawrence Berkeley National Lab.
|
|
kusano |
7d535a |
* November 15, 1997
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#include "slu_zdefs.h"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*
|
|
kusano |
7d535a |
* Convert a full matrix into a sparse matrix format.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
int
|
|
kusano |
7d535a |
sp_zconvert(int m, int n, doublecomplex *A, int lda, int kl, int ku,
|
|
kusano |
7d535a |
doublecomplex *a, int *asub, int *xa, int *nnz)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
int lasta = 0;
|
|
kusano |
7d535a |
int i, j, ilow, ihigh;
|
|
kusano |
7d535a |
int *row;
|
|
kusano |
7d535a |
doublecomplex *val;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (j = 0; j < n; ++j) {
|
|
kusano |
7d535a |
xa[j] = lasta;
|
|
kusano |
7d535a |
val = &a[xa[j]];
|
|
kusano |
7d535a |
row = &asub[xa[j]];
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
ilow = SUPERLU_MAX(0, j - ku);
|
|
kusano |
7d535a |
ihigh = SUPERLU_MIN(n-1, j + kl);
|
|
kusano |
7d535a |
for (i = ilow; i <= ihigh; ++i) {
|
|
kusano |
7d535a |
val[i-ilow] = A[i + j*lda];
|
|
kusano |
7d535a |
row[i-ilow] = i;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
lasta += ihigh - ilow + 1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
xa[n] = *nnz = lasta;
|
|
kusano |
7d535a |
return 0;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|