chore: update
This commit is contained in:
parent
4776edc9db
commit
416d97c513
25 changed files with 1653 additions and 283 deletions
42
lib/hsim/zsolver.ml
Normal file
42
lib/hsim/zsolver.ml
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
open Zls
|
||||
open Illinois
|
||||
|
||||
type state = { state: t; vec: zarray }
|
||||
|
||||
let make_full size : (carray, carray, zarray option) Full.zsolver =
|
||||
let state =
|
||||
{ state = initialize 0 (fun _ _ _ -> ()) (cmake 0);
|
||||
vec = zmake 0 } in
|
||||
let reset { vec; _ } Full.{ fzer; y0; _ } =
|
||||
let fzer t cvec zout =
|
||||
let zout' = fzer t cvec in blit zout' zout in
|
||||
{ state = initialize size fzer y0;
|
||||
vec = if length vec = size then vec else zmake size } in
|
||||
let step ({ state; vec } as s) Full.{ h; f } =
|
||||
let y1 = f h in
|
||||
let fder h _ = let y = f h in blit y y1 in
|
||||
step state h y1;
|
||||
if has_roots state then
|
||||
let h = find state (fder, y1) vec in
|
||||
s, (h, Some vec)
|
||||
else s, (h, None) in
|
||||
Full.DNode { state; step; reset }
|
||||
|
||||
let make size : (carray, carray, zarray option) Fill.zsolver =
|
||||
let state =
|
||||
{ state = initialize 0 (fun _ _ _ -> ()) (cmake 0);
|
||||
vec = zmake 0 } in
|
||||
let reset { vec; _ } Fill.{ fzer; y0; _ } =
|
||||
let fzer t cvec zout =
|
||||
let zout' = fzer t cvec in blit zout' zout in
|
||||
{ state = initialize size fzer y0;
|
||||
vec = if length vec = size then vec else zmake size } in
|
||||
let step ({ state; vec } as s) Fill.{ h; f } =
|
||||
let y1 = f h in
|
||||
let fder h _ = let y = f h in blit y y1 in
|
||||
step state h y1;
|
||||
if has_roots state then
|
||||
let h = find state (fder, y1) vec in
|
||||
s, (h, Some vec)
|
||||
else s, (h, None) in
|
||||
Fill.DNode { state; step; reset }
|
||||
Loading…
Add table
Add a link
Reference in a new issue