File: psasymv_.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 (243 lines) | stat: -rw-r--r-- 9,228 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#include "tools.h"
void psasymv_(uplo, N, alpha, A, IA, JA, descA, X, IX, JX, descX, incX, beta, 
              Y, IY, JY, descY, incY)
F_CHAR uplo;
int *N;
float *alpha;
float *A;
int *IA;
int *JA;
int *descA;
float *X;
int *IX;
int *JX;
int *descX;
int *incX;
float *beta;
float *Y;
int *IY;
int *JY;
int *descY;
int  *incY;
/*
 * Purpose
 * =======
 *
 * PSAHEMV performs the distributed matrix-vector operations
 *
 *     sub( Y ) := alpha*sub( abs(A) ) * sub( abs(X) )  + beta*sub( abs(Y) )
 *
 *  where op may be transpose or conjugate transpose, and
 *
 *        sub( A ) denotes A(IA:IA+M-1,JA:JA+N-1),
 *
 *        sub (X ) denotes
 *                       X(IX:IX,JX:JX+N-1), if INX = M_X
 *                       X(IX:IX+N-1,JX:JX), if INCX = 1 and INCX <> M_X,
 *
 *        sub( Y ) denotes
 *                       Y(IY:IY,JY:JY+M-1), if INCY = M_Y,
 *                       Y(IY:IY+M-1,JY:JY), if INCY = 1 and INCY <> M_Y,
 *
 *  alpha and beta are scalars, and sub( X ) and sub( Y ) are distributed
 *  vectors and sub( A ) is a M-by-N distributed submatrix.
 *
 *  Notes
 *  =====
 *  A description vector is associated with each 2D block-cyclicly dis-
 *  tributed matrix.  This vector stores the information required to
 *  establish the mapping between a matrix entry and its corresponding
 *  process and memory location.
 *
 *  In the following comments, the character _ should be read as
 *  "of the distributed matrix".  Let A be a generic term for any 2D
 *  block cyclicly distributed matrix.  Its description vector is DESC_A:
 *
 *  NOTATION        STORED IN     EXPLANATION
 *  --------------- ------------- ---------------------------------------
 *  M_A    (global) desc_A[M_]    The number of rows in the distributed
 *                                matrix.
 *  N_A    (global) desc_A[N_]    The number of columns in the distribu-
 *                                ted matrix.
 *  MB_A   (global) desc_A[MB_]   The blocking factor used to distribute
 *                                the rows of the matrix.
 *  NB_A   (global) desc_A[NB_]   The blocking factor used to distribute
 *                                the columns of the matrix.
 *  RSRC_A (global) desc_A[RSRC_] The process row over which the first
 *                                row of the matrix is distributed.
 *  CSRC_A (global) desc_A[CSRC_] The process column over which the first
 *                                column of the matrix is distributed.
 *  CTXT_A (global) desc_A[CTXT_] The BLACS context handle, indicating
 *                                the global context of the operation on
 *                                the matrix.  The context is global, but the
 *                                context handle may vary across processes.
 *  LLD_A  (local)  desc_A[LLD_]  The leading dimension of the local
 *                                array storing the local blocks of the
 *                                distributed matrix A.
 *                                LLD_A >= MAX(1,LOCp(M_A)).
 *
 *  Let K be the number of rows or columns of a distributed matrix,
 *  and assume that its process grid has dimension p x q.
 *  LOCp( K ) denotes the number of elements of K that a process
 *  would receive if K were distributed over the p processes of its
 *  process column.
 *  Similarly, LOCq( K ) denotes the number of elements of K that a
 *  process would receive if K were distributed over the q processes of
 *  its process row.
 *  The values of LOCp() and LOCq() may be determined via a call to the
 *  ScaLAPACK tool function, NUMROC.
 *          LOCp( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
 *          LOCq( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
 *
 *  Because vectors are a subclass of matrices, a distributed vector is
 *  considered to be a distributed matrix.
 *
 *  Parameters
 *  ==========
 *
 *  N       (global input) pointer to REAL.
 *          The length of the distributed vectors to be operated on.  N >= 0.
 *
 *  TRANS   (global input) pointer to CHARACTER
 *          On entry, TRANS specifies what op( ) indicates as follows:
 *
 *          if TRANS = 'N' or 'n',
 *             op( A ) = A
 *          else if TRANS = 'T' or 't',
 *             op( A ) = A'
 *          else if TRANS = 'C' or 'c',
 *            op( A ) = A'
 *  M       (global input) pointer to INTEGER
 *          The number of rows to be operated on; i.e the number of rows
 *          of the distributed submatrix sub( A ). M >= 0.
 *
 *  N       (global input) pointer to INTEGER
 *          The number of columns to be operated on; i.e the number of
 *          columns of the distributed submatrix sub( A ). N >= 0.
 *
 *  ALPHA   (global input) pointer to REAL
 *          On entry, ALPHA specifies the scalar alpha.
 *
 *  X       (local input) REAL array containing the local pieces
 *          of a distributed matrix of dimension of at least
 *              ( (JX-1)*M_X + IX + ( N - 1 )*abs( INCX ) )
 *          This array contains the entries of the distributed vector
 *          sub( X ).
 *
 *  IX      (global input) pointer to INTEGER
 *          The global row index of the distributed matrix X which points
 *          to the first row of the submatrix to operated on.
 *
 *  JX      (global input) pointer to INTEGER
 *          The global column index of the distributed matrix X which points
 *          to the first column of the submatrix to operated on.
 *
 *  DESCX   (global and local input) INTEGER array of dimension 8.
 *          The array descriptor of the distributed matrix X.
 *
 *  INCX    (global input) pointer to INTEGER
 *          The global increment for the elements of X. Only two values
 *          of INCX are supported in this version, namely 1 and M_X.
 *
 *  Y       (local input) REAL array containing the local pieces
 *          of a distributed matrix of dimension of at least
 *              ( (JY-1)*M_Y + IY + ( N - 1 )*abs( INCY ) )
 *          This array contains the entries of the distributed vector
 *          sub( Y ).
 *
 *  IY      (global input) pointer to INTEGER
 *          The global row index of the distributed matrix Y which points
 *          to the first row of the submatrix to operated on.
 *
 *  JY      (global input) pointer to INTEGER
 *          The global column index of the distributed matrix Y which points
 *          to the first column of the submatrix to operated on.
 *
 *  DESCY   (global and local input) INTEGER array of dimension 8.
 *          The array descriptor of the distributed matrix Y.
 *
 *  INCY    (global input) pointer to INTEGER
 *          The global increment for the elements of Y. Only two values
 *          of INCY are supported in this version, namely 1 and M_Y.
 *
 *  A       (local input) REAL pointer into local memory to an array
 *          of dimension ( LLD_A, LOCq(JA+N-1) ) containing the local pieces
 *          of the distributed matrix sub( A )
 *
 *  IA      (global input) pointer to INTEGER
 *          The global row index of the distributed matrix A which points
 *          to the first row of the submatrix to operated on.
 *
 *  JA      (global input) pointer to INTEGER
 *          The global column index of the distributed matrix A which points
 *          to the first column of the submatrix to operated on.
 *
 *  DESCA   (global and local input) INTEGER array of dimension 8.
 *          The array descriptor of the distributed matrix A.
 *
 *  ===========================================================================
 */
{
/*
 * .. External routines ..
 */
   void pberror_();
   void CpsahemvU();
   void CpsahemvL();

   char Cuplo;
   int nprow, npcol, myrow, mycol, info=0;

   Cblacs_gridinfo(descA[CTXT_], &nprow, &npcol, &myrow, &mycol);
   pchkmat(*N, 2, *N, 2, *IA, *JA, descA, 7, &info, nprow, npcol, myrow, mycol);
   pchkvec(*N, 2, *IX, *JX, descX, *incX, 11, &info, nprow, npcol,
           myrow, mycol);
   pchkvec(*N, 2, *IY, *JY, descY, *incY, 17, &info, nprow, npcol,
           myrow, mycol);
   if (descA[CTXT_] != descX[CTXT_])
   {
      if (info == 0) info = -(1100+CTXT_+1);
   }
   else if (descX[CTXT_] != descY[CTXT_])
   {
      if (info == 0) info = -(1700+CTXT_+1);
   }
   else if (descA[MB_] != descA[NB_]) /* enforce square blocks */
   {
      if (info == 0) info = -(700+NB_+1);
   }
   else if ((*IA-1) % descA[MB_] != (*JA-1) % descA[NB_])
   {
      fprintf(stderr, "ERROR: IA=%d, JA=%d, descA[MB_]=%d, descA[NB]=%d\n",
              *IA-1, *JA-1, descA[MB_], descA[NB_]);
      if (info == 0) info = -6;
   }
   if (info)
   {
      pberror_(&descA[CTXT_], "PSASYMV", &info);
      return;
   }
/*
 * Quick return, if possible
 */
   if ( (*N == 0) || ((*alpha == 0.0) && (*beta == 1.0)) ) return;

   Cuplo = *F2C_CHAR(uplo);
   Cuplo = Mlowcase(Cuplo);
   if (Cuplo == 'l')
   {
      CpsasymvL(*N, *alpha, A, *IA-1, *JA-1, descA, X, *IX-1, *JX-1,
                descX, *incX, *beta, Y, *IY-1, *JY-1, descY, *incY);
   }
   else if (Cuplo == 'u')
   {
      CpsasymvU(*N, *alpha, A, *IA-1, *JA-1, descA, X,
                *IX-1, *JX-1, descX, *incX, *beta, Y, *IY-1, *JY-1, descY,
                *incY);
   }
   else
   {
      info = -1;
      pberror_(&descA[CTXT_], "PSASYMV", &info);
   }
}