xref: /petsc/include/petscblaslapack.h (revision 2c8e378dfe5c949d40489f8c6ad94751c5f56048)
1a1e12872SBarry Smith /*
24fcfbe5fSBarry Smith   This file dispatches between various header files for blas/lapack distributions to handle the name mangling.
34fcfbe5fSBarry Smith   It also provides C prototypes for all the BLAS/LAPACK functions that PETSc uses
4f3da1532SBarry Smith 
5f3da1532SBarry Smith   This is not included automatically by petscsys.h because some external packages include their own prototypes for
6f3da1532SBarry Smith   certain BLAS/LAPACK functions that conflict with the ones given here. Hence this should only be included when needed.
7f3da1532SBarry Smith 
8a1e12872SBarry Smith */
9c3e41550SBarry Smith #if !defined(_BLASLAPACK_H)
10c3e41550SBarry Smith #define _BLASLAPACK_H
11bb638ab5SSatish Balay 
12429d5388SBarry Smith #if defined(PETSC_BLASLAPACK_STDCALL)
13*2c8e378dSBarry Smith #include <petscblaslapack_stdcall.h>
14c35b00c6SBarry Smith #else
15c35b00c6SBarry Smith 
16429d5388SBarry Smith #if defined(PETSC_BLASLAPACK_UNDERSCORE)
17*2c8e378dSBarry Smith #include <petscblaslapack_uscore.h>
18429d5388SBarry Smith #elif defined(PETSC_BLASLAPACK_CAPS)
19*2c8e378dSBarry Smith #include <petscblaslapack_caps.h>
2025fce39dSBarry Smith #else
21*2c8e378dSBarry Smith #include <petscblaslapack_c.h>
22a1e12872SBarry Smith #endif
23a1e12872SBarry Smith 
24638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgetrf_(PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
25638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKungqr_(PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
26638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgeqrf_(PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
27638cfed1SJed Brown PETSC_EXTERN_C PetscReal BLASnrm2_(const PetscBLASInt*,const PetscScalar*,const PetscBLASInt*);
28638cfed1SJed Brown PETSC_EXTERN_C void       BLASscal_(const PetscBLASInt*,const PetscScalar*,PetscScalar*,const PetscBLASInt*);
29638cfed1SJed Brown PETSC_EXTERN_C void       BLAScopy_(const PetscBLASInt*,const PetscScalar*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*);
30638cfed1SJed Brown PETSC_EXTERN_C void       BLASswap_(const PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*);
31638cfed1SJed Brown PETSC_EXTERN_C void       BLASaxpy_(const PetscBLASInt*,const PetscScalar*,const PetscScalar*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*);
32638cfed1SJed Brown PETSC_EXTERN_C PetscReal BLASasum_(const PetscBLASInt*,const PetscScalar*,const PetscBLASInt*);
33638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKpttrf_(const PetscBLASInt*,PetscReal*,PetscScalar*,const PetscBLASInt*);
34638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKstein_(const PetscBLASInt*,PetscReal*,PetscReal*,const PetscBLASInt*,PetscReal*,const PetscBLASInt*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscReal*,const PetscBLASInt*,const PetscBLASInt*,const PetscBLASInt*);
35638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgesv_(const PetscBLASInt*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscBLASInt*);
36c35b00c6SBarry Smith 
37638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKpotrf_(const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
38638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKpotrs_(const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
39638cfed1SJed Brown PETSC_EXTERN_C void  BLASgemv_(const char*,const PetscBLASInt*,const PetscBLASInt*,const PetscScalar*,const PetscScalar*,const PetscBLASInt*,const PetscScalar *,const PetscBLASInt*,const PetscScalar*,PetscScalar*,const PetscBLASInt*);
40638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgetrs_(const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
41638cfed1SJed Brown PETSC_EXTERN_C void  BLAStrmv_(const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*);
42638cfed1SJed Brown PETSC_EXTERN_C void  BLASgemm_(const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*);
43c35b00c6SBarry Smith 
44f16551e9SSatish Balay /* handle complex dot() with special code */
45f16551e9SSatish Balay #if defined(PETSC_USE_COMPLEX)
46f16551e9SSatish Balay PETSC_STATIC_INLINE PetscScalar BLASdot_(const PetscBLASInt *n,const PetscScalar *x,const PetscBLASInt *sx,const PetscScalar *y,const PetscBLASInt *sy)
47f16551e9SSatish Balay {
48f16551e9SSatish Balay   PetscScalar sum=0.0;
49f16551e9SSatish Balay   int i,j,k;
50f16551e9SSatish Balay   if (*sx==1 && *sy==1) {
51f16551e9SSatish Balay     for (i=0; i < *n; i++) sum += PetscConj(x[i])*y[i];
52f16551e9SSatish Balay   } else {
53f16551e9SSatish Balay     for (i=0,j=0,k=0; i < *n; i++,j+=*sx,k+=*sy) sum += PetscConj(x[j])*y[k];
54f16551e9SSatish Balay   }
55f16551e9SSatish Balay   return sum;
56f16551e9SSatish Balay }
57f16551e9SSatish Balay PETSC_STATIC_INLINE PetscScalar BLASdotu_(const PetscBLASInt *n,const PetscScalar *x,const PetscBLASInt *sx,const PetscScalar *y,const PetscBLASInt *sy)
58f16551e9SSatish Balay {
59f16551e9SSatish Balay   PetscScalar sum=0.0;
60f16551e9SSatish Balay   int i,j,k;
61f16551e9SSatish Balay   if (*sx==1 && *sy==1) {
62f16551e9SSatish Balay     for (i=0; i < *n; i++) sum += x[i]*y[i];
63f16551e9SSatish Balay   } else {
64f16551e9SSatish Balay     for (i=0,j=0,k=0; i < *n; i++,j+=*sx,k+=*sy) sum += x[j]*y[k];
65f16551e9SSatish Balay   }
66f16551e9SSatish Balay   return sum;
67f16551e9SSatish Balay }
68f16551e9SSatish Balay #else
69e52be38fSSatish Balay PETSC_EXTERN_C PetscScalar BLASdot_(const PetscBLASInt*,const PetscScalar*,const PetscBLASInt*,const PetscScalar*,const PetscBLASInt*);
70e52be38fSSatish Balay PETSC_EXTERN_C PetscScalar BLASdotu_(const PetscBLASInt*,const PetscScalar*,const PetscBLASInt*,const PetscScalar*,const PetscBLASInt*);
71f16551e9SSatish Balay #endif
72f16551e9SSatish Balay 
73976cf19bSSatish Balay /* Some functions prototypes differ between real and complex */
74976cf19bSSatish Balay #if defined(PETSC_USE_COMPLEX)
75638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgelss_(const PetscBLASInt*,const PetscBLASInt*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscReal*,const PetscReal*,PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscReal*,PetscBLASInt*);
76638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsyev_(const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
77638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsyevx_(const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
78638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsygv_(PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
79638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsygvx_(PetscBLASInt*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
80638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKpttrs_(const char*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
81638cfed1SJed Brown PETSC_EXTERN_C void LAPACKgerfs_(const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscReal*,PetscBLASInt*);
82638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKtrsen_(const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
83638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKtgsen_(PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
84638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgges_(const char*,const char*,const char*,PetscBLASInt(*)(),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*);
85638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKhseqr_(const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
86976cf19bSSatish Balay #else
87638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgelss_(const PetscBLASInt*,const PetscBLASInt*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscReal*,const PetscReal*,PetscBLASInt*,PetscScalar*,const PetscBLASInt*,PetscBLASInt*);
88638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsyev_(const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
89638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsyevx_(const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
90638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsygv_(PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
91638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKsygvx_(PetscBLASInt*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
92638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKpttrs_(PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
93638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKstebz_(const char*,const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*);
94638cfed1SJed Brown PETSC_EXTERN_C void LAPACKgerfs_(const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,PetscBLASInt*);
95638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKtrsen_(const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
96638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKtgsen_(PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
97638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgges_(const char*,const char*,const char*,PetscBLASInt(*)(),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
98638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKhseqr_(const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
99976cf19bSSatish Balay #endif
100976cf19bSSatish Balay 
101c35b00c6SBarry Smith /* ESSL uses a different calling sequence for dgeev(), zgeev() than LAPACK; */
102c35b00c6SBarry Smith #if defined(PETSC_HAVE_ESSL) && defined(PETSC_USE_COMPLEX)
103638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgeev_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
104638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgesvd_(const char*,const char*,PetscBLASInt *,PetscBLASInt*,PetscScalar *,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
105c35b00c6SBarry Smith #elif defined(PETSC_HAVE_ESSL)
106638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgeev_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
107638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgesvd_(const char*,const char*,PetscBLASInt *,PetscBLASInt*,PetscScalar *,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
108976cf19bSSatish Balay #elif defined(PETSC_USE_COMPLEX)
109638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgeev_(const char*,const char*,PetscBLASInt *,PetscScalar *,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
110638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgesvd_(const char*,const char*,PetscBLASInt *,PetscBLASInt*,PetscScalar *,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
111976cf19bSSatish Balay #else
112638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgeev_(const char*,const char*,PetscBLASInt *,PetscScalar *,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
113638cfed1SJed Brown PETSC_EXTERN_C void  LAPACKgesvd_(const char*,const char*,PetscBLASInt *,PetscBLASInt*,PetscScalar *,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
114c35b00c6SBarry Smith #endif
115c35b00c6SBarry Smith 
116c35b00c6SBarry Smith #endif
117a1e12872SBarry Smith #endif
118