diff --git a/spm.c b/spm.c index dc4a2a8ec70a5992a4e0bd32645d902e47387d7d..e6e3c25daaf7d08f0d75d69d219016a8e4b084a6 100644 --- a/spm.c +++ b/spm.c @@ -1085,32 +1085,35 @@ spmCheckAxb( int nrhs, * * @ingroup pastix_spm * - * @brief Scal a matrix with ||A||_2 + * @brief Scal the spm: A = alpha * A * ******************************************************************************* * + * @param[in] alpha + * The scaling parameter. + * * @param[in,out] spm * The sparse matrix to scal. * *******************************************************************************/ void -spmScal(pastix_spm_t* spm) +spmScal(const pastix_complex64_t alpha, pastix_spm_t* spm) { switch(spm->flttype) { case PastixPattern: break; case PastixFloat: - s_spmScal(spm); + s_spmScal(alpha, spm); break; case PastixComplex32: - c_spmScal(spm); + c_spmScal(alpha, spm); break; case PastixComplex64: - z_spmScal(spm); + z_spmScal(alpha, spm); break; case PastixDouble: default: - d_spmScal(spm); + d_spmScal(alpha, spm); } } diff --git a/spm.h b/spm.h index df5a54ecf3f7f4e61ad2ff7514f66b67bc27c4ee..78dff301c31f22217f468c79249b4842bdab72d9 100644 --- a/spm.h +++ b/spm.h @@ -150,7 +150,7 @@ void * spm2Dense( const pastix_spm_t *spm ); pastix_int_t spmFindBase( const pastix_spm_t *spm ); double spmNorm( int ntype, const pastix_spm_t *spm ); int spmMatVec(const pastix_trans_t trans, const void *alpha, const pastix_spm_t *spm, const void *x, const void *beta, void *y ); -void spmScal( pastix_spm_t* spm ); +void spmScal( const pastix_complex64_t alpha, pastix_spm_t* spm ); int spmSort( pastix_spm_t *spm ); pastix_int_t spmMergeDuplicate( pastix_spm_t *spm ); diff --git a/z_spm.h b/z_spm.h index db2b8a3005757d8e07f284e76ece40d9a07c811d..9211caf5cf65f9ab21259bcc0a3d40b2622fc214 100644 --- a/z_spm.h +++ b/z_spm.h @@ -66,7 +66,7 @@ void z_spmPrint( FILE *f, const pastix_spm_t *spm ); pastix_spm_t *z_spmExpand(const pastix_spm_t *spm); void z_spmDofExtend(pastix_spm_t *spm); -void z_spmScal( pastix_spm_t *spm ); +void z_spmScal( const pastix_complex64_t alpha, pastix_spm_t *spm ); #endif /* _z_spm_H_ */ diff --git a/z_spm_scal.c b/z_spm_scal.c index c79b7857885ea8e359c983eb03f59cbe76fada58..436ec6a560f813764f146f964e97a401bfb2a2f4 100644 --- a/z_spm_scal.c +++ b/z_spm_scal.c @@ -24,26 +24,27 @@ * * @ingroup pastix_spm_internal * - * z_spmScal - Scal the matrix with ||A||_2 + * z_spmScal - Scal the spm: A = alpha * A * ******************************************************************************* * + * @param[in] alpha + * The scaling parameter. + * * @param[in,out] spm * The spm which needs to be scaled. * *******************************************************************************/ void -z_spmScal( pastix_spm_t *spm ) +z_spmScal( const pastix_complex64_t alpha, pastix_spm_t *spm ) { - double norm; pastix_int_t nnz, i; pastix_complex64_t *values; nnz = spm->nnz; values = spm->values; - norm = z_spmNorm( PastixFrobeniusNorm, spm ); for (i=0; i<nnz; i++){ - values[i] /= norm; + values[i] *= alpha; } }