44 #if defined (HAVE_CONFIG_H)
48 #if defined (USE_BLASWRAP)
58 #if ! defined (VECLIB_FILE)
59 # define VECLIB_FILE "/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib"
62 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
67 # pragma GCC diagnostic ignored "-Wmissing-prototypes"
78 static void (*f2c_blas_func[]) (void);
79 static void (*f2c_lapack_func[]) (void);
85 typedef double (*F2C_CALL_0) (void);
86 typedef double (*F2C_CALL_1) (
void *a1);
87 typedef double (*F2C_CALL_2) (
void *a1,
void *
a2);
88 typedef double (*F2C_CALL_3) (
void *a1,
void *
a2,
void *a3);
89 typedef double (*F2C_CALL_4) (
void *a1,
void *
a2,
void *a3,
void *a4);
90 typedef double (*F2C_CALL_5) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5);
91 typedef double (*F2C_CALL_6) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5,
93 typedef double (*F2C_CALL_7) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5,
95 typedef double (*F2C_CALL_8) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5,
96 void *a6,
void *a7,
void *a8);
98 #define F2C_LAPACK_CALL_8(name) \
99 float name (void *a1, void *a2, void *a3, void *a4, void *a5, void *a6, void *a7, void *a8) \
101 return ((F2C_CALL_8)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5, a6, a7, a8); \
104 #define F2C_LAPACK_CALL_7(name) \
105 float name (void *a1, void *a2, void *a3, void *a4, void *a5, void *a6, void *a7) \
107 return ((F2C_CALL_7)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5, a6, a7); \
110 #define F2C_LAPACK_CALL_6(name) \
111 float name (void *a1, void *a2, void *a3, void *a4, void *a5, void *a6) \
113 return ((F2C_CALL_6)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5, a6); \
116 #define F2C_LAPACK_CALL_5(name) \
117 float name (void *a1, void *a2, void *a3, void *a4, void *a5) \
119 return ((F2C_CALL_5)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5); \
122 #define F2C_LAPACK_CALL_4(name) \
123 float name (void *a1, void *a2, void *a3, void *a4) \
125 return ((F2C_CALL_4)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4); \
128 #define F2C_LAPACK_CALL_3(name) \
129 float name (void *a1, void *a2, void *a3) \
131 return ((F2C_CALL_3)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3); \
134 #define F2C_LAPACK_CALL_2(name) \
135 float name (void *a1, void *a2) \
137 return ((F2C_CALL_2)f2c_lapack_func[f2c_ ## name]) (a1, a2); \
140 #define F2C_LAPACK_CALL_1(name) \
141 float name (void *a1) \
143 return ((F2C_CALL_1)f2c_lapack_func[f2c_ ## name]) (a1); \
146 #define F2C_LAPACK_CALL_0(name) \
149 return ((F2C_CALL_0)f2c_lapack_func[f2c_ ## name]) (); \
152 #define F2C_LAPACK_CALL_NONE(name)
154 #define F2C_LAPACK_CALL(name, args) F2C_LAPACK_CALL_ ## args (name)
156 #define ENUM_ITEM(name, args) \
159 #define NAME_TO_STRING_CASE(name, args) \
160 case f2c_ ## name: return #name;
162 #define DEFINE_LAPACK_ENUM(name, list) \
167 f2c_ ## name ## _name (name n) { \
169 list(NAME_TO_STRING_CASE) \
170 default: return ""; \
173 list(F2C_LAPACK_CALL)
175 #define DEFINE_BLAS_ENUM(name, list) \
180 f2c_ ## name ## _name(name n) { \
182 list(NAME_TO_STRING_CASE) \
183 default: return ""; \
191 #define LAPACK_LIST(_) \
228 #define BLAS_LIST(_) \
235 DEFINE_BLAS_ENUM(blas, BLAS_LIST)
237 DEFINE_LAPACK_ENUM(lapack, LAPACK_LIST)
243 typedef struct {
float r, i; } complex;
244 typedef struct {
double r, i; } doublecomplex;
246 typedef void (*F2C_BLAS_CALL_6) (
void *c,
void *a1,
void *
a2,
void *a3,
249 #define F2C_BLAS_CALL(type, name) \
250 type name (void *a1, void *a2, void *a3, void *a4, void *a5) \
253 ((F2C_BLAS_CALL_6)f2c_blas_func[f2c_ ## name]) (&cplx, a1, a2, a3, a4, a5); \
257 F2C_BLAS_CALL(complex, cdotu_)
258 F2C_BLAS_CALL(doublecomplex, zdotu_)
259 F2C_BLAS_CALL(complex, cdotc_)
260 F2C_BLAS_CALL(doublecomplex, zdotc_)
265 static void (*f2c_blas_func[f2c_BLAS_COUNT]) (void) = { 0 };
266 static void (*f2c_lapack_func[f2c_LAPACK_COUNT]) (void) = { 0 };
273 static void * apple_vecLib = 0;
275 __attribute__((constructor))
276 static void initVecLibWrappers (
void)
278 apple_vecLib = dlopen (VECLIB_FILE, RTLD_LOCAL | RTLD_NOLOAD | RTLD_FIRST);
279 if (0 == apple_vecLib)
283 for (i = 0; i < f2c_LAPACK_COUNT; i++)
284 if (0 == (f2c_lapack_func[i] = dlsym (apple_vecLib, f2c_lapack_name(i))))
286 for (i = 0; i < f2c_BLAS_COUNT; i++)
287 if (0 == (f2c_blas_func[i] = dlsym (apple_vecLib, f2c_blas_name(i))))
291 __attribute__((destructor))
292 static void finiVecLibWrappers (
void)
295 dlclose (apple_vecLib);
const octave_base_value & a2