- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

operator()
Complete List of ArrayFire Functions ArrayFire Functions by Category » Functions to create and modify Arrays » | Assignment & Indexing operation on arrays

Gets a reference to a set of elements. More...

array::array_proxy | operator() (const index &s0)
| Gets a reference to a set of linear elements. More...
const array::array_proxy | operator() (const index &s0) const
| Gets a reference to a set of linear elements. More...
array::array_proxy | operator() (const index &s0, const index &s1, const index &s2=span, const index &s3=span)
| Gets a reference to a sub array. More...
const array::array_proxy | operator() (const index &s0, const index &s1, const index &s2=span, const index &s3=span) const
| Gets a reference to a sub array. More...

## Detailed Description

Gets a reference to a set of elements.

array A = array(seq(1,9), 3, 3);
af_print(A);
af_print(A(0)); // first element
af_print(A(0,1)); // first row, second column
af_print(A(end)); // last element
af_print(A(-1)); // also last element
af_print(A(end-1)); // second-to-last element
af_print(A(1,span)); // second row
af_print(A.row(end)); // last row
af_print(A.cols(1,end)); // all but first column
float b_host[] = {0,1,2,3,4,5,6,7,8,9};
array b(10, 1, b_host);
af_print(b(seq(3)));
af_print(b(seq(1,7)));
af_print(b(seq(1,7,2)));
af_print(b(seq(0,end,2)));

This operator returns a reference of the original array at a given coordinate. You can pass af::seq, af::array, or an int as it's parameters. These references can be used for assignment or returning references to af::array objects.

## Function Documentation

array::array_proxy operator() | ( | const index & | s0 | ) |

Gets a reference to a set of linear elements.

You can pass af::seq, af::array, or an int as it's parameters. These references can be used for assignment or returning references to af::array objects.

If the af::array is a multi-dimensional array then this coordinate will treated as the data as a linear array.

Parameters

  [in] | s0 | is sequence of linear indices

Returns
  A reference to the array at the given index

const array::array_proxy operator() | ( | const index & | s0 | ) | const

Gets a reference to a set of linear elements.

You can pass af::seq, af::array, or an int as it's parameters. These references can be used for assignment or returning references to af::array objects.

If the af::array is a multi-dimensional array then this coordinate will treated as the data as a linear array.

Parameters

  [in] | s0 | is sequence of linear indices

Returns
  A reference to the array at the given index

array::array_proxy operator() | ( | const index & | s0,
|  | const index & | s1,
|  | const index & | s2 = `span`,
|  | const index & | s3 = `span`
| ) |  |

Gets a reference to a sub array.

You can pass af::seq, af::array, or an int as it's parameters. These references can be used for assignment or returning references to af::array objects.

Parameters

  [in] | s0 | is sequence of indices along the first dimension
  [in] | s1 | is sequence of indices along the second dimension
  [in] | s2 | is sequence of indices along the third dimension
  [in] | s3 | is sequence of indices along the fourth dimension

Returns
  A reference to the array at the given index

const array::array_proxy operator() | ( | const index & | s0,
|  | const index & | s1,
|  | const index & | s2 = `span`,
|  | const index & | s3 = `span`
| ) |  | const

Gets a reference to a sub array.

You can pass af::seq, af::array, or an int as it's parameters. These references can be used for assignment or returning references to af::array objects.

Parameters

  [in] | s0 | is sequence of indices along the first dimension
  [in] | s1 | is sequence of indices along the second dimension
  [in] | s2 | is sequence of indices along the third dimension
  [in] | s3 | is sequence of indices along the fourth dimension

Returns
  A reference to the array at the given index