I have released a small numerical library for solving delay differential equations: http://github.com/masterdezign/dde
The main technical constraints:
- Make the library flexible with respect to the number of dynamical variables (x(t), y(t),...), i.e. a
State
of the dynamical system for a given moment of time. - Easily integrate with libraries that exploit Data.Vector.Storable (e.g.
hmatrix
). Therefore, as input/output I extensively employ Data.Vector.Storable.
As a result, unlike in this solution:
How do I optimize numerical integration performance in Haskell (with example),
newtype State = State { _state :: V.Vector Double }
is used
instead of data State = State {-# UNPACK #-} !Double {-# UNPACK #-} !Double
. However, the library runs twice slower now.
The question: is there any way to bring both the speed of data State = State {-# UNPACK #-}...
and the flexibility of newtype State = State { _state :: V.Vector Double }
for unspecified number of variables? Shall I consider Template Haskell to create data UNPACK
-like structures during the compilation time?