xref: /petsc/include/petscblaslapack.h (revision 6d84be18fbb99ba69be7b8bdde5411a66955b7ea)
1 /* $Id: plapack.h,v 1.16 1996/02/19 03:52:15 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 LAtrmv_  STRMV
93 #define LAtrsl_  STRSL
94 #elif defined(HAVE_FORTRAN_CAPS)
95 #define LAormqr_ DORMQR
96 #define LAtrtrs_ DTRTRS
97 #define LApotrf_ DPOTRF
98 #define LApotrs_ DPOTRS
99 #define LAgemv_  DGEMV
100 #define LAgetrs_ DGETRS
101 #define LAtrmv_  DTRMV
102 #define LAtrsl_  DTRSL
103 #define BLgemm_  DGEMM
104 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
105 #define LAormqr_ dormqr
106 #define LAtrtrs_ dtrtrs
107 #define LApotrf_ dpotrf
108 #define LApotrs_ dpotrs
109 #define LAgemv_  dgemv
110 #define LAgetrs_ dgetrs
111 #define LAtrmv_  dtrmv
112 #define LAtrsl_  dtrsl
113 #define BLgemm_  dgemm
114 #else
115 #define LAormqr_ dormqr_
116 #define LAtrtrs_ dtrtrs_
117 #define LApotrf_ dpotrf_
118 #define LApotrs_ dpotrs_
119 #define LAgemv_  dgemv_
120 #define LAgetrs_ dgetrs_
121 #define LAtrmv_  dtrmv_
122 #define LAtrsl_  dtrsl_
123 #define BLgemm_  dgemm_
124 #endif
125 
126 #else
127 
128 /*
129    Complex with no character string arguments
130 */
131 #if defined(PARCH_t3d)
132 #define LAgeqrf_ CGEQRF
133 #define BLdot_   CDOTC
134 #define BLnrm2_  SCNRM2
135 #define BLscal_  CSCAL
136 #define BLcopy_  CCOPY
137 #define BLswap_  CSWAP
138 #define BLaxpy_  CAXPY
139 #define BLasum_  SCASUM
140 #define LAgetrf_ CGETRF
141 #define LAgetf2_ CGETRF
142 #elif defined(HAVE_FORTRAN_CAPS)
143 #define LAgeqrf_ ZGEQRF
144 #define BLdot_   ZDOTC
145 #define BLnrm2_  DZNRM2
146 #define BLscal_  ZSCAL
147 #define BLcopy_  ZCOPY
148 #define BLswap_  ZSWAP
149 #define BLaxpy_  ZAXPY
150 #define BLasum_  DZASUM
151 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
152 #define LAgeqrf_ zgeqrf
153 #define LAgetrf_ zgetrf
154 #define LAgetf2_ zgetf2
155 #define BLdot_   zdotc
156 #define BLnrm2_  dznrm2
157 #define BLscal_  zscal
158 #define BLcopy_  zcopy
159 #define BLswap_  zswap
160 #define BLaxpy_  zaxpy
161 #define BLasum_  dzasum
162 #else
163 #define LAgeqrf_ zgeqrf_
164 #define LAgetrf_ zgetrf_
165 #define LAgetf2_ zgetf2_
166 #define BLdot_   zdotc_
167 #define BLnrm2_  dznrm2_
168 #define BLscal_  zscal_
169 #define BLcopy_  zcopy_
170 #define BLswap_  zswap_
171 #define BLaxpy_  zaxpy_
172 #define BLasum_  dzasum_
173 #endif
174 
175 /*
176     Complex with character string arguments.
177   Who the F&%&^ was stupid enough to put character strings
178   into low-level computational kernels? It was a mistake!
179 */
180 #if defined(PARCH_t3d)
181 #define LAtrtrs_(a,b,c,d,e,f,g,h,i,j) CTRTRS(_cptofcd((a),1),_cptofcd((b),1),\
182                               _cptofcd((c),1),(d),(e),(f),(g),(h),(i),(j))
183 #define LApotrf_(a,b,c,d,e)       CPOTRF(_cptofcd((a),1),(b),(c),(d),(e))
184 #define LApotrs_(a,b,c,d,e,f,g,h) CPOTRS(_cptofcd((a),1),(b),(c),(d),(e),\
185                                          (f),(g),(h))
186 #define LAgemv_(a,b,c,d,e,f,g,h,i,j,k) CGEMV(_cptofcd((a),1),(b),(c),(d),(e),\
187                                         (f),(g),(h),(i),(j),(k))
188 #define LAgetrs_(a,b,c,d,e,f,g,h,i) CGETRS(_cptofcd((a),1),(b),(c),(d),(e),\
189                                         (f),(g),(h),(i))
190 #define LAgemm_(a,b,c,d,e,f,g,h,i,j,k,l,m) SGEMM(_cptofcd((a),1), \
191                                             _cptofcd((a),1),(c),(d),(e),\
192                                         (f),(g),(h),(i),(j),(k),(l),(m))
193 #define LAtrmv_  CTRMV
194 #define LAtrsl_  CTRSL
195 #elif defined(HAVE_FORTRAN_CAPS)
196 #define LAtrtrs_ ZTRTRS
197 #define LApotrf_ ZPOTRF
198 #define LApotrs_ ZPOTRS
199 #define LAgemv_  ZGEMV
200 #define LAgetrf_ ZGETRF
201 #define LAgetf2_ ZGETF2
202 #define LAgetrs_ ZGETRS
203 #define LAtrmv_  ZTRMV
204 #define LAtrsl_  ZTRSL
205 #define BLgemm_  ZGEMM
206 #elif !defined(HAVE_FORTRAN_UNDERSCORE)
207 #define LAtrtrs_ ztrtrs
208 #define LApotrf_ zpotrf
209 #define LApotrs_ zpotrs
210 #define LAgemv_  zgemv
211 #define LAgetrs_ zgetrs
212 #define LAtrmv_  ztrmv
213 #define LAtrsl_  ztrsl
214 #define BLgemm_  zgemm
215 #else
216 #define LAtrtrs_ ztrtrs_
217 #define LApotrf_ zpotrf_
218 #define LApotrs_ zpotrs_
219 #define LAgemv_  zgemv_
220 #define LAgetrs_ zgetrs_
221 #define LAtrmv_  ztrmv_
222 #define LAtrsl_  ztrsl_
223 #define BLgemm_  zgemm_
224 #endif
225 
226 #endif
227 
228 #if defined(__cplusplus)
229 extern "C" {
230 #endif
231 
232 /* note that BLdot cannot be used with COMPLEX because it cannot
233    handle returing a double complex!!
234 */
235 extern double BLdot_(int*,Scalar*,int*,Scalar*,int*);
236 extern double BLnrm2_(int*,Scalar*,int*),BLasum_(int*,Scalar*,int*);
237 extern void   BLscal_(int*,Scalar*,Scalar*,int*);
238 extern void   BLcopy_(int*,Scalar*,int*,Scalar*,int*);
239 extern void   BLswap_(int*,Scalar*,int*,Scalar*,int*);
240 extern void   BLaxpy_(int*,Scalar*,Scalar*,int*,Scalar*,int*);
241 extern void   LAgetrf_(int*,int*,Scalar*,int*,int*,int*);
242 extern void   LAgetf2_(int*,int*,Scalar*,int*,int*,int*);
243 extern void   LAgeqrf_(int*,int*,Scalar*,int*,Scalar*,Scalar*,int*,int*);
244 
245 #if defined(PARCH_t3d)
246 
247 #if defined(PETSC_COMPLEX)
248 extern void   CPOTRF(_fcd,int*,Scalar*,int*,int*);
249 extern void   CGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
250                         Scalar*,Scalar*,int*);
251 extern void   CPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
252 extern void   CGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
253 extern void   CGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
254                       Scalar*,int*,Scalar*,Scalar*,int*);
255 #else
256 extern void   SPOTRF(_fcd,int*,Scalar*,int*,int*);
257 extern void   SGEMV(_fcd,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
258                         Scalar*,Scalar*,int*);
259 extern void   SPOTRS(_fcd,int*,int*,Scalar*,int*,Scalar*,int*,int*);
260 extern void   SGETRS(_fcd,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
261 extern void   SGEMM(_fcd,_fcd,int*,int*,int*,Scalar*,Scalar*,int*,
262                       Scalar*,int*,Scalar*,Scalar*,int*);
263 #endif
264 
265 #else
266 extern void   LAormqr_(char*,char*,int*,int*,int*,Scalar*,int*,Scalar*,Scalar*,
267                        int*,Scalar*,int*,int*);
268 extern void   LAtrtrs_(char*,char*,char*,int*,int*,Scalar*,int*,Scalar*,int*,
269                        int*);
270 extern void   LApotrf_(char*,int*,Scalar*,int*,int*);
271 extern void   LAgemv_(char*,int*,int*,Scalar*,Scalar*,int*,Scalar *,int*,
272                        Scalar*,Scalar*,int*);
273 extern void   LApotrs_(char*,int*,int*,Scalar*,int*,Scalar*,int*,int*);
274 extern void   LAgetrs_(char*,int*,int*,Scalar*,int*,int*,Scalar*,int*,int*);
275 extern void   BLgemm_(char *,char*,int*,int*,int*,Scalar*,Scalar*,int*,
276                       Scalar*,int*,Scalar*,Scalar*,int*);
277 #endif
278 
279 #if defined(__cplusplus)
280 }
281 #endif
282 
283 #endif
284 
285 
286 
287