Sets every item of a matrix, or of a block inside it, to one value.
matrix.fill(m, 0.0) zeroes the whole grid. Pass from_row, to_row, from_column and to_column to fill a block; each end is exclusive, so to_row = 2 fills rows 0 and 1.
A block that falls outside the matrix stops the script with an error naming the offending index.
Syntax
matrix.fill(id: any matrix type, value: series <type of the matrix's elements>, from_row: series int (optional), to_row: series int (optional), from_column: series int (optional), to_column: series int (optional)) -> void
matrix.fill(value: series <type of the matrix's elements>, from_row: series int (optional), to_row: series int (optional), from_column: series int (optional), to_column: series int (optional)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to overwrite, all of it or the block chosen by the row and column ranges. |
| value | series <type of the matrix's elements> | required | The value to store. It has to match the type of the matrix's elements. |
| from_row | series int | 0 | First row of the range. Counts from 0. |
| to_row | series int | the number of rows | Row just after the last row of the range. |
| from_column | series int | 0 | First column of the range. Counts from 0. |
| to_column | series int | the number of columns | Column just after the last column of the range. |
Returns
Nothing.
Example
//@version=6
indicator("matrix.fill: block", overlay = false)
matrix<float> m = matrix.new<float>(3, 3, 1.0)
matrix.fill(m, 0.0, 0, 2, 0, 2)
plot(matrix.get(m, 0, 0) + matrix.get(m, 2, 2), "Zeroed cell plus untouched cell")See also
Runs on Sidechair