Using matrix operations to wrap arrays

94 Views Asked by At

I'm coding with Maple and I need an efficient way to wrap arrays of numbers to different dimensions. For example, let $A$ be the 3x5 matrix listing the numbers 1-15 in order, and $B$ be the 5x3 matrix of the same numbers. Is there an easy way to relate these two matrices in terms of matrix algebra?

1

There are 1 best solutions below

0
On

Leaving aside the question of relating the matrices using matrix algebra, if you simply want to reshape the matrix of values in Maple you have a couple of options:

In the ArrayTools package, you can use the Reshape command to copy the original data to a new matrix with the specified shape. The Alias command can also provide a different view (shape) of the data and does not create a copy of the underlying data, however if you do change the underlying data, this may have some adverse effects. Note that neither of these commands change the underlying order of the elements. Here's an example:

data := Array(seq([1..15]));
A := ArrayTools:-Reshape(data, [3,5]);
B := ArrayTools:-Reshape(data, [5,3]);