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"
66 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
76 static void (*f2c_blas_func[]) (void);
77 static void (*f2c_lapack_func[]) (void);
83 typedef double (*F2C_CALL_0) (void);
84 typedef double (*F2C_CALL_1) (
void *a1);
85 typedef double (*F2C_CALL_2) (
void *a1,
void *
a2);
86 typedef double (*F2C_CALL_3) (
void *a1,
void *
a2,
void *a3);
87 typedef double (*F2C_CALL_4) (
void *a1,
void *
a2,
void *a3,
void *a4);
88 typedef double (*F2C_CALL_5) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5);
89 typedef double (*F2C_CALL_6) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5,
91 typedef double (*F2C_CALL_7) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5,
93 typedef double (*F2C_CALL_8) (
void *a1,
void *
a2,
void *a3,
void *a4,
void *a5,
94 void *a6,
void *a7,
void *a8);
96 #define F2C_LAPACK_CALL_8(name) \
97 float name (void *a1, void *a2, void *a3, void *a4, void *a5, void *a6, void *a7, void *a8) \
99 return ((F2C_CALL_8)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5, a6, a7, a8); \
102 #define F2C_LAPACK_CALL_7(name) \
103 float name (void *a1, void *a2, void *a3, void *a4, void *a5, void *a6, void *a7) \
105 return ((F2C_CALL_7)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5, a6, a7); \
108 #define F2C_LAPACK_CALL_6(name) \
109 float name (void *a1, void *a2, void *a3, void *a4, void *a5, void *a6) \
111 return ((F2C_CALL_6)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5, a6); \
114 #define F2C_LAPACK_CALL_5(name) \
115 float name (void *a1, void *a2, void *a3, void *a4, void *a5) \
117 return ((F2C_CALL_5)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4, a5); \
120 #define F2C_LAPACK_CALL_4(name) \
121 float name (void *a1, void *a2, void *a3, void *a4) \
123 return ((F2C_CALL_4)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3, a4); \
126 #define F2C_LAPACK_CALL_3(name) \
127 float name (void *a1, void *a2, void *a3) \
129 return ((F2C_CALL_3)f2c_lapack_func[f2c_ ## name]) (a1, a2, a3); \
132 #define F2C_LAPACK_CALL_2(name) \
133 float name (void *a1, void *a2) \
135 return ((F2C_CALL_2)f2c_lapack_func[f2c_ ## name]) (a1, a2); \
138 #define F2C_LAPACK_CALL_1(name) \
139 float name (void *a1) \
141 return ((F2C_CALL_1)f2c_lapack_func[f2c_ ## name]) (a1); \
144 #define F2C_LAPACK_CALL_0(name) \
147 return ((F2C_CALL_0)f2c_lapack_func[f2c_ ## name]) (); \
150 #define F2C_LAPACK_CALL_NONE(name)
152 #define F2C_LAPACK_CALL(name, args) F2C_LAPACK_CALL_ ## args (name)
154 #define ENUM_ITEM(name, args) \
157 #define NAME_TO_STRING_CASE(name, args) \
158 case f2c_ ## name: return #name;
160 #define DEFINE_LAPACK_ENUM(name, list) \
165 f2c_ ## name ## _name (name n) { \
167 list(NAME_TO_STRING_CASE) \
168 default: return ""; \
171 list(F2C_LAPACK_CALL)
173 #define DEFINE_BLAS_ENUM(name, list) \
178 f2c_ ## name ## _name(name n) { \
180 list(NAME_TO_STRING_CASE) \
181 default: return ""; \
189 #define LAPACK_LIST(_) \
226 #define BLAS_LIST(_) \
233 DEFINE_BLAS_ENUM(blas, BLAS_LIST)
235 DEFINE_LAPACK_ENUM(lapack, LAPACK_LIST)
241 typedef struct {
float r, i; } complex;
242 typedef struct {
double r, i; } doublecomplex;
244 typedef void (*F2C_BLAS_CALL_6) (
void *c,
void *a1,
void *
a2,
void *a3,
247 #define F2C_BLAS_CALL(type, name) \
248 type name (void *a1, void *a2, void *a3, void *a4, void *a5) \
251 ((F2C_BLAS_CALL_6)f2c_blas_func[f2c_ ## name]) (&cplx, a1, a2, a3, a4, a5); \
255 F2C_BLAS_CALL(complex, cdotu_)
256 F2C_BLAS_CALL(doublecomplex, zdotu_)
257 F2C_BLAS_CALL(complex, cdotc_)
258 F2C_BLAS_CALL(doublecomplex, zdotc_)
263 static void (*f2c_blas_func[f2c_BLAS_COUNT]) (void) = { 0 };
264 static void (*f2c_lapack_func[f2c_LAPACK_COUNT]) (void) = { 0 };
271 static void * apple_vecLib = 0;
273 __attribute__((constructor))
274 static void initVecLibWrappers (
void)
276 apple_vecLib = dlopen (VECLIB_FILE, RTLD_LOCAL | RTLD_NOLOAD | RTLD_FIRST);
277 if (0 == apple_vecLib)
281 for (i = 0; i < f2c_LAPACK_COUNT; i++)
282 if (0 == (f2c_lapack_func[i] = dlsym (apple_vecLib, f2c_lapack_name(i))))
284 for (i = 0; i < f2c_BLAS_COUNT; i++)
285 if (0 == (f2c_blas_func[i] = dlsym (apple_vecLib, f2c_blas_name(i))))
289 __attribute__((destructor))
290 static void finiVecLibWrappers (
void)
293 dlclose (apple_vecLib);
const octave_base_value & a2