remove redundant row-ops

This commit is contained in:
mehbark 2023-01-15 20:36:26 -05:00
parent b414870e70
commit 0e215c7475
3 changed files with 14 additions and 2 deletions

View file

@ -76,7 +76,8 @@
after-g-elim (apply-all-at-once m g-elim-steps)
bsub-steps (back-sub after-g-elim)
after-bsub (apply-all-at-once after-g-elim bsub-steps)]
[(concat g-elim-steps bsub-steps)
[(filter (comp not is-redundant)
(concat g-elim-steps bsub-steps))
after-bsub]))
(def auto-steps (comp first auto-steps-and-final))

View file

@ -113,3 +113,14 @@
(map #(map f %))
(map to-vec)
to-vec)))
(defn is-redundant
"Takes a row op and returns whether it IS redundant"
[op]
(if-let [[op-type inner] (opspec/conform op)]
(case op-type
:swap (= (:swap inner) ; swapping a row with itself
(:with inner))
:add (= 0 (:times inner)) ; adding 0 times a row to another row
:mul (= 1 (:by inner)) ; multiplying a row by 1
)))

View file

@ -25,4 +25,4 @@
; DONE: solving id-matrix
; DONE: solving gaussian-eliminated matrix
; DONE: automation
; TODO: remove redundant row ops
; DONE: remove redundant row ops