]> gitweb.factorcode.org Git - factor.git/blob - basis/math/matrices/matrices-docs.factor
Docs: fixed doc example errors triggered by help-lint and added with-disposal where...
[factor.git] / basis / math / matrices / matrices-docs.factor
1 USING: help.markup help.syntax math sequences ;
2 IN: math.matrices
3
4 HELP: zero-matrix
5 { $values { "m" integer } { "n" integer } { "matrix" sequence } }
6 { $description "Creates a matrix of size " { $snippet "m x n" } ", filled with zeroes." } ;
7
8 HELP: diagonal-matrix
9 { $values { "diagonal-seq" sequence } { "matrix" sequence } }
10 { $description "Creates a matrix with the specified diagonal values." } ;
11
12 HELP: identity-matrix
13 { $values { "n" integer } { "matrix" sequence } }
14 { $description "Creates an identity matrix of size " { $snippet "n x n" } ", where the diagonal values are all ones." } ;
15
16 HELP: m.v
17 { $values { "m" sequence } { "v" sequence } }
18 { $description "Computes the dot product between a matrix and a vector." }
19 { $examples
20   { $example
21     "USING: math.matrices prettyprint ;"
22     "{ { 1 -1 2 } { 0 -3 1 } } { 2 1 0 } m.v ."
23     "{ 1 -3 }"
24   }
25 } ;
26
27 HELP: m.
28 { $values { "m" sequence } }
29 { $description "Computes the dot product between two matrices, i.e multiplies them." }
30 { $examples
31   { $example
32     "USING: math.matrices prettyprint ;"
33     "{ { 1 -1 2 } { 0 -3 1 } } { { 3 7 } { 9 12 } } m. ."
34     "{ { -6 -5 } { -27 -36 } }"
35   }
36 } ;
37
38 HELP: m+
39 { $values { "m" sequence } }
40 { $description "Adds the matrices component-wise." }
41 { $examples
42   { $example
43     "USING: math.matrices prettyprint ;"
44     "{ { 1 2 } { 3 4 } } { { 5 6 } { 7 8 } } m+ ."
45     "{ { 6 8 } { 10 12 } }"
46   }
47 } ;
48
49 HELP: m-
50 { $values { "m" sequence } }
51 { $description "Subtracts the matrices component-wise." }
52 { $examples
53   { $example
54     "USING: math.matrices prettyprint ;"
55     "{ { 5 9 } { 15 17 } } { { 3 2 } { 4 9 } } m- ."
56     "{ { 2 7 } { 11 8 } }"
57   }
58 } ;
59
60 HELP: kron
61 { $values { "m1" sequence } { "m2" sequence } { "m" sequence } }
62 { $description "Calculates the Kronecker product of two matrices." }
63 { $examples
64     { $example "USING: math.matrices prettyprint ;"
65         "{ { 1 2 } { 3 4 } } { { 0 5 } { 6 7 } } kron ."
66         "{ { 0 5 0 10 } { 6 7 12 14 } { 0 15 0 20 } { 18 21 24 28 } }" }
67 } ;
68
69 HELP: outer
70 { $values { "u" sequence } { "v" sequence } { "m" sequence } }
71 { $description "Computers the outer product of " { $snippet "u" } " and " { $snippet "v" } "." }
72 { $examples
73     { $example "USING: math.matrices prettyprint ;"
74         "{ 5 6 7 } { 1 2 3 } outer ."
75         "{ { 5 10 15 } { 6 12 18 } { 7 14 21 } }" }
76 } ;