 LinearAlgebra - Maple Programming Help

Home : Support : Online Help : Mathematics : Linear Algebra : LinearAlgebra Package : Support : LinearAlgebra/GetResultShape

LinearAlgebra

 GetResultShape
 return the resulting shape of a Matrix or Vector operation

 Calling Sequence GetResultShape(s1, s2, opn)

Parameters

 s1, s2 - name; Matrix or Vector shape opn - name that is one of 'add', 'multiply', 'inverse', or 'transpose'; specifies the operation

Description

 • The GetResultShape(s1, s2, opn) function returns a list containing a shape name which can be used as the right-hand side of a shape equation when constructing a new Matrix or Vector from one or two other such objects. The empty list signifies no shape (i.e., rectangular shape).
 • This routine should be used by routines that operate on one or two input Matrices or Vectors, producing a new Matrix or Vector, and that need to set a shape on the resulting object.
 The shape parameters, s1 and s2, should be names returned by MatrixOptions or VectorOptions. This routine recognizes the following built-in shapes:

 symmetric skewsymmetric hermitian skewhermitian diagonal triangular[upper] triangular[lower] triangular[upper,unit] triangular[lower,unit] Hessenberg[upper] Hessenberg[lower] band[l,u]

 Note:  The shape antisymmetric must be specified as skewsymmetric, and triangular[unit, lower] must be specified as triangular[lower, unit], even though these alternate shape names are accepted by the Matrix constructor.
 • If a shape name is not recognized (e.g., any user-defined indexing function), GetResultShape returns the empty list.
 Note:  No special handling is done for the following Matrix and Vector shapes:

 unit scalar constant identity

 • GetResultShape returns a shape that contains the result of the specified operation on input with the specified shape(s). The shape returned is valid for all input objects with the specified shape(s).
 • Since the dimension of the Matrices or Vectors is not provided, GetResultShape may return the empty list even in cases where a specific shape could be determined. For example, multiplying two banded Matrices together produces a banded Matrix, but it is not possible to determine whether the number of bands would be valid without knowledge of the dimensions of the input Matrices.
 • This function is part of the LinearAlgebra package, and so it can be used in the form GetResultShape(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[GetResultShape](..).

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $A≔\mathrm{RandomMatrix}\left(4,\mathrm{shape}=\mathrm{triangular}\left[\mathrm{upper}\right]\right):$
 > $B≔\mathrm{RandomMatrix}\left(4,\mathrm{shape}=\mathrm{triangular}\left[\mathrm{upper}\right]\right):$
 > $\mathrm{ShapeA},\mathrm{ShapeB}≔\mathrm{op}\left(\mathrm{MatrixOptions}\left(A,\mathrm{shape}\right)\right),\mathrm{op}\left(\mathrm{MatrixOptions}\left(B,\mathrm{shape}\right)\right)$
 ${\mathrm{ShapeA}}{,}{\mathrm{ShapeB}}{≔}{{\mathrm{triangular}}}_{{\mathrm{upper}}}{,}{{\mathrm{triangular}}}_{{\mathrm{upper}}}$ (1)
 > $\mathrm{ShapeOut}≔\mathrm{GetResultShape}\left(\mathrm{ShapeA},\mathrm{ShapeB},'\mathrm{add}'\right)$
 ${\mathrm{ShapeOut}}{≔}\left[{{\mathrm{triangular}}}_{{\mathrm{upper}}}\right]$ (2)
 > $\mathrm{GetResultShape}\left('\mathrm{band}\left[1,3\right]','\mathrm{transpose}'\right)$
 $\left[{{\mathrm{band}}}_{{3}{,}{1}}\right]$ (3)
 > $\mathrm{GetResultShape}\left(\mathrm{triangular}\left[\mathrm{upper},\mathrm{unit}\right],\mathrm{diagonal},'\mathrm{multiply}'\right)$
 $\left[{{\mathrm{triangular}}}_{{\mathrm{upper}}}\right]$ (4)