 Fill - Maple Help

ArrayTools

 Fill
 fill portion of Matrix, Vector, or Array with specified value Calling Sequence Fill(num, val, A, offset, skip) Parameters

 num - (optional) number of elements to fill val - fill value; must correspond to data type of input Matrix, Vector, or Array A - rectangular storage Matrix, Vector, or Array of any data type and ordering offset - (optional) offset for start of fill skip - (optional) fill every 'skip'th element. Can be specified only if offset specified Description

 • The Fill command sets entries of the input Matrix, Vector, or Array A to the specified value val. The value must be of the same type as the input Matrix, Vector, or Array, or an error results. In addition, the input Matrix, Vector, or Array must have rectangular (dense) storage.
 • The additional parameters, num, offset, and skip, extend Fill command usage. For example, you can set every second element in a Vector, a specific row or column in a Matrix, all entries [4,*,*] in a C_order Array.
 The use of these additional parameters is a programmer level feature, and requires detailed knowledge of the storage structure of multidimensional rtables under different data orderings (C_order and Fortran_order). For a description of storage under these orderings,  see Fortran_order.
 • Knowledge of these storage schemes becomes required when you want to compute the num, offset, and skip values to fill a row or column of a Matrix using the Fill command.
 Filling the third column of a 6 x 10 C_order Matrix corresponds to acting on the elements $10\left(i-1\right)+\left(3-1\right)$ for i from 1 to 6.
 - num is the number of elements to fill, which is 6
 - offset is the offset of the first element to be filled, which is (3-1)=2
 - skip is the distance between consecutive elements (the multiplier of the 'i' above), which is 10.
 The resulting command is Fill(6,val,A,2,10).
 In contrast, the same operation for a 6 x 10 Fortran_order Matrix corresponds to acting on the elements $\left(i-1\right)+6\left(3-1\right)$ for i from 1 to 6. In this case the command is Fill(6,val,A,12,1), which can be abbreviated to Fill(6,val,A,12). This is shown in the following examples.
 • The default values of the optional parameters are described as follows.
 - offset is 0 (start at the very beginning)
 - skip is 1 (fill all consecutive elements)
 - num is chosen so that the operation does not exceed the storage of the rtable
 • This function is part of the ArrayTools package, so it can be used in the short form Fill(..) only after executing the command with(ArrayTools).  However, it can always be accessed through the long form of the command by using ArrayTools[Fill](..). • The Fill command is thread safe as of Maple 2023, provided that the rtable A is not shared between threads. Examples

 > $\mathrm{with}\left(\mathrm{ArrayTools}\right):$

Vector

 > $A≔{\mathrm{Vector}}_{\mathrm{row}}\left(10\right)$
 ${A}{≔}\left[\begin{array}{cccccccccc}{0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\end{array}\right]$ (1)

Set all entries to 1.

 > $\mathrm{Fill}\left(1,A\right)$
 > $A$
 $\left[\begin{array}{cccccccccc}{1}& {1}& {1}& {1}& {1}& {1}& {1}& {1}& {1}& {1}\end{array}\right]$ (2)

Set every second entry to 2.

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

Set every second entry to 3 starting at an offset of 1.

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

C_order Matrix

 > $M≔\mathrm{Matrix}\left(6,10,\mathrm{order}=\mathrm{C_order}\right)$
 ${M}{≔}\left[\begin{array}{cccccccccc}{0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\end{array}\right]$ (5)

Set all entries to 2.

 > $\mathrm{Fill}\left(2,M\right)$
 > $M$
 $\left[\begin{array}{cccccccccc}{2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\end{array}\right]$ (6)

Set first 20 entries to 3.

 > $\mathrm{Fill}\left(20,3,M\right)$
 > $M$
 $\left[\begin{array}{cccccccccc}{3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}\\ {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\end{array}\right]$ (7)

Set second-last row to zero.

 > $\mathrm{Fill}\left(10,0,M,40\right)$
 > $M$
 $\left[\begin{array}{cccccccccc}{3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}\\ {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}& {3}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\end{array}\right]$ (8)

Set third column to 5.

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

Fortran_order Matrix

 > $M≔\mathrm{Matrix}\left(6,10,\mathrm{order}=\mathrm{Fortran_order}\right)$
 ${M}{≔}\left[\begin{array}{cccccccccc}{0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\end{array}\right]$ (10)

Set all entries to 2.

 > $\mathrm{Fill}\left(2,M\right)$
 > $M$
 $\left[\begin{array}{cccccccccc}{2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\\ {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}& {2}\end{array}\right]$ (11)

Set first 12 entries to 3.

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

Set second-last row to zero.

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

Set third column to 5.

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