2 ms·
> Clojure is a pretty bad choice for numerical work in general since function parameters are usually just Object and this leads to a lot of boxing This is quit
by fulafel 8y ago
> Clojure is a pretty bad choice for numerical work in general since function parameters are usually just Object and this leads to a lot of boxing
This is quite easily solved by just declaring your parameters with type hints, and testing the code with the provided warnings about reflection and boxed math.
This still leaves container data structures, the native arrays and vectors are boxed. To address this, you can to use Java arrays or 3rd party specialized containers like data.int-map instead.
- lrc 8y agoThere is good news and bad news. The ODE integrators (etc.) in Apache Commons Math are great and work with unboxed types. In SICM, however, you'll be dealing with clojure functions generated by the system to map states to their time derivatives, and those states will be stored in "up tuples" and not native java []double. So copying must happen at state-derivative evaluation time. The system attempts to win back some speed by at least avoiding interpreting the state function. For the kind of explorations the book enables, it seems good enough. Also, you can "take your equations of motion out" of the system with ->JavaScript, and run that code in the browser with a suitable JavaScript integrator and that works too.