File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/cdomains/affineEquality/sparseImplementation Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ module ListMatrix: AbstractMatrix =
151151
152152 let init_with_vec v =
153153 [v]
154-
154+
155155 let normalize m =
156156 let col_count = num_cols m in
157157 let dec_mat_2D (m : t ) (row_idx : int ) (col_idx : int ) : t =
@@ -211,6 +211,25 @@ module ListMatrix: AbstractMatrix =
211211 | Some (pivot_col , _ ) -> (i, pivot_col) :: acc
212212 ) [] m
213213
214+ let assert_rref m =
215+ let pivot_l = get_pivot_positions m in
216+ let rec validate m i =
217+ match m with
218+ | [] -> ()
219+ | v ::vs when (V. is_zero_vec v) ->
220+ if List. exists (fun v -> not @@ V. is_zero_vec v) vs
221+ then raise (Invalid_argument " Matrix not in rref: zero row!" )
222+ else ()
223+ | v ::vs ->
224+ let rec validate_vec pl =
225+ match pivot_l with
226+ | [] -> true
227+ | (pr , pc )::ps ->
228+ let target = if pr <> i then A. zero else A. one in
229+ if V. nth v pc <> target then false else validate_vec ps
230+ in if validate_vec pivot_l then validate vs (i+ 1 ) else raise (Invalid_argument " Matrix not in rref: pivot column not empty!" )
231+ in validate m 0
232+
214233 (* Inserts the vector v with pivot at piv_idx at the correct position in m. m has to be in rref form. *)
215234 let insert_v_according_to_piv m v piv_idx pivot_positions =
216235 match List. find_opt (fun (row_idx , piv_col ) -> piv_col > piv_idx) pivot_positions with
You can’t perform that action at this time.
0 commit comments