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 165 commits into
base: master
Choose a base branch
from

Conversation

GollokG
Copy link

@GollokG GollokG commented Nov 5, 2024

This pull request contributes a sparse implementation of the Affine Equality Matrix.

This implementation is part of the assignment given by Tum practical WiSe 24/25 - Automated Bug Hunting and Beyond (IN0012, IN2106, IN4301).

@DrMichaelPetter DrMichaelPetter self-requested a review December 16, 2024 11:49

let add_empty_columns m cols =
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
@@ -337,7 +70,8 @@
V.of_array m.(n)

let remove_row m n =
let new_matrix = make_matrix (num_rows m - 1) (num_cols m) A.zero in
let () = Printf.printf "Before remove_row %i of m:\n%s\n" n (show m) in
let new_matrix = Array.make_matrix (num_rows m - 1) (num_cols m) A.zero in

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging

let set_col_with m new_col n =
for i = 0 to num_rows m - 1 do
m.(i).(n) <- V.nth new_col i
done; m
done;

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let () = Printf.printf "Before normalizing we have m:\n%s" (show m) in
if normalize_with copy then
let () = Printf.printf "After normalizing we have m:\n%s" (show copy) in
Some copy

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
Some copy
else
let () = Printf.printf "No normalization" in
None

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let m1' = copy m1 in
let m2' = copy m2 in
match rref_matrix_with m1' m2' with
| Some m -> let () = Printf.printf "After rref_matrix m:\n %s\n" (show m) in Some m

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
let f' x y = V.to_array @@ f (V.of_array x) y in Array.map2 f' m (V.to_array v)
*)

let map2 f m v =

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging
end
let map2i_with f m v = Timing.wrap "map2i_with" (map2i_with f m) v

(* Deprecated

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 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 map2 we have m:\n%s\n" (show m) in
let m' = copy m in
map2_with f m' v;
let () = Printf.printf "After map2 we have m:\n%s\n" (show m') in

Check warning

Code scanning / Semgrep OSS

printing should be replaced with 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 m' = copy m in

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: semgrep.print-not-logging Warning

printing should be replaced with logging

let is_covered_by m1 m2 =
(*Performs a partial rref reduction to check if concatenating both matrices and afterwards normalizing them would yield a matrix <> m2 *)
(*Both input matrices must be in rref form!*)
let () = Printf.printf "is_covered_by m1: \n%s " (show m1) in

Check warning

Code scanning / Semgrep OSS

printing should be replaced with logging Warning

printing should be replaced with logging

let is_covered_by m1 m2 =
(*Performs a partial rref reduction to check if concatenating both matrices and afterwards normalizing them would yield a matrix <> m2 *)
(*Both input matrices must be in rref form!*)
let () = Printf.printf "is_covered_by m1: \n%s " (show m1) in
let () = Printf.printf "is_covered_by m2 \n%s " (show m2) in

Check warning

Code scanning / Semgrep OSS

printing should be replaced with logging Warning

printing should be replaced with logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature in progress performance Analysis time, memory usage practical-course Practical Course at TUM student-job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Affine Equalities Mostly Contain Only Small Portions of Actual Information
6 participants