From f99a03fc47b36c968e3edfc13c2be1de07687c2e Mon Sep 17 00:00:00 2001 From: Gregoire Pichon <gregoire.pichon@inria.fr> Date: Tue, 29 Nov 2016 14:41:17 +0100 Subject: [PATCH] add alpha parameter for spmScal function --- spm.c | 15 +++++++++------ spm.h | 2 +- z_spm.h | 2 +- z_spm_scal.c | 11 ++++++----- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/spm.c b/spm.c index dc4a2a8e..e6e3c25d 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 df5a54ec..78dff301 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 db2b8a30..9211caf5 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 c79b7857..436ec6a5 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; } } -- GitLab