Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparsification of Affine Equality Matrix #1625

Draft
wants to merge 176 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
cb0eec6
Created SparseMatrix module
GollokG Nov 5, 2024
5ba152c
Merge pull request #1 from CopperCableIsolator/affeq-sparsification
GollokG Nov 5, 2024
f931125
Merge remote-tracking branch 'upstream/master'
GollokG Nov 5, 2024
69cc72f
changed type to lists
Nov 7, 2024
1b5f531
SparseMatrix list and get_col
GollokG Nov 7, 2024
b1c877a
Implement del_col and del_cols for SparseMatrix
GollokG Nov 8, 2024
bfbd373
added row functions and conversions between vectors and sparse lists
Nov 10, 2024
d0124f9
add_empty_columns untested
CopperCableIsolator Nov 11, 2024
dbc0fdc
merge
CopperCableIsolator Nov 11, 2024
d789459
Implement set_col for SparseMatrix
GollokG Nov 12, 2024
8c23838
Add functions without side effects to ArrayVector and Vector interface
GollokG Nov 12, 2024
fd73a7c
Removed some _with functions from the AffineEqualityDomain
feniup Nov 12, 2024
11e7dcd
sparseVector stumb
CopperCableIsolator Nov 12, 2024
d3b4072
Extracted operations
feniup Nov 14, 2024
7141f97
Implement normalize SparseMatrix
GollokG Nov 14, 2024
7c2cb08
sparseVector stumb
CopperCableIsolator Nov 12, 2024
37d1bc0
Removed some _with functions from the AffineEqualityDomain
feniup Nov 12, 2024
3e159ad
Some Vector Functions
CopperCableIsolator Nov 14, 2024
9acc346
Implement some more SparseMatrix functions
GollokG Nov 15, 2024
128d368
added rref_vec und rref_matrix ohne _with
Nov 18, 2024
89588ab
added new interface functions to sparsematrix
Nov 18, 2024
d3477c0
implemented reduce_col and remove_zero_rows and fixed some bugs
Nov 19, 2024
5a28e34
matrix_normalize_stub
CopperCableIsolator Nov 19, 2024
090b31f
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
CopperCableIsolator Nov 19, 2024
daec67b
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Nov 19, 2024
225c730
sexier sub function
CopperCableIsolator Nov 19, 2024
420bde8
toMatrix vec funcs
CopperCableIsolator Nov 19, 2024
4dbc81f
toVector
CopperCableIsolator Nov 19, 2024
af2fc0f
Change of_sparse_list param order and continued normalize function
GollokG Nov 19, 2024
acf5851
Split up vectorMatrix into multiple files; Removed VectorMatrix from …
feniup Nov 20, 2024
32c378d
Merge remote-tracking branch 'origin/master' into file-splitting
feniup Nov 20, 2024
5ce5ee8
Bugfix Matrix.map2i without side effects (different length lists)
GollokG Nov 21, 2024
63506ea
Merge remote-tracking branch 'origin/master' into file-splitting
feniup Nov 21, 2024
7643899
added missing module BatList
feniup Nov 21, 2024
41bb6ed
RenamedFolder; Revealed modules to goblint_lib
feniup Nov 21, 2024
6602d75
Directly revealed modules to goblint_lib
feniup Nov 21, 2024
b7d5c1a
Added missing ArrayVector module to goblint_lib
feniup Nov 21, 2024
b1beb54
Merge pull request #2 from CopperCableIsolator/file-splitting
feniup Nov 21, 2024
8476f95
Vector List
CopperCableIsolator Nov 26, 2024
5fb8041
someMatFuncs
CopperCableIsolator Nov 26, 2024
8c3824f
some functions changed to use vectors
Nov 26, 2024
3234896
again
Nov 26, 2024
fb3442b
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Nov 26, 2024
251f1c9
Reimplemented some matrix functions to vector
GollokG Nov 26, 2024
67c9ef4
Added find_opt and remove_nth to vector interface
GollokG Nov 26, 2024
19ac2db
pushing is_zero_vec
Nov 26, 2024
47f4fa1
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Nov 26, 2024
a0e0f1b
Formatting
GollokG Nov 26, 2024
d768b46
vector functions
Nov 26, 2024
74ce9fe
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Nov 26, 2024
422dd54
Removed some _with functions from the AffineEqualityDomain
feniup Nov 26, 2024
6afcb81
Implement inefficient rref functions
GollokG Nov 26, 2024
e7aa151
Merge branch 'master' into affine-equality-domain-without-with
feniup Nov 26, 2024
7b4173a
ocp-indent on sparseMatrix.ml
feniup Nov 26, 2024
c8db710
del_cols and remove_at_indices
Nov 26, 2024
24fd057
commiting again for indentation
Nov 26, 2024
0e702ee
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Nov 26, 2024
0c9eb46
Vector functions
GollokG Nov 26, 2024
0db8b61
some vector functions
Nov 27, 2024
f413d51
Merge branch 'master' into affine-equality-domain-without-with
GollokG Nov 28, 2024
d439b20
vector conversion to array
Nov 28, 2024
03fab15
Explicit types on normalize
GollokG Nov 28, 2024
f018a06
map2_preserve_zero
CopperCableIsolator Nov 28, 2024
70dbf4d
exists, vector interface
CopperCableIsolator Nov 28, 2024
215b25e
ups
CopperCableIsolator Nov 28, 2024
fd16be1
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Nov 28, 2024
680e56b
Reimplemented normalize in SparseMatrix, some TODOs missing
GollokG Nov 28, 2024
40996b7
Renamed sparseMatrix.ml to match module name
feniup Nov 28, 2024
cb62292
Merge branch 'master' of github.com:CopperCableIsolator/goblint-spars…
feniup Nov 28, 2024
702f258
builds now + reduce_col
Nov 28, 2024
e556c41
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Nov 28, 2024
bec7535
Moved swap, div, sub and normalize to new listMatrix.ml
GollokG Nov 28, 2024
ad34bc7
Renamed tV according to best practices
feniup Nov 28, 2024
bd81ac1
Implement vector findi and minor bugfix in ListMatrix normalize
GollokG Nov 28, 2024
06a32ea
vectorfuncs, foldleftpreservezero
CopperCableIsolator Nov 28, 2024
05a3dc5
Add normalize check for invalid affeq matrix
GollokG Nov 28, 2024
409c01d
Vector function findi_val_opt
GollokG Nov 28, 2024
ad9f618
Adapting normalize and reordering deprecated functions in ListMatrix.ml
GollokG Nov 28, 2024
33b8723
Implement Vector foldleft and apply_with_c
GollokG Nov 28, 2024
785f75d
add column and helper functions
Nov 29, 2024
fe9513a
Fix del_cols duplicate edge case chech before comparing length
GollokG Nov 30, 2024
7a8fab9
Fix set_nth in Vector
GollokG Nov 30, 2024
519ee02
Remove double Mpqf definition
GollokG Dec 1, 2024
d3d998d
Renamed SparseMatrix to ListMatrix in goblint_lib.ml
feniup Dec 3, 2024
b339b78
Merge branch 'master' of github.com:CopperCableIsolator/goblint-spars…
feniup Dec 3, 2024
d68c719
Implement is_covered_by structure, but helper function still missing
GollokG Dec 3, 2024
159d07e
bugfix in insert_at and reduce_col_with_vec
Dec 3, 2024
1f85d28
Implement more vector functions
GollokG Dec 3, 2024
793df4a
Formatting
GollokG Dec 3, 2024
ffa0b54
Merge branch 'master' into affine-equality-domain-without-with
Dec 3, 2024
abdae29
Merge pull request #3 from CopperCableIsolator/affine-equality-domain…
charlotte-brandt Dec 3, 2024
6021c42
Implement is_covered_by
GollokG Dec 3, 2024
97a735b
small bugfixes
Dec 4, 2024
b17f33e
Finish normalize first version with dec2D
GollokG Dec 4, 2024
80672a1
bugfix in find_val_opt and lin_independent
Dec 5, 2024
418de56
Fixed affeq_rows_are_valid helper for normalize
GollokG Dec 5, 2024
e10493a
better map2pz,better naming
CopperCableIsolator Dec 5, 2024
d2b0be7
small hickup
CopperCableIsolator Dec 5, 2024
859ec26
normalize bug fix
Dec 5, 2024
67c1d5c
small naming
CopperCableIsolator Dec 5, 2024
71768be
fold_left2_f_preserves_zero
CopperCableIsolator Dec 5, 2024
0207a73
print for debugging
Dec 5, 2024
2bc4b66
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
Dec 5, 2024
ef0cc36
Bugfixes in Vector and more Debug prints
GollokG Dec 5, 2024
c038dc7
Bugfix in Vector keep_vals and to_list; Implement set_nth in Vector"
GollokG Dec 6, 2024
92b784a
Bugfix insert_val_at
GollokG Dec 6, 2024
8ba5777
Bugfix Matrix map2i and Vector insert_val_at again
GollokG Dec 6, 2024
f6a415e
Add more debug-prints
GollokG Dec 6, 2024
3e7d3d6
Bugfix in Vector rev and Matrix map2i again
GollokG Dec 6, 2024
0c95dc7
Bugfix in Matrix del_cols and Vector remove_at_indices
GollokG Dec 6, 2024
c72c77d
arraymatrix passes tests again
Dec 6, 2024
09054a1
Reduced test suite; Simple normalized test with mxn-Matrix with m!=n;
feniup Dec 6, 2024
99cf805
Merge branch 'master' of github.com:CopperCableIsolator/goblint-spars…
feniup Dec 6, 2024
2968963
Added example source
feniup Dec 6, 2024
4ef3acc
more debugging prints and added remove_zero_rows to rref_vec
Dec 7, 2024
968c533
Bugfixes in ListMatrix normalize
GollokG Dec 7, 2024
fe6b2a6
Added a solution vector to the normalize unit test
feniup Dec 9, 2024
18acca5
Normalize test for a shuffeled matrix
feniup Dec 9, 2024
43e042f
Normalize test for row elimination
feniup Dec 9, 2024
ef07123
Normalize tests with different domains
feniup Dec 9, 2024
8d1c548
Normalize tests for idempotency and negation
feniup Dec 9, 2024
d71d7bd
bugfix in add_empty_columns, behavious still differs from arraymatrix
Dec 10, 2024
db97f30
add_emtpy_cols uses arraymatrix logic here + bugfix in normalize - on…
Dec 10, 2024
315dac6
appending and normalizing in is_covered_by - all tests pass
Dec 10, 2024
58e34c0
Normalize tests for empty matrix, two column matrix and a normalized …
feniup Dec 10, 2024
9f7cec9
Added a newline
feniup Dec 10, 2024
6673aae
Changed the assert failure text for when the normalization fails
feniup Dec 10, 2024
fe984fb
Add some is_covered_by tests
GollokG Dec 10, 2024
f44f2eb
Formatting
GollokG Dec 10, 2024
79f890a
Added some comments on the test setup
feniup Dec 10, 2024
4b34fda
Added some comments on the test setup
feniup Dec 10, 2024
586cc38
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
GollokG Dec 10, 2024
1241795
bugfix in insert_zeros and use list funtionality again, uses apron st…
Dec 10, 2024
091b9fa
coveredddd
CopperCableIsolator Dec 10, 2024
a7a4e14
Fix normalize tests for floating point and fraction
GollokG Dec 12, 2024
b15b9d2
small tweak in findi_val_opt, could be even a tini tiny bit faster bu…
CopperCableIsolator Dec 12, 2024
0f6509b
removed prints for benchmarking
Dec 12, 2024
9ea8cc2
Remove old copies in AffineEqualityDomain
GollokG Dec 12, 2024
ca91d48
Adapt sparseVector functions to tail recursive
GollokG Dec 12, 2024
6883084
added Timingwraps to vector functions and alternative to findivalopt
Dec 13, 2024
61caba2
implemented different rref_vec that doesn't use normalize
Dec 13, 2024
c9be718
new rref_vec should be faster
Dec 13, 2024
fb1f36a
removed files with debug logs that I pushed by accident
Dec 13, 2024
0535677
Add apply_with_c_f_preserves_zero
GollokG Dec 13, 2024
c776a2b
Changed some calls in Domain to zero preserving
GollokG Dec 13, 2024
d3b18aa
Change rref_matrix without append and normalize, still have to benchmark
GollokG Dec 14, 2024
eba9d49
Remove some warnings of deprecated code
GollokG Dec 14, 2024
21a839c
Merge branch 'master' into benchmarks
GollokG Dec 15, 2024
dd0000e
Merge branch 'benchmarks' into master
GollokG Dec 17, 2024
2e80b94
removed second remove_nth
charlotte-brandt Dec 17, 2024
1fa998f
Remove deprecated _with functions from Vector and Matrix interface
GollokG Dec 17, 2024
1ea8040
Remove deprecated _with functions from Vector and Matrix interface
GollokG Dec 17, 2024
fd5689a
commenting some functions
charlotte-brandt Dec 17, 2024
335d4ea
Merge branch 'master' of https://github.com/CopperCableIsolator/gobli…
charlotte-brandt Dec 17, 2024
6186435
is_cons_vec
CopperCableIsolator Dec 17, 2024
d42bf5f
replace the last findi_val_opt
charlotte-brandt Dec 17, 2024
0088812
ein paar maps ausgetauscht
CopperCableIsolator Dec 17, 2024
92802e5
Optimize non zero-preserving Vector.map and Vector.map2i
GollokG Dec 18, 2024
2c8901f
added test from lin2vareq to affeq that found mistake in dim_add
charlotte-brandt Dec 19, 2024
4411280
Implement zero preserving Array Vector functions by calling normal fu…
GollokG Dec 19, 2024
012104f
assert_rref
CopperCableIsolator Dec 19, 2024
37190f4
assert_rref
CopperCableIsolator Dec 19, 2024
d7da9c7
small bugfix assert_rref
CopperCableIsolator Dec 19, 2024
bb15181
Bugfix rref_vec using reduce_col_with_vec
GollokG Dec 19, 2024
0678f66
Change order of functions because of compilation error
GollokG Dec 19, 2024
3b49ba5
Organize Vector and Matrix interface
GollokG Dec 21, 2024
93463f2
Bugfix Vector is_const_vec
GollokG Dec 21, 2024
6ae9bf1
Remove prints in ArrayMatrix
GollokG Dec 21, 2024
b8ba2bb
reordered function in vector so that they match the interface
charlotte-brandt Dec 21, 2024
60f7b67
Reorder listMatrix; Some renaming
GollokG Dec 23, 2024
8c931a7
Optimize get_col for sparse; Some timing_wraps for matrix
GollokG Dec 23, 2024
de6acc7
Fix semantics Matrix.map2, changed Matrix.map2i but might still have …
GollokG Dec 23, 2024
c01b627
comments
CopperCableIsolator Dec 27, 2024
1a33f55
findi_f_false_at_zero
CopperCableIsolator Dec 27, 2024
aaadeaa
Add find2i_f_false_at_zero to ArrayVector and remove duplicate code f…
GollokG Dec 28, 2024
a82e652
Merge remote-tracking branch 'upstream/master'
GollokG Dec 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove some warnings of deprecated code
  • Loading branch information
GollokG committed Dec 14, 2024
commit eba9d498586c050fd2563d0ea637960972b19e3c
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,4 @@ module ArrayVector: AbstractVector =

let find_first_non_zero v =
failwith "TODO"

end
38 changes: 0 additions & 38 deletions src/cdomains/affineEquality/sparseImplementation/listMatrix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

(* This only works if Array.modifyi has been removed from dim_add *)
let add_empty_columns (m : t) (cols : int array) : t =
let () = Printf.printf "Before add_empty_columns m:\n%sindices: %s\n" (show m) (Array.fold_right (fun x s -> (Int.to_string x) ^ "," ^ s) cols "") in

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let cols = Array.to_list cols in
let sorted_cols = List.sort Stdlib.compare cols in
let rec count_sorted_occ acc cols last count =
Expand All @@ -49,7 +49,7 @@
| x :: xs when x = last -> count_sorted_occ acc xs x (count + 1)
| x :: xs -> let acc = if count > 0 then (last, count) :: acc else acc in
count_sorted_occ acc xs x 1
in

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let occ_cols = List.rev @@ count_sorted_occ [] sorted_cols 0 0 in
let () = Printf.printf "After add_empty_columns m:\n%s\n" (show (List.map (fun row -> V.insert_zero_at_indices row occ_cols (List.length cols)) m)) in
List.map (fun row -> V.insert_zero_at_indices row occ_cols (List.length cols)) m
Expand All @@ -73,9 +73,9 @@

let get_col m n =
Timing.wrap "get_col" (get_col m) n

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let set_col m new_col n =
let () = Printf.printf "Before set_col m:\n%s\n" (show m) in

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
(* List.mapi (fun row_idx row -> V.set_nth row n (V.nth new_col row_idx)) m *)
let () = Printf.printf "After set_col m:\n%s\n" (show (List.map2 (fun row value -> V.set_nth row n value) m (V.to_list new_col))) in
List.map2 (fun row value -> V.set_nth row n value) m (V.to_list new_col)
Expand All @@ -85,9 +85,6 @@

let equal m1 m2 = Timing.wrap "equal" (equal m1) m2

let sub_rows (minu : V.t) (subt : V.t) : V.t =
V.map2_f_preserves_zero (-:) minu subt

let div_row (row : V.t) (pivot : A.t) : V.t =
V.map_f_preserves_zero (fun a -> a /: pivot) row

Expand All @@ -96,12 +93,12 @@

let sub_scaled_row row1 row2 s =
V.map2_f_preserves_zero (fun x y -> x -: s *: y) row1 row2

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let reduce_col m j =
let () = Printf.printf "Before reduce_col %i of m:\n%s\n" j (show m) in
if is_empty m then m
else
let rec find_pivot idx entries = (* Finds non-zero element in column j and returns pair of row idx and the pivot value *)

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
match entries with
| [] -> None
| row :: rest -> let value = V.nth row j in
Expand All @@ -111,9 +108,9 @@
| None -> let () = Printf.printf "After reduce_col %i of m:\n%s\n" j (show m) in m (* column is already filled with zeroes *)
| Some (row_idx, pivot) ->
let () = Printf.printf "After reduce_col %i of m:\n%s\n" j (show (let pivot_row = List.nth m row_idx in
List.mapi (fun idx row ->

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
if idx = row_idx then
V.zero_vec (num_cols m)

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
else
let row_value = V.nth row j in
if row_value =: A.zero then row
Expand All @@ -124,7 +121,7 @@
List.mapi (fun idx row ->
if idx = row_idx then
V.zero_vec (num_cols m)
else

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let row_value = V.nth row j in
if row_value = A.zero then row
else (let s = row_value /: pivot in
Expand All @@ -149,14 +146,14 @@

let del_cols m cols =
let cols = Array.to_list cols in (* TODO: Is it possible to use list for Apron dimchange? *)
let sorted_cols = List.sort_uniq Stdlib.compare cols in (* Apron Docs: Repetitions are meaningless (and are not correct specification) *)

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let () = Printf.printf "Before del_cols cols_length=%i \nm:\n%s\n" (List.length cols) (show m) in
if (List.length sorted_cols) = num_cols m then empty()
else
List.map (fun row -> V.remove_at_indices row sorted_cols) m

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging

let del_cols m cols = Timing.wrap "del_cols" (del_cols m) cols

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let map2i f m v =
let () = Printf.printf "Before map2i m:\n%sv:%s\n" (show m) (V.show v) in
let rec map2i_min i acc m v =
Expand All @@ -170,22 +167,10 @@

let remove_zero_rows m =
List.filter (fun row -> not (V.is_zero_vec row)) m

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let init_with_vec v =
[v]

let get_pivot_positions m =
List.mapi (fun i row -> V.findi (fun z -> z =: A.one) row) m

let sub_rows (minu : V.t) (subt : V.t) : V.t =
V.map2_f_preserves_zero (-:) minu subt

let div_row (row : V.t) (pivot : A.t) : V.t =
V.map_f_preserves_zero (fun a -> a /: pivot) row

let swap_rows m j k =
List.mapi (fun i row -> if i = j then List.nth m k else if i = k then List.nth m j else row) m

let normalize m =

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.list-length-compare-n Warning

computing list length is inefficient for length comparison, use compare_length_with instead
let () = Printf.printf "Before normalizing we have m:\n%s" (show m) in
let col_count = num_cols m in
Expand Down Expand Up @@ -226,7 +211,7 @@
let m = if piv_row_idx <> row_idx then swap_rows m row_idx piv_row_idx else m in
let normalized_m = List.mapi (fun idx row -> if idx = row_idx then div_row row piv_val else row) m in
let piv_row = (List.nth normalized_m row_idx) in
let subtracted_m = List.mapi (fun idx row -> if idx <> row_idx then

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let scale = V.nth row piv_col_idx in
sub_scaled_row row piv_row scale else row) normalized_m in
let m' = dec_mat_2D subtracted_m (row_idx + 1) (piv_col_idx + 1) in
Expand Down Expand Up @@ -268,35 +253,34 @@
let v_after_elim = List.fold_left (
fun acc (row_idx, pivot_position) ->
let v_at_piv = V.nth acc pivot_position in
if v_at_piv =: A.zero then

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
acc
else
let piv_row = List.nth m row_idx in

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
sub_scaled_row acc piv_row v_at_piv
) v pivot_positions
in
match V.find_first_non_zero v_after_elim with (* now we check for contradictions and finally insert v *)

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
| None -> let () = Printf.printf "After rref_vec we have m:\n%s\n" (show m) in
Some m (* v is zero vector and was therefore already covered by zero *)
| Some (idx, value) ->
if idx = (num_cols m - 1) then

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let () = Printf.printf "After rref_vec there is no normalization\n " in None
else
let normalized_v = V.map_f_preserves_zero (fun x -> x /: value) v_after_elim in
let res = insert_v_according_to_piv m normalized_v idx pivot_positions in
let () = Printf.printf "After rref_vec we have m:\n%s\n" (show res) in

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
Some res

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging

(*This function yields the same result as appending vector v to m and normalizing it afterwards would. However, it is usually faster than performing those ops manually.*)
(*m must be in rref form and contain the same num of cols as v*)
(*If m is empty then v is simply normalized and returned*)
(* TODO: OPTIMIZE! *)
(*let rref_vec m v =

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let () = Printf.printf "Before rref_vec we have m:\n%sv: %s\n" (show m) (V.show v) in
match normalize @@ append_matrices m (init_with_vec v) with

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
| Some res -> let () = Printf.printf "After rref_vec, before removing zero rows, we have m:\n%s\n" (show res) in
Some (remove_zero_rows res)

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
| None -> let () = Printf.printf "After rref_vec there is no normalization\n " in None*)

(*Similar to rref_vec_with but takes two matrices instead.*)
Expand All @@ -309,15 +293,11 @@
| Some m -> let () = Printf.printf "After rref_matrix m, before removing zero rows:\n %s\n" (show m) in Some (remove_zero_rows m)
| None -> let () = Printf.printf "No normalization for rref_matrix found" in None
*)

let rref_matrix (m1 : t) (m2 : t) =
let big_m, small_m = if num_rows m1 > num_rows m2 then m1, m2 else m2, m1 in
fst @@ List.fold_while (fun acc _ -> Option.is_some acc)
(fun acc_big_m small -> rref_vec (Option.get acc_big_m) small ) (Some big_m) small_m

let delete_row_with_pivots row pivots m2 =
failwith "TODO"

let is_covered_by m1 m2 =
let rec is_linearly_independent_rref v m =
let pivot_opt = V.findi_val_opt ((<>:) A.zero) v in
Expand Down Expand Up @@ -369,44 +349,26 @@
(*If m is empty then v is simply normalized and returned*)
failwith "deprecated"

let rref_vec_with m v = Timing.wrap "rref_vec_with" (rref_vec_with m) v
let rref_with m =
failwith "deprecated"

let reduce_col_with m j =
failwith "deprecated"

let reduce_col_with m j = Timing.wrap "reduce_col_with" (reduce_col_with m) j


let rref_with m = Timing.wrap "rref_with" rref_with m

let normalize_with m =
failwith "deprecated"

let normalize_with m = Timing.wrap "normalize_with" normalize_with m


let set_col_with m new_col n =
failwith "deprecated"

let set_col_with m new_col n = Timing.wrap "set_col" (set_col_with m new_col) n

let map2_with f m v =
failwith "deprecated"

let map2_with f m v = Timing.wrap "map2_with" (map2_with f m) v

let map2i_with f m v =
failwith "deprecated"

let map2i_with f m v = Timing.wrap "map2i_with" (map2i_with f m) v

let rref_matrix_with m1 m2 =
(*Similar to rref_vec_with but takes two matrices instead.*)
(*ToDo Could become inefficient for large matrices since pivot_elements are always recalculated + many row additions*)
failwith "deprecated"

let rref_matrix_with m1 m2 = Timing.wrap "rref_matrix_with" (rref_matrix_with m1) m2

end
Loading