29#if defined(HAVE_BLAS_SET_NUM_THREADS)
30#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
32#elif defined(HAVE_MKL_SET_NUM_THREADS)
33#include <mkl_service.h>
37#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
39static int (*conversionTable[3][3][6])(
spmatrix_t*) = {
41 {{ NULL, NULL, NULL, NULL, NULL, NULL },
61 { NULL, NULL, NULL, NULL, NULL, NULL },
81 { NULL, NULL, NULL, NULL, NULL, NULL }}
131#if defined(SPM_WITH_MPI)
180 if ( spm->
colptr == NULL ) {
183 if ( spm->
rowptr == NULL ) {
187 if ( ( spm->
dof < 1 ) &&
188 ( spm->
dofs == NULL ) )
190 size_t dofsize = spm->
gN + 1;
198 spm->
values = malloc( valsize );
207 fprintf( stderr,
"[%s] WARNING: replicated field is not initialized, loc2glob can't be correctly allocated\n", __func__ );
244 if(spm->
dofs != NULL) {
275 size_t i, n, nnz, colsize, rowsize;
279 fprintf( stderr,
"spmBase: spm pointer is NULL");
290 if ( ((colsize > 0) && (spm->
colptr == NULL)) ||
291 ((rowsize > 0) && (spm->
rowptr == NULL)) )
293 fprintf( stderr,
"spmBase: spm pointers are not correctly initialized");
296 if ( (baseval != 0) &&
299 fprintf( stderr,
"spmBase: baseval is incorrect, must be 0 or 1");
303 baseadj = baseval - spm->
baseval;
304 if ( baseadj == 0 ) {
308 for (i = 0; i < colsize; i++) {
309 spm->
colptr[i] += baseadj;
311 for (i = 0; i < rowsize; i++) {
312 spm->
rowptr[i] += baseadj;
317 for (i = 0; i < n; i++) {
321 if (spm->
dofs != NULL) {
322 for (i = 0; i <= (size_t)(spm->
gN); i++) {
323 spm->
dofs[i] += baseadj;
356 if ( (spm->
n > 0 ) &&
364 assert( baseval >= 0 );
366 if ( ( baseval != 0 ) &&
373 for(i=0; i<spm->
nnz; i++, colptr++, rowptr++){
374 baseval =
spm_imin( *colptr, baseval );
375 baseval =
spm_imin( *rowptr, baseval );
380#if defined(SPM_WITH_MPI)
383 MPI_Allreduce( MPI_IN_PLACE, &baseval, 1,
SPM_MPI_INT,
384 MPI_MIN, spm->
comm );
388 assert( ( baseval == 0 ) ||
424 return conversionTable[spm->
fmttype][ofmttype][spm->
flttype]( spm );
605 fprintf( stderr,
"spmNormVec: incx values different from 1 are not supported yet\n" );
610 fprintf( stderr,
"spmNormVec: invalide value of parameter incx. Must be > 0\n" );
827#if defined(SPM_WITH_MPI)
893 spm_print_error(
"spmCheckAndCorrect: error during the conversion to CSC format\n" );
911 fprintf( stderr,
"spmCheckAndCorrect: %ld entries have been merged\n", (
long)count );
926 fprintf( stderr,
"spmCheckAndCorrect: %ld entries have been added for symmetry\n", (
long)count );
939 memcpy( spm_out, &newspm,
sizeof(
spmatrix_t) );
943 memcpy( spm_out, spm_in,
sizeof(
spmatrix_t) );
972 size_t colsize, rowsize, valsize, dofsize;
981 dofsize = spm->
gN + 1;
1000 if(spm->
dofs != NULL) {
1004 if(spm->
values != NULL) {
1006 newspm->
values = malloc(valsize);
1029 char *mtxtypestr[4] = {
"General",
"Symmetric",
"Hermitian",
"Incorrect" };
1030 char *flttypestr[7] = {
"Pattern",
"",
"Float",
"Double",
"Complex32",
"Complex64",
"Incorrect" };
1031 char *fmttypestr[4] = {
"CSC",
"CSR",
"IJV",
"Incorrect" };
1038 if (stream == NULL) {
1042 mtxtype = (mtxtype > 2 || mtxtype < 0) ? 3 : mtxtype;
1043 flttype = (flttype > 5 || flttype < 0) ? 6 : flttype;
1044 fmttype = (fmttype > 2 || fmttype < 0) ? 3 : fmttype;
1048 " Matrix type: %s\n"
1053 mtxtypestr[mtxtype],
1054 flttypestr[flttype],
1055 fmttypestr[fmttype],
1059 if ( spm->
dof != 1 ) {
1060 if ( spm->
dof > 1 ) {
1067 " Dof: Variadic\n" );
1071 " N expanded: %ld\n"
1072 " NNZ expanded: %ld\n",
1082 ( spm->
dof != 1 ) ?
" Nexp NNZexp" :
"" );
1086 if ( spm->
dof != 1 ) {
1088 " %4d: %7ld %9ld %8ld %11ld\n",
1093 " %4d: %7ld %9ld\n",
1096#if defined(SPM_WITH_MPI)
1097 MPI_Barrier( spm->
comm );
1124 if (stream == NULL) {
1255 rc =
spm_sspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1258 rc =
spm_cspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1261 rc =
spm_zspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1265 rc =
spm_dspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1268 if ( spm != espm ) {
1341 fprintf( stderr,
"spmMatMat: ldb must be >= max( 1, A->nexp )\n" );
1345 fprintf( stderr,
"spmMatMat: ldc must be >= max( 1, A->nexp )\n" );
1353 rc =
spm_sspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1356 rc =
spm_cspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1359 rc =
spm_zspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1363 rc =
spm_dspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1433 static int (*ptrfunc[4])( double, int,
const spmatrix_t *,
1434 void *, int,
void *, int,
const void *, int ) =
1441 if ( (x0 != NULL) && (ldx0 <
spm_imax( 1, spm->
nexp )) ) {
1442 fprintf( stderr,
"spmCheckAxb: ldx0 must be >= max( 1, spm->nexp )\n" );
1446 fprintf( stderr,
"spmCheckAxb: ldb must be >= max( 1, spm->nexp )\n" );
1450 fprintf( stderr,
"spmCheckAxb: ldx must be >= max( 1, spm->nexp )\n" );
1454 if ( (
id < 0) || (
id > 3) ) {
1460 return ptrfunc[id]( eps, nrhs, spm, x0, ldx0, b, ldb, x, ldx );
1558 cblas_sscal( n, (
float)alpha, x, incx );
1561 cblas_csscal( n, (
float)alpha, x, incx );
1564 cblas_zdscal( n, alpha, x, incx );
1568 cblas_dscal( n, alpha, x, incx );
1617 m, n, (
float *)A, lda );
1625 m, n, (spm_complex64_t *)A, lda );
1630 m, n, (
double *)A, lda );
1676 cblas_sscal( n, (
float)alpha, x, incx );
1679 cblas_csscal( n, (
float)alpha, x, incx );
1682 cblas_zdscal( n, alpha, x, incx );
1686 cblas_dscal( n, alpha, x, incx );
1736 unsigned long long int seed,
1742 void *,
unsigned long long int,
1750 fprintf( stderr,
"spmGenMat: lda(%ld) must be >= max( 1, spm->nexp(%ld) )\n",
1751 (
long)lda, (
long)spm->
nexp );
1755 if ( (
id < 0) || (
id > 3) ) {
1760 return ptrfunc[id]( type, nrhs, spm, alpha, seed, A, lda );
1805 unsigned long long int seed,
1844 spm_int_t i, size, begin, end, *loc2glob;
1846 int clustnum, clustnbr;
1851 size = spm->
gN / clustnbr;
1852 begin = size * clustnum +
spm_imin( clustnum, spm->
gN % clustnbr );
1853 end = size * (clustnum+1) +
spm_imin( clustnum+1, spm->
gN % clustnbr );
1856 *l2g_ptr = malloc( size *
sizeof(
spm_int_t) );
1857 loc2glob = *l2g_ptr;
1859 for ( i=begin; i<end; i++, loc2glob++ )
1861 *loc2glob = i+baseval;
1895#if defined(SPM_WITH_MPI)
1898 spm_int_t *loc2glob, *loc2globptr = NULL;
1902 assert( spm->
gN != -1 );
1904 glob2locptr = malloc( spm->
gN *
sizeof(
spm_int_t) );
1905 glob2loc = glob2locptr;
1910 for( ig=0; ig<spm->
gN; ig++ ) {
1911 glob2loc[ig] = - spm->
clustnbr - 1;
1917 glob2loc = glob2locptr - spm->
baseval;
1932 for(il=0; il<n; il++, loc2glob++) {
1945 newptr = realloc( loc2globptr, nr *
sizeof(
spm_int_t) );
1946 if ( newptr == NULL ) {
1947 free( loc2globptr );
1948 free( glob2locptr );
1952 loc2globptr = newptr;
1954 loc2glob = loc2globptr;
1961 for(il=0; il<n; il++, loc2glob++) {
1963 glob2loc[ ig ] = - c - 1;
1970 glob2loc = glob2locptr;
1972 free( loc2globptr );
1978 for( ig=0; ig<spm->
gN; ig++, g2l++ ) {
1979 assert( *g2l != (- spm->
clustnbr - 1) );
2015#if defined(SPM_WITH_MPI)
2018 if ( spm->
gN == -1 ) {
2051 int distribution = 0;
2056 return distribution;
2071 if ( !((spm->
n == spm->
gN) || (spm->
n == 0)) )
2074 if ( glob2loc == NULL ) {
2077 assert( glob2loc != NULL );
2078 for ( i = 0; i < spm->
nnz; i++, colptr++, rowptr++ )
2084 if ( glob2loc[*colptr - baseval] < 0 ) {
2085 distribution &= ~SpmDistByColumn;
2092 if ( glob2loc[*rowptr - baseval] < 0 ) {
2093 distribution &= ~SpmDistByRow;
2098 if ( (spm->
glob2loc == NULL) && glob2loc ) {
2103#if defined(SPM_WITH_MPI)
2105 MPI_Allreduce( MPI_IN_PLACE, &distribution, 1, MPI_INT,
2106 MPI_BAND, spm->
comm );
2111 assert( ( (spm->
n == 0) || (spm->
n == spm->
gN) ) ||
2112 (( (spm->
n != 0) && (spm->
n != spm->
gN) ) && (distribution != 0)) );
2117 return distribution;
2161 spm_attr_fallthrough;
2166 for ( j = 0; j < n; j++, colptr++, loc2glob++, valtmp++ )
2168 jg = spm->
replicated ? j : *loc2glob - baseval;
2169 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
2172 for ( i = colptr[0]; i < colptr[1]; i++, rowptr++ )
2174 ig = *rowptr - baseval;
2175 dofi += (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
2177 valtmp[1] = valtmp[0] + (dofj*dofi);
2186 assert((valtmp - values) == spm->
n);
2187 assert( values[spm->
n] == spm->
nnzexp );
2232 spm_attr_fallthrough;
2237 for ( j = 0; j < n; j++, colptr++, loc2glob++ )
2239 jg = spm->
replicated ? j : *loc2glob - baseval;
2240 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
2241 for ( i = colptr[0]; i < colptr[1]; i++, rowptr++, valtmp++ )
2243 ig = *rowptr - baseval;
2244 dofi = (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
2246 valtmp[1] = valtmp[0] + (dofj*dofi);
2253 for ( j = 0; j < n; j++, colptr++, rowptr++, valtmp++ )
2255 jg = *colptr - baseval;
2256 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
2257 ig = *rowptr - baseval;
2258 dofi = (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
2260 valtmp[1] = valtmp[0] + (dofj*dofi);
2264 assert((valtmp - values) == spm->
nnz);
2265 assert( values[spm->
nnz] == spm->
nnzexp );
2282#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
2283 return bli_thread_get_num_threads();
2284#elif defined(HAVE_MKL_SET_NUM_THREADS)
2285 return mkl_get_max_threads();
2286#elif defined(HAVE_OPENBLAS_SET_NUM_THREADS)
2287 return openblas_get_num_threads();
2311#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
2312 bli_thread_set_num_threads( nt );
2313#elif defined(HAVE_MKL_SET_NUM_THREADS)
2314 mkl_set_num_threads( nt );
2315#elif defined(HAVE_OPENBLAS_SET_NUM_THREADS)
2316 openblas_set_num_threads( nt );
#define LAPACKE_clascl_work(_dir_, _uplo_, _kl_, _ku_, _cfrom_, _cto_, _m_, _n_, _A_, _lda_)
Alias if Lapacke zlscl is not available.
#define LAPACKE_dlascl_work(_dir_, _uplo_, _kl_, _ku_, _cfrom_, _cto_, _m_, _n_, _A_, _lda_)
Alias if Lapacke zlscl is not available.
static size_t spm_size_of(spm_coeftype_t type)
Double datatype that is not converted through precision generator functions.
static spm_int_t spm_imin(spm_int_t a, spm_int_t b)
Internal function to compute min(a,b)
float _Complex spm_complex32_t
static spm_int_t spm_imax(spm_int_t a, spm_int_t b)
Internal function to compute max(a,b)
enum spm_rhstype_e spm_rhstype_t
How to generate RHS.
enum spm_coeftype_e spm_coeftype_t
Arithmetic types.
#define SpmDistByColumn
Distribution of the matrix storage.
enum spm_normtype_e spm_normtype_t
Norms.
enum spm_trans_e spm_trans_t
Transpostion.
void d_spmSort(spmatrix_t *spm)
This routine sorts the spm matrix.
void z_spmSort(spmatrix_t *spm)
This routine sorts the spm matrix.
spm_int_t * spm_get_value_idx_by_elt(const spmatrix_t *spm)
Create an array that represents the shift for each sub-element of the original multidof value array.
spm_int_t d_spmMergeDuplicate(spmatrix_t *spm)
This routine merge the multiple entries in a sparse matrix by summing their values together.
spm_int_t s_spmMergeDuplicate(spmatrix_t *spm)
This routine merge the multiple entries in a sparse matrix by summing their values together.
void c_spmSort(spmatrix_t *spm)
This routine sorts the spm matrix.
spm_int_t c_spmMergeDuplicate(spmatrix_t *spm)
This routine merge the multiple entries in a sparse matrix by summing their values together.
spm_int_t p_spmMergeDuplicate(spmatrix_t *spm)
This routine merge the multiple entries in a sparse matrix by summing their values together.
void p_spmSort(spmatrix_t *spm)
This routine sorts the spm matrix.
void s_spmSort(spmatrix_t *spm)
This routine sorts the spm matrix.
spm_int_t z_spmMergeDuplicate(spmatrix_t *spm)
This routine merge the multiple entries in a sparse matrix by summing their values together.
spm_int_t * spm_get_value_idx_by_col(const spmatrix_t *spm)
Create an array that represents the shift for each sub-element of the original multidof value array.
int c_spmConvertCSR2CSC(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in CSC format.
int z_spmConvertCSR2CSC(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in CSC format.
int d_spmConvertIJV2CSC(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSC format.
int p_spmConvertIJV2CSR(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSR format.
int d_spmConvertCSR2IJV(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in IJV format.
void s_spm2dense(const spmatrix_t *spm, float *A)
Convert a sparse matrix into a dense matrix.
int d_spmConvertCSR2CSC(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in CSC format.
int p_spmConvertCSR2CSC(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in CSC format.
int c_spmConvertIJV2CSR(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSR format.
int z_spmConvertCSR2IJV(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in IJV format.
int p_spmConvertCSR2IJV(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in IJV format.
int s_spmConvertIJV2CSC(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSC format.
void c_spm2dense(const spmatrix_t *spm, spm_complex32_t *A)
Convert a sparse matrix into a dense matrix.
int p_spmConvertCSC2CSR(spmatrix_t *spm)
Conversion routines.
int z_spmConvertCSC2IJV(spmatrix_t *spm)
Convert a matrix in CSC format to a matrix in IJV format.
int c_spmConvertCSC2IJV(spmatrix_t *spm)
Convert a matrix in CSC format to a matrix in IJV format.
int d_spmConvertCSC2IJV(spmatrix_t *spm)
Convert a matrix in CSC format to a matrix in IJV format.
int z_spmConvertIJV2CSR(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSR format.
int s_spmConvertCSC2IJV(spmatrix_t *spm)
Convert a matrix in CSC format to a matrix in IJV format.
int s_spmConvertIJV2CSR(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSR format.
int p_spmConvertIJV2CSC(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSC format.
int p_spmConvertCSC2IJV(spmatrix_t *spm)
Convert a matrix in CSC format to a matrix in IJV format.
int s_spmConvertCSC2CSR(spmatrix_t *spm)
convert a matrix in CSC format to a matrix in CSR format.
int c_spmConvertCSR2IJV(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in IJV format.
int d_spmConvertCSC2CSR(spmatrix_t *spm)
convert a matrix in CSC format to a matrix in CSR format.
int c_spmConvertIJV2CSC(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSC format.
int d_spmConvertIJV2CSR(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSR format.
int c_spmConvertCSC2CSR(spmatrix_t *spm)
convert a matrix in CSC format to a matrix in CSR format.
int z_spmConvertCSC2CSR(spmatrix_t *spm)
convert a matrix in CSC format to a matrix in CSR format.
int z_spmConvertIJV2CSC(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSC format.
void z_spm2dense(const spmatrix_t *spm, spm_complex64_t *A)
Convert a sparse matrix into a dense matrix.
int s_spmConvertCSR2CSC(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in CSC format.
int s_spmConvertCSR2IJV(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in IJV format.
void d_spm2dense(const spmatrix_t *spm, double *A)
Convert a sparse matrix into a dense matrix.
void s_spmExpand(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Expand a single dof sparse matrix to a multi-dofs sparse matrix.
void c_spmExpand(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Expand a single dof sparse matrix to a multi-dofs sparse matrix.
void p_spmExpand(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Expand a single dof sparse matrix to a multi-dofs sparse matrix.
void d_spmExpand(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Expand a single dof sparse matrix to a multi-dofs sparse matrix.
void z_spmExpand(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Expand a single dof sparse matrix to a multi-dofs sparse matrix.
int spm_zspmv(spm_trans_t trans, spm_complex64_t alpha, const spmatrix_t *A, const spm_complex64_t *x, spm_int_t incx, spm_complex64_t beta, spm_complex64_t *y, spm_int_t incy)
compute the matrix-vector product:
int spm_zspmm(spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, spm_complex64_t alpha, const spmatrix_t *A, const spm_complex64_t *B, spm_int_t ldb, spm_complex64_t beta, spm_complex64_t *C, spm_int_t ldc)
Compute a matrix-matrix product.
int spm_sspmv(spm_trans_t trans, float alpha, const spmatrix_t *A, const float *x, spm_int_t incx, float beta, float *y, spm_int_t incy)
compute the matrix-vector product:
int spm_sspmm(spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, float alpha, const spmatrix_t *A, const float *B, spm_int_t ldb, float beta, float *C, spm_int_t ldc)
Compute a matrix-matrix product.
int spm_dspmm(spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, double alpha, const spmatrix_t *A, const double *B, spm_int_t ldb, double beta, double *C, spm_int_t ldc)
Compute a matrix-matrix product.
int spm_dspmv(spm_trans_t trans, double alpha, const spmatrix_t *A, const double *x, spm_int_t incx, double beta, double *y, spm_int_t incy)
compute the matrix-vector product:
int spm_cspmv(spm_trans_t trans, spm_complex32_t alpha, const spmatrix_t *A, const spm_complex32_t *x, spm_int_t incx, spm_complex32_t beta, spm_complex32_t *y, spm_int_t incy)
compute the matrix-vector product:
int spm_cspmm(spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, spm_complex32_t alpha, const spmatrix_t *A, const spm_complex32_t *B, spm_int_t ldb, spm_complex32_t beta, spm_complex32_t *C, spm_int_t ldc)
Compute a matrix-matrix product.
double d_spmNorm(spm_normtype_t ntype, const spmatrix_t *spm)
Compute the norm of an spm matrix.
double z_spmNormMat(spm_normtype_t ntype, const spmatrix_t *spm, spm_int_t n, const spm_complex64_t *A, spm_int_t lda)
Compute the norm of a dense matrix that follows the distribution of an spm matrix.
double z_spmNorm(spm_normtype_t ntype, const spmatrix_t *spm)
Compute the norm of an spm matrix.
float s_spmNorm(spm_normtype_t ntype, const spmatrix_t *spm)
Compute the norm of an spm matrix.
float c_spmNormMat(spm_normtype_t ntype, const spmatrix_t *spm, spm_int_t n, const spm_complex32_t *A, spm_int_t lda)
Compute the norm of a dense matrix that follows the distribution of an spm matrix.
float s_spmNormMat(spm_normtype_t ntype, const spmatrix_t *spm, spm_int_t n, const float *A, spm_int_t lda)
Compute the norm of a dense matrix that follows the distribution of an spm matrix.
float c_spmNorm(spm_normtype_t ntype, const spmatrix_t *spm)
Compute the norm of an spm matrix.
double d_spmNormMat(spm_normtype_t ntype, const spmatrix_t *spm, spm_int_t n, const double *A, spm_int_t lda)
Compute the norm of a dense matrix that follows the distribution of an spm matrix.
void z_spmPrint(FILE *f, const spmatrix_t *spm)
Write a spm matrix in a file.
void s_spmPrint(FILE *f, const spmatrix_t *spm)
Write a spm matrix in a file.
void d_spmPrint(FILE *f, const spmatrix_t *spm)
Write a spm matrix in a file.
void c_spmPrint(FILE *f, const spmatrix_t *spm)
Write a spm matrix in a file.
int z_spmGenMat(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, int lda)
Generate nrhs right hand side vectors associated to a given matrix to test a problem with a solver.
int d_spmCheckAxb(spm_fixdbl_t eps, int nrhs, const spmatrix_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx)
Check the backward error, and the forward error if x0 is provided.
int d_spmGenMat(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, int lda)
Generate nrhs right hand side vectors associated to a given matrix to test a problem with a solver.
int s_spmCheckAxb(spm_fixdbl_t eps, int nrhs, const spmatrix_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx)
Check the backward error, and the forward error if x0 is provided.
int c_spmGenMat(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, int lda)
Generate nrhs right hand side vectors associated to a given matrix to test a problem with a solver.
int z_spmCheckAxb(spm_fixdbl_t eps, int nrhs, const spmatrix_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx)
Check the backward error, and the forward error if x0 is provided.
int s_spmGenMat(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, int lda)
Generate nrhs right hand side vectors associated to a given matrix to test a problem with a solver.
int c_spmCheckAxb(spm_fixdbl_t eps, int nrhs, const spmatrix_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx)
Check the backward error, and the forward error if x0 is provided.
void d_spmScal(const double alpha, spmatrix_t *spm)
Scal the spm: A = alpha * A.
void c_spmScal(const float alpha, spmatrix_t *spm)
Scal the spm: A = alpha * A.
void z_spmScal(const double alpha, spmatrix_t *spm)
Scal the spm: A = alpha * A.
void s_spmScal(const float alpha, spmatrix_t *spm)
Scal the spm: A = alpha * A.
double spmNormMat(spm_normtype_t ntype, const spmatrix_t *spm, spm_int_t n, const void *A, spm_int_t lda)
Compute the norm of the spm.
void spmAlloc(spmatrix_t *spm)
Allocate the arrays of an spm structure.
void spmExit(spmatrix_t *spm)
Cleanup the spm structure but do not free the spm pointer.
spm_int_t spmSymmetrize(spmatrix_t *spm)
Symmetrize the pattern of the spm.
#define SPM_MPI_INT
The MPI type associated to spm_int_t.
void spmUpdateComputedFields(spmatrix_t *spm)
Update all the computed fields based on the static values stored.
void spmBase(spmatrix_t *spm, int baseval)
Rebase the arrays of the spm to the given value.
int spm_int_t
The main integer datatype used in spm arrays.
spm_int_t spmFindBase(const spmatrix_t *spm)
Search the base used in the spm structure.
int spmMatVec(spm_trans_t trans, double alpha, const spmatrix_t *spm, const void *x, double beta, void *y)
Compute a matrix-vector product.
int spmCheckAxb(double eps, spm_int_t nrhs, const spmatrix_t *spm, void *opt_X0, spm_int_t opt_ldx0, void *B, spm_int_t ldb, const void *X, spm_int_t ldx)
Check the backward error, and the forward error if x0 is provided.
void spmInitDist(spmatrix_t *spm, SPM_Comm comm)
Init the spm structure with a specific communicator.
int spmConvert(int ofmttype, spmatrix_t *ospm)
Convert the storage format of the spm.
double spmNormVec(spm_normtype_t ntype, const spmatrix_t *spm, const void *x, spm_int_t incx)
Compute the norm of the spm.
spm_int_t spmMergeDuplicate(spmatrix_t *spm)
Merge multiple entries in a spm by summing their values together.
int spmMatMat(spm_trans_t trans, spm_int_t n, double alpha, const spmatrix_t *A, const void *B, spm_int_t ldb, double beta, void *C, spm_int_t ldc)
Compute a matrix-matrix product.
int spmCheckAndCorrect(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Check the correctness of a spm.
int spmSort(spmatrix_t *spm)
Sort the subarray of edges of each vertex.
void spmScal(double alpha, spmatrix_t *spm)
Scale the spm.
void spmExpand(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Expand a multi-dof spm matrix into an spm with constant dof set to 1.
void spmPrint(const spmatrix_t *spm, FILE *f)
Print an spm matrix into into a given file.
void spmScalVec(double alpha, const spmatrix_t *spm, void *x, spm_int_t incx)
Scale a vector associated to a sparse matrix. Deprecated function replaced by spmScalVec() or spmScal...
void spmScalMat(double alpha, const spmatrix_t *spm, spm_int_t n, void *A, spm_int_t lda)
Scale a matrix associated to a sparse matrix.
void spmScalMatrix(double alpha, spmatrix_t *spm) __attribute__((__deprecated__("Please replace by spmScal() function (will be removed in 1.3.0)")))
Scale the spm.
int spmGenVec(spm_rhstype_t type, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *x, spm_int_t incx)
Generate a vector associated to a given matrix.
double spmNorm(spm_normtype_t ntype, const spmatrix_t *spm)
Compute the norm of the spm.
void spm2Dense(const spmatrix_t *spm, void *A)
Convert the spm matrix into a dense matrix for test purpose.
void spmCopy(const spmatrix_t *spm_in, spmatrix_t *spm_out)
Create a copy of the spm.
void spmInit(spmatrix_t *spm)
Init the spm structure.
int spmGenMat(spm_rhstype_t type, spm_int_t nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, spm_int_t lda)
Generate a set of vectors associated to a given matrix.
void spmScalVector(spm_coeftype_t flt, double alpha, spm_int_t n, void *A, spm_int_t lda) __attribute__((__deprecated__("Please replace by spmScalVec() or spmScalMat() depending on usage (will be removed in 1.3.0)")))
Scale a vector according to the spm type.
void spmPrintInfo(const spmatrix_t *spm, FILE *f)
Print basic informations about the spm matrix into a given stream.
The sparse matrix data structure.
#define LAPACKE_slascl_work(_dir_, _uplo_, _kl_, _ku_, _cfrom_, _cto_, _m_, _n_, _A_, _lda_)
Alias if Lapacke zlscl is not available.
int spmBlasSetNumThreadsOne(void)
Set the number of threads for blas calls (BLIS, MKL, OpenBLAS) to 1 and return the previous number of...
spm_int_t * spm_getandset_glob2loc(spmatrix_t *spm)
Computes the glob2loc array if needed, and returns it.
int spmBlasGetNumThreads(void)
Return the current number of threads used for blas calls.
int spmBlasSetNumThreads(int nt)
Set the number of threads for blas calls (BLIS, MKL, OpenBLAS) and return the previous number of blas...
spm_int_t spm_create_loc2glob_continuous(const spmatrix_t *spm, spm_int_t **l2g_ptr)
Generate a continuous loc2glob array on each node.
spm_int_t * spm_get_glob2loc(const spmatrix_t *spm)
Computes the glob2loc array if needed, and returns it.
int spm_get_distribution(const spmatrix_t *spm)
Search the distribution pattern used in the spm structure.
#define LAPACKE_zlascl_work(_dir_, _uplo_, _kl_, _ku_, _cfrom_, _cto_, _m_, _n_, _A_, _lda_)
Alias if Lapacke zlscl is not available.