Skip to content

Commit 5ba152c

Browse files
authored
Merge pull request #1 from CopperCableIsolator/affeq-sparsification
Created SparseMatrix module
2 parents 913220d + cb0eec6 commit 5ba152c

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed

src/cdomains/vectorMatrix.ml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,156 @@ module ArrayMatrix: AbstractMatrix =
609609

610610
let map2i_with f m v = timing_wrap "map2i_with" (map2i_with f m) v
611611
end
612+
613+
614+
(** Sparse matrix implementation.
615+
It provides a normalization function to reduce a matrix into reduced row echelon form.
616+
Operations exploit that the input matrix/matrices are in reduced row echelon form already. *)
617+
module SparseMatrix: AbstractMatrix =
618+
functor (A: RatOps) (V: AbstractVector) ->
619+
struct
620+
include ConvenienceOps(A)
621+
module V = V(A)
622+
623+
(*Array of arrays implementation. One array per row containing tuple of column index and value*)
624+
type t = (int * A.t) array array [@@deriving eq, ord, hash]
625+
626+
let show x =
627+
failwith "TODO"
628+
629+
let empty () =
630+
Array.make_matrix 0 0 (0, A.zero)
631+
632+
let num_rows m =
633+
failwith "TODO"
634+
635+
let is_empty m =
636+
num_rows m = 0
637+
638+
let num_cols m =
639+
failwith "TODO"
640+
641+
let copy m =
642+
failwith "TODO"
643+
644+
let copy m =
645+
failwith "TODO"
646+
647+
let add_empty_columns m cols =
648+
failwith "TODO"
649+
650+
let add_empty_columns m cols =
651+
timing_wrap "add_empty_cols" (add_empty_columns m) cols
652+
653+
let append_row m row =
654+
failwith "TODO"
655+
656+
let get_row m n =
657+
failwith "TODO"
658+
659+
let remove_row m n =
660+
failwith "TODO"
661+
662+
let get_col m n =
663+
failwith "TODO"
664+
665+
let get_col m n =
666+
timing_wrap "get_col" (get_col m) n
667+
668+
let set_col_with m new_col n =
669+
failwith "TODO"
670+
671+
let set_col_with m new_col n = timing_wrap "set_col" (set_col_with m new_col) n
672+
673+
let set_col m new_col n =
674+
failwith "TODO"
675+
676+
let append_matrices m1 m2 =
677+
failwith "TODO"
678+
679+
let equal m1 m2 = timing_wrap "equal" (equal m1) m2
680+
681+
let reduce_col_with m j =
682+
failwith "TODO"
683+
684+
let reduce_col_with m j = timing_wrap "reduce_col_with" (reduce_col_with m) j
685+
let reduce_col m j =
686+
failwith "TODO"
687+
688+
let del_col m j =
689+
failwith "TODO"
690+
691+
let del_cols m cols =
692+
failwith "TODO"
693+
694+
let del_cols m cols = timing_wrap "del_cols" (del_cols m) cols
695+
696+
let map2i f m v =
697+
failwith "TODO"
698+
699+
let remove_zero_rows m =
700+
failwith "TODO"
701+
702+
let rref_with m =
703+
failwith "TODO"
704+
705+
let rref_with m = timing_wrap "rref_with" rref_with m
706+
707+
let init_with_vec v =
708+
failwith "TODO"
709+
710+
711+
let reduce_col_with_vec m j v =
712+
failwith "TODO"
713+
714+
let get_pivot_positions m =
715+
failwith "TODO"
716+
717+
let rref_vec m pivot_positions v =
718+
failwith "TODO"
719+
720+
721+
let rref_vec_with m v =
722+
(*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.*)
723+
(*m must be in rref form and contain the same num of cols as v*)
724+
(*If m is empty then v is simply normalized and returned*)
725+
failwith "TODO"
726+
727+
let rref_vec_with m v = timing_wrap "rref_vec_with" (rref_vec_with m) v
728+
729+
let rref_matrix_with m1 m2 =
730+
(*Similar to rref_vec_with but takes two matrices instead.*)
731+
(*ToDo Could become inefficient for large matrices since pivot_elements are always recalculated + many row additions*)
732+
failwith "TODO"
733+
734+
let rref_matrix_with m1 m2 = timing_wrap "rref_matrix_with" (rref_matrix_with m1) m2
735+
736+
let normalize_with m =
737+
failwith "TODO"
738+
739+
let normalize_with m = timing_wrap "normalize_with" normalize_with m
740+
741+
let normalize m =
742+
failwith "TODO"
743+
744+
let is_covered_by m1 m2 =
745+
failwith "TODO"
746+
747+
let is_covered_by m1 m2 = timing_wrap "is_covered_by" (is_covered_by m1) m2
748+
749+
let find_opt f m =
750+
failwith "TODO"
751+
752+
let map2 f m v =
753+
failwith "TODO"
754+
755+
let map2_with f m v =
756+
failwith "TODO"
757+
758+
let map2_with f m v = timing_wrap "map2_with" (map2_with f m) v
759+
760+
let map2i_with f m v =
761+
failwith "TODO"
762+
763+
let map2i_with f m v = timing_wrap "map2i_with" (map2i_with f m) v
764+
end

0 commit comments

Comments
 (0)