xref: /petsc/include/petscblaslapack.h (revision 606d414c6e034e02e67059b83ebaefc3ebe99698)
1 /* $Id: blaslapack.h,v 1.35 1998/12/09 19:59:31 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/T3E.
10 
11 */
12 #if !defined(_BLASLAPACK_H)
13 #define _BLASLAPACK_H
14 
15 #include "petsc.h"
16 
17 /*
18    This include file on the Cray T3D/T3E defines the interface between
19   Fortran and C representations of charactor strings.
20 */
21 #if defined(USES_CPTOFCD)
22 #include <fortran.h>
23 #endif
24 
25 #if !defined(PETSC_USE_COMPLEX)
26 
27 /*
28     These are real case with no character string arguments
29 */
30 
31 #if defined(USES_FORTRAN_SINGLE)
32 /*
33    For these machines we must call the single precision Fortran version
34 */
35 #define DGEQRF   SGEQRF
36 #define DGETRF   SGETRF
37 #define DDOT     SDOT
38 #define DNRM2    SNRM2
39 #define DSCAL    SSCAL
40 #define DCOPY    SCOPY
41 #define DSWAP    SSWAP
42 #define DAXPY    SAXPY
43 #define DASUM    SASUM
44 #define DSORMQR  SORMQR
45 #define DTRTRS   STRTRS
46 #define DPOTRF   SPOTRF
47 #define DPOTRS   SPOTRS
48 #define DGEMV    SGEMV
49 #define DGETRS   SGETRS
50 #define DGETRS   SGETRS
51 #define DGEMM    SGEMM
52 #define DGESVD   SGESVD
53 #define DGEEV    SGEEV
54 #define DTRMV    STRMV
55 #define DTRSL    STRSL
56 #endif
57 
58 #if defined(PETSC_HAVE_FORTRAN_UNDERSCORE) || defined(PETSC_USE_CBLASLAPACK)
59 #define LAgeqrf_ dgeqrf_
60 #define LAgetrf_ dgetrf_
61 #define LAgetf2_ dgetf2_
62 #define BLdot_   ddot_
63 #define BLnrm2_  dnrm2_
64 #define BLscal_  dscal_
65 #define BLcopy_  dcopy_
66 #define BLswap_  dswap_
67 #define BLaxpy_  daxpy_
68 #define BLasum_  dasum_
69 #elif defined(PETSC_HAVE_FORTRAN_CAPS)
70 #define LAgeqrf_ DGEQRF
71 #define LAgetrf_ DGETRF
72 #define LAgetf2_ DGETF2
73 #define BLdot_   DDOT
74 #define BLnrm2_  DNRM2
75 #define BLscal_  DSCAL
76 #define BLcopy_  DCOPY
77 #define BLswap_  DSWAP
78 #define BLaxpy_  DAXPY
79 #define BLasum_  DASUM
80 #else
81 #define LAgeqrf_ dgeqrf
82 #define LAgetrf_ dgetrf
83 #define LAgetf2_ dgetf2
84 #define BLdot_   ddot
85 #define BLnrm2_  dnrm2
86 #define BLscal_  dscal
87 #define BLcopy_  dcopy
88 #define BLswap_  dswap
89 #define BLaxpy_  daxpy
90 #define BLasum_  dasum
91 #endif
92 
93 /*
94    Real with character string arguments.
95 */
96 #if defined(USES_CPTOFCD)
97 /*
98    Note that this assumes that machines which use cptofcd() use
99   the PETSC_HAVE_FORTRAN_CAPS option. This is true on the Cray T3D/T3E.
100 */
101 #define LAormqr_(a,b,c,d,e,f,g,h,i,j,k,l,m)  DORMQR(_cptofcd((a),1),\
102              _cptofcd((b),1),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
103 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) DTRTRS(_cptofcd((a),1),_cptofcd((b),1),\
104                              _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
105 #define LApotrf_(a,b,c,d,e) DPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
106 #define LApotrs_(a,b,c,d,e,f,g,h) DPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
107                                          (f),(g),(h))
108 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) DGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
109                                         (f),(g),(h),(i),(j),(k))
110 #define LAgetrs_(a,b,c,d,e,f,g,h,i) DGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
111                                         (f),(g),(h),(i))
112 #define LAgetrs_(a,b,c,d,e,f,g,h,i) DGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
113                                         (f),(g),(h),(i))
114 #define BLgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) DGEMM(_cptofcd((a),1), \
115                                             _cptofcd((a),1),(c),(d),(e),\
116                                         (f),(g),(h),(i),(j),(k),(l),(m))
117 #define LAgesvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) DGESVD(_cptofcd((a),1), \
118                                             _cptofcd((a),1),(c),(d),(e),\
119                                         (f),(g),(h),(i),(j),(k),(l),(m),(n))
120 #define LAgeev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) DGEEV(_cptofcd((a),1), \
121                                             _cptofcd((a),1),(c),(d),(e),\
122                                         (f),(g),(h),(i),(j),(k),(l),(m),(n))
123 #define LAtrmv_  DTRMV
124 #define LAtrsl_  DTRSL
125 #define LAgetrf_ DGETRF
126 #elif defined(PETSC_HAVE_FORTRAN_UNDERSCORE) || defined(PETSC_USE_CBLASLAPACK)
127 #define LAormqr_ dormqr_
128 #define LAtrtrs_ dtrtrs_
129 #define LApotrf_ dpotrf_
130 #define LApotrs_ dpotrs_
131 #define LAgemv_  dgemv_
132 #define LAgetrs_ dgetrs_
133 #define LAtrmv_  dtrmv_
134 #define LAtrsl_  dtrsl_
135 #define BLgemm_  dgemm_
136 #define LAgesvd_ dgesvd_
137 #define LAgeev_  dgeev_
138 #elif defined(PETSC_HAVE_FORTRAN_CAPS)
139 #define LAormqr_ DORMQR
140 #define LAtrtrs_ DTRTRS
141 #define LApotrf_ DPOTRF
142 #define LApotrs_ DPOTRS
143 #define LAgemv_  DGEMV
144 #define LAgetrs_ DGETRS
145 #define LAtrmv_  DTRMV
146 #define LAtrsl_  DTRSL
147 #define LAgesvd_ DGESVD
148 #define LAgeev_  DGEEV
149 #define BLgemm_  DGEMM
150 #else
151 #define LAormqr_ dormqr
152 #define LAtrtrs_ dtrtrs
153 #define LApotrf_ dpotrf
154 #define LApotrs_ dpotrs
155 #define LAgemv_  dgemv
156 #define LAgetrs_ dgetrs
157 #define LAtrmv_  dtrmv
158 #define LAtrsl_  dtrsl
159 #define BLgemm_  dgemm
160 #define LAgesvd_ dgesvd
161 #define LAgeev_  dgeev
162 #endif
163 
164 #else
165 /*
166    Complex with no character string arguments
167 */
168 #if defined(USES_FORTRAN_SINGLE)
169 #define ZGEQRF  CGEQRF
170 #define ZDOTC   CDOTC
171 #define DZNRM2  SCNRM2
172 #define ZSCAL   CSCAL
173 #define ZCOPY   CCOPY
174 #define ZSWAP   CSWAP
175 #define ZAXPY   CAXPY
176 #define DZASUM  SCASUM
177 #define ZGETRF  CGETRF
178 #define ZTRTRS  CTRTRS
179 #define ZPOTRF  CPOTRF
180 #define ZPOTRS  CPOTRS
181 #define ZGEMV   CGEMV
182 #define ZGETRS  CGETRS
183 #define ZGEMM   SGEMM
184 #define ZTRMV   CTRMV
185 #define ZTRSL   CTRSL
186 #define ZGEEV   CGEEV
187 #endif
188 
189 #if defined(PETSC_HAVE_FORTRAN_UNDERSCORE) || defined(PETSC_USE_CBLASLAPACK)
190 #define LAgeqrf_ zgeqrf_
191 #define LAgetrf_ zgetrf_
192 #define LAgetf2_ zgetf2_
193 #define BLdot_   zdotc_
194 #define BLnrm2_  dznrm2_
195 #define BLscal_  zscal_
196 #define BLcopy_  zcopy_
197 #define BLswap_  zswap_
198 #define BLaxpy_  zaxpy_
199 #define BLasum_  dzasum_
200 #elif defined(PETSC_HAVE_FORTRAN_CAPS)
201 #define LAgeqrf_ ZGEQRF
202 #define BLdot_   ZDOTC
203 #define BLnrm2_  DZNRM2
204 #define BLscal_  ZSCAL
205 #define BLcopy_  ZCOPY
206 #define BLswap_  ZSWAP
207 #define BLaxpy_  ZAXPY
208 #define BLasum_  DZASUM
209 #define LAgetrf_ ZGETRF
210 #else
211 #define LAgeqrf_ zgeqrf
212 #define LAgetrf_ zgetrf
213 #define LAgetf2_ zgetf2
214 #define BLdot_   zdotc
215 #define BLnrm2_  dznrm2
216 #define BLscal_  zscal
217 #define BLcopy_  zcopy
218 #define BLswap_  zswap
219 #define BLaxpy_  zaxpy
220 #define BLasum_  dzasum
221 #endif
222 
223 #if defined(USES_CPTOFCD)
224 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) ZTRTRS(_cptofcd((a),1),_cptofcd((b),1),\
225                               _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
226 #define LApotrf_(a,b,c,d,e)       ZPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
227 #define LApotrs_(a,b,c,d,e,f,g,h) ZPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
228                                          (f),(g),(h))
229 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) ZGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
230                                         (f),(g),(h),(i),(j),(k))
231 #define LAgetrs_(a,b,c,d,e,f,g,h,i) ZGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
232                                         (f),(g),(h),(i))
233 #define BLgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) ZGEMM(_cptofcd((a),1), \
234                                             _cptofcd((a),1),(c),(d),(e),\
235                                         (f),(g),(h),(i),(j),(k),(l),(m))
236 #define LAgesvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,p) ZGESVD(_cptofcd((a),1), \
237                                             _cptofcd((a),1),(c),(d),(e),\
238                                         (f),(g),(h),(i),(j),(k),(l),(m),(n),(p))
239 #define LAgeev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) ZGEEV(_cptofcd((a),1), \
240                                             _cptofcd((a),1),(c),(d),(e),\
241                                         (f),(g),(h),(i),(j),(k),(l),(m),(n))
242 #define LAtrmv_  ZTRMV
243 #define LAtrsl_  ZTRSL
244 #elif defined(PETSC_HAVE_FORTRAN_UNDERSCORE) || defined(PETSC_USE_CBLASLAPACK)
245 #define LAtrtrs_ ztrtrs_
246 #define LApotrf_ zpotrf_
247 #define LApotrs_ zpotrs_
248 #define LAgemv_  zgemv_
249 #define LAgetrs_ zgetrs_
250 #define LAtrmv_  ztrmv_
251 #define LAtrsl_  ztrsl_
252 #define BLgemm_  zgemm_
253 #define LAgesvd_ zgesvd_
254 #define LAgeev_  zgeev_
255 #elif defined(PETSC_HAVE_FORTRAN_CAPS)
256 #define LAtrtrs_ ZTRTRS
257 #define LApotrf_ ZPOTRF
258 #define LApotrs_ ZPOTRS
259 #define LAgemv_  ZGEMV
260 #define LAgetrf_ ZGETRF
261 #define LAgetf2_ ZGETF2
262 #define LAgetrs_ ZGETRS
263 #define LAtrmv_  ZTRMV
264 #define LAtrsl_  ZTRSL
265 #define BLgemm_  ZGEMM
266 #define LAgesvd_ ZGESVD
267 #define LAgeev_  ZGEEV
268 #else
269 #define LAtrtrs_ ztrtrs
270 #define LApotrf_ zpotrf
271 #define LApotrs_ zpotrs
272 #define LAgemv_  zgemv
273 #define LAgetrs_ zgetrs
274 #define LAtrmv_  ztrmv
275 #define LAtrsl_  ztrsl
276 #define BLgemm_  zgemm
277 #define LAgesvd_ zgesvd
278 #define LAgeev_  zgeev
279 #endif
280 
281 #endif
282 
283 #if !defined(PETSC_USE_CBLASLAPACK)
284 EXTERN_C_BEGIN
285 #endif
286 
287 /*
288    BLdot cannot be used with COMPLEX because it cannot
289    handle returing a double complex to C++.
290 */
291 extern double BLdot_(int*,Scalar*,int*,Scalar*,int*);
292 extern double BLnrm2_(int*,Scalar*,int*),BLasum_(int*,Scalar*,int*);
293 extern void   BLscal_(int*,Scalar*,Scalar*,int*);
294 extern void   BLcopy_(int*,Scalar*,int*,Scalar*,int*);
295 extern void   BLswap_(int*,Scalar*,int*,Scalar*,int*);
296 extern void   BLaxpy_(int*,Scalar*,Scalar*,int*,Scalar*,int*);
297 extern void   LAgetrf_(int*,int*,Scalar*,int*,int*,int*);
298 extern void   LAgetf2_(int*,int*,Scalar*,int*,int*,int*);
299 extern void   LAgeqrf_(int*,int*,Scalar*,int*,Scalar*,Scalar*,int*,int*);
300 
301 #if defined(USES_CPTOFCD)
302 
303 #if defined(PETSC_USE_COMPLEX)
304 extern void   ZPOTRF(_fcd,int*,Scalar*,int*,int*);
305 extern void   ZGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
306                         Scalar*,Scalar*,int*);
307 extern void   ZPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
308 extern void   ZGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
309 extern void   ZGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
310                       Scalar*,int*,Scalar*,Scalar*,int*);
311 extern void   ZGESVD(_fcd,_fcd,int *,int*, Scalar *,int*,double*,Scalar*,
312                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
313 extern void   ZGEEV(_fcd,_fcd,int *, Scalar *,int*,Scalar*,Scalar*,
314                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
315 #else
316 extern void   DPOTRF(_fcd,int*,Scalar*,int*,int*);
317 extern void   DGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
318                         Scalar*,Scalar*,int*);
319 extern void   DPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
320 extern void   DGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
321 extern void   DGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
322                       Scalar*,int*,Scalar*,Scalar*,int*);
323 extern void   DGESVD(_fcd,_fcd,int *,int*, Scalar *,int*,Scalar*,Scalar*,
324                       int*,Scalar*,int*,Scalar*,int*,int*);
325 extern void   DGEEV(_fcd,_fcd,int *,Scalar *,int*,Scalar*,Scalar*,Scalar*,
326                       int*,Scalar*,int*,Scalar*,int*,int*);
327 #endif
328 
329 #else
330 extern void   LAormqr_(char*,char*,int*,int*,int*,Scalar*,int*,Scalar*,Scalar*,
331                        int*,Scalar*,int*,int*);
332 extern void   LAtrtrs_(char*,char*,char*,int*,int*,Scalar*,int*,Scalar*,int*,
333                        int*);
334 extern void   LApotrf_(char*,int*,Scalar*,int*,int*);
335 extern void   LAgemv_(char*,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
336                        Scalar*,Scalar*,int*);
337 extern void   LApotrs_(char*,int*,int*,Scalar*,int*,Scalar*,int*,int*);
338 extern void   LAgetrs_(char*,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
339 extern void   BLgemm_(char *,char*,int*,int*,int*,Scalar*,Scalar*,int*,
340                       Scalar*,int*,Scalar*,Scalar*,int*);
341 
342 /* ESSL uses a different calling sequence for dgeev(), zgeev() than LAPACK; */
343 #if defined(PETSC_HAVE_ESSL) && defined(PETSC_USE_COMPLEX)
344 extern void   LAgeev_(int*,Scalar*,int*,Scalar*,Scalar*,int*,int*,int*,double*,int*);
345 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,double*,Scalar*,
346                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
347 #elif defined(PETSC_HAVE_ESSL)
348 extern void   LAgeev_(int*,Scalar*,int*,Scalar*,Scalar*,int*,int*,int*,double*,int*);
349 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,double*,Scalar*,
350                       int*,Scalar*,int*,Scalar*,int*,int*);
351 #elif !defined(PETSC_USE_COMPLEX)
352 extern void   LAgeev_(char *,char *,int *, Scalar *,int*,double*,double*,Scalar*,
353                       int*,Scalar*,int*,Scalar*,int*,int*);
354 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,double*,Scalar*,
355                       int*,Scalar*,int*,Scalar*,int*,int*);
356 #else
357 extern void   LAgeev_(char *,char *,int *, Scalar *,int*,Scalar*,Scalar*,
358                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
359 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,double*,Scalar*,
360                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
361 #endif
362 #endif
363 
364 #if !defined(PETSC_USE_CBLASLAPACK)
365 EXTERN_C_END
366 #endif
367 
368 #endif
369 
370 
371 
372