Skip to content

Commit abe08c2

Browse files
committed
Removed some _with functions from the AffineEqualityDomain
1 parent 8c23838 commit abe08c2

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/cdomains/apron/affineEqualityDomain.apron.ml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct
2929
m
3030
else (
3131
Array.modifyi (+) ch.dim;
32-
let m' = if not del then let m = copy m in Array.fold_left (fun y x -> reduce_col_with y x; y) m ch.dim else m in
32+
let m' = if not del then let m = copy m in Array.fold_left (fun y x -> reduce_col y x) m ch.dim else m in
3333
remove_zero_rows @@ del_cols m' ch.dim)
3434

3535
let dim_remove ch m ~del = VectorMatrix.timing_wrap "dim remove" (fun del -> dim_remove ch m ~del:del) del
@@ -59,7 +59,7 @@ struct
5959
let open Apron.Texpr1 in
6060
let exception NotLinear in
6161
let zero_vec = Vector.zero_vec @@ Environment.size t.env + 1 in
62-
let neg v = Vector.map_with Mpqf.neg v; v in
62+
let neg v = Vector.map Mpqf.neg v in
6363
let is_const_vec v = Vector.compare_length_with (Vector.filteri (fun i x -> (*Inefficient*)
6464
Vector.compare_length_with v (i + 1) > 0 && x <>: Mpqf.zero) v) 1 = 0
6565
in
@@ -75,13 +75,13 @@ struct
7575
Vector.set_val zero_vec ((Vector.length zero_vec) - 1) (of_union x)
7676
| Var x ->
7777
let zero_vec_cp = Vector.copy zero_vec in
78-
let entry_only v = Vector.set_val_with v (Environment.dim_of_var t.env x) Mpqf.one; v in
78+
let entry_only v = Vector.set_val v (Environment.dim_of_var t.env x) Mpqf.one in
7979
begin match t.d with
8080
| Some m ->
8181
let row = Matrix.find_opt (fun r -> Vector.nth r (Environment.dim_of_var t.env x) =: Mpqf.one) m in
8282
begin match row with
8383
| Some v when is_const_vec v ->
84-
Vector.set_val_with zero_vec_cp ((Vector.length zero_vec) - 1) (Vector.nth v (Vector.length v - 1)); zero_vec_cp
84+
Vector.set_val zero_vec_cp ((Vector.length zero_vec) - 1) (Vector.nth v (Vector.length v - 1))
8585
| _ -> entry_only zero_vec_cp
8686
end
8787
| None -> entry_only zero_vec_cp end
@@ -91,17 +91,17 @@ struct
9191
| Binop (Add, e1, e2, _, _) ->
9292
let v1 = convert_texpr e1 in
9393
let v2 = convert_texpr e2 in
94-
Vector.map2_with (+:) v1 v2; v1
94+
Vector.map2 (+:) v1 v2
9595
| Binop (Sub, e1, e2, _, _) ->
9696
let v1 = convert_texpr e1 in
9797
let v2 = convert_texpr e2 in
98-
Vector.map2_with (+:) v1 (neg @@ v2); v1
98+
Vector.map2 (+:) v1 (neg @@ v2)
9999
| Binop (Mul, e1, e2, _, _) ->
100100
let v1 = convert_texpr e1 in
101101
let v2 = convert_texpr e2 in
102102
begin match to_constant_opt v1, to_constant_opt v2 with
103-
| _, Some c -> Vector.apply_with_c_with ( *:) c v1; v1
104-
| Some c, _ -> Vector.apply_with_c_with ( *:) c v2; v2
103+
| _, Some c -> Vector.apply_with_c ( *:) c v1
104+
| Some c, _ -> Vector.apply_with_c ( *:) c v2
105105
| _, _ -> raise NotLinear
106106
end
107107
| Binop _ -> raise NotLinear
@@ -294,18 +294,17 @@ struct
294294
(a, b, max)
295295
else
296296
(
297-
Vector.rev_with col_a;
298-
Vector.rev_with col_b;
297+
let col_a = Vector.rev col_a in
298+
let col_b = Vector.rev col_b in
299299
let i = Vector.find2i (<>:) col_a col_b in
300300
let (x, y) = Vector.nth col_a i, Vector.nth col_b i in
301301
let r, diff = Vector.length col_a - (i + 1), x -: y in
302302
let a_r, b_r = Matrix.get_row a r, Matrix.get_row b r in
303-
Vector.map2_with (-:) col_a col_b;
304-
Vector.rev_with col_a;
303+
let col_a = Vector.map2 (-:) col_a col_b in
304+
let col_a = Vector.rev col_a in
305305
let multiply_by_t m t =
306-
Matrix.map2i_with (fun i' x c -> if i' <= max then (let beta = c /: diff in
307-
Vector.map2_with (fun u j -> u -: (beta *: j)) x t); x) m col_a;
308-
m
306+
Matrix.map2i (fun i' x c -> if i' <= max then (let beta = c /: diff in Vector.map2 (fun u j -> u -: (beta *: j)) x t) else x) m col_a;
307+
309308
in
310309
Matrix.remove_row (multiply_by_t a a_r) r, Matrix.remove_row (multiply_by_t b b_r) r, (max - 1)
311310
)

0 commit comments

Comments
 (0)