Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f99a03fc authored by PICHON Gregoire's avatar PICHON Gregoire
Browse files

add alpha parameter for spmScal function

parent 6a169e28
No related branches found
No related tags found
No related merge requests found
...@@ -1085,32 +1085,35 @@ spmCheckAxb( int nrhs, ...@@ -1085,32 +1085,35 @@ spmCheckAxb( int nrhs,
* *
* @ingroup pastix_spm * @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 * @param[in,out] spm
* The sparse matrix to scal. * The sparse matrix to scal.
* *
*******************************************************************************/ *******************************************************************************/
void void
spmScal(pastix_spm_t* spm) spmScal(const pastix_complex64_t alpha, pastix_spm_t* spm)
{ {
switch(spm->flttype) switch(spm->flttype)
{ {
case PastixPattern: case PastixPattern:
break; break;
case PastixFloat: case PastixFloat:
s_spmScal(spm); s_spmScal(alpha, spm);
break; break;
case PastixComplex32: case PastixComplex32:
c_spmScal(spm); c_spmScal(alpha, spm);
break; break;
case PastixComplex64: case PastixComplex64:
z_spmScal(spm); z_spmScal(alpha, spm);
break; break;
case PastixDouble: case PastixDouble:
default: default:
d_spmScal(spm); d_spmScal(alpha, spm);
} }
} }
...@@ -150,7 +150,7 @@ void * spm2Dense( const pastix_spm_t *spm ); ...@@ -150,7 +150,7 @@ void * spm2Dense( const pastix_spm_t *spm );
pastix_int_t spmFindBase( const pastix_spm_t *spm ); pastix_int_t spmFindBase( const pastix_spm_t *spm );
double spmNorm( int ntype, 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 ); 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 ); int spmSort( pastix_spm_t *spm );
pastix_int_t spmMergeDuplicate( pastix_spm_t *spm ); pastix_int_t spmMergeDuplicate( pastix_spm_t *spm );
......
...@@ -66,7 +66,7 @@ void z_spmPrint( FILE *f, const pastix_spm_t *spm ); ...@@ -66,7 +66,7 @@ void z_spmPrint( FILE *f, const pastix_spm_t *spm );
pastix_spm_t *z_spmExpand(const pastix_spm_t *spm); pastix_spm_t *z_spmExpand(const pastix_spm_t *spm);
void z_spmDofExtend(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_ */ #endif /* _z_spm_H_ */
...@@ -24,26 +24,27 @@ ...@@ -24,26 +24,27 @@
* *
* @ingroup pastix_spm_internal * @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 * @param[in,out] spm
* The spm which needs to be scaled. * The spm which needs to be scaled.
* *
*******************************************************************************/ *******************************************************************************/
void 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_int_t nnz, i;
pastix_complex64_t *values; pastix_complex64_t *values;
nnz = spm->nnz; nnz = spm->nnz;
values = spm->values; values = spm->values;
norm = z_spmNorm( PastixFrobeniusNorm, spm );
for (i=0; i<nnz; i++){ for (i=0; i<nnz; i++){
values[i] /= norm; values[i] *= alpha;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment