xref: /petsc/include/petscblaslapack.h (revision ab94cc7af4fcd5c63a93b94bdec4707d4e0807cd)
1 /* $Id: plapack.h,v 1.20 1996/04/10 04:31:14 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 DTRMV    STRMV
54 #define DTRSL    STRSL
55 #endif
56 
57 #if defined(HAVE_FORTRAN_CAPS)
58 #define LAgeqrf_ DGEQRF
59 #define LAgetrf_ DGETRF
60 #define LAgetf2_ DGETF2
61 #define BLdot_   DDOT
62 #define BLnrm2_  DNRM2
63 #define BLscal_  DSCAL
64 #define BLcopy_  DCOPY
65 #define BLswap_  DSWAP
66 #define BLaxpy_  DAXPY
67 #define BLasum_  DASUM
68 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
69 #define LAgeqrf_ dgeqrf
70 #define LAgetrf_ dgetrf
71 #define LAgetf2_ dgetf2
72 #define BLdot_   ddot
73 #define BLnrm2_  dnrm2
74 #define BLscal_  dscal
75 #define BLcopy_  dcopy
76 #define BLswap_  dswap
77 #define BLaxpy_  daxpy
78 #define BLasum_  dasum
79 #else
80 #define LAgeqrf_ dgeqrf_
81 #define LAgetrf_ dgetrf_
82 #define LAgetf2_ dgetf2_
83 #define BLdot_   ddot_
84 #define BLnrm2_  dnrm2_
85 #define BLscal_  dscal_
86 #define BLcopy_  dcopy_
87 #define BLswap_  dswap_
88 #define BLaxpy_  daxpy_
89 #define BLasum_  dasum_
90 #endif
91 
92 /*
93    Real with character string arguments.
94 */
95 #if defined(USES_CPTOFCD)
96 /*
97    Note that this assumes that machines which use cptofcd() use
98   the HAVE_FORTRAN_CAPS option. This is true on the Cray T3d.
99 */
100 #define LAormqr_(a,b,c,d,e,f,g,h,i,j,k,l,m)  DORMQR(_cptofcd((a),1),\
101              _cptofcd((b),1),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
102 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) DTRTRS(_cptofcd((a),1),_cptofcd((b),1),\
103                              _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
104 #define LApotrf_(a,b,c,d,e) DPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
105 #define LApotrs_(a,b,c,d,e,f,g,h) DPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
106                                          (f),(g),(h))
107 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) DGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
108                                         (f),(g),(h),(i),(j),(k))
109 #define LAgetrs_(a,b,c,d,e,f,g,h,i) DGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
110                                         (f),(g),(h),(i))
111 #define LAgetrs_(a,b,c,d,e,f,g,h,i) DGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
112                                         (f),(g),(h),(i))
113 #define BLgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) DGEMM(_cptofcd((a),1), \
114                                             _cptofcd((a),1),(c),(d),(e),\
115                                         (f),(g),(h),(i),(j),(k),(l),(m))
116 #define LAgesvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) DGESVD(_cptofcd((a),1), \
117                                             _cptofcd((a),1),(c),(d),(e),\
118                                         (f),(g),(h),(i),(j),(k),(l),(m),(n))
119 #define LAtrmv_  DTRMV
120 #define LAtrsl_  DTRSL
121 #elif defined(HAVE_FORTRAN_CAPS)
122 #define LAormqr_ DORMQR
123 #define LAtrtrs_ DTRTRS
124 #define LApotrf_ DPOTRF
125 #define LApotrs_ DPOTRS
126 #define LAgemv_  DGEMV
127 #define LAgetrs_ DGETRS
128 #define LAtrmv_  DTRMV
129 #define LAtrsl_  DTRSL
130 #define LAgesvd_ DGESVD
131 #define BLgemm_  DGEMM
132 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
133 #define LAormqr_ dormqr
134 #define LAtrtrs_ dtrtrs
135 #define LApotrf_ dpotrf
136 #define LApotrs_ dpotrs
137 #define LAgemv_  dgemv
138 #define LAgetrs_ dgetrs
139 #define LAtrmv_  dtrmv
140 #define LAtrsl_  dtrsl
141 #define BLgemm_  dgemm
142 #define LAgesvd_ dgesvd
143 #else
144 #define LAormqr_ dormqr_
145 #define LAtrtrs_ dtrtrs_
146 #define LApotrf_ dpotrf_
147 #define LApotrs_ dpotrs_
148 #define LAgemv_  dgemv_
149 #define LAgetrs_ dgetrs_
150 #define LAtrmv_  dtrmv_
151 #define LAtrsl_  dtrsl_
152 #define BLgemm_  dgemm_
153 #define LAgesvd_ dgesvd_
154 #endif
155 
156 #else
157 /*
158    Complex with no character string arguments
159 */
160 #if defined(USES_FORTRAN_SINGLE)
161 #define ZGEQRF  CGEQRF
162 #define ZDOTC   CDOTC
163 #define DZNRM2  SCNRM2
164 #define ZSCAL   CSCAL
165 #define ZCOPY   CCOPY
166 #define ZSWAP   CSWAP
167 #define ZAXPY   CAXPY
168 #define DZASUM  SCASUM
169 #define ZGETRF  CGETRF
170 #define ZTRTRS  CTRTRS
171 #define ZPOTRF  CPOTRF
172 #define ZPOTRS  CPOTRS
173 #define ZGEMV   CGEMV
174 #define ZGETRS  CGETRS
175 #define ZGEMM   SGEMM
176 #define ZTRMV   CTRMV
177 #define ZTRSL   CTRSL
178 #endif
179 
180 #if defined(HAVE_FORTRAN_CAPS)
181 #define LAgeqrf_ ZGEQRF
182 #define BLdot_   ZDOTC
183 #define BLnrm2_  DZNRM2
184 #define BLscal_  ZSCAL
185 #define BLcopy_  ZCOPY
186 #define BLswap_  ZSWAP
187 #define BLaxpy_  ZAXPY
188 #define BLasum_  DZASUM
189 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
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 #else
201 #define LAgeqrf_ zgeqrf_
202 #define LAgetrf_ zgetrf_
203 #define LAgetf2_ zgetf2_
204 #define BLdot_   zdotc_
205 #define BLnrm2_  dznrm2_
206 #define BLscal_  zscal_
207 #define BLcopy_  zcopy_
208 #define BLswap_  zswap_
209 #define BLaxpy_  zaxpy_
210 #define BLasum_  dzasum_
211 #endif
212 
213 #if defined(USES_CTOPFCD)
214 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) ZTRTRS(_cptofcd((a),1),_cptofcd((b),1),\
215                               _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
216 #define LApotrf_(a,b,c,d,e)       ZPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
217 #define LApotrs_(a,b,c,d,e,f,g,h) ZPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
218                                          (f),(g),(h))
219 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) ZGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
220                                         (f),(g),(h),(i),(j),(k))
221 #define LAgetrs_(a,b,c,d,e,f,g,h,i) ZGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
222                                         (f),(g),(h),(i))
223 #define BLgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) ZGEMM(_cptofcd((a),1), \
224                                             _cptofcd((a),1),(c),(d),(e),\
225                                         (f),(g),(h),(i),(j),(k),(l),(m))
226 #define LAtrmv_  ZTRMV
227 #define LAtrsl_  ZTRSL
228 #elif defined(HAVE_FORTRAN_CAPS)
229 #define LAtrtrs_ ZTRTRS
230 #define LApotrf_ ZPOTRF
231 #define LApotrs_ ZPOTRS
232 #define LAgemv_  ZGEMV
233 #define LAgetrf_ ZGETRF
234 #define LAgetf2_ ZGETF2
235 #define LAgetrs_ ZGETRS
236 #define LAtrmv_  ZTRMV
237 #define LAtrsl_  ZTRSL
238 #define BLgemm_  ZGEMM
239 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
240 #define LAtrtrs_ ztrtrs
241 #define LApotrf_ zpotrf
242 #define LApotrs_ zpotrs
243 #define LAgemv_  zgemv
244 #define LAgetrs_ zgetrs
245 #define LAtrmv_  ztrmv
246 #define LAtrsl_  ztrsl
247 #define BLgemm_  zgemm
248 #else
249 #define LAtrtrs_ ztrtrs_
250 #define LApotrf_ zpotrf_
251 #define LApotrs_ zpotrs_
252 #define LAgemv_  zgemv_
253 #define LAgetrs_ zgetrs_
254 #define LAtrmv_  ztrmv_
255 #define LAtrsl_  ztrsl_
256 #define BLgemm_  zgemm_
257 #endif
258 
259 #endif
260 
261 #if defined(__cplusplus)
262 extern "C" {
263 #endif
264 
265 /*
266    BLdot cannot be used with COMPLEX because it cannot
267    handle returing a double complex to C++.
268 */
269 extern double BLdot_(int*,Scalar*,int*,Scalar*,int*);
270 extern double BLnrm2_(int*,Scalar*,int*),BLasum_(int*,Scalar*,int*);
271 extern void   BLscal_(int*,Scalar*,Scalar*,int*);
272 extern void   BLcopy_(int*,Scalar*,int*,Scalar*,int*);
273 extern void   BLswap_(int*,Scalar*,int*,Scalar*,int*);
274 extern void   BLaxpy_(int*,Scalar*,Scalar*,int*,Scalar*,int*);
275 extern void   LAgetrf_(int*,int*,Scalar*,int*,int*,int*);
276 extern void   LAgetf2_(int*,int*,Scalar*,int*,int*,int*);
277 extern void   LAgeqrf_(int*,int*,Scalar*,int*,Scalar*,Scalar*,int*,int*);
278 
279 #if defined(USES_CPTOFCD)
280 
281 #if defined(PETSC_COMPLEX)
282 extern void   ZPOTRF(_fcd,int*,Scalar*,int*,int*);
283 extern void   ZGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
284                         Scalar*,Scalar*,int*);
285 extern void   ZPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
286 extern void   ZGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
287 extern void   ZGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
288                       Scalar*,int*,Scalar*,Scalar*,int*);
289 #else
290 extern void   DPOTRF(_fcd,int*,Scalar*,int*,int*);
291 extern void   DGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
292                         Scalar*,Scalar*,int*);
293 extern void   DPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
294 extern void   DGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
295 extern void   DGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
296                       Scalar*,int*,Scalar*,Scalar*,int*);
297 extern void   DGESVD(_fcd,_fcd,int *,int*, Scalar *,int*,Scalar*,Scalar*,
298                       int*,Scalar*,int*,Scalar*,int*,int*);
299 #endif
300 
301 #else
302 extern void   LAormqr_(char*,char*,int*,int*,int*,Scalar*,int*,Scalar*,Scalar*,
303                        int*,Scalar*,int*,int*);
304 extern void   LAtrtrs_(char*,char*,char*,int*,int*,Scalar*,int*,Scalar*,int*,
305                        int*);
306 extern void   LApotrf_(char*,int*,Scalar*,int*,int*);
307 extern void   LAgemv_(char*,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
308                        Scalar*,Scalar*,int*);
309 extern void   LApotrs_(char*,int*,int*,Scalar*,int*,Scalar*,int*,int*);
310 extern void   LAgetrs_(char*,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
311 extern void   BLgemm_(char *,char*,int*,int*,int*,Scalar*,Scalar*,int*,
312                       Scalar*,int*,Scalar*,Scalar*,int*);
313 extern void   LAgesvd_(char *,char *,int *,int*, Scalar *,int*,Scalar*,Scalar*,
314                       int*,Scalar*,int*,Scalar*,int*,int*);
315 #endif
316 
317 #if defined(__cplusplus)
318 }
319 #endif
320 
321 #endif
322 
323 
324 
325