Fill - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ArrayTools

  

Fill

  

fill portion of Matrix, Vector, or Array with specified value

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

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 10i1+31 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 i1+631 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](..).

Thread Safety

• 

The Fill command is thread safe as of Maple 2023, provided that the rtable A is not shared between threads.

• 

For more information on thread safety, see index/threadsafe.

Examples

withArrayTools:

Vector

AVectorrow10

A0000000000

(1)

Set all entries to 1.

Fill1,A

A

1111111111

(2)

Set every second entry to 2.

Fill5,2,A,0,2

A

2121212121

(3)

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

Fill3,A,1,2

A

2323232323

(4)

C_order Matrix

MMatrix6,10,order=C_order

M000000000000000000000000000000000000000000000000000000000000

(5)

Set all entries to 2.

Fill2,M

M

222222222222222222222222222222222222222222222222222222222222

(6)

Set first 20 entries to 3.

Fill20,3,M

M

333333333333333333332222222222222222222222222222222222222222

(7)

Set second-last row to zero.

Fill10,0,M,40

M

333333333333333333332222222222222222222200000000002222222222

(8)

Set third column to 5.

Fill6,5,M,2,10

M

335333333333533333332252222222225222222200500000002252222222

(9)

Fortran_order Matrix

MMatrix6,10,order=Fortran_order

M000000000000000000000000000000000000000000000000000000000000

(10)

Set all entries to 2.

Fill2,M

M

222222222222222222222222222222222222222222222222222222222222

(11)

Set first 12 entries to 3.

Fill12,3,M

M

332222222233222222223322222222332222222233222222223322222222

(12)

Set second-last row to zero.

Fill10,0,M,4,6

M

332222222233222222223322222222332222222200000000003322222222

(13)

Set third column to 5.

Fill6,5,M,12

M

335222222233522222223352222222335222222200500000003352222222

(14)

See Also

ArrayTools

C_order

Fortran_order

Matrix

Vector