ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
SL_gridreshape.c File Reference
#include <stdlib.h>
#include <stdio.h>
Include dependency graph for SL_gridreshape.c:

Go to the source code of this file.

Functions/Subroutines

int SL_Cgridreshape (int ctxt, int pstart, int row_major_in, int row_major_out, int P, int Q)
int sl_gridreshape_ (int *ctxt, int *pstart, int *row_major_in, int *row_major_out, int *P, int *Q)
int SL_GRIDRESHAPE (int *ctxt, int *pstart, int *row_major_in, int *row_major_out, int *P, int *Q)
int sl_gridreshape__ (int *ctxt, int *pstart, int *row_major_in, int *row_major_out, int *P, int *Q)
int sl_gridreshape (int *ctxt, int *pstart, int *row_major_in, int *row_major_out, int *P, int *Q)

Function/Subroutine Documentation

int SL_Cgridreshape ( int  ctxt,
int  pstart,
int  row_major_in,
int  row_major_out,
int  P,
int  Q 
)

Definition at line 4 of file SL_gridreshape.c.

{
   int Cblacs_pnum();
   int nctxt, P0, Q0, Np, i, *g;

   Cblacs_gridinfo(ctxt, &P0, &Q0, &i, &Np);
   Np = P * Q;
   if (Np+pstart > P0*Q0)
   {
      fprintf(stderr, "Illegal reshape command in %s\n",__FILE__);
      Cblacs_abort(ctxt, -22);
   }
   g = (int *) malloc(Np * sizeof(int));
   if (!g)
   {
      fprintf(stderr, "Cannot allocate memory in %s\n",__FILE__);
      Cblacs_abort(ctxt, -23);
   }
   if (row_major_in)  /* Read in in row-major order */
   {
      if (row_major_out)
         for (i=0; i != Np; i++)
            g[(i%Q)*P+i/Q] = Cblacs_pnum(ctxt, (pstart+i)/Q0, (pstart+i)%Q0);
      else
         for (i=0; i != Np; i++)
            g[i] = Cblacs_pnum(ctxt, (pstart+i)/Q0, (pstart+i)%Q0);
   }
   else /* read in in column-major order */
   {
      if (row_major_out)
         for (i=0; i != Np; i++)
            g[(i%Q)*P+i/Q] = Cblacs_pnum(ctxt, (pstart+i)%P0, (pstart+i)/P0);
      else
         for (i=0; i != Np; i++)
            g[i] = Cblacs_pnum(ctxt, (pstart+i)%P0, (pstart+i)/P0);
   }
   Cblacs_get(ctxt, 10, &nctxt);
   Cblacs_gridmap(&nctxt, g, P, P, Q);
   free(g);

   return(nctxt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int SL_GRIDRESHAPE ( int *  ctxt,
int *  pstart,
int *  row_major_in,
int *  row_major_out,
int *  P,
int *  Q 
)

Definition at line 55 of file SL_gridreshape.c.

{
   return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
                           *P, *Q) );
}

Here is the call graph for this function:

int sl_gridreshape ( int *  ctxt,
int *  pstart,
int *  row_major_in,
int *  row_major_out,
int *  P,
int *  Q 
)

Definition at line 69 of file SL_gridreshape.c.

{
   return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
                           *P, *Q) );
}

Here is the call graph for this function:

int sl_gridreshape_ ( int *  ctxt,
int *  pstart,
int *  row_major_in,
int *  row_major_out,
int *  P,
int *  Q 
)

Definition at line 48 of file SL_gridreshape.c.

{
   return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
                           *P, *Q) );
}

Here is the call graph for this function:

int sl_gridreshape__ ( int *  ctxt,
int *  pstart,
int *  row_major_in,
int *  row_major_out,
int *  P,
int *  Q 
)

Definition at line 62 of file SL_gridreshape.c.

{
   return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
                           *P, *Q) );
}

Here is the call graph for this function: