Array Concatenation and Construction


General array concatenation can be done through the array concatenation operator
cat(k, A, B, C, ...) that concatenates the arrays A, B, C, .... along the k:th dimension. Concatenating along the first dimension is to concate rows and the second dimension is to concatenate colums.


1 Class Concat


1.1 Simulation of Concat




2 More Concatenation

A matrix can be constructed from scalar expressions by separating rows by semicolon and columns by comma. The previous example of concatenation along the second dimension can be expressed like this:



2.1 Simulation of Concat2





3 Type Rules for Concatenation

The arrays that is concatenated must have the same number of dimensions. The concatenation dimension k must exist. Arrays must have identical dimension sizes with the exception of the size of dimension k, which is called Size matching. Argument arrays must have equivalent maximally expanded element types. The element type of the result array is the element type of the maximally expanded type of the arguments. These rules make it possible to mix integers and real numbers as in the example below:



3.1 Simulation of Concat3




4 Concatenating Larger Arrays


4.1 Simulation of Concat4