RandomMatrix - Maple Help

LinearAlgebra

 RandomMatrix
 construct a random Matrix
 RandomVector
 construct a random Vector

 Calling Sequence RandomMatrix(r, c, den, gen, options) RandomVector[o](d, den, gen, options)

Parameters

 r - (optional) non-negative integer; row dimension of the resulting Matrix c - (optional) non-negative integer; column dimension of the resulting Matrix d - (optional) non-negative integer; dimension of the resulting Vector den - (optional) equation of the form density = p where p is a numeric value with 0 <= p <= 1; probability that a generated value is assigned to an entry in the resulting Matrix or Vector gen - (optional) equation of the form generator = f where f is a generator of values for the entries [o] - (optional) use either [row] or [column] to specify the orientation of the resulting Vector options - (optional); constructor options for the result object

Description

 • The RandomMatrix(r, c) function returns an r x c Matrix in which all of the entries have integer values in the range -99..99.
 If the row dimension is not provided, it defaults to 0. If the column dimension is not provided, it defaults to the row dimension.
 • The RandomVector(d) function returns a d-dimensional Vector in which all of the entries have integer entries in the range -99..99.
 The RandomVector[row](d) function acts like RandomVector(d), except that a row Vector is returned.  If the orientation option is omitted or if RandomVector[column](d) is used, a column Vector is returned.
 If the dimension is not provided, it defaults to 0.
 • The optional parameter gen can be used to define an alternate number generator. If the generator is specified as an integer or floating-point range, the appropriate rtable random initializer is used to generate the entries. This form of the generator can be used to create very large Matrices or Vectors.  This generator is very fast, but it may return different results on different platforms.  If values that are stable across platforms are required, then a stable generating procedure should be given.
 If the optional parameter gen is given but is not a range, then it must be a procedure which takes no arguments and returns a value to be put into the constructed Matrix or Vector.
 • The probability that an entry is assigned a value in the resulting Matrix or Vector is determined by including density = p, where 0 <= p <= 1, in the calling sequence. The placement of the random values is determined without regard to the shape (indexing function) of the Matrix or Vector; failed attempts to write a random value to a non-mutable location (as determined by the shape) are ignored.  In other words, p determines the proportion of entries in the full rectangular Matrix or Vector which the routine attempts to set to a random value, rather than the number of mutable locations which are actually set.
 If density = p is not provided in the calling sequence, the value of p defaults to 1.
 • The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Matrix or Vector constructor that builds the result. These options may also be provided in the form outputoptions=[...], where [...] represents a Maple list.  If a constructor option is provided in both the calling sequence directly and in an outputoptions option, the latter takes precedence (regardless of the order).
 • This function is part of the LinearAlgebra package, and so it can be used in the form RandomMatrix(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[RandomMatrix](..).

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $\mathrm{RandomVector}\left(2\right)$
 $\left[\begin{array}{c}{-31}\\ {67}\end{array}\right]$ (1)
 > ${\mathrm{RandomVector}}_{\mathrm{row}}\left(6,\mathrm{generator}=\frac{\mathrm{rand}\left(1..5\right)}{10}\right)$
 $\left[\begin{array}{cccccc}\frac{{1}}{{5}}& \frac{{1}}{{2}}& \frac{{1}}{{5}}& \frac{{3}}{{10}}& \frac{{2}}{{5}}& \frac{{2}}{{5}}\end{array}\right]$ (2)
 > $\mathrm{RandomMatrix}\left(3,\mathrm{density}=0.75,\mathrm{generator}=0..0.5\right)$
 $\left[\begin{array}{ccc}{0.}& {0.399052928389163564}& {0.}\\ {0.319881680578765704}& {0.490554846663649902}& {0.}\\ {0.00239174225092408932}& {0.}& {0.0941909870016631179}\end{array}\right]$ (3)
 > $\mathrm{RandomMatrix}\left(4,4,\mathrm{generator}=1..9,\mathrm{shape}={\mathrm{triangular}}_{\mathrm{lower}}\right)$
 $\left[\begin{array}{cccc}{8}& {0}& {0}& {0}\\ {2}& {2}& {0}& {0}\\ {3}& {4}& {4}& {0}\\ {7}& {2}& {9}& {9}\end{array}\right]$ (4)