Documentation
|
|
Get or set part of an array. More...
Data Structures | |
| class | seq |
| sequential index generator More... | |
Modules | |
| row/rows | |
| Access one or more rows of an array. | |
| col/cols | |
| Access one or more columns of an array. | |
| slice/slices | |
| Access one or more slices of an array. | |
| operator() | |
| Indexing using the () operator. | |
| operator= | |
| Assignment operator. | |
| end | |
| Reference last element in dimension. | |
| span | |
| Reference the entire dimension. | |
Get or set part of an array.
Each array has a dim4 that specifies the size of the array along each of the 4 dimensions. The size of each dimension is alteast 1.
The most common ways to index are using a specific index locations, seq or using an array of indices.
Other variables that are commonly used are span, and end. Span is used to reference the entire dimension. End is used to specify the last index in the dimension.
Use of negative indices or indices greater than the size of the dimensions for subscripting results in undefined behavior.
For more examples, see Indexing .
produces:
a =
0.7402 0.9690 0.6673 0.5132
0.9210 0.9251 0.1099 0.7762
0.0390 0.4464 0.4702 0.2948
a.row(1) =
0.9210 0.9251 0.1099 0.7762
a.rows(0,1) =
0.7402 0.9690 0.6673 0.5132
0.9210 0.9251 0.1099 0.7762
a.col(0) =
0.7402
0.9210
0.0390
a.cols(1,3) =
0.9690 0.6673 0.5132
0.9251 0.1099 0.7762
0.4464 0.4702 0.2948
a(4) =
0.9251
a(seq(3)) =
0.7402
0.9210
0.0390
a.col(end) = -1
a =
0.7402 0.9690 0.6673 -1.0000
0.9210 0.9251 0.1099 -1.0000
0.0390 0.4464 0.4702 -1.0000
a(a > .5) =
0.7402
0.9210
0.9690
0.9251
0.6673
Use seq objects to create numeric sequences for subscripting or arithmetic. See also Indexing .
Sequences can also be combined with arithmetic after casting:
For examples, see Indexing .