A high-performance general-purpose compute library

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

Functions

array::array_proxy operator() (const index &s0)
 This operator returns a reference of the original array at a given coordinate. More...
 
const array::array_proxy operator() (const index &s0) const
 This operator returns a reference of the original array at a given coordinate. More...
 
array::array_proxy operator() (const index &s0, const index &s1, const index &s2=span, const index &s3=span)
 This operator returns a reference of the original array at a given coordinate. More...
 
const array::array_proxy operator() (const index &s0, const index &s1, const index &s2=span, const index &s3=span) const
 This operator returns a reference of the original array at a given coordinate. More...
 

Detailed Description

Gets a reference to a set of elements.

array A = array(seq(1, 9), 3, 3);
// 1.0000 4.0000 7.0000
// 2.0000 5.0000 8.0000
// 3.0000 6.0000 9.0000
af_print(A(0)); // first element
// 1.0000
af_print(A(0, 1)); // first row, second column
// 4.0000
af_print(A(end)); // last element
// 9.0000
af_print(A(-1)); // also last element
// 9.0000
af_print(A(end - 1)); // second-to-last element
// 8.0000
af_print(A(1, span)); // second row
// 2.0000 5.0000 8.0000
af_print(A.row(end)); // last row
// 3.0000 6.0000 9.0000
af_print(A.cols(1, end)); // all but first column
// 4.0000 7.0000
// 5.0000 8.0000
// 6.0000 9.0000
float b_host[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
array b(10, 1, b_host);
af_print(b(seq(3)));
// 0.0000
// 1.0000
// 2.0000
af_print(b(seq(1, 7)));
// 1.0000
// 2.0000
// 3.0000
// 4.0000
// 5.0000
// 6.0000
// 7.0000
af_print(b(seq(1, 7, 2)));
// 1.0000
// 3.0000
// 5.0000
// 7.0000
af_print(b(seq(0, end, 2)));
// 0.0000
// 2.0000
// 4.0000
// 6.0000
// 8.0000
#define af_print(...)
Definition: util.h:148

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

◆ operator()() [1/4]

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

This operator returns a reference of the original array at a given coordinate.

You can pass af::seq, af::array, or an int as its 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]s0is sequence of linear indices
Returns
A reference to the array at the given index

◆ operator()() [2/4]

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

This operator returns a reference of the original array at a given coordinate.

You can pass af::seq, af::array, or an int as its 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]s0is sequence of linear indices
Returns
A reference to the array at the given index

◆ operator()() [3/4]

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

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.

Parameters
[in]s0is sequence of indices along the first dimension
[in]s1is sequence of indices along the second dimension
[in]s2is sequence of indices along the third dimension
[in]s3is sequence of indices along the fourth dimension
Returns
A reference to the array at the given index

◆ operator()() [4/4]

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

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.

Parameters
[in]s0is sequence of indices along the first dimension
[in]s1is sequence of indices along the second dimension
[in]s2is sequence of indices along the third dimension
[in]s3is sequence of indices along the fourth dimension
Returns
A reference to the array at the given index