Commit 8ae0efaf authored by Benoit Barbot's avatar Benoit Barbot
Browse files

fix unbounded loop

parent 7fc577a7
Pipeline #2286 passed with stages
in 1 minute and 40 seconds
......@@ -22,7 +22,7 @@
(modules wordgen)
(instrumentation (backend bisect_ppx))
(libraries wordgen_lib unix arguments)
(modes native))
(modes native byte))
......
......@@ -35,18 +35,18 @@ let newton_raphson_iterate ?(factor = 1e-9) ?(max_iter = 20) ?bound f guess_p =
delta := copysign (0.9 *. abs_float !result) !delta
else delta := shift;
delta1 := 3.0 *. !delta;
delta2 := 3.0 *. !delta );
delta2 := 3.0 *. !delta);
(*Format.printf "test2@.";*)
guess := !result;
result := !result -. !delta;
if !result <= !min then (
delta := 0.5 *. (!guess -. !min);
result := !guess -. !delta;
if !result = !min || !result = !max then raise Exit )
if !result = !min || !result = !max then raise Exit)
else if !result >= !max then (
delta := 0.5 *. (!guess -. !max);
result := !guess -. !delta;
if !result = !min || !result = !max then raise Exit );
if !result = !min || !result = !max then raise Exit);
if !delta > 0.0 then max := !guess else min := !guess;
if abs_float (!result *. factor) >= abs_float !delta then raise Exit
done;
......@@ -97,7 +97,7 @@ let rec bisect_increasing ?(factor = 1e-10) ?(strict = true) ?(relax = 0.0) ?low
(*Format.printf "right\n";*)
bisect_increasing ~relax ~strict ~factor ~low:(m, fx, a)
(m -. (relax *. width), bmax +. (relax *. width))
f_to_evaluate )
f_to_evaluate)
else
let fx, _, _ = f_to_evaluate bmax in
if classify_float fx = FP_nan || fx > 0.0 || fx < yfmin then
......
......@@ -216,7 +216,7 @@ struct
(fun k v b ->
if b && v > F.zero then Format.fprintf f "+";
Format.fprintf f "%s%a"
( match (F.is_exact, v, is_not_const k) with
(match (F.is_exact, v, is_not_const k) with
| false, v1, true when v1 = F.of_float 1.0 -> ""
| false, v1, true when v1 = F.of_float (-1.0) -> "-"
| false, v1, _ when v1 = F.of_float 0.5 -> "½"
......@@ -226,7 +226,7 @@ struct
| false, v1, _ when v1 = F.of_float (-0.75) -> "-¾"
| false, v1, _ when v1 = F.of_float (-0.25) -> "-¼"
| _, x, _ when F.is_integer x -> string_of_int (F.to_int x)
| _ -> F.to_string v )
| _ -> F.to_string v)
print_monome k;
true)
a false
......@@ -422,7 +422,7 @@ struct
if a <> 0 then (
let k2 = Array.copy k in
k2.(x) <- a - 1;
add_mon k2 (F.mul v (F.of_int a)) it )
add_mon k2 (F.mul v (F.of_int a)) it)
else it)
p Poly.empty
......@@ -613,7 +613,8 @@ struct
else
let upval = cc up in
if upval <> lowval then dicho low up true lowval
else dicho up (2.0 *. up) false upval
else if up < 1. /. factor then dicho up (2.0 *. up) false upval
else up
in
dicho start 1.0 false (cc start)
......
Markdown is supported
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