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)
184 if ( spm->
colptr == NULL ) {
187 if ( spm->
rowptr == NULL ) {
191 if ( ( spm->
dof < 1 ) &&
192 ( spm->
dofs == NULL ) )
194 size_t dofsize = spm->
gN + 1;
202 spm->
values = malloc( valsize );
217 fprintf( stderr,
"[%s] WARNING: replicated field is not initialized, loc2glob can't be correctly allocated\n", __func__ );
254 if(spm->
dofs != NULL) {
285 size_t i, n, nnz, colsize, rowsize;
289 fprintf( stderr,
"spmBase: spm pointer is NULL");
301 if ( ((colsize > 0) && (spm->
colptr == NULL)) ||
302 ((rowsize > 0) && (spm->
rowptr == NULL)) )
304 fprintf( stderr,
"spmBase: spm pointers are not correctly initialized");
307 if ( (baseval != 0) &&
310 fprintf( stderr,
"spmBase: baseval is incorrect, must be 0 or 1");
314 baseadj = baseval - spm->
baseval;
315 if ( baseadj == 0 ) {
319 for (i = 0; i < colsize; i++) {
320 spm->
colptr[i] += baseadj;
322 for (i = 0; i < rowsize; i++) {
323 spm->
rowptr[i] += baseadj;
328 for (i = 0; i < n; i++) {
332 if (spm->
dofs != NULL) {
333 for (i = 0; i <= (size_t)(spm->
gN); i++) {
334 spm->
dofs[i] += baseadj;
367 if ( (spm->
n > 0 ) &&
375 assert( baseval >= 0 );
377 if ( ( baseval != 0 ) &&
384 for(i=0; i<spm->
nnz; i++, colptr++, rowptr++){
385 baseval =
spm_imin( *colptr, baseval );
386 baseval =
spm_imin( *rowptr, baseval );
391#if defined(SPM_WITH_MPI)
394 MPI_Allreduce( MPI_IN_PLACE, &baseval, 1,
SPM_MPI_INT,
395 MPI_MIN, spm->
comm );
399 assert( ( baseval == 0 ) ||
435 return conversionTable[spm->
fmttype][ofmttype][spm->
flttype]( spm );
616 fprintf( stderr,
"spmNormVec: incx values different from 1 are not supported yet\n" );
621 fprintf( stderr,
"spmNormVec: invalide value of parameter incx. Must be > 0\n" );
838#if defined(SPM_WITH_MPI)
904 spm_print_error(
"spmCheckAndCorrect: error during the conversion to CSC format\n" );
922 fprintf( stderr,
"spmCheckAndCorrect: %ld entries have been merged\n", (
long)count );
937 fprintf( stderr,
"spmCheckAndCorrect: %ld entries have been added for symmetry\n", (
long)count );
950 memcpy( spm_out, &newspm,
sizeof(
spmatrix_t) );
954 memcpy( spm_out, spm_in,
sizeof(
spmatrix_t) );
983 size_t colsize, rowsize, valsize, dofsize;
992 dofsize = spm->
gN + 1;
1011 if(spm->
dofs != NULL) {
1015 if(spm->
values != NULL) {
1017 newspm->
values = malloc(valsize);
1040 char *mtxtypestr[4] = {
"General",
"Symmetric",
"Hermitian",
"Incorrect" };
1041 char *flttypestr[7] = {
"Pattern",
"",
"Float",
"Double",
"Complex32",
"Complex64",
"Incorrect" };
1042 char *fmttypestr[4] = {
"CSC",
"CSR",
"IJV",
"Incorrect" };
1049 if (stream == NULL) {
1053 mtxtype = (mtxtype > 2 || mtxtype < 0) ? 3 : mtxtype;
1054 flttype = (flttype > 5 || flttype < 0) ? 6 : flttype;
1055 fmttype = (fmttype > 2 || fmttype < 0) ? 3 : fmttype;
1059 " Matrix type: %s\n"
1064 mtxtypestr[mtxtype],
1065 flttypestr[flttype],
1066 fmttypestr[fmttype],
1070 if ( spm->
dof != 1 ) {
1071 if ( spm->
dof > 1 ) {
1078 " Dof: Variadic\n" );
1082 " N expanded: %ld\n"
1083 " NNZ expanded: %ld\n",
1093 ( spm->
dof != 1 ) ?
" Nexp NNZexp" :
"" );
1097 if ( spm->
dof != 1 ) {
1099 " %4d: %7ld %9ld %8ld %11ld\n",
1104 " %4d: %7ld %9ld\n",
1107#if defined(SPM_WITH_MPI)
1108 MPI_Barrier( spm->
comm );
1135 if (stream == NULL) {
1266 rc =
spm_sspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1269 rc =
spm_cspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1272 rc =
spm_zspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1276 rc =
spm_dspmv( trans, alpha, espm, x, 1, beta, y, 1 );
1279 if ( spm != espm ) {
1352 fprintf( stderr,
"spmMatMat: ldb must be >= max( 1, A->nexp )\n" );
1356 fprintf( stderr,
"spmMatMat: ldc must be >= max( 1, A->nexp )\n" );
1364 rc =
spm_sspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1367 rc =
spm_cspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1370 rc =
spm_zspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1374 rc =
spm_dspmm(
SpmLeft, trans,
SpmNoTrans, n, alpha, espm, B, ldb, beta, C, ldc );
1444 static int (*ptrfunc[4])( double, int,
const spmatrix_t *,
1445 void *, int,
void *, int,
const void *, int ) =
1452 if ( (x0 != NULL) && (ldx0 <
spm_imax( 1, spm->
nexp )) ) {
1453 fprintf( stderr,
"spmCheckAxb: ldx0 must be >= max( 1, spm->nexp )\n" );
1457 fprintf( stderr,
"spmCheckAxb: ldb must be >= max( 1, spm->nexp )\n" );
1461 fprintf( stderr,
"spmCheckAxb: ldx must be >= max( 1, spm->nexp )\n" );
1465 if ( (
id < 0) || (
id > 3) ) {
1471 return ptrfunc[id]( eps, nrhs, spm, x0, ldx0, b, ldb, x, ldx );
1569 cblas_sscal( n, (
float)alpha, x, incx );
1572 cblas_csscal( n, (
float)alpha, x, incx );
1575 cblas_zdscal( n, alpha, x, incx );
1579 cblas_dscal( n, alpha, x, incx );
1628 m, n, (
float *)A, lda );
1641 m, n, (
double *)A, lda );
1687 cblas_sscal( n, (
float)alpha, x, incx );
1690 cblas_csscal( n, (
float)alpha, x, incx );
1693 cblas_zdscal( n, alpha, x, incx );
1697 cblas_dscal( n, alpha, x, incx );
1747 unsigned long long int seed,
1753 void *,
unsigned long long int,
1761 fprintf( stderr,
"spmGenMat: lda(%ld) must be >= max( 1, spm->nexp(%ld) )\n",
1762 (
long)lda, (
long)spm->
nexp );
1766 if ( (
id < 0) || (
id > 3) ) {
1771 return ptrfunc[id]( type, nrhs, spm, alpha, seed, A, lda );
1816 unsigned long long int seed,
1855 spm_int_t i, size, begin, end, *loc2glob;
1857 int clustnum, clustnbr;
1862 size = spm->
gN / clustnbr;
1863 begin = size * clustnum +
spm_imin( clustnum, spm->
gN % clustnbr );
1864 end = size * (clustnum+1) +
spm_imin( clustnum+1, spm->
gN % clustnbr );
1867 *l2g_ptr = malloc( size *
sizeof(
spm_int_t) );
1868 loc2glob = *l2g_ptr;
1870 for ( i=begin; i<end; i++, loc2glob++ )
1872 *loc2glob = i+baseval;
1907#if defined(SPM_WITH_MPI)
1910 spm_int_t *loc2glob, *loc2globptr = NULL;
1914 assert( spm->
gN != -1 );
1916 glob2locptr = malloc( spm->
gN *
sizeof(
spm_int_t) );
1917 glob2loc = glob2locptr;
1922 for( ig=0; ig<spm->
gN; ig++ ) {
1923 glob2loc[ig] = - spm->
clustnbr - 1;
1929 glob2loc = glob2locptr - spm->
baseval;
1944 for(il=0; il<n; il++, loc2glob++) {
1957 newptr = realloc( loc2globptr, nr *
sizeof(
spm_int_t) );
1958 if ( newptr == NULL ) {
1959 free( loc2globptr );
1960 free( glob2locptr );
1964 loc2globptr = newptr;
1966 loc2glob = loc2globptr;
1973 for(il=0; il<n; il++, loc2glob++) {
1975 glob2loc[ ig ] = - c - 1;
1982 glob2loc = glob2locptr;
1984 free( loc2globptr );
1990 for( ig=0; ig<spm->
gN; ig++, g2l++ ) {
1991 assert( *g2l != (- spm->
clustnbr - 1) );
2028#if defined(SPM_WITH_MPI)
2031 if ( spm->
gN == -1 ) {
2064 int distribution = 0;
2069 return distribution;
2084 if ( !((spm->
n == spm->
gN) || (spm->
n == 0)) )
2087 if ( glob2loc == NULL ) {
2090 assert( glob2loc != NULL );
2091 for ( i = 0; i < spm->
nnz; i++, colptr++, rowptr++ )
2097 if ( glob2loc[*colptr - baseval] < 0 ) {
2105 if ( glob2loc[*rowptr - baseval] < 0 ) {
2111 if ( (spm->
glob2loc == NULL) && glob2loc ) {
2116#if defined(SPM_WITH_MPI)
2118 MPI_Allreduce( MPI_IN_PLACE, &distribution, 1, MPI_INT,
2119 MPI_BAND, spm->
comm );
2124 assert( ( (spm->
n == 0) || (spm->
n == spm->
gN) ) ||
2125 (( (spm->
n != 0) && (spm->
n != spm->
gN) ) && (distribution != 0)) );
2130 return distribution;
2174 spm_attr_fallthrough;
2179 for ( j = 0; j < n; j++, colptr++, loc2glob++, valtmp++ )
2181 jg = spm->
replicated ? j : *loc2glob - baseval;
2182 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
2185 for ( i = colptr[0]; i < colptr[1]; i++, rowptr++ )
2187 ig = *rowptr - baseval;
2188 dofi += (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
2190 valtmp[1] = valtmp[0] + (dofj*dofi);
2199 assert((valtmp - values) == spm->
n);
2200 assert( values[spm->
n] == spm->
nnzexp );
2245 spm_attr_fallthrough;
2250 for ( j = 0; j < n; j++, colptr++, loc2glob++ )
2252 jg = spm->
replicated ? j : *loc2glob - baseval;
2253 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
2254 for ( i = colptr[0]; i < colptr[1]; i++, rowptr++, valtmp++ )
2256 ig = *rowptr - baseval;
2257 dofi = (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
2259 valtmp[1] = valtmp[0] + (dofj*dofi);
2266 for ( j = 0; j < n; j++, colptr++, rowptr++, valtmp++ )
2268 jg = *colptr - baseval;
2269 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
2270 ig = *rowptr - baseval;
2271 dofi = (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
2273 valtmp[1] = valtmp[0] + (dofj*dofi);
2277 assert((valtmp - values) == spm->
nnz);
2278 assert( values[spm->
nnz] == spm->
nnzexp );
2295#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
2296 return bli_thread_get_num_threads();
2297#elif defined(HAVE_MKL_SET_NUM_THREADS)
2298 return mkl_get_max_threads();
2299#elif defined(HAVE_OPENBLAS_SET_NUM_THREADS)
2300 return openblas_get_num_threads();
2324#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
2325 bli_thread_set_num_threads( nt );
2326#elif defined(HAVE_MKL_SET_NUM_THREADS)
2327 mkl_set_num_threads( nt );
2328#elif defined(HAVE_OPENBLAS_SET_NUM_THREADS)
2329 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).
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.
struct spmatrix_s spmatrix_t
The sparse matrix data structure.
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.
double _Complex spm_complex64_t
The double complex arithmetic datatype.
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 spm_int_t
The main integer datatype used in spm arrays.
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.
float _Complex spm_complex32_t
The real complex arithmetic datatype.
void spmPrintInfo(const spmatrix_t *spm, FILE *f)
Print basic informations about the spm matrix into a given stream.
#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.