 Vector Construction - Maple Help

Vector

construct a Vector Calling Sequence Vector(n, init, ro, sym, sh, st, dt, f, a, o) Vector[column](n, init, ro, sym, sh, st, dt, f, a, o) Vector[row](n, init, ro, sym, sh, st, dt, f, a, o) Parameters

 n - (optional) non-negative integer or integer range starting at 1; number of elements in the Vector init - (optional) Maple procedure, table, Array, Vector, set of equations, list, or expression of type algebraic; initial values for the Vector ro - (optional) equation of the form readonly=true or false; specify whether Vector entries can be changed sym - (optional) equation of the form symbol=name; specifies the symbolic name to be used for the Vector entries sh - (optional) equation of the form shape=name or shape=list specifying one or more built-in or user-defined indexing functions; storage allocation for Vector entries st - (optional) equation of the form storage=name, where name is a permitted storage mode; storage requirements for Vector entries dt - (optional) equation of the form datatype=name, where name is any Maple type, float, float, double, complex, or integer[n] for n=1,2,4, or 8; type of data stored in Vector f - (optional) equation of the form fill=value, where value is of the type specified by the dt parameter; specifies Vector entries at locations not otherwise set a - (optional) equation of the form attributes=list, where list contains permitted attributes; specifies additional mathematical properties of the Vector o - (optional) equation of the form orientation=name, where name is either row or column; specifies Vector orientation Description

 • The Vector(..) function (vector) is the constructor for the Vector data structure. It is one of the principal data structures on which the LinearAlgebra routines operate. The specialized Maple packages for computing with vectors are VectorCalculus and Physics/Vectors.
 • In Vector(..), all parameters are optional. However, enough information must be provided in the calling sequence for the mathematical shape of the Vector and the storage requirements for its entries to be determined. In particular, if no parameters are specified, the result is a size 0 Vector (that is, an element of a zero-dimensional vector space).
 • The Vector(n) function constructs an n-element column Vector whose entries are determined by the fill value in parameter f (default = 0). If the number of elements is not provided, it defaults to 0. If the orientation option is omitted or if Vector[column](n) is used, a column Vector is returned.
 • The Vector(init) function constructs a Vector whose shape and entries are determined by parameter init.
 The Vector(n, init) function constructs an n-element column Vector whose initial entries are determined by parameter init (and parameter f if all of the entries in the Vector are not set by init). Details

 Parameter init can take any one of the following forms. (The number of elements, n, must be provided in the calling sequence if init is an expression, table, or set.)
 procedure
 The procedure must accept a positive integer as an argument (that is, Vector index) and return the value for the corresponding entry in the Vector.
 expression of type algebraic
 The expression is evaluated as a function (or procedure) which takes a positive integer as an argument (that is, Vector index) and returns the value of the corresponding entry of the Vector.
 table
 The table is referenced by index of the form [j] where j is a positive integer (that is, Vector index). (The table may include entries for indices of other forms.  These will be ignored.)
 set of equations
 The set of equations must take the form j =  where j is a positive integer (that is, Vector index). It is an error to specify entries for locations that are outside the index range of the resulting Vector.
 Array
 The Array must be a one-dimensional. The indexing in the Array is shifted to be 1-based.  It is an error to specify entries for locations that are outside the index range of the resulting Vector.
 Vector
 The Vector constructor accepts another Vector as an initializer for the entries.  It is an error to specify entries for locations that are outside the index range of the resulting Vector. Therefore, the size of the initializing Vector must be less than or equal to the size of the resulting Vector.
 list
 If L is a list, then it is first scanned to see if any of its entries are themselves lists.  Any such sublists are unwrapped, replacing the sublists with the expression sequence of their entries. This operation is not recursive (the unwrapping is carried out only one level). Once this unwrapping is completed, the elements of the (possibly modified) list are placed, in order, in the corresponding locations of the Vector under construction.  It is an error to specify entries for locations that are outside the index range of the resulting Vector.  It is an error for the list to be two dimensional (for example, contain both a row Vector and column Vector, or contain a Matrix, or 2-D Array).
 • If the ro option is included in the calling sequence as either readonly or readonly=true, then the resulting Vector is "readonly" (that is, its entries cannot be changed after construction).
 • The sym option, in the form symbol=name, provides a symbolic name to use for the Vector entries if no initializer is provided.  This parameter is ignored if an initializer is given.
 • Parameters may be included more than once. If more than one integer is included in the calling sequence, the first is n and the second is init (algebraic expression case). Otherwise, if a parameter is repeated, the last occurrence is the effective one.
 • Parameters may be given in any order (except that the interpretation of integer parameters is always that the first is n).
 • The remaining parameters in the calling sequence have been provided for achieving maximal efficiency in computations with Vectors.
 shape=name or shape=list
 Specifies one or more built-in or user-defined indexing functions that determine the nonzero structure of the Vector. If more than one indexing function is included, they must be entered as a list. The default shape is [] (none). For Vectors, the built-in indexing functions are:

 storage=name
 Specifies how physical memory is allocated for storing the entries of the Vector. The default storage is rectangular.
 datatype=name
 Specifies the type of data stored in the Vector. It can be one of integer[n], float[n], double, complex[n], or any Maple type specification.
 For integer[n], n can be 1, 2, 4, or 8, indicating the number of bytes per integer. For float[n] , n can be 4 or 8, again indicating the number of bytes per floating-point number. The double datatype is the same as the float datatype. For complex[n], the only allowable value of n is 8, indicating the number of bytes allocated for each of the real and imaginary parts of the values stored in the Vector. The default datatype is the general Maple type anything.
 fill=value
 Specifies the value for unspecified Vector elements. This value must meet the same evaluation requirements as the initializer values. The default fill value is 0.
 Note:  The fill value is only used to fill those elements of the Vector that are unspecified in spite of the indexing function. In the case of a sparse Vector, the fill value is always ignored.
 attributes=list
 Specifies the attributes with which the Vector is created. This option can be used to attach mathematical properties to the Vector. Anything that is a valid argument to setattribute can be an attribute of a Vector.
 The default is to have no attributes.
 orientation=name
 Specifies whether the resulting object is a row Vector or a column Vector. If the orientation is specified both as an index (for example, Vector[row]) and by this parameter in the calling sequence, the index orientation takes precedence. For example, if the calling sequence is specified as Vector[row](.., orientation=column, ...), then the resulting object is a row Vector.
 • After creation, it is possible to change the entries and some of the mathematical properties of the Vector. See Vector assignment and Vector options for more information.
 • For additional information on accessing elements or groups of elements of a Vector, see Vector indexing.
 • If expr is a Vector[row] or Vector[column] expression, the nops(expr) function returns 3.
 If expr is a Vector[row] or Vector[column] expression, the op(o, expr) function returns the following operands for the specified values of o.

 o returned operand 0 Vector[row] or Vector[column] 1 Vector size as an integer 2 Vector elements as a set of equations of the form (indices)=value  * 3 Vector options as an expression sequence of equations of the form option=value  **

 * Only the elements that explicitly need to be specified, taking into account storage, are returned.
 ** The subtype option is not returned since it is implicitly Vector[row] or Vector[column]. The user and built-in indexing functions are returned as options.
 • Only small Vectors are displayed inline in Maple. By default, a small Vector is defined as one whose size is in the range 1..25 (TTY version of Maple)  or the range 1..10 (GUI version of Maple). Any Vector larger than this size is displayed by using a placeholder. For information on how to view a placeholder, see structuredview.
 You can display larger Vectors inline by using the interface(rtablesize=value) command, where value is an integer that represents the upper bound of the size range.
 To change the environment so that Maple always displays rtables inline, include the interface(rtablesize=infinity) command in a Maple initialization file (see maple).
 • Vectors do not have last name evaluation. Examples

A two-element Vector.

 > $\mathrm{Vector}\left(2\right)$
 $\left[\begin{array}{c}{0}\\ {0}\end{array}\right]$ (1)

A column Vector with all entries set to 5.

Note that when orientation of a Vector is not provided, a column Vector is returned.

 > $\mathrm{Vector}\left(1..3,5\right)$
 $\left[\begin{array}{c}{5}\\ {5}\\ {5}\end{array}\right]$ (2)

A row Vector with entries given as list.

 > $\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[1,2,3\right]\right)$
 $\left[\begin{array}{ccc}{1}& {2}& {3}\end{array}\right]$ (3)

You can use functions to initialize values for corresponding entries in a Vector.

 > $f≔j↦{x}^{j-1}:$
 > $\mathrm{Vector}\left(3,f\right)$
 $\left[\begin{array}{c}{1}\\ {x}\\ {{x}}^{{2}}\end{array}\right]$ (4)

Or, use set notation to specify entries at each location.

 > $s≔\left\{1=0,2=1\right\}:$
 > $\mathrm{Vector}\left(2,s\right)$
 $\left[\begin{array}{c}{0}\\ {1}\end{array}\right]$ (5)

Create a Vector using symbolic name for the entries.

 > $\mathrm{Vector}\left(3,\mathrm{symbol}=v\right)$
 $\left[\begin{array}{c}{{v}}_{{1}}\\ {{v}}_{{2}}\\ {{v}}_{{3}}\end{array}\right]$ (6)

Use the built-in index function unit to construct a unit Vector.

 > $\mathrm{Vector}\left(4,\mathrm{shape}=\mathrm{unit}\left[3\right]\right)$
 $\left[\begin{array}{c}{0}\\ {0}\\ {1}\\ {0}\end{array}\right]$ (7)

In the following example, S returns the addition of two column Vectors. The option fill specifies entries for the first Vector, and a list is used to specify entries of the second Vector.

 > $S≔\mathrm{Vector}\left(3,\mathrm{fill}=2\right)+\mathrm{Vector}\left(3,\left[1,2,3\right]\right)$
 ${S}{≔}\left[\begin{array}{c}{3}\\ {4}\\ {5}\end{array}\right]$ (8)

To evaluate the data type of S:

 > $\mathrm{whattype}\left(S\right)$
 ${{\mathrm{Vector}}}_{{\mathrm{column}}}$ (9)

It is an error to attempt to write to a read-only Vector.

 > $A≔\mathrm{Vector}\left(\left[1,2,3\right],\mathrm{readonly}=\mathrm{true}\right)$
 ${A}{≔}\left[\begin{array}{c}{1}\\ {2}\\ {3}\end{array}\right]$ (10)
 > $A\left[1\right]≔\mathrm{Vector}\left(\left[2\right]\right)$ Compatibility

 • The datatype option was updated in Maple 2015.