ArrayTools - Maple Help

Overview of the ArrayTools Package

 Calling Sequence ArrayTools[command](arguments) command(arguments)

Description

 • The ArrayTools package is an efficient set of programmer tools used for low level manipulation of rectangular storage Matrices, Vectors, and Arrays.
 Note: This package contains tools for storage manipulation only. For mathematical operations on Matrices and Vectors, see the LinearAlgebra and VectorCalculus packages.
 • As a programmer package, the key focus is on efficient computation. Use of the package requires a fair understanding of internal representation of Matrix and Array data structures. For information on internal storage of Matrices and Arrays, see C_order and Fortran_order.
 • The package is primarily external (compiled code), and contains highly efficient functions for common Array related programming tasks. Some of these tasks would be impossible to program at the Maple level (for example, ComplexAsFloat), while others would be merely time consuming (for example, Fill) or require additional storage allocation (for example, DataTranspose).
 At this time, all functions are restricted to rectangular storage Array objects.
 Most functions in the package work for Matrices of any data type, and exceptions are noted on a by command basis.
 • Each command in the ArrayTools package can be accessed by using either the long form or the short form of the command name in the command calling sequence.
 The long form, ArrayTools:-command, is always available.  The short form can be used after loading the package.

List of ArrayTools Package Commands

 The following is a list of available commands.
 Constructing Arrays

 Querying Array Properties

 Modifying Arrays

 Computing with Arrays

 To display the help page for a particular ArrayTools command, see Getting Help with a Command in a Package.

Examples

Vector example

 > $\mathrm{with}\left(\mathrm{ArrayTools}\right)$
 $\left[{\mathrm{AddAlongDimension}}{,}{\mathrm{Alias}}{,}{\mathrm{AllNonZero}}{,}{\mathrm{AnyNonZeros}}{,}{\mathrm{Append}}{,}{\mathrm{BlockCopy}}{,}{\mathrm{CircularShift}}{,}{\mathrm{ComplexAsFloat}}{,}{\mathrm{Compress}}{,}{\mathrm{Concatenate}}{,}{\mathrm{Copy}}{,}{\mathrm{DataTranspose}}{,}{\mathrm{Diagonal}}{,}{\mathrm{Dimensions}}{,}{\mathrm{ElementDivide}}{,}{\mathrm{ElementMultiply}}{,}{\mathrm{ElementPower}}{,}{\mathrm{Extend}}{,}{\mathrm{Fill}}{,}{\mathrm{FlipDimension}}{,}{\mathrm{GeneralInnerProduct}}{,}{\mathrm{GeneralOuterProduct}}{,}{\mathrm{HasNonZero}}{,}{\mathrm{HasZero}}{,}{\mathrm{Insert}}{,}{\mathrm{IsEqual}}{,}{\mathrm{IsMonotonic}}{,}{\mathrm{IsZero}}{,}{\mathrm{LowerTriangle}}{,}{\mathrm{MultiplyAlongDimension}}{,}{\mathrm{NumElems}}{,}{\mathrm{Partition}}{,}{\mathrm{Permute}}{,}{\mathrm{PermuteInverse}}{,}{\mathrm{RandomArray}}{,}{\mathrm{ReduceAlongDimension}}{,}{\mathrm{RegularArray}}{,}{\mathrm{Remove}}{,}{\mathrm{RemoveSingletonDimensions}}{,}{\mathrm{Replicate}}{,}{\mathrm{Reshape}}{,}{\mathrm{Reverse}}{,}{\mathrm{ScanAlongDimension}}{,}{\mathrm{SearchArray}}{,}{\mathrm{Size}}{,}{\mathrm{SuggestedDatatype}}{,}{\mathrm{SuggestedOrder}}{,}{\mathrm{SuggestedSubtype}}{,}{\mathrm{Uncompress}}{,}{\mathrm{UpperTriangle}}\right]$ (1)
 > $M≔\mathrm{Vector}\left[\mathrm{row}\right]\left(10,i↦i\right)$
 ${M}{≔}\left[\begin{array}{cccccccccc}{1}& {2}& {3}& {4}& {5}& {6}& {7}& {8}& {9}& {10}\end{array}\right]$ (2)

Duplicate first 5 entries in last 5

 > $\mathrm{Copy}\left(5,M,M,5\right),M$
 $\left[\begin{array}{cccccccccc}{1}& {2}& {3}& {4}& {5}& {1}& {2}& {3}& {4}& {5}\end{array}\right]$ (3)

Clear every second entry

 > $\mathrm{Fill}\left(0,M,1,2\right),M$
 $\left[\begin{array}{cccccccccc}{1}& {0}& {3}& {0}& {5}& {0}& {2}& {0}& {4}& {0}\end{array}\right]$ (4)

Alias as a 2 x 5 Matrix

 > $\mathrm{Alias}\left(M,\left[2,5\right],\mathrm{C_order}\right)$
 $\left[\begin{array}{ccccc}{1}& {0}& {3}& {0}& {5}\\ {0}& {2}& {0}& {4}& {0}\end{array}\right]$ (5)

Complex-valued example

 > $M≔\mathrm{Matrix}\left(2,3,\left(i,j\right)↦i+I\cdot j,\mathrm{datatype}=\mathrm{complex}\left[8\right],\mathrm{order}=\mathrm{C_order}\right)$
 ${M}{≔}\left[\begin{array}{ccc}{1.}{+}{I}& {1.}{+}{2.}{}{I}& {1.}{+}{3.}{}{I}\\ {2.}{+}{I}& {2.}{+}{2.}{}{I}& {2.}{+}{3.}{}{I}\end{array}\right]$ (6)

View Matrix as a double-size real Matrix, type float[8]

 > $\mathrm{Mr}≔\mathrm{ComplexAsFloat}\left(M\right)$
 ${\mathrm{Mr}}{≔}\left[\begin{array}{cccccc}{1.}& {1.}& {1.}& {2.}& {1.}& {3.}\\ {2.}& {1.}& {2.}& {2.}& {2.}& {3.}\end{array}\right]$ (7)

Clear the real part only using the view Mr

 > $\mathrm{Fill}\left(0,\mathrm{Mr},0,2\right),M$
 $\left[\begin{array}{ccc}{0.}{+}{I}& {0.}{+}{2.}{}{I}& {0.}{+}{3.}{}{I}\\ {0.}{+}{I}& {0.}{+}{2.}{}{I}& {0.}{+}{3.}{}{I}\end{array}\right]$ (8)