File: Cpcsvabs1.c

package info (click to toggle)
scalapack 1.6-13
  • links: PTS
  • area: main
  • in suites: potato
  • size: 30,476 kB
  • ctags: 25,789
  • sloc: fortran: 296,718; ansic: 51,265; makefile: 1,541; sh: 4
file content (77 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "tools.h"
void Cpcsvabs1(N, X, IX, JX, descX, incX, Y, IY, JY, descY, incY)
int N;
float *X;
int IX;
int JX;
int *descX;
int incX;
float **Y;
int *IY;
int *JY;
int *descY;
int  *incY;
/*
 * Y(i) = abs( real(X(i)) ) + abs( imaginary(X(i)) )
 */
{
   void pberror_();
   void Cinfog2l();
   int Cnumroc2();
   void Cblacs_gridinfo();
   int i, j, k, info, xrow, xcol;
   int nprow, npcol, myrow, mycol;
   float *x, *y;

   Cblacs_gridinfo(descX[CTXT_], &nprow, &npcol, &myrow, &mycol);
   Cinfog2l(IX, JX, descX, nprow, npcol, myrow, mycol, &i, &j, &xrow, &xcol);
   x = &X[ 2*(i+j*descX[LLD_]) ];

   *incY = 1;
   if (incX == descX[M_])  /* X is a row vector (or degenerate) */
   {
      *IY = 0;
      *JY = JX % descX[NB_];
      Mdescset(descY, 1, N + *JY, 1, descX[NB_], xrow, xcol, descX[CTXT_], 1);
      if (myrow == xrow)
      {
         j = Cnumroc2(N, JX, descX[NB_], mycol, descX[CSRC_], npcol);
         if (mycol == xcol) i = *JY;
         else i = 0;
         k = j + i;
         if (!k) k = 1;
         Mmalloc(y, float, k, info, descX[CTXT_]);
         *Y = y;
         y += i;
         for (i=0; i != j; i++)
            y[i] = ABS( x[ i*2*descX[LLD_] ] ) + ABS( x[ i*2*descX[LLD_]+1 ] );
      }
      else
      {
         Mmalloc(*Y, float, 1, info, descX[CTXT_]);
      }
   }
   else  /* X is a column vector */
   {
      *IY = IX % descX[MB_];
      *JY = 0;
      if (mycol == xcol)
      {
         j = Cnumroc2(N, IX, descX[MB_], myrow, descX[RSRC_], nprow);
         if (myrow == xrow) i = *IY;
         else i = 0;
         k = i + j;
         if (!k) k = 1;
         Mmalloc(y, float, k, info, descX[CTXT_]);
         *Y = y;
         y += i;
         for (i=0; i != j; i++) y[i] = ABS( x[i*2] ) + ABS( x[i*2+1] );
      }
      else
      {
         Mmalloc(*Y, float, 1, info, descX[CTXT_]);
         k = 1;
      }
      Mdescset(descY, N + *IY, 1, descX[MB_], 1, xrow, xcol, descX[CTXT_], k);
   }
}