ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
PB_Ctzsyr2k.c
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2 *
3 * -- PBLAS auxiliary 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 PB_Ctzsyr2k( PBTYP_T * TYPE, char * UPLO, int M, int N, int K,
21  int IOFFD, char * ALPHA, char * AC, int LDAC,
22  char * BC, int LDBC, char * AR, int LDAR, char * BR,
23  int LDBR, char * C, int LDC )
24 #else
25 void PB_Ctzsyr2k( TYPE, UPLO, M, N, K, IOFFD, ALPHA, AC, LDAC, BC, LDBC,
26  AR, LDAR, BR, LDBR, C, LDC )
27 /*
28 * .. Scalar Arguments ..
29 */
30  char * UPLO;
31  int IOFFD, K, LDAC, LDAR, LDBC, LDBR, LDC, M, N;
32  char * ALPHA;
33 /*
34 * .. Array Arguments ..
35 */
36  char * AC, * AR, * BC, * BR, * C;
37  PBTYP_T * TYPE;
38 #endif
39 {
40 /*
41 * Purpose
42 * =======
43 *
44 * PB_Ctzsyr2k performs the trapezoidal symmetric o Hermitian rank 2k
45 * operation:
46 *
47 * C := alpha * AC * BR + alpha * BC * AR + C,
48 *
49 * where alpha is a scalar, AC and BC are m by k matrices, AR and BR are
50 * n by k matrices and C is an m by n trapezoidal symmetric or Hermitian
51 * matrix.
52 *
53 * Arguments
54 * =========
55 *
56 * TYPE (local input) pointer to a PBTYP_T structure
57 * On entry, TYPE is a pointer to a structure of type PBTYP_T,
58 * that contains type information (See pblas.h).
59 *
60 * UPLO (input) pointer to CHAR
61 * On entry, UPLO specifies which part of the matrix C is to be
62 * referenced as follows:
63 *
64 * UPLO = 'L' or 'l' the lower trapezoid of C is referenced,
65 *
66 * UPLO = 'U' or 'u' the upper trapezoid of C is referenced,
67 *
68 * otherwise all of the matrix C is referenced.
69 *
70 * M (input) INTEGER
71 * On entry, M specifies the number of rows of the matrix C. M
72 * must be at least zero.
73 *
74 * N (input) INTEGER
75 * On entry, N specifies the number of columns of the matrix C.
76 * N must be at least zero.
77 *
78 * K (input) INTEGER
79 * On entry, K specifies the number of columns of the matrices
80 * AC and BC, and the number of rows of the matrices AR and BR.
81 * K must be at least zero.
82 *
83 * IOFFD (input) INTEGER
84 * On entry, IOFFD specifies the position of the offdiagonal de-
85 * limiting the upper and lower trapezoidal part of C as follows
86 * (see the notes below):
87 *
88 * IOFFD = 0 specifies the main diagonal C( i, i ),
89 * with i = 1 ... MIN( M, N ),
90 * IOFFD > 0 specifies the subdiagonal C( i+IOFFD, i ),
91 * with i = 1 ... MIN( M-IOFFD, N ),
92 * IOFFD < 0 specifies the superdiagonal C( i, i-IOFFD ),
93 * with i = 1 ... MIN( M, N+IOFFD ).
94 *
95 * ALPHA (input) pointer to CHAR
96 * On entry, ALPHA specifies the scalar alpha.
97 *
98 * AC (input) pointer to CHAR
99 * On entry, AC is an array of dimension (LDAC,K) containing the
100 * m by k matrix AC.
101 *
102 * LDAC (input) INTEGER
103 * On entry, LDAC specifies the leading dimension of the array
104 * AC. LDAC must be at least max( 1, M ).
105 *
106 * BC (input) pointer to CHAR
107 * On entry, BC is an array of dimension (LDBC,K) containing the
108 * m by k matrix BC.
109 *
110 * LDBC (input) INTEGER
111 * On entry, LDBC specifies the leading dimension of the array
112 * BC. LDBC must be at least max( 1, M ).
113 *
114 * AR (input) pointer to CHAR
115 * On entry, AR is an array of dimension (LDAR,N) containing the
116 * k by n matrix AR.
117 *
118 * LDAR (input) INTEGER
119 * On entry, LDAR specifies the leading dimension of the array
120 * AR. LDAR must be at least K.
121 *
122 * BR (input) pointer to CHAR
123 * On entry, BR is an array of dimension (LDBR,N) containing the
124 * k by n matrix BR.
125 *
126 * LDBR (input) INTEGER
127 * On entry, LDBR specifies the leading dimension of the array
128 * BR. LDBR must be at least K.
129 *
130 * C (input/output) pointer to CHAR
131 * On entry, C is an array of dimension (LDC,N) containing the m
132 * by n matrix C. Only the trapezoidal part of C determined by
133 * UPLO and IOFFD is updated.
134 *
135 * LDC (input) INTEGER
136 * On entry, LDC specifies the leading dimension of the array C.
137 * LDC must be at least max( 1, M ).
138 *
139 * Notes
140 * =====
141 * N N
142 * ---------------------------- -----------
143 * | d | | |
144 * M | d Upper | | Upper |
145 * | Lower d | |d |
146 * | d | M | d |
147 * ---------------------------- | d |
148 * | d |
149 * IOFFD < 0 | Lower d |
150 * | d|
151 * N | |
152 * ----------- -----------
153 * | d Upper|
154 * | d | IOFFD > 0
155 * M | d |
156 * | d| N
157 * | Lower | ----------------------------
158 * | | | Upper |
159 * | | |d |
160 * | | | d |
161 * | | | d |
162 * | | |Lower d |
163 * ----------- ----------------------------
164 *
165 * -- Written on April 1, 1998 by
166 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
167 *
168 * ---------------------------------------------------------------------
169 */
170 /*
171 * .. Local Scalars ..
172 */
173  char * one;
174  int i1, j1, m1, mn, n1, size;
175  GEMM_T gemm;
176 /* ..
177 * .. Executable Statements ..
178 *
179 */
180  if( ( M <= 0 ) || ( N <= 0 ) ) return;
181 
182  if( Mupcase( UPLO[0] ) == CLOWER )
183  {
184  size = TYPE->size; one = TYPE->one; gemm = TYPE->Fgemm;
185  mn = MAX( 0, -IOFFD );
186  if( ( n1 = MIN( mn, N ) ) > 0 )
187  {
188  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &M, &n1, &K, ALPHA, AC,
189  &LDAC, BR, &LDBR, one, C, &LDC );
190  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &M, &n1, &K, ALPHA, BC,
191  &LDBC, AR, &LDAR, one, C, &LDC );
192  }
193  n1 = M - IOFFD;
194  if( ( n1 = MIN( n1, N ) - mn ) > 0 )
195  {
196  i1 = ( j1 = mn ) + IOFFD;
197  TYPE->Fsyr2k( C2F_CHAR( UPLO ), C2F_CHAR( NOTRAN ), &n1, &K, ALPHA,
198  Mptr( AC, i1, 0, LDAC, size ), &LDAC, Mptr( BC, i1, 0,
199  LDBC, size ), &LDBC, one, Mptr( C, i1, j1, LDC, size ),
200  &LDC );
201  if( ( m1 = M - mn - n1 - IOFFD ) > 0 )
202  {
203  i1 += n1;
204  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &m1, &n1, &K,
205  ALPHA, Mptr( AC, i1, 0, LDAC, size ), &LDAC, Mptr( BR,
206  0, j1, LDBR, size ), &LDBR, one, Mptr( C, i1, j1, LDC,
207  size ), &LDC );
208  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &m1, &n1, &K,
209  ALPHA, Mptr( BC, i1, 0, LDBC, size ), &LDBC, Mptr( AR,
210  0, j1, LDAR, size ), &LDAR, one, Mptr( C, i1, j1, LDC,
211  size ), &LDC );
212  }
213  }
214  }
215  else if( Mupcase( UPLO[0] ) == CUPPER )
216  {
217  size = TYPE->size; one = TYPE->one; gemm = TYPE->Fgemm;
218  mn = M - IOFFD; mn = MIN( mn, N );
219  if( ( n1 = mn - MAX( 0, -IOFFD ) ) > 0 )
220  {
221  j1 = mn - n1;
222  if( ( m1 = MAX( 0, IOFFD ) ) > 0 )
223  {
224  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &m1, &n1, &K, ALPHA,
225  AC, &LDAC, BR, &LDBR, one, C, &LDC );
226  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &m1, &n1, &K, ALPHA,
227  BC, &LDBC, AR, &LDAR, one, C, &LDC );
228  }
229  TYPE->Fsyr2k( C2F_CHAR( UPLO ), C2F_CHAR( NOTRAN ), &n1, &K, ALPHA,
230  Mptr( AC, m1, 0, LDAC, size ), &LDAC, Mptr( BC, m1, 0,
231  LDBC, size ), &LDBC, one, Mptr( C, m1, j1, LDC, size ),
232  &LDC );
233  }
234  if( ( n1 = N - MAX( 0, mn ) ) > 0 )
235  {
236  j1 = N - n1;
237  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &M, &n1, &K, ALPHA, AC,
238  &LDAC, Mptr( BR, 0, j1, LDBR, size ), &LDBR, one, Mptr( C, 0, j1,
239  LDC, size ), &LDC );
240  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &M, &n1, &K, ALPHA, BC,
241  &LDBC, Mptr( AR, 0, j1, LDAR, size ), &LDAR, one, Mptr( C, 0, j1,
242  LDC, size ), &LDC );
243  }
244  }
245  else
246  {
247  one = TYPE->one; gemm = TYPE->Fgemm;
248  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &M, &N, &K, ALPHA, AC,
249  &LDAC, BR, &LDBR, one, C, &LDC );
250  gemm( C2F_CHAR( NOTRAN ), C2F_CHAR( NOTRAN ), &M, &N, &K, ALPHA, BC,
251  &LDBC, AR, &LDAR, one, C, &LDC );
252  }
253 /*
254 * End of PB_Ctzsyr2k
255 */
256 }
TYPE
#define TYPE
Definition: clamov.c:7
GEMM_T
F_VOID_FCT(* GEMM_T)()
Definition: pblas.h:313
NOTRAN
#define NOTRAN
Definition: PBblas.h:44
CLOWER
#define CLOWER
Definition: PBblas.h:25
PB_Ctzsyr2k
void PB_Ctzsyr2k(PBTYP_T *TYPE, char *UPLO, int M, int N, int K, int IOFFD, char *ALPHA, char *AC, int LDAC, char *BC, int LDBC, char *AR, int LDAR, char *BR, int LDBR, char *C, int LDC)
Definition: PB_Ctzsyr2k.c:25
MIN
#define MIN(a_, b_)
Definition: PBtools.h:76
C2F_CHAR
#define C2F_CHAR(a)
Definition: pblas.h:121
MAX
#define MAX(a_, b_)
Definition: PBtools.h:77
PBTYP_T
Definition: pblas.h:325
Mupcase
#define Mupcase(C)
Definition: PBtools.h:83
CUPPER
#define CUPPER
Definition: PBblas.h:26
Mptr
#define Mptr(a_, i_, j_, lda_, siz_)
Definition: PBtools.h:132