5 CAT: Horizontally concatenate. Vectors are treated as column matrices.
8 cat((1,2,3), (4,5,6)) = cat | [2] [5] | = [2 5]
11 VCAT: Vertical (or vector-wise) concatenation.
15 vcat((1,2), (3,4)) = vcat \ [2], [4] / = [3] = (1,2,3,4)
20 The following examples utilize the "store" function to build all
21 variables from the result of different concatenations.
23 ------------------------------------------------------------------------
25 store("A", cat(3,5,7))
27 (store "A" (cat 3 5 7))
31 Join the numbers to make a row matrix.
33 ------------------------------------------------------------------------
35 store("u", vcat(1,2,3))
37 (store "u" (vcat 1 2 3))
41 This time, the result is a vector. Stored as /u/
43 ------------------------------------------------------------------------
52 The column vector /u/ joins with /A/ by allocating the needed rows of
55 ------------------------------------------------------------------------
64 /u/ joined with A from the other side.
66 ------------------------------------------------------------------------
73 Vertical concatenation using the transpose of the column vector /u/.
74 vcat will always transpose vectors to be horizontal when called with a
76 I figure this is the "best" behavior.
78 ------------------------------------------------------------------------
80 vcat(vcat(3,4,5), vcat(6,7,8,9))
82 (vcat (vcat 3 4 5) (vcat 6 7 8 9))
84 ==> (3, 4, 5, 6, 7, 8, 9)
86 Create 2 vectors: (3, 4, 5) and (6, 7, 8, 9)
87 and through vcat, join them.
89 ------------------------------------------------------------------------
91 cat(vcat(3,4,5), vcat(6,7,8,9))
93 (cat (vcat 3 4 5) (vcat 6 7 8 9))
100 Using cat instead gives the two vectors stacked as columns in a matrix.
101 Note the extra zero given to the left column.
103 ------------------------------------------------------------------------
105 store("B", vcat(cat(1,2), cat(3,4)))
107 (store "B" (vcat (cat 1 2) (cat 3 4)))
112 If you want to make a matrix by rows via cat, use this format. Of
113 course, here we also store the result as matrix /B/.
116 Of course, it only follows that matrices can be joined in the same way.
118 ------------------------------------------------------------------------
129 ------------------------------------------------------------------------
141 ------------------------------------------------------------------------
143 Lineal interprets some interesting
144 number/matrix concatenation as well...
146 ------------------------------------------------------------------------
154 Add a column of 9's onto the left of /B/.
156 ------------------------------------------------------------------------
165 Add a row of 9's onto the bottom of /B/.
167 ------------------------------------------------------------------------
169 store("S", cat(4, vcat(4,5)))
171 (store "S" (cat 4 (vcat 4 5)))
176 Make a symmetric matrix /S/.
178 ------------------------------------------------------------------------
180 store("S", cat(3, vcat(3,S)))
182 (store "S" (cat 3 (vcat 3 S)))
188 Build on a row of 3's atop /S/ then a column of 3's onto its left side.
190 ------------------------------------------------------------------------
192 store("S", cat(1, vcat(1, (cat 2, vcat(2, S)))))
194 (store "S" (cat 1 (vcat 1 (cat 2 (vcat 2 S)))))
202 Finish off the symmetric pattern. Re-store it as /S/.
204 ------------------------------------------------------------------------
206 This concept holds with vectors too! But results may be surprising.
207 Which is why vcat = vertical and cat = horizontal.
209 ------------------------------------------------------------------------
218 /u/ is treated like a matrix.
219 If you wanted (7, 1, 2, 3), use (vcat 7 u).
221 ------------------------------------------------------------------------
223 And in some situations, results may be very surprising...
225 ------------------------------------------------------------------------
234 OK, so that's not too surprising since Lineal has a lot of functions
235 which take an arbitrary number of terms.
237 ------------------------------------------------------------------------
246 Again, nothing too out of the ordinary.
248 ------------------------------------------------------------------------
257 A little strange. This happens because the cat and vcat functions build
258 from right to left. Here, it is equivalent to calling
259 (cat 7 (cat u (cat 8 9)))
262 returns a row matrix [8 9] and so on.
264 ------------------------------------------------------------------------
265 vim:ft=:expandtab:tw=72: