1 USING: help.markup help.syntax math sequences ;
5 { $values { "m" integer } { "n" integer } { "matrix" sequence } }
6 { $description "Creates a matrix of size " { $snippet "m x n" } ", filled with zeroes." } ;
9 { $values { "diagonal-seq" sequence } { "matrix" sequence } }
10 { $description "Creates a matrix with the specified diagonal values." } ;
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." } ;
17 { $values { "m" sequence } { "v" sequence } }
18 { $description "Computes the dot product between a matrix and a vector." }
21 "USING: math.matrices prettyprint ;"
22 "{ { 1 -1 2 } { 0 -3 1 } } { 2 1 0 } m.v ."
28 { $values { "m" sequence } }
29 { $description "Computes the dot product between two matrices, i.e multiplies them." }
32 "USING: math.matrices prettyprint ;"
33 "{ { 1 -1 2 } { 0 -3 1 } } { { 3 7 } { 9 12 } } m. ."
34 "{ { -6 -5 } { -27 -36 } }"
39 { $values { "m" sequence } }
40 { $description "Adds the matrices component-wise." }
43 "USING: math.matrices prettyprint ;"
44 "{ { 1 2 } { 3 4 } } { { 5 6 } { 7 8 } } m+ ."
45 "{ { 6 8 } { 10 12 } }"
50 { $values { "m" sequence } }
51 { $description "Subtracts the matrices component-wise." }
54 "USING: math.matrices prettyprint ;"
55 "{ { 5 9 } { 15 17 } } { { 3 2 } { 4 9 } } m- ."
56 "{ { 2 7 } { 11 8 } }"
61 { $values { "m1" sequence } { "m2" sequence } { "m" sequence } }
62 { $description "Calculates the Kronecker product of two matrices." }
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 } }" }
70 { $values { "u" sequence } { "v" sequence } { "m" sequence } }
71 { $description "Computers the outer product of " { $snippet "u" } " and " { $snippet "v" } "." }
73 { $example "USING: math.matrices prettyprint ;"
74 "{ 5 6 7 } { 1 2 3 } outer ."
75 "{ { 5 10 15 } { 6 12 18 } { 7 14 21 } }" }