ScaLAPACK 2.1  2.1 ScaLAPACK: Scalable Linear Algebra PACKage
pctranc_.c
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2 *
3 * -- PBLAS routine (version 2.0) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * April 1, 1998
7 *
8 * ---------------------------------------------------------------------
9 */
10 /*
11 * Include files
12 */
13 #include "pblas.h"
14 #include "PBpblas.h"
15 #include "PBtools.h"
16 #include "PBblacs.h"
17 #include "PBblas.h"
18
19 #ifdef __STDC__
20 void pctranc_( int * M, int * N,
21  float * ALPHA,
22  float * A, int * IA, int * JA, int * DESCA,
23  float * BETA,
24  float * C, int * IC, int * JC, int * DESCC )
25 #else
26 void pctranc_( M, N, ALPHA, A, IA, JA, DESCA, BETA, C, IC, JC, DESCC )
27 /*
28 * .. Scalar Arguments ..
29 */
30  int * IA, * IC, * JA, * JC, * M, * N;
31  float * ALPHA, * BETA;
32 /*
33 * .. Array Arguments ..
34 */
35  int * DESCA, * DESCC;
36  float * A, * C;
37 #endif
38 {
39 /*
40 * Purpose
41 * =======
42 *
43 * PCTRANC transposes a matrix
44 *
45 * sub( C ) := beta*sub( C ) + alpha*op( sub( A ) )
46 *
47 * where
48 *
49 * sub( C ) denotes C(IC:IC+M-1,JC:JC+N-1),
50 *
51 * sub( A ) denotes A(IA:IA+N-1,JA:JA+M-1), and,
52 *
53 * op( X ) = conjg( X )'.
54 *
55 * Thus, op( sub( A ) ) denotes conjg( A(IA:IA+N-1,JA:JA+M-1)' ).
56 *
57 * Beta is a scalar, sub( C ) is an m by n submatrix, and sub( A ) is an
58 * n by m submatrix.
59 *
60 * Notes
61 * =====
62 *
63 * A description vector is associated with each 2D block-cyclicly dis-
64 * tributed matrix. This vector stores the information required to
65 * establish the mapping between a matrix entry and its corresponding
66 * process and memory location.
67 *
68 * In the following comments, the character _ should be read as
69 * "of the distributed matrix". Let A be a generic term for any 2D
70 * block cyclicly distributed matrix. Its description vector is DESC_A:
71 *
72 * NOTATION STORED IN EXPLANATION
73 * ---------------- --------------- ------------------------------------
74 * DTYPE_A (global) DESCA[ DTYPE_ ] The descriptor type.
75 * CTXT_A (global) DESCA[ CTXT_ ] The BLACS context handle, indicating
76 * the NPROW x NPCOL BLACS process grid
77 * A is distributed over. The context
78 * itself is global, but the handle
79 * (the integer value) may vary.
80 * M_A (global) DESCA[ M_ ] The number of rows in the distribu-
81 * ted matrix A, M_A >= 0.
82 * N_A (global) DESCA[ N_ ] The number of columns in the distri-
83 * buted matrix A, N_A >= 0.
84 * IMB_A (global) DESCA[ IMB_ ] The number of rows of the upper left
85 * block of the matrix A, IMB_A > 0.
86 * INB_A (global) DESCA[ INB_ ] The number of columns of the upper
87 * left block of the matrix A,
88 * INB_A > 0.
89 * MB_A (global) DESCA[ MB_ ] The blocking factor used to distri-
90 * bute the last M_A-IMB_A rows of A,
91 * MB_A > 0.
92 * NB_A (global) DESCA[ NB_ ] The blocking factor used to distri-
93 * bute the last N_A-INB_A columns of
94 * A, NB_A > 0.
95 * RSRC_A (global) DESCA[ RSRC_ ] The process row over which the first
96 * row of the matrix A is distributed,
97 * NPROW > RSRC_A >= 0.
98 * CSRC_A (global) DESCA[ CSRC_ ] The process column over which the
99 * first column of A is distributed.
100 * NPCOL > CSRC_A >= 0.
101 * LLD_A (local) DESCA[ LLD_ ] The leading dimension of the local
102 * array storing the local blocks of
103 * the distributed matrix A,
104 * IF( Lc( 1, N_A ) > 0 )
105 * LLD_A >= MAX( 1, Lr( 1, M_A ) )
106 * ELSE
107 * LLD_A >= 1.
108 *
109 * Let K be the number of rows of a matrix A starting at the global in-
110 * dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
111 * that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
112 * receive if these K rows were distributed over NPROW processes. If K
113 * is the number of columns of a matrix A starting at the global index
114 * JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
115 * lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
116 * these K columns were distributed over NPCOL processes.
117 *
118 * The values of Lr() and Lc() may be determined via a call to the func-
119 * tion PB_Cnumroc:
120 * Lr( IA, K ) = PB_Cnumroc( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
121 * Lc( JA, K ) = PB_Cnumroc( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
122 *
123 * Arguments
124 * =========
125 *
126 * M (global input) INTEGER
127 * On entry, M specifies the number of rows of the submatrix
128 * sub( C ) and the number of columns of the submatrix sub( A ).
129 * M must be at least zero.
130 *
131 * N (global input) INTEGER
132 * On entry, N specifies the number of columns of the submatrix
133 * sub( C ) and the number of rows of the submatrix sub( A ). N
134 * must be at least zero.
135 *
136 * ALPHA (global input) COMPLEX
137 * On entry, ALPHA specifies the scalar alpha. When ALPHA is
138 * supplied as zero then the local entries of the array A
139 * corresponding to the entries of the submatrix sub( A ) need
140 * not be set on input.
141 *
142 * A (local input) COMPLEX array
143 * On entry, A is an array of dimension (LLD_A, Ka), where Ka is
144 * at least Lc( 1, JA+M-1 ). Before entry, this array contains
145 * the local entries of the matrix A.
146 *
147 * IA (global input) INTEGER
148 * On entry, IA specifies A's global row index, which points to
149 * the beginning of the submatrix sub( A ).
150 *
151 * JA (global input) INTEGER
152 * On entry, JA specifies A's global column index, which points
153 * to the beginning of the submatrix sub( A ).
154 *
155 * DESCA (global and local input) INTEGER array
156 * On entry, DESCA is an integer array of dimension DLEN_. This
157 * is the array descriptor for the matrix A.
158 *
159 * BETA (global input) COMPLEX
160 * On entry, BETA specifies the scalar beta. When BETA is
161 * supplied as zero then the local entries of the array C
162 * corresponding to the entries of the submatrix sub( C ) need
163 * not be set on input.
164 *
165 * C (local input/local output) COMPLEX array
166 * On entry, C is an array of dimension (LLD_C, Kc), where Kc is
167 * at least Lc( 1, JC+N-1 ). Before entry, this array contains
168 * the local entries of the matrix C.
169 * On exit, the entries of this array corresponding to the local
170 * entries of the submatrix sub( C ) are overwritten by the
171 * local entries of the m by n updated submatrix.
172 *
173 * IC (global input) INTEGER
174 * On entry, IC specifies C's global row index, which points to
175 * the beginning of the submatrix sub( C ).
176 *
177 * JC (global input) INTEGER
178 * On entry, JC specifies C's global column index, which points
179 * to the beginning of the submatrix sub( C ).
180 *
181 * DESCC (global and local input) INTEGER array
182 * On entry, DESCC is an integer array of dimension DLEN_. This
183 * is the array descriptor for the matrix C.
184 *
185 * -- Written on April 1, 1998 by
186 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
187 *
188 * ---------------------------------------------------------------------
189 */
190 /*
191 * .. Local Scalars ..
192 */
193  int Ai, Aj, Ci, Cj, ctxt, info, mycol, myrow, npcol, nprow;
194 /*
195 * .. Local Arrays ..
196 */
197  int Ad[DLEN_], Cd[DLEN_];
198 /* ..
199 * .. Executable Statements ..
200 *
201 */
202  PB_CargFtoC( *IA, *JA, DESCA, &Ai, &Aj, Ad );
203  PB_CargFtoC( *IC, *JC, DESCC, &Ci, &Cj, Cd );
204 #ifndef NO_ARGCHK
205 /*
206 * Test the input parameters
207 */
208  Cblacs_gridinfo( ( ctxt = Ad[CTXT_] ), &nprow, &npcol, &myrow, &mycol );
209  if( !( info = ( ( nprow == -1 ) ? -( 701 + CTXT_ ) : 0 ) ) )
210  {
211  PB_Cchkmat( ctxt, "PCTRANC", "A", *N, 2, *M, 1, Ai, Aj, Ad, 7, &info );
212  PB_Cchkmat( ctxt, "PCTRANC", "C", *M, 1, *N, 2, Ci, Cj, Cd, 12, &info );
213  }
214  if( info ) { PB_Cabort( ctxt, "PCTRANC", info ); return; }
215 #endif
216 /*
217 * Quick return if possible
218 */
219  if( ( *M == 0 ) || ( *N == 0 ) ||
220  ( ( ALPHA[REAL_PART] == ZERO && ALPHA[IMAG_PART] == ZERO ) &&
221  ( BETA [REAL_PART] == ONE && BETA [IMAG_PART] == ZERO ) ) )
222  return;
223 /*
224 * And when alpha is zero
225 */
226  if( ( ALPHA[REAL_PART] == ZERO ) && ( ALPHA[IMAG_PART] == ZERO ) )
227  {
228  if( ( BETA[REAL_PART] == ZERO ) && ( BETA[IMAG_PART] == ZERO ) )
229  {
230  PB_Cplapad( PB_Cctypeset(), ALL, NOCONJG, *M, *N, ((char *)BETA),
231  ((char *)BETA), ((char *) C), Ci, Cj, Cd );
232  }
233  else
234  {
235  PB_Cplascal( PB_Cctypeset(), ALL, NOCONJG, *M, *N, ((char *)BETA),
236  ((char * )C), Ci, Cj, Cd );
237  }
238  return;
239  }
240 /*
241 * Start the operations
242 */
243  PB_Cptran( PB_Cctypeset(), CONJG, *M, *N, ((char *) ALPHA),
244  ((char *) A), Ai, Aj, Ad, ((char *) BETA), ((char *) C),
245  Ci, Cj, Cd );
246 /*
247 * End of PCTRANC
248 */
249 }
PBblacs.h
PBtools.h
PBblas.h
NOCONJG
#define NOCONJG
Definition: PBblas.h:45
REAL_PART
#define REAL_PART
Definition: pblas.h:135
PBpblas.h
DLEN_
#define DLEN_
Definition: PBtools.h:48
pctranc_
void pctranc_(int *M, int *N, float *ALPHA, float *A, int *IA, int *JA, int *DESCA, float *BETA, float *C, int *IC, int *JC, int *DESCC)
Definition: pctranc_.c:26
ZERO
#define ZERO
Definition: PBtools.h:66
PB_Cplascal
void PB_Cplascal()
PB_Cabort
void PB_Cabort()
PB_Cplapad
void PB_Cplapad()
ONE
#define ONE
Definition: PBtools.h:64
PB_CargFtoC
void PB_CargFtoC()
CONJG
#define CONJG
Definition: PBblas.h:47
PB_Cchkmat
void PB_Cchkmat()
ALL
#define ALL
Definition: PBblas.h:50
Cblacs_gridinfo
void Cblacs_gridinfo()
pblas.h
CTXT_
#define CTXT_
Definition: PBtools.h:38
IMAG_PART
#define IMAG_PART
Definition: pblas.h:136
PB_Cctypeset
PBTYP_T * PB_Cctypeset()
Definition: PB_Cctypeset.c:19
PB_Cptran
void PB_Cptran()