diff --git a/basis/math/matrices/matrices-docs.factor b/basis/math/matrices/matrices-docs.factor new file mode 100644 index 0000000000..11a5e45857 --- /dev/null +++ b/basis/math/matrices/matrices-docs.factor @@ -0,0 +1,24 @@ +USING: help.markup help.syntax math sequences ; + +IN: math.matrices + +HELP: zero-matrix +{ $values { "m" integer } { "n" integer } { "matrix" sequence } } +{ $description "Creates a matrix of size " { $snippet "m x n" } ", filled with zeroes." } ; + +HELP: diagonal-matrix +{ $values { "diagonal-seq" sequence } { "matrix" sequence } } +{ $description "Creates a matrix with the specified diagonal values." } ; + +HELP: identity-matrix +{ $values { "n" integer } { "matrix" sequence } } +{ $description "Creates an identity matrix of size " { $snippet "n x n" } ", where the diagonal values are all ones." } ; + +HELP: kron +{ $values { "m1" sequence } { "m2" sequence } { "m" sequence } } +{ $description "Calculates the Kronecker product of two matrices." } +{ $examples + { $example "USING: math.matrices prettyprint ;" + "{ { 1 2 } { 3 4 } } { { 0 5 } { 6 7 } } kron ." + "{ { 0 5 0 10 } { 6 7 12 14 } { 0 15 0 20 } { 18 21 24 28 } }" } +} ; diff --git a/basis/math/matrices/matrices.factor b/basis/math/matrices/matrices.factor index a408ecb975..857f4905c7 100644 --- a/basis/math/matrices/matrices.factor +++ b/basis/math/matrices/matrices.factor @@ -157,7 +157,6 @@ IN: math.matrices make-bits over first length identity-matrix [ [ dupd m. ] when [ dup m. ] dip ] reduce nip ; - : stitch ( m -- m' ) [ ] [ [ append ] 2map ] map-reduce ;