@@ -87,8 +87,6 @@ module ListMatrix: AbstractMatrix =
8787 Timing. wrap " add_empty_cols" (add_empty_columns m) cols
8888
8989 let append_row m row =
90- let () = Printf. printf " Before append_row m:\n %s\n " (show m) in
91- let () = Printf. printf " After append_row m:\n %s\n " (show ( m @ [row])) in
9290 m @ [row]
9391
9492 let get_row m n =
@@ -305,23 +303,28 @@ module ListMatrix: AbstractMatrix =
305303 is_linearly_independent_rref new_v xs
306304
307305 let is_covered_by m1 m2 =
306+ Printf. printf " Is m1 covered by m2?\n m1:\n %sm2:\n %s" (show m1) (show m2);
307+ match normalize @@ append_matrices m2 m1 with
308+ | None -> false
309+ | Some m -> let m2' = remove_zero_rows m in List. for_all2 (fun x y -> V. equal x y) m2 m2'
310+ (* let () = Printf.printf "Is m1 covered by m2?\n m1:\n%sm2:\n%s" (show m1) (show m2) in
308311 if num_rows m1 > num_rows m2 then false else
309- let rec is_covered_by_helper m1 m2 =
310- match m1 with
311- | [] -> true
312- | v1 ::vs1 ->
313- let first_non_zero = V. findi_val_opt ((<> :) A. zero) v1 in
314- match first_non_zero with
315- | None -> true (* vs1 must also be zero-vectors because of rref *)
316- | Some (idx , _ ) ->
317- let m' = List. drop_while (fun v2 ->
318- match V. findi_val_opt ((<> :) A. zero) v2 with
319- | None -> true (* In this case, m2 only has zero rows after that *)
320- | Some (idx' , _ ) -> idx' < idx
321- ) m2 in (* Only consider the part of m2 where the pivot is at a position useful for deleting first_non_zero of v1*)
322- let linearly_indep = is_linearly_independent_rref v1 m' in
323- if linearly_indep then false else is_covered_by_helper vs1 m'
324- in is_covered_by_helper m1 m2
312+ let rec is_covered_by_helper m1 m2 =
313+ match m1 with
314+ | [] -> true
315+ | v1::vs1 ->
316+ let first_non_zero = V.findi_val_opt ((<>:) A.zero) v1 in
317+ match first_non_zero with
318+ | None -> true (* vs1 must also be zero-vectors because of rref *)
319+ | Some (idx, _) ->
320+ let m' = List.drop_while (fun v2 ->
321+ match V.findi_val_opt ((<>:) A.zero) v2 with
322+ | None -> true (* In this case, m2 only has zero rows after that *)
323+ | Some (idx', _) -> idx' < idx
324+ ) m2 in (* Only consider the part of m2 where the pivot is at a position useful for deleting first_non_zero of v1*)
325+ let linearly_indep = is_linearly_independent_rref v1 m' in
326+ if linearly_indep then false else is_covered_by_helper vs1 m'
327+ in is_covered_by_helper m1 m2*)
325328
326329 let is_covered_by m1 m2 = Timing. wrap " is_covered_by" (is_covered_by m1) m2
327330
0 commit comments