create a reshaped copy of a Matrix, Vector, or Array - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Low-level Manipulation : Matrices, Vectors, and Arrays : ArrayTools : ArrayTools/Reshape

ArrayTools[Reshape] - create a reshaped copy of a Matrix, Vector, or Array

Calling Sequence

Reshape(A, bounds)

Reshape(A, bound1, bound2, ...)

Parameters

A

-

Matrix, Vector, or Array

bounds

-

list of integers or ranges of integers

boundN

-

integer or range of integers

Description

• 

The Reshape command copies the elements of a Matrix, Vector, or Array into a new Matrix, Vector, or Array of a different shape, but does not change the underlying ordering of the elements.  Although the datatype of the rtable remains unchanged, its dimensions are changed to match those given in the bounds.

• 

Unlike ArrayTools[Alias], which provides a new view of the existing data within a given rtable without copying it, Reshape instead creates and returns a new rtable containing a complete physical copy of the data in the input. Unless a full copy of the input is required, it is usually much faster to use ArrayTools[Alias], which allows in-place actions to be performed on an rtable as if it were a different shape.

• 

The product of the dimension sizes must equal the number of elements in the original rtable.  Each bound in the input may be specified as either a range of integers or a single integer.  Single integers will be assumed to represent the upper bound of a range, with the lower bound being 1.  Ranges with lower bounds not equal to 1 are only permissible if the input is of subtype Array.

• 

Both Fortran and C order rtables are supported.  Reshape always returns an rtable of the same order as the input.  Note that the location of the elements in the reshaped rtable is entirely dependent on the order of the input rtable.  For example, reshaping a 2-dimensional Array into a 1-dimensional Array will produce very different results depending on the order of the input.

• 

If the input rtable has non-rectangular storage, it is converted to rectangular storage before it is reshaped.

• 

Reshape creates an rtable whose subtype matches the subtype of the input, where possible.  Matrices will be reshaped into Matrices and Vectors if possible, and Vectors will be reshaped into Vectors and Matrices, if possible.  Arrays will always be reshaped into Arrays.

• 

This function is part of the ArrayTools package, so it can be used in the short form Reshape(..) only after executing the command with(ArrayTools).  However, it can always be accessed through the long form of the command by using ArrayTools[Reshape](..).

Examples

withArrayTools:

ReshapeArraya,b,c,d,2,2

acbd

(1)

ReshapeArraya,b,c,d,0..3

Array0..3,0=a,1=c,2=b,3=d

(2)

ReshapeVector1,2,3,4,5,6,3,2

142536

(3)

ReshapeVector1,2,3,4,5,6,2,3

135246

(4)

P:=rtable1,2,3,4,5,6,order=Fortran_order

P:=123456

(5)

Q:=rtable1,2,3,4,5,6,order=C_order

Q:=123456

(6)

ReshapeP,1..6

142536

(7)

ReshapeQ,1..6

123456

(8)

See Also

ArrayTools, ArrayTools[Alias]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam