Mentions légales du service

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

add a function in spm to scal a matrix and obtain a norm of 1

parent b781244e
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ set(SOURCES ...@@ -20,6 +20,7 @@ set(SOURCES
z_spm_2dense.c z_spm_2dense.c
z_spm_dof_extend.c z_spm_dof_extend.c
z_spm_norm.c z_spm_norm.c
z_spm_scal.c
z_spm_convert_to_csc.c z_spm_convert_to_csc.c
z_spm_convert_to_csr.c z_spm_convert_to_csr.c
......
...@@ -1079,3 +1079,38 @@ spmCheckAxb( int nrhs, ...@@ -1079,3 +1079,38 @@ spmCheckAxb( int nrhs,
return ptrfunc[id](nrhs, spm, x0, ldx0, b, ldb, x, ldx ); return ptrfunc[id](nrhs, spm, x0, ldx0, b, ldb, x, ldx );
} }
} }
/**
*******************************************************************************
*
* @ingroup pastix_spm
*
* @brief Scal a matrix with ||A||_2
*
*******************************************************************************
*
* @param[in,out] spm
* The sparse matrix to scal.
*
*******************************************************************************/
void
spmScal(pastix_spm_t* spm)
{
switch(spm->flttype)
{
case PastixPattern:
break;
case PastixFloat:
s_spmScal(spm);
break;
case PastixComplex32:
c_spmScal(spm);
break;
case PastixComplex64:
z_spmScal(spm);
break;
case PastixDouble:
default:
d_spmScal(spm);
}
}
...@@ -150,6 +150,7 @@ void * spm2Dense( const pastix_spm_t *spm ); ...@@ -150,6 +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 );
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 );
...@@ -171,4 +172,5 @@ int spmReadDriver( pastix_driver_t driver, ...@@ -171,4 +172,5 @@ int spmReadDriver( pastix_driver_t driver,
pastix_spm_t *spm, pastix_spm_t *spm,
MPI_Comm pastix_comm ); MPI_Comm pastix_comm );
#endif /* _SPM_H_ */ #endif /* _SPM_H_ */
...@@ -64,8 +64,9 @@ int z_spmCheckAxb( int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void * ...@@ -64,8 +64,9 @@ int z_spmCheckAxb( int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void *
void z_spmDensePrint( FILE *f, pastix_int_t m, pastix_int_t n, pastix_complex64_t *A, pastix_int_t lda ); void z_spmDensePrint( FILE *f, pastix_int_t m, pastix_int_t n, pastix_complex64_t *A, pastix_int_t lda );
void z_spmPrint( FILE *f, const pastix_spm_t *spm ); 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 );
#endif /* _z_spm_H_ */ #endif /* _z_spm_H_ */
/**
* @file z_spm_scal.c
*
* PaStiX spm computational routines.
*
* PaStiX is a software package provided by Inria Bordeaux - Sud-Ouest,
* LaBRI, University of Bordeaux 1 and IPB.
*
* @version 1.0.0
* @author Mathieu Faverge
* @author Pierre Ramet
* @author Xavier Lacoste
* @author Theophile Terraz
* @date 2015-06-01
* @precisions normal z -> c d s
*
**/
#include "common.h"
#include "spm.h"
#include "z_spm.h"
/**
*******************************************************************************
*
* @ingroup pastix_spm_internal
*
* z_spmScal - Scal the matrix with ||A||_2
*
*******************************************************************************
*
* @param[in,out] spm
* The spm which needs to be scaled.
*
*******************************************************************************/
void
z_spmScal( 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 );
printf("NORM IN %.3g\n", norm);
for (i=0; i<nnz; i++){
values[i] /= norm;
}
norm = z_spmNorm( PastixFrobeniusNorm, spm );
printf("NORM OUT %.3g\n", norm);
}
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