add gaussian-column

This commit is contained in:
mehbark 2023-01-15 13:25:38 -05:00
parent a09cfe7b19
commit 514cb4139b
4 changed files with 12 additions and 6 deletions

View file

@ -27,7 +27,8 @@
;; "Takes a matrix and a list of operations and returns a seq of matrices"
;; )
;; (defn gaussian-top-op
;; [m]
;; "Takes a matrix and returns the op required to gaussian-eliminate the top"
;; {:n})
(defn gaussian-column
[m col]
(cons {:mul-row col :by (/ 1 (at m col col))}
(for [y (range (inc col) (matrix-height m))]
{:add-row col :times (- (at m col y)) :to-row y})))

View file

@ -89,3 +89,8 @@
m
(:by inner)
(:mul-row inner))))))
(defn at
"Returns the number at x y in a matrix"
[m x y]
(get (get m y) x))

View file

@ -167,7 +167,7 @@
(str n
"R" (shrink-number (:add-row op))
" + "
"R" (shrink-number (:to op)))))
"R" (shrink-number (:to-row op)))))
(defn pretty-row-op
"Returns a pretty string of a row operation"

View file

@ -12,7 +12,7 @@
(spec/map-of #{:swap :with} number?))
(spec/def ::add
(spec/map-of #{:add-row :times :to} number?))
(spec/map-of #{:add-row :times :to-row} number?))
(spec/def ::mul
(spec/map-of #{:mul-row :by} number?))