From 8b4af6bc8698dc7bd9ad4ad8db801160642b91fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Wed, 9 Apr 2014 17:36:51 +0200 Subject: [PATCH] Docs: doc and examples for math.matrices --- basis/math/matrices/matrices-docs.factor | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/basis/math/matrices/matrices-docs.factor b/basis/math/matrices/matrices-docs.factor index 9a83d438db..99a7c62356 100644 --- a/basis/math/matrices/matrices-docs.factor +++ b/basis/math/matrices/matrices-docs.factor @@ -14,6 +14,39 @@ 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: m.v +{ $values { "m" sequence } { "v" sequence } { "v" sequence } } +{ $description "Computes the dot product between a matrix and a vector." } +{ $examples + { $example + "USING: math.matrices prettyprint ;" + "{ { 1 -1 2 } { 0 -3 1 } } { 2 1 0 } m.v ." + "{ 1 -3 }" + } +} ; + +HELP: m. +{ $values { "m" sequence } { "m" sequence } { "m" sequence } } +{ $description "Computes the dot product between two matrices, i.e multiplies them." } +{ $examples + { $example + "USING: math.matrices prettyprint ;" + "{ { 1 -1 2 } { 0 -3 1 } } { { 3 7 } { 9 12 } } m. ." + "{ { -6 -5 } { -27 -36 } }" + } +} ; + +HELP: m+ +{ $values { "m" sequence } { "m" sequence } { "m" sequence } } +{ $description "Adds the matrices component-wise." } +{ $examples + { $example + "USING: math.matrices prettyprint ;" + "{ { 1 2 } { 3 4 } } { { 5 6 } { 7 8 } } m+ ." + "{ { 6 8 } { 10 12 } }" + } +} ; + HELP: kron { $values { "m1" sequence } { "m2" sequence } { "m" sequence } } { $description "Calculates the Kronecker product of two matrices." }