File tree Expand file tree Collapse file tree 3 files changed +31
-10
lines changed Expand file tree Collapse file tree 3 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 3838def generate_csrc_prelude (io : IO [str ]):
3939 io .write (
4040 """// includes
41- #include "stddef.h"
42- #include "math.h"
41+ #include <stddef.h>
4342
4443// typedefs
4544typedef double float_point_t;
4645
46+ // declare mathematical functions
47+ #define UNARY(f) float_point_t f(float_point_t x)
48+ #define BINARY(f) float_point_t f(float_point_t x, float_point_t y)
49+
50+ // unary functions
51+ UNARY(fabs);
52+ UNARY(acos);
53+ UNARY(asin);
54+ UNARY(atan);
55+ UNARY(cos);
56+ UNARY(exp);
57+ UNARY(log);
58+ UNARY(sin);
59+ UNARY(sqrt);
60+ UNARY(tan);
61+
62+ // binary functions
63+ BINARY(pow);
64+
4765// externals
4866// azmul
4967float_point_t azmul(float_point_t x, float_point_t y)
Original file line number Diff line number Diff line change 2020# On Linux/Mac, tcc has lib/tcc/include/ and lib/tcc/libtcc1.a which must be included in compilation
2121libtcc_extra_include_path = None
2222libtcc_extra_lib_path = None
23- libtcc_extra_lib_name = None
23+ libtcc_extra_lib_names = None
2424if system in ["Linux" , "Darwin" ]:
2525 libtcc_extra_include_path = os .path .join (libtcc_dir , "tcc" , "include" )
2626 libtcc_extra_lib_path = os .path .join (libtcc_dir , "tcc" )
27- libtcc_extra_lib_name = "libtcc1.a"
27+ libtcc_extra_lib_names = [ "libtcc1.a" , "m" ]
2828
2929# Define types
3030TCCState = ctypes .c_void_p
@@ -82,9 +82,10 @@ def create_state(self):
8282 == - 1
8383 ):
8484 raise Exception ("Failed to add extra library path" )
85- if libtcc_extra_lib_name :
86- if self .libtcc .tcc_add_library (state , libtcc_extra_lib_name .encode ()) == - 1 :
87- raise Exception ("Failed to add extra library" )
85+ if libtcc_extra_lib_names :
86+ for name in libtcc_extra_lib_names :
87+ if self .libtcc .tcc_add_library (state , name .encode ()) == - 1 :
88+ raise Exception ("Failed to add extra library" )
8889
8990 self .states .append (state )
9091
Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ def con(vars):
157157
158158
159159if __name__ == "__main__" :
160- test_ipopt (ipopt .Model )
161- test_nlp_param (ipopt .Model )
162- test_nlfunc_ifelse (ipopt .Model )
160+ def c ():
161+ return ipopt .Model (jit = "C" )
162+ test_ipopt (c )
163+ test_nlp_param (c )
164+ test_nlfunc_ifelse (c )
You can’t perform that action at this time.
0 commit comments