File: BI_TransDist.c

package info (click to toggle)
scalapack 2.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 37,012 kB
  • sloc: fortran: 339,113; ansic: 74,517; makefile: 1,494; sh: 34
file content (58 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "Bdef.h"

void BI_TransDist(BLACSCONTEXT *ctxt, char scope, Int m, Int n, Int *rA,
                  Int *cA, Int ldrc, BI_DistType *dist, Int rdest, Int cdest)
/*
 *  This routine translates distances (offsets from the destination node),
 *  stored in location dist, into row and column coordinates.
 */
{
   Int i, j, k, dest;
   Int Ng, nprow, npcol, myrow, mycol;

   Mgridinfo(ctxt, Ng, nprow, npcol, myrow, mycol);
   if (rdest == -1) rdest = cdest = 0;

   switch (scope)
   {
   case 'r':
      for (j=0; j < n; j++)
      {
         for (i=0; i < m; i++)
         {
            rA[i] = myrow;
            cA[i] = (Int) (cdest + dist[i]) % npcol;
         }
         rA += ldrc;
         cA += ldrc;
         dist += m;
       }
       break;
   case 'c':
      for (j=0; j < n; j++)
      {
         for (i=0; i < m; i++)
         {
            rA[i] = (Int) (rdest + dist[i]) % nprow;
            cA[i] = mycol;
         }
         rA += ldrc;
         cA += ldrc;
         dist += m;
      }
      break;
   case 'a':
      dest = Mvkpnum(ctxt, rdest, cdest);
      for (j=0; j < n; j++)
      {
         for (i=0; i < m; i++)
         {
            k = (Int) (dest + dist[i]) % Ng;   /* figure node number */
            Mvpcoord(ctxt, k, rA[i], cA[i]);   /* figure node coordinates */
         }
         rA += ldrc;
         cA += ldrc;
         dist += m;
      }
   }
}