Created
October 5, 2012 01:34
-
-
Save zerokarmaleft/3837554 to your computer and use it in GitHub Desktop.
reducing into a 2d matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; matrix M | |
;; 0 1 2 3 | |
;; ========== | |
;; 0: 1 0 0 1 | |
;; 1: 0 0 1 0 | |
;; 2: 0 1 0 1 | |
;; 3: 1 0 1 1 | |
;; 4: 0 0 1 0 | |
;; index correspond to checking rows of M | |
(def sigs [[1 1] [2 4] [3 2] [4 0] [0 3]]) | |
;; check row for bits flipped to 1 | |
;; corresponding columns in sig-M have the minimum of the new sig values and existing sig values | |
;; row 0, columns 0 and 3 are flipped | |
;; since there are no entries, the sig vector [1 1] is assoc'd into the corresponding columns | |
;; sig-M [[1 1] nil nil [1 1]] | |
;; row 1, column 2 is flipped | |
;; since there are no entries, the sig vector [2 4] is assoc'd, the other don't change | |
;; sig-M [[1 1] nil [2 4] [1 1]] | |
;; row 2, column 1 and 3 are flipped | |
;; column 3 doesn't change | |
;; sig-M [[1 1] [3 2] [2 4] [1 1]] | |
;; row 3, column 0, 1, and 3 are flipped | |
;; assoc the minimum of the existing value and the new sig vector values | |
;; sig-M [[1 0] [3 2] [2 0] [1 0]] | |
... | |
;; expected result | |
(def sig-M [[1 0] [3 2] [0 0] [1 0]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment