add gaussian-column
This commit is contained in:
parent
a09cfe7b19
commit
514cb4139b
4 changed files with 12 additions and 6 deletions
|
@ -27,7 +27,8 @@
|
||||||
;; "Takes a matrix and a list of operations and returns a seq of matrices"
|
;; "Takes a matrix and a list of operations and returns a seq of matrices"
|
||||||
;; )
|
;; )
|
||||||
|
|
||||||
;; (defn gaussian-top-op
|
(defn gaussian-column
|
||||||
;; [m]
|
[m col]
|
||||||
;; "Takes a matrix and returns the op required to gaussian-eliminate the top"
|
(cons {:mul-row col :by (/ 1 (at m col col))}
|
||||||
;; {:n})
|
(for [y (range (inc col) (matrix-height m))]
|
||||||
|
{:add-row col :times (- (at m col y)) :to-row y})))
|
||||||
|
|
|
@ -89,3 +89,8 @@
|
||||||
m
|
m
|
||||||
(:by inner)
|
(:by inner)
|
||||||
(:mul-row inner))))))
|
(:mul-row inner))))))
|
||||||
|
|
||||||
|
(defn at
|
||||||
|
"Returns the number at x y in a matrix"
|
||||||
|
[m x y]
|
||||||
|
(get (get m y) x))
|
||||||
|
|
|
@ -167,7 +167,7 @@
|
||||||
(str n
|
(str n
|
||||||
"R" (shrink-number (:add-row op))
|
"R" (shrink-number (:add-row op))
|
||||||
" + "
|
" + "
|
||||||
"R" (shrink-number (:to op)))))
|
"R" (shrink-number (:to-row op)))))
|
||||||
|
|
||||||
(defn pretty-row-op
|
(defn pretty-row-op
|
||||||
"Returns a pretty string of a row operation"
|
"Returns a pretty string of a row operation"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
(spec/map-of #{:swap :with} number?))
|
(spec/map-of #{:swap :with} number?))
|
||||||
|
|
||||||
(spec/def ::add
|
(spec/def ::add
|
||||||
(spec/map-of #{:add-row :times :to} number?))
|
(spec/map-of #{:add-row :times :to-row} number?))
|
||||||
|
|
||||||
(spec/def ::mul
|
(spec/def ::mul
|
||||||
(spec/map-of #{:mul-row :by} number?))
|
(spec/map-of #{:mul-row :by} number?))
|
||||||
|
|
Loading…
Reference in a new issue