Skip to content

Commit 4411280

Browse files
committed
Implement zero preserving Array Vector functions by calling normal functions
1 parent 2c8901f commit 4411280

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/cdomains/affineEquality/arrayImplementation/arrayMatrix.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ module ArrayMatrix: AbstractMatrix =
318318
let is_covered_by m1 m2 =
319319
(*Performs a partial rref reduction to check if concatenating both matrices and afterwards normalizing them would yield a matrix <> m2 *)
320320
(*Both input matrices must be in rref form!*)
321-
let () = Printf.printf "Is m1 covered by m2?\n m1:\n%sm2:\n%s" (show m1) (show m2) in
321+
let () = Printf.printf "is_covered_by m1: \n%s " (show m1) in
322+
let () = Printf.printf "is_covered_by m2 \n%s " (show m2) in
322323
if num_rows m1 > num_rows m2 then false else
323324
let p2 = lazy (get_pivot_positions m2) in
324325
try (

src/cdomains/affineEquality/arrayImplementation/arrayVector.ml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ module ArrayVector: AbstractVector =
5757

5858
let is_zero_vec v = not (Array.exists (fun x -> x <>: A.zero) v)
5959

60-
let is_const_vec v = failwith "Never implemented!"
60+
let is_const_vec v =
61+
compare_length_with (filteri (fun i x -> (*Inefficient*)
62+
compare_length_with v (i + 1) > 0 && x <>: A.zero) v) 1 = 0
6163

6264
let nth = Array.get
6365

@@ -108,11 +110,17 @@ module ArrayVector: AbstractVector =
108110
let find_opt f v =
109111
failwith "Never implemented!"
110112

111-
let map_f_preserves_zero f v = failwith "Never implemented!"
112-
let map2_f_preserves_zero f v1 v2 = failwith "Never implemented!"
113+
let map_f_preserves_zero f v =
114+
map f v
113115

114-
let mapi_f_preserves_zero f v = failwith "Never implemented!"
115-
let map2i_f_preserves_zero f v v' = failwith "Never implemented!"
116+
let map2_f_preserves_zero f v1 v2 =
117+
map2 f v1 v2
118+
119+
let mapi_f_preserves_zero f v =
120+
mapi f v
121+
122+
let map2i_f_preserves_zero f v v' =
123+
map2i f v v'
116124

117125
let fold_left_f_preserves_zero f acc v =
118126
failwith "Never implemented!"
@@ -133,5 +141,5 @@ module ArrayVector: AbstractVector =
133141
failwith "Never implemented!"
134142

135143
let apply_with_c_f_preserves_zero f c v =
136-
failwith "Never implemented!"
144+
apply_with_c f c v
137145
end

0 commit comments

Comments
 (0)