Commit f7641a47 authored by Benoit Barbot's avatar Benoit Barbot
Browse files

wip

parent 11fc815c
Pipeline #3002 failed with stages
in 60 minutes
......@@ -22,11 +22,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
open Common
module Poly = Map.Make (struct
type t = bound
module Key = struct
type t = Finite of int * VarSet.var | Const of int | Infinite
let of_bound = function
| Common.Infinite -> Infinite
| Const x -> Const x
| Finite (i, v) -> Finite (i, v)
let compare a b = compare a b
end)
end
module Poly = Map.Make (Key)
module Make
(P : Polynomial.S) (Param : sig
......@@ -81,10 +88,10 @@ struct
| x -> Format.fprintf f "%g" x
let simp_bound vs f = function
| Infinite -> Format.fprintf f "inf"
| Key.Infinite -> Format.fprintf f "inf"
| Const x -> Format.fprintf f "%as" (simp_int false) x
| Finite (0, _) as b when is_time b -> Format.fprintf f "-st"
| Finite (x, vi) as b when is_time b ->
| Finite (0, v) when v = tvar -> Format.fprintf f "-st"
| Finite (x, vi) when vi = tvar ->
Format.fprintf f "-s(%i+%s)" (-x) (fst vs.(VarSet.int_of_var vi))
| Finite (x, vi) ->
Format.fprintf f "-s(%i-%s)" (-x) (fst vs.(VarSet.int_of_var vi))
......@@ -177,7 +184,7 @@ struct
let ex = P.var ?exp v in
Poly.singleton (Const 0) ex
let term p b = Poly.singleton b p
let term p b = Poly.singleton (Key.of_bound b) p
let const x =
(* Const 0 means e-0 i.e. 1.0 *)
......@@ -197,6 +204,15 @@ struct
add_mon k2 v2 acc)
ep Poly.empty*)
let poly_of_key = function
| Key.Infinite -> P.const F.infinity
| Const a -> P.const (F.of_int a)
| Finite (a, c) ->
assert (c <> VarSet.var_of_int 0);
(* use Const instead *)
let rv = P.const (F.of_int a) in
P.(rv -.. var c)
let map_var ep map =
Poly.fold
(fun k v acc ->
......@@ -244,7 +260,7 @@ struct
add_mon k P.(diff v t +.. (F.of_int c **. v)) acc
| Finite (_, vi) when t = s ->
assert (vi <> t);
let p = P.of_bound k in
let p = poly_of_key k in
add_mon k P.(diff v t +.. (p *.. v)) acc
| Const _ -> add_mon k (P.diff v t) acc
(* diff w.r. to t *)
......@@ -275,7 +291,7 @@ struct
let p = F.of_int c **. var s in
acc +.. ((snd @@ taylor_exp_exp p n) *.. v)
| Finite _ ->
let p = of_bound k *.. var s in
let p = poly_of_key k *.. var s in
acc +.. ((snd @@ taylor_exp_exp p n) *.. v))
ep P.zero
in
......@@ -477,7 +493,7 @@ struct
s
let simp_bound vs f = function
| Infinite -> Format.fprintf f "inf"
| Key.Infinite -> Format.fprintf f "inf"
| Const x -> Format.fprintf f "%as" (simp_int false) x
| Finite (0, _) -> ()
| Finite (x, vi) ->
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment