Get or set part of an array. More...
Classes | |
| class | seq |
Functions | |
| array | row (int i) const |
Access row i to form row vector. | |
| array | col (int i) const |
Access column i to form column vector. | |
| array | slice (int i) const |
Access slice i to form a matrix. | |
| array | rows (int first, int last) const |
Access rows first through last to form a matrix. | |
| array | cols (int first, int last) const |
Access columns first through last to form a matrix. | |
| array | slices (int first, int last) const |
Access slices first through last to form a volume. | |
| template<typename ty > | |
| array & | operator= (const ty) |
| scalar assignment | |
| array & | operator= (const array &) |
| array assignment | |
Variables | |
| int | end |
| Reference last element in dimension. | |
| seq | span |
| Reference entire dimension. | |
One subscript | |
| array | operator() (int x) const |
Access linear element x. | |
| array | operator() (const seq &) const |
| Access linear sequence of elements. | |
| array | operator() (array indices) const |
Use indices (integer values or boolean mask) | |
Two subscripts | |
| array | operator() (const seq &, const seq &) const |
| Access submatrix. | |
| array | operator() (int row, int col) const |
Access linear element at row and col. | |
| array | operator() (int row, const seq &y) const |
Access linear sequence of elements along row. | |
| array | operator() (int row, array columns) const |
Elements along row and columns. | |
| array | operator() (const seq &x, int column) const |
Access linear sequence of elements along column. | |
| array | operator() (const seq &rows, array columns) const |
Elements along rows and columns. | |
| array | operator() (array rows, int column) const |
Elements along rows and column. | |
| array | operator() (array rows, const seq &columns) const |
Elements along rows and columns. | |
| array | operator() (array rows, array columns) const |
Elements along rows and columns. | |
Three subscripts | |
| array | operator() (const seq &, const seq &, const seq &) const |
| Access volume. | |
| array | operator() (int x, int y, int z) const |
| Access element. | |
| array | operator() (const seq &x, int y, int z) const |
| Access vector. | |
| array | operator() (int x, const seq &y, int z) const |
| Access vector. | |
| array | operator() (int x, int y, const seq &z) const |
| Access vector. | |
| array | operator() (int x, const seq &y, const seq &z) const |
| Access matrix. | |
| array | operator() (const seq &x, const seq &y, int z) const |
| Access matrix. | |
| array | operator() (const seq &x, int y, const seq &z) const |
| Access matrix. | |
| array | operator() (array rows, array cols, const seq &slices) const |
Elements along rows, columns, slices. | |
| array | operator() (array rows, array cols, int slice) const |
Elements along rows, cols, slice. | |
| array | operator() (array rows, const seq &cols, const seq &slices) const |
Elements along rows, columns, slices. | |
| array | operator() (array rows, const seq &cols, int slice) const |
Elements along rows, cols, slice. | |
| array | operator() (const seq &rows, array cols, const seq &slices) const |
Elements along rows, columns, slices. | |
| array | operator() (const seq &, const seq &, array) const |
| Access submatrix. | |
Four subscripts | |
| array | operator() (const seq &w, const seq &x, const seq &y, const seq &z) const |
| Access volume. | |
| array | operator() (const seq &w, const seq &x, const seq &y, int z) const |
| Access volume. | |
| array | operator() (const seq &w, const seq &x, int y, int z) const |
| Access matrix. | |
Get or set part of an array.
For more examples, see Indexing.
array a = randu(3,4); print(a); print(a.col(0)); print(a(4)); print(a(seq(3))); a.col(end) = -1; // set last column print(a); print(a(a > .5));
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.col(0) =
0.7402
0.9210
0.0390
a(4) =
0.9251
a(seq(3)) =
0.7402
0.9210
0.0390
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.
array A = randu(5,1); array B = A(seq(0,3)); // extract elements {0,1,2,3}
Sequences can also be combined with arithmetic after casting:
randu(1,5) + array(seq(3, 3, 16));
For examples, see Indexing.
| array row | ( | int | i | ) | const [inline, inherited] |
Access row i to form row vector.
| array col | ( | int | i | ) | const [inline, inherited] |
Access column i to form column vector.
| array slice | ( | int | i | ) | const [inline, inherited] |
Access slice i to form a matrix.
| array rows | ( | int | first, |
| int | last | ||
| ) | const [inline, inherited] |
Access rows first through last to form a matrix.
| array cols | ( | int | first, |
| int | last | ||
| ) | const [inline, inherited] |
Access columns first through last to form a matrix.
| array slices | ( | int | first, |
| int | last | ||
| ) | const [inline, inherited] |
Access slices first through last to form a volume.
| array operator() | ( | int | x | ) | const [inline, inherited] |
Access linear element x.
| array operator() | ( | const seq & | ) | const [inherited] |
Access linear sequence of elements.
| array operator() | ( | array | indices | ) | const [inherited] |
Use indices (integer values or boolean mask)
| array operator() | ( | int | row, |
| int | col | ||
| ) | const [inline, inherited] |
Access linear element at row and col.
| array operator() | ( | int | row, |
| const seq & | y | ||
| ) | const [inline, inherited] |
Access linear sequence of elements along row.
| array operator() | ( | int | row, |
| array | columns | ||
| ) | const [inline, inherited] |
Elements along row and columns.
| array operator() | ( | const seq & | x, |
| int | column | ||
| ) | const [inline, inherited] |
Access linear sequence of elements along column.
Elements along rows and columns.
| array operator() | ( | array | rows, |
| int | column | ||
| ) | const [inline, inherited] |
Elements along rows and column.
Elements along rows and columns.
| array operator() | ( | int | x, |
| int | y, | ||
| int | z | ||
| ) | const [inline, inherited] |
Access element.
| array operator() | ( | const seq & | x, |
| int | y, | ||
| int | z | ||
| ) | const [inline, inherited] |
Access vector.
| array operator() | ( | int | x, |
| const seq & | y, | ||
| int | z | ||
| ) | const [inline, inherited] |
Access vector.
| array operator() | ( | int | x, |
| int | y, | ||
| const seq & | z | ||
| ) | const [inline, inherited] |
Access vector.
Elements along rows, columns, slices.
Elements along rows, cols, slice.
Elements along rows, columns, slices.
Elements along rows, cols, slice.
Elements along rows, columns, slices.
Access volume.
Access volume.
Access matrix.
| array& operator= | ( | const ty | ) | [inherited] |
scalar assignment
| array& operator= | ( | const array & | ) | [inherited] |
array assignment
| int end |
Reference last element in dimension.
float hA[] = { 0,1,2,3,4,5 }; array A(hA,2,3); A(end,0) // last element in first column: 1 A(end) // last element of entire array: 5 A(-1) // equivalent to A(end) A(-2) // equivalent to A(end-1)
| seq span |
Reference entire dimension.
float hA[] = { 0,1,2,3,4,5 }; array A(hA,2,3); A(span,1) // reference second column: {2 3} A(span) // entire array flattened as column vector