Mentions légales du service

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

start moving dof2flat to expand

parent 8a3e00ef
No related branches found
No related tags found
No related merge requests found
...@@ -23,57 +23,239 @@ ...@@ -23,57 +23,239 @@
pastix_spm_t * pastix_spm_t *
z_spmExpand(const pastix_spm_t *spm) z_spmExpand(const pastix_spm_t *spm)
{ {
pastix_spm_t *newspm; pastix_spm_t *newspm;
pastix_int_t i, col, row, cpt, dofj, dofi, baseval; pastix_int_t i, j, k, ii, jj, dofi, dofj, col, row, baseval, cpt;
pastix_int_t *newcol, *newrow, *oldcol, *oldrow, *dofs;
#if !defined(PRECISION_p) #if !defined(PRECISION_p)
pastix_complex64_t *oldvalptr; pastix_complex64_t *newval, *oldval;
pastix_complex64_t *newvalptr;
#endif #endif
if (spm->dof == 1) { if ( spm->dof == 1 ) {
return spm; return (pastix_spm_t*)spm;
} }
if (1) { if ( spm->layout != PastixColMajor ) {
pastix_error_print( "Unsupported layout\n" );
return NULL; return NULL;
} }
newspm = malloc( sizeof(pastix_spm_t) );
/* baseval = spmFindBase( spm ); */ spmInit( newspm );
/* #if !defined(PRECISION_p) */ baseval = spmFindBase( spm );
/* oldvalptr = (pastix_complex64_t*)spm->values; */ oldcol = spm->colptr;
/* spm->values = malloc( spm->nnzexp * sizeof(pastix_complex64_t) ); */ oldrow = spm->rowptr;
/* newvalptr = (pastix_complex64_t*)spm->values; */ dofs = spm->dofs;
/* #endif */ #if !defined(PRECISION_p)
oldval = (pastix_complex64_t*)(spm->values);
/* cpt = 0; */ #endif
/* dofi = spm->dof; */
/* dofj = spm->dof; */ switch(spm->fmttype)
{
/* for( col=0; col<spm->n; col++) */ case PastixCSC:
/* { */ newspm->colptr = newcol = malloc(sizeof(pastix_int_t)*spm->nexp);
/* if ( spm->dof <= 0 ) { */ newspm->rowptr = newrow = malloc(sizeof(pastix_int_t)*spm->nnzexp);
/* dofi = spm->dofs[col+1] - spm->dofs[col]; */ #if !defined(PRECISION_p)
/* } */ newspm->values = newval = malloc(sizeof(pastix_complex64_t)*spm->nnzexp);
#endif
/* for( row=spm->colptr[col]-baseval; row<spm->colptr[col+1]-baseval; row++) */
/* { */ *newcol = 0; newcol++;
/* if ( spm->dof <= 0 ) { */ *newrow = 0;
/* dofj = spm->dofs[spm->rowptr[row]-baseval+1] - spm->dofs[spm->rowptr[row]-baseval]; */ /**
/* } */ * Loop on col
*/
/* for( i=0; i<dofi*dofj; i++) */ for(i=0; i<spm->n; i++)
/* { */ {
/* #if !defined(PRECISION_p) */ if ( spm->dof > 0 ) {
/* newvalptr[cpt] = oldvalptr[row] / ((i/dofj) + (i%dofj) + 2); // Col major */ col = spm->dof * i;
/* cpt++; */ dofi = spm->dof;
/* #endif */ }
/* } */ else {
/* } */ col = dofs[i];
/* } */ dofi = dofs[i+1] - dofs[i];
}
/* #if !defined(PRECISION_p) */
/* free( oldvalptr ); */ for(ii=0; ii<dofi; ii++, newcol++)
/* #endif */ {
/**
* Loop on rows
*/
for(k=oldcol[i]; k<oldcol[i+1]; k++)
{
j = oldrow[k-baseval]-baseval;
if ( spm->dof > 0 ) {
row = spm->dof * j;
dofj = spm->dof;
}
else {
row = dofs[j];
dofj = dofs[j+1] - dofs[j];
}
for(jj=0; jj<dofj; jj++, newrow++)
{
(*newcol)++;
(*newrow) = row + jj + baseval;
#if !defined(PRECISION_p)
if ( (spm->mtxtype != PastixGeneral) &&
(row + jj < col + ii) )
{
(*newval) = oldval[ cpt ];
newval++;
}
cpt++;
#endif
}
}
(*newcol) += baseval;
}
}
break;
case PastixCSR:
case PastixIJV:
free( newspm );
return NULL;
}
/* for(i=0; i<spm->nexp; i++) */
/* { */
/* new_col[i+1]+=new_col[i]; */
/* } */
/* cpt = 0; */
/* for(i=0; i < spm->n;i++) */
/* { */
/* col = ( spm->dof > 0 ) ? i : dofs[i]; */
/* dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; */
/* for(k=spm->colptr[i]-baseval ; k<spm->colptr[i+1]-baseval ;k++) */
/* { */
/* j = spm->rowptr[k] - baseval; */
/* row = ( spm->dof > 0 ) ? j : dofs[j]; */
/* dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; */
/* for(ii=0;ii < dofi; ii++) */
/* { */
/* for(jj=0;jj < dofj ; jj++) */
/* { */
/* new_vals[new_col[col+ii]] = vals[cpt]; */
/* new_row[new_col[col+ii]] = row + jj + baseval; */
/* new_col[col+ii]++; */
/* cpt++; */
/* } */
/* } */
/* } */
/* } */
/* { */
/* int tmp; */
/* int tmp1 = 0; */
/* for(i=0; i<spm->nexp; i++) */
/* { */
/* tmp = new_col[i]; */
/* new_col[i] = tmp1+baseval; */
/* tmp1 = tmp; */
/* } */
/* new_col[i] += baseval; */
/* } */
/* spm->gN = spm->gNexp; */
/* spm->n = spm->nexp; */
/* spm->gnnz = spm->gnnzexp; */
/* spm->nnz = spm->nnzexp; */
/* spm->dof = 1; */
/* spm->dofs = NULL; */
/* spm->layout = PastixColMajor; */
/* spm->colptr = new_col; */
/* spm->rowptr = new_row; */
/* //spm->loc2glob = NULL; // ? */
/* spm->values = new_vals; */
/* break; */
/* case PastixSymmetric: */
/* for(i=0;i<spm->n ; i++) */
/* { */
/* col = ( spm->dof > 0 ) ? i : dofs[i]; */
/* dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; */
/* for(k=spm->colptr[i]-baseval; k<spm->colptr[i+1]-baseval; k++) */
/* { */
/* j = spm->rowptr[k]-baseval; */
/* row = ( spm->dof > 0 ) ? j : dofs[j]; */
/* dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; */
/* for(ii=0; ii<dofi; ii++) */
/* { */
/* for(jj=0; jj<dofj; jj++) */
/* { */
/* if( i != j ) */
/* new_col[col+ii+1] += 1; */
/* else */
/* if(ii <= jj ) */
/* new_col[col+ii+1] += 1; */
/* } */
/* } */
/* } */
/* } */
/* for(i=0; i<spm->nexp; i++) */
/* { */
/* new_col[i+1] += new_col[i]; */
/* } */
/* pastix_int_t nnz = new_col[spm->nexp]; */
/* new_row = malloc(sizeof(pastix_int_t)*nnz); */
/* new_vals = malloc(sizeof(pastix_complex64_t)*nnz); */
/* cpt = 0; */
/* for(i=0; i < spm->n;i++) */
/* { */
/* col = ( spm->dof > 0 ) ? i : dofs[i]; */
/* dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; */
/* for(k=spm->colptr[i]-baseval ; k<spm->colptr[i+1]-baseval ;k++) */
/* { */
/* j = spm->rowptr[k] - baseval; */
/* row = ( spm->dof > 0 ) ? j : dofs[j]; */
/* dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; */
/* for(ii=0;ii < dofi; ii++) */
/* { */
/* for(jj=0;jj < dofj ; jj++) */
/* { */
/* if( i == j ) */
/* { */
/* if ( ii <= jj ) */
/* { */
/* /\* diagonal dominant for spd matrix */
/* if( ii == jj) */
/* new_vals[new_col[col+ii]] = 2*vals[cpt]; */
/* else */
/* *\/ */
/* new_vals[new_col[col+ii]] = vals[cpt]; */
/* new_row[new_col[col+ii]] = row + jj + baseval; */
/* new_col[col+ii]++; */
/* } */
/* } */
/* else */
/* { */
/* new_vals[new_col[col+ii]] = vals[cpt]; */
/* new_row[new_col[col+ii]] = row + jj + baseval; */
/* new_col[col+ii]++; */
/* } */
/* cpt++; */
/* } */
/* } */
/* } */
/* } */
newspm->gN = spm->gNexp;
newspm->n = spm->nexp;
newspm->gnnz = spm->gnnzexp;
newspm->nnz = spm->nnzexp;
newspm->gnnzexp = spm->gnnzexp;
newspm->nnzexp = spm->nnzexp;
newspm->dof = 1;
newspm->dofs = NULL;
newspm->layout = PastixColMajor;
assert(spm->loc2glob == NULL);//to do
(void)col; (void)cpt;
return newspm;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment