remove redundant row-ops
This commit is contained in:
parent
b414870e70
commit
0e215c7475
3 changed files with 14 additions and 2 deletions
|
@ -76,7 +76,8 @@
|
||||||
after-g-elim (apply-all-at-once m g-elim-steps)
|
after-g-elim (apply-all-at-once m g-elim-steps)
|
||||||
bsub-steps (back-sub after-g-elim)
|
bsub-steps (back-sub after-g-elim)
|
||||||
after-bsub (apply-all-at-once after-g-elim bsub-steps)]
|
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]))
|
after-bsub]))
|
||||||
|
|
||||||
(def auto-steps (comp first auto-steps-and-final))
|
(def auto-steps (comp first auto-steps-and-final))
|
||||||
|
|
|
@ -113,3 +113,14 @@
|
||||||
(map #(map f %))
|
(map #(map f %))
|
||||||
(map to-vec)
|
(map to-vec)
|
||||||
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
|
||||||
|
)))
|
||||||
|
|
|
@ -25,4 +25,4 @@
|
||||||
; DONE: solving id-matrix
|
; DONE: solving id-matrix
|
||||||
; DONE: solving gaussian-eliminated matrix
|
; DONE: solving gaussian-eliminated matrix
|
||||||
; DONE: automation
|
; DONE: automation
|
||||||
; TODO: remove redundant row ops
|
; DONE: remove redundant row ops
|
||||||
|
|
Loading…
Reference in a new issue