Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 74163848 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Start cleaning up the multi-dof

parent 93571870
No related branches found
No related tags found
No related merge requests found
......@@ -99,6 +99,7 @@ pastix_int_t spmSymmetrize( pastix_spm_t *spm );
pastix_spm_t *spmCheckAndCorrect( pastix_spm_t *spm );
void spmExpand(pastix_spm_t* spm);
void dofVar(pastix_spm_t* spm);//tmp
#endif /* _SPM_H_ */
......@@ -15,25 +15,30 @@
**/
#include "common.h"
#include "spm.h"
#include "z_spm.h"
#include "c_spm.h"
#include "d_spm.h"
#include "s_spm.h"
#include "p_spm.h"
void
spmExpandCSC(pastix_spm_t* spm)
spmExpand(pastix_spm_t* spm)
{
switch(spm->flttype)
{
case PastixFloat:
s_extandCSC(spm);
s_spmExpand(spm);
break;
case PastixComplex32:
c_extandCSC(spm);
c_spmExpand(spm);
break;
case PastixComplex64:
z_extandCSC(spm);
z_spmExpand(spm);
break;
case PastixDouble:
default:
d_extandCSC(spm);
d_spmExpand(spm);
break;
}
}
......@@ -141,7 +146,7 @@ dofCst(pastix_spm_t* spm,pastix_int_t dof)
for(i=0;i<spm->n+1;i++)
dofs[i]=dof*i;
spmExpandCSC(spm);
spmExpand(spm);
}
......@@ -194,7 +199,7 @@ dofVar(pastix_spm_t* spm)
pastix_int_t* tab = computeCorrespondIndex(dofs,spm->n);
spm->dofs = tab;
spmExpandCSC(spm);
spmExpand(spm);
/*
print_tab_int(spm->colptr,spm->n);
......
......@@ -18,6 +18,9 @@
#ifndef _z_spm_H_
#define _z_spm_H_
/**
* Conversion routines
*/
int z_spmConvertCSC2CSR( pastix_spm_t *spm );
int z_spmConvertCSC2IJV( pastix_spm_t *spm );
int z_spmConvertCSR2CSC( pastix_spm_t *spm );
......@@ -25,10 +28,21 @@ int z_spmConvertCSR2IJV( pastix_spm_t *spm );
int z_spmConvertIJV2CSC( pastix_spm_t *spm );
int z_spmConvertIJV2CSR( pastix_spm_t *spm );
void z_spmConvertColMaj2RowMaj(pastix_spm_t *spm);
void z_spmConvertRowMaj2ColMaj(pastix_spm_t *spm);
pastix_complex64_t *z_spm2dense( const pastix_spm_t *spm );
/**
* Matrix-Vector product routines
*/
int z_spmGeCSCv(int trans, pastix_complex64_t alpha, const pastix_spm_t *csc, const pastix_complex64_t *x, pastix_complex64_t beta, pastix_complex64_t *y);
int z_spmSyCSCv( pastix_complex64_t alpha, const pastix_spm_t *csc, const pastix_complex64_t *x, pastix_complex64_t beta, pastix_complex64_t *y);
int z_spmHeCSCv( pastix_complex64_t alpha, const pastix_spm_t *csc, const pastix_complex64_t *x, pastix_complex64_t beta, pastix_complex64_t *y);
/**
* Extra routines
*/
double z_spmNorm( int ntype, const pastix_spm_t *csc );
void z_spmSort( pastix_spm_t *csc );
pastix_int_t z_spmMergeDuplicate( pastix_spm_t *csc );
......@@ -37,15 +51,14 @@ pastix_int_t z_spmSymmetrize( pastix_spm_t *csc );
int z_spmGenRHS(int type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
int z_spmCheckAxb( int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx );
pastix_complex64_t *z_spm2dense( const pastix_spm_t *spm );
/**
* Output routines
*/
void z_spmDensePrint( pastix_int_t m, pastix_int_t n, pastix_complex64_t *A, pastix_int_t lda );
void z_spmPrint( const pastix_spm_t *spm );
void z_spmConvertColMaj2RowMaj(pastix_spm_t *spm);
void z_spmConvertRowMaj2ColMaj(pastix_spm_t *spm);
void z_extandCSC(pastix_spm_t *spm);
void z_spmExpand(pastix_spm_t *spm);
void z_spmDofs2Flat(pastix_spm_t *spm);
#endif /* _z_spm_H_ */
......@@ -8,7 +8,6 @@
*
* @version 5.1.0
* @author Mathieu Faverge
* @author Theophile Terraz
* @author Alban Bellot
* @date 2015-01-01
*
......@@ -18,29 +17,49 @@
#include "spm.h"
#include "z_spm.h"
void z_extandCSC(pastix_spm_t* spm)
/**
* TODO: This function is incorrect
*/
int
z_spmExpand(pastix_spm_t* spm)
{
pastix_int_t col, row, i, cpt, dofj, dofi, baseval;
cpt=0;
pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values;
pastix_complex64_t *newval = calloc(spm->nnzexp,sizeof(pastix_complex64_t));
baseval=spmFindBase( spm );
for( col=0; col<spm->n; col++)
{
for( row=spm->colptr[col]-baseval; row<spm->colptr[col+1]-baseval; row++)
{
dofi = ( spm->dof > 0 ) ? spm->dof : spm->dofs[col+1] - spm->dofs[col];
dofj = ( spm->dof > 0 ) ? spm->dof : spm->dofs[spm->rowptr[row]-baseval+1] - spm->dofs[spm->rowptr[row]-baseval];
for( i=0; i<dofi*dofj; i++)
{
newval[cpt] = valptr[row] / ((i/dofj) + (i%dofj) + 2); // Col major
cpt++;
}
}
}
spm->values=newval;
pastix_int_t i, col, row, cpt, dofj, dofi, baseval;
pastix_complex64_t *oldvalptr;
pastix_complex64_t *newvalptr;
if (1) {
return PASTIX_ERR_NOTIMPLEMENTED;
}
baseval = spmFindBase( spm );
oldvalptr = (pastix_complex64_t*)spm->values;
spm->values = malloc( spm->nnzexp * sizeof(pastix_complex64_t) );
newvalptr = (pastix_complex64_t*)spm->values;
cpt = 0;
dofi = spm->dof;
dofj = spm->dof;
for( col=0; col<spm->n; col++)
{
if ( spm->dof <= 0 ) {
dofi = spm->dofs[col+1] - spm->dofs[col];
}
for( row=spm->colptr[col]-baseval; row<spm->colptr[col+1]-baseval; row++)
{
if ( spm->dof <= 0 ) {
dofj = spm->dofs[spm->rowptr[row]-baseval+1] - spm->dofs[spm->rowptr[row]-baseval];
}
for( i=0; i<dofi*dofj; i++)
{
newvalptr[cpt] = oldvalptr[row] / ((i/dofj) + (i%dofj) + 2); // Col major
cpt++;
}
}
}
free( oldvalptr );
}
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