feat: a lot of stuff

This commit is contained in:
Henri Saudubray 2025-05-12 14:50:10 +02:00
parent dd6152833f
commit 6cec3d6c5d
Signed by: hms
GPG key ID: 7065F57ED8856128
22 changed files with 476 additions and 276 deletions

View file

@ -11,33 +11,36 @@ let mu = 5.0
let x0 = 1.0
let y0 = 1.0
let csize = 2
let zsize = 1
let yd = cmake 2
let zout = cmake 1
let fder _ _ y =
let fder y yd =
yd.{0} <- y.{1};
yd.{1} <- (mu *. (1.0 -. (y.{0} *. y.{0})) *. y.{1}) -. y.{0};
yd
let fzer _ _ _ = zout
let fout _ _ y = of_array [| y.{0}; y.{1} |]
let step { i; lx } _ =
let lx = if i then of_array [| x0; y0 |] else lx in
of_array [| lx.{0}; lx.{1} |], { lx; i=false }
let cget s = s.lx
let cset s lx = { s with lx }
let zset s _ = s
let state = { lx=of_array [| x0; y0 |]; i=true }
let reset _ _ = state
let jump _ = true
let horizon _ = max_float
let cget s = s.lx
let cset s lx = { s with lx }
let zset s _ = s
let jump _ = true
let horizon _ = max_float
let van_der_pol () = HNode {
state; fder; fzer; fout; step; reset; horizon; jump; cset; cget; zset; zsize
}
let van_der_pol ()
: (state, _, _, carray, carray, carray, zarray, carray) hnode
= let yd = cmake csize in
let zout = cmake zsize in
let fder _ _ y = fder y yd in
let fzer _ _ _ = zout in
let init _ = { lx=of_array [| x0; y0 |]; i=true } in
let reset _ _ = init () in
HNode { init; fder; fzer; fout; step; reset; horizon;
jump; cset; cget; zset; csize; zsize }
let errmsg = "Too many arguments for the model (needed: 0)"
let van_der_pol = function
let init = function
| [] -> van_der_pol ()
| _ -> raise (Invalid_argument errmsg)