ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
BI_TransDist.c
Go to the documentation of this file.
00001 #include "Bdef.h"
00002 
00003 void BI_TransDist(BLACSCONTEXT *ctxt, char scope, int m, int n, int *rA,
00004                   int *cA, int ldrc, BI_DistType *dist, int rdest, int cdest)
00005 /*
00006  *  This routine translates distances (offsets from the destination node),
00007  *  stored in location dist, into row and column coordinates.
00008  */
00009 {
00010    int i, j, k, dest;
00011    int Ng, nprow, npcol, myrow, mycol;
00012 
00013    Mgridinfo(ctxt, Ng, nprow, npcol, myrow, mycol);
00014    if (rdest == -1) rdest = cdest = 0;
00015 
00016    switch (scope)
00017    {
00018    case 'r':
00019       for (j=0; j < n; j++)
00020       {
00021          for (i=0; i < m; i++)
00022          {
00023             rA[i] = myrow;
00024             cA[i] = (int) (cdest + dist[i]) % npcol;
00025          }
00026          rA += ldrc;
00027          cA += ldrc;
00028          dist += m;
00029        }
00030        break;
00031    case 'c':
00032       for (j=0; j < n; j++)
00033       {
00034          for (i=0; i < m; i++)
00035          {
00036             rA[i] = (int) (rdest + dist[i]) % nprow;
00037             cA[i] = mycol;
00038          }
00039          rA += ldrc;
00040          cA += ldrc;
00041          dist += m;
00042       }
00043       break;
00044    case 'a':
00045       dest = Mvkpnum(ctxt, rdest, cdest);
00046       for (j=0; j < n; j++)
00047       {
00048          for (i=0; i < m; i++)
00049          {
00050             k = (int) (dest + dist[i]) % Ng;   /* figure node number */
00051             Mvpcoord(ctxt, k, rA[i], cA[i]);   /* figure node coordinates */
00052          }
00053          rA += ldrc;
00054          cA += ldrc;
00055          dist += m;
00056       }
00057    }
00058 }