xref: /petsc/include/petscblaslapack.h (revision 639f9d9dbbc54d6ac4e42e98283c540b41bb2cee)
1 /* $Id: plapack.h,v 1.23 1996/09/12 16:28:52 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 /*
18    This include file on the Cray T3D 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_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(HAVE_FORTRAN_CAPS)
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(HAVE_FORTRAN_UNDERSCORE)
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 HAVE_FORTRAN_CAPS option. This is true on the Cray T3d.
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 #elif defined(HAVE_FORTRAN_CAPS)
126 #define LAormqr_ DORMQR
127 #define LAtrtrs_ DTRTRS
128 #define LApotrf_ DPOTRF
129 #define LApotrs_ DPOTRS
130 #define LAgemv_  DGEMV
131 #define LAgetrs_ DGETRS
132 #define LAtrmv_  DTRMV
133 #define LAtrsl_  DTRSL
134 #define LAgesvd_ DGESVD
135 #define LAgeev_  DGEEV
136 #define BLgemm_  DGEMM
137 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
138 #define LAormqr_ dormqr
139 #define LAtrtrs_ dtrtrs
140 #define LApotrf_ dpotrf
141 #define LApotrs_ dpotrs
142 #define LAgemv_  dgemv
143 #define LAgetrs_ dgetrs
144 #define LAtrmv_  dtrmv
145 #define LAtrsl_  dtrsl
146 #define BLgemm_  dgemm
147 #define LAgesvd_ dgesvd
148 #define LAgeev_  dgeev
149 #else
150 #define LAormqr_ dormqr_
151 #define LAtrtrs_ dtrtrs_
152 #define LApotrf_ dpotrf_
153 #define LApotrs_ dpotrs_
154 #define LAgemv_  dgemv_
155 #define LAgetrs_ dgetrs_
156 #define LAtrmv_  dtrmv_
157 #define LAtrsl_  dtrsl_
158 #define BLgemm_  dgemm_
159 #define LAgesvd_ dgesvd_
160 #define LAgeev_  dgeev_
161 #endif
162 
163 #else
164 /*
165    Complex with no character string arguments
166 */
167 #if defined(USES_FORTRAN_SINGLE)
168 #define ZGEQRF  CGEQRF
169 #define ZDOTC   CDOTC
170 #define DZNRM2  SCNRM2
171 #define ZSCAL   CSCAL
172 #define ZCOPY   CCOPY
173 #define ZSWAP   CSWAP
174 #define ZAXPY   CAXPY
175 #define DZASUM  SCASUM
176 #define ZGETRF  CGETRF
177 #define ZTRTRS  CTRTRS
178 #define ZPOTRF  CPOTRF
179 #define ZPOTRS  CPOTRS
180 #define ZGEMV   CGEMV
181 #define ZGETRS  CGETRS
182 #define ZGEMM   SGEMM
183 #define ZTRMV   CTRMV
184 #define ZTRSL   CTRSL
185 #endif
186 
187 #if defined(HAVE_FORTRAN_CAPS)
188 #define LAgeqrf_ ZGEQRF
189 #define BLdot_   ZDOTC
190 #define BLnrm2_  DZNRM2
191 #define BLscal_  ZSCAL
192 #define BLcopy_  ZCOPY
193 #define BLswap_  ZSWAP
194 #define BLaxpy_  ZAXPY
195 #define BLasum_  DZASUM
196 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
197 #define LAgeqrf_ zgeqrf
198 #define LAgetrf_ zgetrf
199 #define LAgetf2_ zgetf2
200 #define BLdot_   zdotc
201 #define BLnrm2_  dznrm2
202 #define BLscal_  zscal
203 #define BLcopy_  zcopy
204 #define BLswap_  zswap
205 #define BLaxpy_  zaxpy
206 #define BLasum_  dzasum
207 #else
208 #define LAgeqrf_ zgeqrf_
209 #define LAgetrf_ zgetrf_
210 #define LAgetf2_ zgetf2_
211 #define BLdot_   zdotc_
212 #define BLnrm2_  dznrm2_
213 #define BLscal_  zscal_
214 #define BLcopy_  zcopy_
215 #define BLswap_  zswap_
216 #define BLaxpy_  zaxpy_
217 #define BLasum_  dzasum_
218 #endif
219 
220 #if defined(USES_CPTOFCD)
221 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) ZTRTRS(_cptofcd((a),1),_cptofcd((b),1),\
222                               _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
223 #define LApotrf_(a,b,c,d,e)       ZPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
224 #define LApotrs_(a,b,c,d,e,f,g,h) ZPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
225                                          (f),(g),(h))
226 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) ZGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
227                                         (f),(g),(h),(i),(j),(k))
228 #define LAgetrs_(a,b,c,d,e,f,g,h,i) ZGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
229                                         (f),(g),(h),(i))
230 #define BLgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) ZGEMM(_cptofcd((a),1), \
231                                             _cptofcd((a),1),(c),(d),(e),\
232                                         (f),(g),(h),(i),(j),(k),(l),(m))
233 #define LAgesvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,p) ZGESVD(_cptofcd((a),1), \
234                                             _cptofcd((a),1),(c),(d),(e),\
235                                         (f),(g),(h),(i),(j),(k),(l),(m),(n),(p))
236 #define LAgeev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) ZGEEV(_cptofcd((a),1), \
237                                             _cptofcd((a),1),(c),(d),(e),\
238                                         (f),(g),(h),(i),(j),(k),(l),(m),(n))
239 #define LAtrmv_  ZTRMV
240 #define LAtrsl_  ZTRSL
241 #elif defined(HAVE_FORTRAN_CAPS)
242 #define LAtrtrs_ ZTRTRS
243 #define LApotrf_ ZPOTRF
244 #define LApotrs_ ZPOTRS
245 #define LAgemv_  ZGEMV
246 #define LAgetrf_ ZGETRF
247 #define LAgetf2_ ZGETF2
248 #define LAgetrs_ ZGETRS
249 #define LAtrmv_  ZTRMV
250 #define LAtrsl_  ZTRSL
251 #define BLgemm_  ZGEMM
252 #define LAgesvd_ ZGESVD
253 #define LAgeev_  ZGEEV
254 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
255 #define LAtrtrs_ ztrtrs
256 #define LApotrf_ zpotrf
257 #define LApotrs_ zpotrs
258 #define LAgemv_  zgemv
259 #define LAgetrs_ zgetrs
260 #define LAtrmv_  ztrmv
261 #define LAtrsl_  ztrsl
262 #define BLgemm_  zgemm
263 #define LAgesvd_ zgesvd
264 #define LAgeev_  zgeev
265 #else
266 #define LAtrtrs_ ztrtrs_
267 #define LApotrf_ zpotrf_
268 #define LApotrs_ zpotrs_
269 #define LAgemv_  zgemv_
270 #define LAgetrs_ zgetrs_
271 #define LAtrmv_  ztrmv_
272 #define LAtrsl_  ztrsl_
273 #define BLgemm_  zgemm_
274 #define LAgesvd_ zgesvd_
275 #define LAgeev_  zgeev_
276 #endif
277 
278 #endif
279 
280 #if defined(__cplusplus)
281 extern "C" {
282 #endif
283 
284 /*
285    BLdot cannot be used with COMPLEX because it cannot
286    handle returing a double complex to C++.
287 */
288 extern double BLdot_(int*,Scalar*,int*,Scalar*,int*);
289 extern double BLnrm2_(int*,Scalar*,int*),BLasum_(int*,Scalar*,int*);
290 extern void   BLscal_(int*,Scalar*,Scalar*,int*);
291 extern void   BLcopy_(int*,Scalar*,int*,Scalar*,int*);
292 extern void   BLswap_(int*,Scalar*,int*,Scalar*,int*);
293 extern void   BLaxpy_(int*,Scalar*,Scalar*,int*,Scalar*,int*);
294 extern void   LAgetrf_(int*,int*,Scalar*,int*,int*,int*);
295 extern void   LAgetf2_(int*,int*,Scalar*,int*,int*,int*);
296 extern void   LAgeqrf_(int*,int*,Scalar*,int*,Scalar*,Scalar*,int*,int*);
297 
298 #if defined(USES_CPTOFCD)
299 
300 #if defined(PETSC_COMPLEX)
301 extern void   ZPOTRF(_fcd,int*,Scalar*,int*,int*);
302 extern void   ZGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
303                         Scalar*,Scalar*,int*);
304 extern void   ZPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
305 extern void   ZGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
306 extern void   ZGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
307                       Scalar*,int*,Scalar*,Scalar*,int*);
308 extern void   ZGESVD(_fcd,_fcd,int *,int*, Scalar *,int*,double*,Scalar*,
309                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
310 extern void   ZGEEV(_fcd,_fcd,int *, Scalar *,int*,Scalar*,Scalar*,
311                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
312 #else
313 extern void   DPOTRF(_fcd,int*,Scalar*,int*,int*);
314 extern void   DGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
315                         Scalar*,Scalar*,int*);
316 extern void   DPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
317 extern void   DGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
318 extern void   DGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
319                       Scalar*,int*,Scalar*,Scalar*,int*);
320 extern void   DGESVD(_fcd,_fcd,int *,int*, Scalar *,int*,Scalar*,Scalar*,
321                       int*,Scalar*,int*,Scalar*,int*,int*);
322 extern void   DGEEV(_fcd,_fcd,int *,Scalar *,int*,Scalar*,Scalar*,Scalar*,
323                       int*,Scalar*,int*,Scalar*,int*,int*);
324 #endif
325 
326 #else
327 extern void   LAormqr_(char*,char*,int*,int*,int*,Scalar*,int*,Scalar*,Scalar*,
328                        int*,Scalar*,int*,int*);
329 extern void   LAtrtrs_(char*,char*,char*,int*,int*,Scalar*,int*,Scalar*,int*,
330                        int*);
331 extern void   LApotrf_(char*,int*,Scalar*,int*,int*);
332 extern void   LAgemv_(char*,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
333                        Scalar*,Scalar*,int*);
334 extern void   LApotrs_(char*,int*,int*,Scalar*,int*,Scalar*,int*,int*);
335 extern void   LAgetrs_(char*,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
336 extern void   BLgemm_(char *,char*,int*,int*,int*,Scalar*,Scalar*,int*,
337                       Scalar*,int*,Scalar*,Scalar*,int*);
338 #if !defined(PETSC_COMPLEX)
339 extern void   LAgeev_(char *,char *,int *, Scalar *,int*,double*,double*,Scalar*,
340                       int*,Scalar*,int*,Scalar*,int*,int*);
341 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,double*,Scalar*,
342                       int*,Scalar*,int*,Scalar*,int*,int*);
343 #else
344 extern void   LAgeev_(char *,char *,int *, Scalar *,int*,Scalar*,Scalar*,
345                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
346 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,double*,Scalar*,
347                       int*,Scalar*,int*,Scalar*,int*,double*,int*);
348 #endif
349 #endif
350 
351 #if defined(__cplusplus)
352 }
353 #endif
354 
355 #endif
356 
357 
358 
359