1 /* -------------------------------------------------------------
2 
3 This file is a component of SDPA
4 Copyright (C) 2004-2012 SDPA Project
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 
20 ------------------------------------------------------------- */
21 /*  sdpa_algebra.h
22 
23 LAPACK+BLAS definitions wrapper
24 
25 Define macros to mangle the given C identifier (in lower and upper
26 case), which must not contain underscores, for linking with Fortran.
27 
28 */
29 
30 #ifndef __sdpa_algebra_h__
31 #define __sdpa_algebra_h__
32 
33 #define FC_RET_I int
34 #define FC_RET_D double
35 
36 #if defined(__APPLE__) // Dirty...
37 #define FC_FUNC(name,NAME) name ## _
38 #endif
39 
40 #define dtrsm_fc  FC_FUNC (dtrsm, DTRSM)
41 #define dsyrk_fc  FC_FUNC (dsyrk, DSYRK)
42 #define dcopy_fc  FC_FUNC (dcopy, DCOPY)
43 #define daxpy_fc  FC_FUNC (daxpy, DAXPY)
44 #define dgemm_fc  FC_FUNC (dgemm, DGEMM)
45 #define dgemv_fc  FC_FUNC (dgemv, DGEMV)
46 #define dscal_fc  FC_FUNC (dscal, DSCAL)
47 #define dtrsv_fc  FC_FUNC (dtrsv, DTRSV)
48 #define dtrmv_fc  FC_FUNC (dtrmv, DTRMV)
49 #define ddot_fc   FC_FUNC (ddot, DDOT)
50 #define dtrmm_fc  FC_FUNC (dtrmm, DTRMM)
51 #define ilaenv_fc FC_FUNC (ilaenv, ILAENV)
52 #define dsteqr_fc FC_FUNC (dsteqr, DSTEQR)
53 #define dsyev_fc  FC_FUNC (dsyev, DSYEV)
54 #define dpotrf_fc FC_FUNC (dpotrf, DPORTRF)
55 
56 
57 extern "C"
58 {
59 // BLAS
60   FC_RET_I  dtrsm_fc
61       (char* side, char* uplo, char* trans, char* diag,
62        int* M, int* N,
63        double* alpha,
64        double* A, int* lda,
65        double* B, int* ldb, int side_len,
66        int uplo_len, int trans_len, int diag_len);
67 
68   FC_RET_I  dsyrk_fc
69       (char* uplo, char* trans, int* N, int* K,
70        double* alpha,
71        double* A, int* lda,
72        double* beta,
73        double* C, int* ldc, int uplo_len, int trans_len);
74 
75   FC_RET_I  dcopy_fc
76       (int* N,
77        double* X, int* incX,
78        double* Y, int* incY);
79 
80   FC_RET_I  daxpy_fc
81       (int* N,
82        double* alpha,
83        double* X, int* incX,
84        double* Y, int* incY);
85 
86   FC_RET_I  dgemm_fc
87       (char* transA, char* transB, int* M, int* N, int* K,
88        double* alpha,
89        double* A, int* lda,
90        double* B, int* ldb,
91        double* beta,
92        double* C, int* ldc, int transA_len, int transB_len);
93 
94   FC_RET_I  dgemv_fc
95       (char* trans, int* M, int* N,
96        double* alpha,
97        double* A, int* lda,
98        double* X, int* incX,
99        double* beta,
100        double* Y, int* incY, int trans_len);
101 
102   FC_RET_I  dscal_fc
103       (int* N,
104        double* alpha,
105        double* X, int* incX);
106 
107   FC_RET_I  dtrsv_fc
108       (char* uplo, char* trans, char* diag, int* N,
109        double* A, int* lda,
110        double* X, int* incX, int uplo_len,
111        int trans_len, int diag_len);
112 
113   FC_RET_I  dtrmv_fc
114       (char* uplo, char *trans, char* diag, int *N,
115        double *A, int *lda,
116        double *X, int *incX, int uplo_len, int trans_len, int diag_len);
117 
118   FC_RET_D  ddot_fc
119       (int* N, double* X, int* incX, double* Y, int* incY);
120 
121   FC_RET_I  dtrmm_fc
122       (char* side, char* uplo, char* trans, char* diag,
123        int* M, int* N,
124        double* alpha,
125        double* A, int* lda,
126        double* B, int* ldb, int side_len, int uplo_len,
127        int trans_len, int diag_len);
128 
129 // LAPACK
130 
131   FC_RET_I  ilaenv_fc
132       (int *ispec, char *name, char *opts, int *n1,
133 	int *n2, int *n3, int *n4, int name_len, int opts_len);
134 
135   FC_RET_I  dsteqr_fc
136       (char *compz, int *n, double *d,
137 	double *e, double *z, int *ldz, double *work,
138 	int *info, int compz_len);
139 
140   FC_RET_I  dsyev_fc
141       (char *jobz, char *uplo, int *n, double *a,
142         int *lda, double *w, double *work, int *lwork,
143 	int *info, int jobz_len, int uplo_len);
144 
145   FC_RET_I  dpotrf_fc
146      (char *uplo, int *n, double *a, int *lda,
147       int *info, int uplo_len);
148 }
149 
150 #endif // __sdpa_algebra_h__
151