@@ -269,6 +269,45 @@ def __init__(self, file=None, charset='utf-8', model_name="anon_model",
269269 s = template .safe_substitute (model_cppname = self .model_cppname )
270270 outfile .write (s )
271271
272+ ## cvodes sources
273+
274+ # cvodes sources are complied and linked together with the Stan model
275+ # extension module. This is not ideal. In theory, build_clib could be
276+ # used to build a library once and models would be complied and then
277+ # linked with this library. This would save 7 or more seconds from every build.
278+ # But such a strategy is frustrated by the
279+ # lack of ``install_clib`` functionality in Python's distutils.
280+ #
281+ # TODO: numpy provides install_clib functionality, use that.
282+ cvodes_src_path = os .path .join (pystan_dir , 'stan' , 'lib' , 'stan_math' , 'lib' , 'cvodes_2.9.0' , 'src' )
283+ cvodes_sources = [
284+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodea.c' ),
285+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodea_io.c' ),
286+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes.c' ),
287+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_band.c' ),
288+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_bandpre.c' ),
289+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_bbdpre.c' ),
290+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_dense.c' ),
291+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_diag.c' ),
292+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_direct.c' ),
293+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_io.c' ),
294+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_sparse.c' ),
295+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_spbcgs.c' ),
296+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_spgmr.c' ),
297+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_spils.c' ),
298+ os .path .join (cvodes_src_path , 'cvodes' , 'cvodes_sptfqmr.c' ),
299+ os .path .join (cvodes_src_path , 'nvec_ser' , 'nvector_serial.c' ),
300+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_band.c' ),
301+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_dense.c' ),
302+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_direct.c' ),
303+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_iterative.c' ),
304+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_math.c' ),
305+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_nvector.c' ),
306+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_spbcgs.c' ),
307+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_spgmr.c' ),
308+ os .path .join (cvodes_src_path , 'sundials' , 'sundials_sptfqmr.c' ),
309+ ]
310+
272311 stan_macros = [
273312 ('BOOST_RESULT_OF_USE_TR1' , None ),
274313 ('BOOST_NO_DECLTYPE' , None ),
@@ -291,7 +330,7 @@ def __init__(self, file=None, charset='utf-8', model_name="anon_model",
291330 distutils .log .set_verbosity (verbose )
292331 extension = Extension (name = self .module_name ,
293332 language = "c++" ,
294- sources = [pyx_file ],
333+ sources = [pyx_file ] + cvodes_sources ,
295334 define_macros = stan_macros ,
296335 include_dirs = include_dirs ,
297336 extra_compile_args = extra_compile_args )
0 commit comments