xref: /petsc/include/petscblaslapack.h (revision aa79bc6d89adb718802453cbc2f155d610aa3690)
1 /* $Id: plapack.h,v 1.17 1996/02/27 17:53:25 bsmith Exp bsmith $ */
2 /*
3    This file provides some name space protection from LAPACK and BLAS and
4 allows the appropriate single or double precision version to be used.
5 This file also deals with different Fortran 77 naming conventions on machines.
6 
7    Another problem is charactor strings are represented differently on
8 on some machines in C and Fortran 77. This problem comes up on the
9 Cray T3D.  Yet another reason to hate ...
10 
11 */
12 #if !defined(_PLAPACK_H)
13 #define _PLAPACK_H
14 
15 #include "petsc.h"
16 
17 #if defined(PARCH_t3d)
18 #include "fortran.h"
19 #endif
20 
21 #if !defined(PETSC_COMPLEX)
22 
23 /*
24     These are real case with no character string arguments
25 */
26 #if defined(PARCH_t3d)
27 #define LAgeqrf_ SGEQRF
28 #define LAgetrf_ SGETRF
29 #define LAgetf2_ SGETRF
30 #define BLdot_   SDOT
31 #define BLnrm2_  SNRM2
32 #define BLscal_  SSCAL
33 #define BLcopy_  SCOPY
34 #define BLswap_  SSWAP
35 #define BLaxpy_  SAXPY
36 #define BLasum_  SASUM
37 #elif defined(HAVE_FORTRAN_CAPS)
38 #define LAgeqrf_ DGEQRF
39 #define LAgetrf_ DGETRF
40 #define LAgetf2_ DGETF2
41 #define BLdot_   DDOT
42 #define BLnrm2_  DNRM2
43 #define BLscal_  DSCAL
44 #define BLcopy_  DCOPY
45 #define BLswap_  DSWAP
46 #define BLaxpy_  DAXPY
47 #define BLasum_  DASUM
48 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
49 #define LAgeqrf_ dgeqrf
50 #define LAgetrf_ dgetrf
51 #define LAgetf2_ dgetf2
52 #define BLdot_   ddot
53 #define BLnrm2_  dnrm2
54 #define BLscal_  dscal
55 #define BLcopy_  dcopy
56 #define BLswap_  dswap
57 #define BLaxpy_  daxpy
58 #define BLasum_  dasum
59 #else
60 #define LAgeqrf_ dgeqrf_
61 #define LAgetrf_ dgetrf_
62 #define LAgetf2_ dgetf2_
63 #define BLdot_   ddot_
64 #define BLnrm2_  dnrm2_
65 #define BLscal_  dscal_
66 #define BLcopy_  dcopy_
67 #define BLswap_  dswap_
68 #define BLaxpy_  daxpy_
69 #define BLasum_  dasum_
70 #endif
71 
72 /*
73    Real with character string arguments.
74 */
75 #if defined(PARCH_t3d)
76 #define LAormqr_(a,b,c,d,e,f,g,h,i,j,k,l,m)  SORMQR(_cptofcd((a),1),\
77              _cptofcd((b),1),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
78 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) STRTRS(_cptofcd((a),1),_cptofcd((b),1),\
79                              _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
80 #define LApotrf_(a,b,c,d,e) SPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
81 #define LApotrs_(a,b,c,d,e,f,g,h) SPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
82                                          (f),(g),(h))
83 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) SGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
84                                         (f),(g),(h),(i),(j),(k))
85 #define LAgetrs_(a,b,c,d,e,f,g,h,i) SGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
86                                         (f),(g),(h),(i))
87 #define LAgetrs_(a,b,c,d,e,f,g,h,i) SGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
88                                         (f),(g),(h),(i))
89 #define LAgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) SGEMM(_cptofcd((a),1), \
90                                             _cptofcd((a),1),(c),(d),(e),\
91                                         (f),(g),(h),(i),(j),(k),(l),(m))
92 #define LAgesvd_(a,b,c,d,e,f,g,h,i,j,k,l,m) SGESVD(_cptofcd((a),1), \
93                                             _cptofcd((a),1),(c),(d),(e),\
94                                         (f),(g),(h),(i),(j),(k),(l),(m))
95 #define LAtrmv_  STRMV
96 #define LAtrsl_  STRSL
97 #elif defined(HAVE_FORTRAN_CAPS)
98 #define LAormqr_ DORMQR
99 #define LAtrtrs_ DTRTRS
100 #define LApotrf_ DPOTRF
101 #define LApotrs_ DPOTRS
102 #define LAgemv_  DGEMV
103 #define LAgetrs_ DGETRS
104 #define LAtrmv_  DTRMV
105 #define LAtrsl_  DTRSL
106 #define LAgesvd_ DGESVD
107 #define BLgemm_  DGEMM
108 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
109 #define LAormqr_ dormqr
110 #define LAtrtrs_ dtrtrs
111 #define LApotrf_ dpotrf
112 #define LApotrs_ dpotrs
113 #define LAgemv_  dgemv
114 #define LAgetrs_ dgetrs
115 #define LAtrmv_  dtrmv
116 #define LAtrsl_  dtrsl
117 #define BLgemm_  dgemm
118 #define LAgesvd_ dgesvd
119 #else
120 #define LAormqr_ dormqr_
121 #define LAtrtrs_ dtrtrs_
122 #define LApotrf_ dpotrf_
123 #define LApotrs_ dpotrs_
124 #define LAgemv_  dgemv_
125 #define LAgetrs_ dgetrs_
126 #define LAtrmv_  dtrmv_
127 #define LAtrsl_  dtrsl_
128 #define BLgemm_  dgemm_
129 #define LAgesvd_ dgesvd_
130 #endif
131 
132 #else
133 
134 /*
135    Complex with no character string arguments
136 */
137 #if defined(PARCH_t3d)
138 #define LAgeqrf_ CGEQRF
139 #define BLdot_   CDOTC
140 #define BLnrm2_  SCNRM2
141 #define BLscal_  CSCAL
142 #define BLcopy_  CCOPY
143 #define BLswap_  CSWAP
144 #define BLaxpy_  CAXPY
145 #define BLasum_  SCASUM
146 #define LAgetrf_ CGETRF
147 #define LAgetf2_ CGETRF
148 #elif defined(HAVE_FORTRAN_CAPS)
149 #define LAgeqrf_ ZGEQRF
150 #define BLdot_   ZDOTC
151 #define BLnrm2_  DZNRM2
152 #define BLscal_  ZSCAL
153 #define BLcopy_  ZCOPY
154 #define BLswap_  ZSWAP
155 #define BLaxpy_  ZAXPY
156 #define BLasum_  DZASUM
157 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
158 #define LAgeqrf_ zgeqrf
159 #define LAgetrf_ zgetrf
160 #define LAgetf2_ zgetf2
161 #define BLdot_   zdotc
162 #define BLnrm2_  dznrm2
163 #define BLscal_  zscal
164 #define BLcopy_  zcopy
165 #define BLswap_  zswap
166 #define BLaxpy_  zaxpy
167 #define BLasum_  dzasum
168 #else
169 #define LAgeqrf_ zgeqrf_
170 #define LAgetrf_ zgetrf_
171 #define LAgetf2_ zgetf2_
172 #define BLdot_   zdotc_
173 #define BLnrm2_  dznrm2_
174 #define BLscal_  zscal_
175 #define BLcopy_  zcopy_
176 #define BLswap_  zswap_
177 #define BLaxpy_  zaxpy_
178 #define BLasum_  dzasum_
179 #endif
180 
181 /*
182     Complex with character string arguments.
183   Who the F&%&^ was stupid enough to put character strings
184   into low-level computational kernels? It was a mistake!
185 */
186 #if defined(PARCH_t3d)
187 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) CTRTRS(_cptofcd((a),1),_cptofcd((b),1),\
188                               _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
189 #define LApotrf_(a,b,c,d,e)       CPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
190 #define LApotrs_(a,b,c,d,e,f,g,h) CPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
191                                          (f),(g),(h))
192 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) CGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
193                                         (f),(g),(h),(i),(j),(k))
194 #define LAgetrs_(a,b,c,d,e,f,g,h,i) CGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
195                                         (f),(g),(h),(i))
196 #define LAgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) SGEMM(_cptofcd((a),1), \
197                                             _cptofcd((a),1),(c),(d),(e),\
198                                         (f),(g),(h),(i),(j),(k),(l),(m))
199 #define LAtrmv_  CTRMV
200 #define LAtrsl_  CTRSL
201 #elif defined(HAVE_FORTRAN_CAPS)
202 #define LAtrtrs_ ZTRTRS
203 #define LApotrf_ ZPOTRF
204 #define LApotrs_ ZPOTRS
205 #define LAgemv_  ZGEMV
206 #define LAgetrf_ ZGETRF
207 #define LAgetf2_ ZGETF2
208 #define LAgetrs_ ZGETRS
209 #define LAtrmv_  ZTRMV
210 #define LAtrsl_  ZTRSL
211 #define BLgemm_  ZGEMM
212 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
213 #define LAtrtrs_ ztrtrs
214 #define LApotrf_ zpotrf
215 #define LApotrs_ zpotrs
216 #define LAgemv_  zgemv
217 #define LAgetrs_ zgetrs
218 #define LAtrmv_  ztrmv
219 #define LAtrsl_  ztrsl
220 #define BLgemm_  zgemm
221 #else
222 #define LAtrtrs_ ztrtrs_
223 #define LApotrf_ zpotrf_
224 #define LApotrs_ zpotrs_
225 #define LAgemv_  zgemv_
226 #define LAgetrs_ zgetrs_
227 #define LAtrmv_  ztrmv_
228 #define LAtrsl_  ztrsl_
229 #define BLgemm_  zgemm_
230 #endif
231 
232 #endif
233 
234 #if defined(__cplusplus)
235 extern "C" {
236 #endif
237 
238 /* note that BLdot cannot be used with COMPLEX because it cannot
239    handle returing a double complex!!
240 */
241 extern double BLdot_(int*,Scalar*,int*,Scalar*,int*);
242 extern double BLnrm2_(int*,Scalar*,int*),BLasum_(int*,Scalar*,int*);
243 extern void   BLscal_(int*,Scalar*,Scalar*,int*);
244 extern void   BLcopy_(int*,Scalar*,int*,Scalar*,int*);
245 extern void   BLswap_(int*,Scalar*,int*,Scalar*,int*);
246 extern void   BLaxpy_(int*,Scalar*,Scalar*,int*,Scalar*,int*);
247 extern void   LAgetrf_(int*,int*,Scalar*,int*,int*,int*);
248 extern void   LAgetf2_(int*,int*,Scalar*,int*,int*,int*);
249 extern void   LAgeqrf_(int*,int*,Scalar*,int*,Scalar*,Scalar*,int*,int*);
250 
251 #if defined(PARCH_t3d)
252 
253 #if defined(PETSC_COMPLEX)
254 extern void   CPOTRF(_fcd,int*,Scalar*,int*,int*);
255 extern void   CGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
256                         Scalar*,Scalar*,int*);
257 extern void   CPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
258 extern void   CGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
259 extern void   CGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
260                       Scalar*,int*,Scalar*,Scalar*,int*);
261 #else
262 extern void   SPOTRF(_fcd,int*,Scalar*,int*,int*);
263 extern void   SGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
264                         Scalar*,Scalar*,int*);
265 extern void   SPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
266 extern void   SGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
267 extern void   SGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
268                       Scalar*,int*,Scalar*,Scalar*,int*);
269 extern void   SGESVD(_fcd,_fcd,int *,int*, Scalar *,int*,Scalar*,Scalar*,
270                       int*,Scalar*,int*,Scalar*,int*,int*);
271 #endif
272 
273 #else
274 extern void   LAormqr_(char*,char*,int*,int*,int*,Scalar*,int*,Scalar*,Scalar*,
275                        int*,Scalar*,int*,int*);
276 extern void   LAtrtrs_(char*,char*,char*,int*,int*,Scalar*,int*,Scalar*,int*,
277                        int*);
278 extern void   LApotrf_(char*,int*,Scalar*,int*,int*);
279 extern void   LAgemv_(char*,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
280                        Scalar*,Scalar*,int*);
281 extern void   LApotrs_(char*,int*,int*,Scalar*,int*,Scalar*,int*,int*);
282 extern void   LAgetrs_(char*,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
283 extern void   BLgemm_(char *,char*,int*,int*,int*,Scalar*,Scalar*,int*,
284                       Scalar*,int*,Scalar*,Scalar*,int*);
285 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,Scalar*,Scalar*,
286                       int*,Scalar*,int*,Scalar*,int*,int*);
287 #endif
288 
289 #if defined(__cplusplus)
290 }
291 #endif
292 
293 #endif
294 
295 
296 
297