HCC
HCC is a single-source, C/C++ compiler for heterogeneous computing. It's optimized with HSA (http://www.hsafoundation.com/).
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
hc::array< T, N > Class Template Reference

Represents an N-dimensional region of memory (with type T) located on an accelerator. More...

#include <hc.hpp>

Collaboration diagram for hc::array< T, N >:
Collaboration graph

Public Types

typedef Kalmar::_data_host< T > acc_buffer_t
 
typedef T value_type
 The element type of this array.
 

Public Member Functions

 array ()=delete
 There is no default constructor for array<T,N>.
 
 array (const array &other)
 Copy constructor. More...
 
 array (array &&other)
 Move constructor. More...
 
 array (const extent< N > &ext)
 Constructs a new array with the supplied extent, located on the default view of the default accelerator. More...
 
 array (const array_view< const T, N > &src)
 Constructs a new array, located on the default view of the default accelerator, initialized with the contents of the array_view "src". More...
 
 array (const extent< N > &ext, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Constructs a new array with the supplied extent, located on the accelerator bound to the accelerator_view "av". More...
 
 array (const extent< N > &ext, accelerator_view av, void *accelerator_pointer, access_type cpu_access_type=access_type_auto)
 Constructs an array instance based on the given pointer on the device memory. More...
 
template<typename InputIter >
 array (const extent< N > &ext, InputIter srcBegin, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Constructs a new array with the supplied extent, located on the accelerator bound to the accelerator_view "av", initialized with the contents of the source container specified by a beginning and optional ending iterator. More...
 
template<typename InputIter >
 array (const extent< N > &ext, InputIter srcBegin, InputIter srcEnd, accelerator_view av, access_type cpu_access_type=access_type_auto)
 
 array (const array_view< const T, N > &src, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Constructs a new array initialized with the contents of the array_view "src". More...
 
 array (const extent< N > &ext, accelerator_view av, accelerator_view associated_av)
 Constructs a staging array with the given extent, which acts as a staging area between accelerator views "av" and "associated_av". More...
 
 array (const array_view< const T, N > &src, accelerator_view av, accelerator_view associated_av)
 Constructs a staging array initialized with the array_view given by "src", which acts as a staging area between accelerator_views "av" (which must be the CPU accelerator) and "associated_av". More...
 
extent< N > get_extent () const __CPU__ __HC__
 Access the extent that defines the shape of this array.
 
accelerator_view get_accelerator_view () const
 This property returns the accelerator_view representing the location where this array has been allocated.
 
accelerator_view get_associated_accelerator_view () const
 This property returns the accelerator_view representing the preferred target where this array can be copied.
 
access_type get_cpu_access_type () const
 This property returns the CPU "access_type" allowed for this array.
 
arrayoperator= (const array &other)
 Assigns the contents of the array "other" to this array, using a deep copy. More...
 
arrayoperator= (array &&other)
 Moves the contents of the array "other" to this array. More...
 
arrayoperator= (const array_view< T, N > &src)
 Assigns the contents of the array_view "src", as if by calling "copy(src, *this)". More...
 
void copy_to (array &dest) const
 Copies the contents of this array to the array given by "dest", as if by calling "copy(*this, dest)". More...
 
void copy_to (const array_view< T, N > &dest) const
 Copies the contents of this array to the array_view given by "dest", as if by calling "copy(*this, dest)". More...
 
T * data () const __CPU__ __HC__
 Returns a pointer to the raw data underlying this array. More...
 
T * accelerator_pointer () const __CPU__ __HC__
 Returns a pointer to the device memory underlying this array. More...
 
 operator std::vector< T > () const
 Implicitly converts an array to a std::vector, as if by "copy(*this, vector)". More...
 
const acc_buffer_t & internal () const __CPU__ __HC__
 
int get_offset () const __CPU__ __HC__
 
index< N > get_index_base () const __CPU__ __HC__
 
 array (int e0)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]))". More...
 
 array (int e0, int e1)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]))". More...
 
 array (int e0, int e1, int e2)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]))". More...
 
template<typename InputIter >
 array (const extent< N > &ext, InputIter srcBegin)
 Constructs a new array with the supplied extent, located on the default accelerator, initialized with the contents of a source container specified by a beginning and optional ending iterator. More...
 
template<typename InputIter >
 array (const extent< N > &ext, InputIter srcBegin, InputIter srcEnd)
 Constructs a new array with the supplied extent, located on the default accelerator, initialized with the contents of a source container specified by a beginning and optional ending iterator. More...
 
template<typename InputIter >
 array (int e0, InputIter srcBegin)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)". More...
 
template<typename InputIter >
 array (int e0, InputIter srcBegin, InputIter srcEnd)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)". More...
 
template<typename InputIter >
 array (int e0, int e1, InputIter srcBegin)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)". More...
 
template<typename InputIter >
 array (int e0, int e1, InputIter srcBegin, InputIter srcEnd)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)". More...
 
template<typename InputIter >
 array (int e0, int e1, int e2, InputIter srcBegin)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)". More...
 
template<typename InputIter >
 array (int e0, int e1, int e2, InputIter srcBegin, InputIter srcEnd)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)". More...
 
 array (int e0, void *accelerator_pointer)
 Constructs an array instance based on the given pointer on the device memory.
 
 array (int e0, int e1, void *accelerator_pointer)
 Constructs an array instance based on the given pointer on the device memory.
 
 array (int e0, int e1, int e2, void *accelerator_pointer)
 Constructs an array instance based on the given pointer on the device memory.
 
 array (const extent< N > &ext, void *accelerator_pointer)
 Constructs an array instance based on the given pointer on the device memory.
 
 array (int e0, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, cpu_access_type)". More...
 
 array (int e0, int e1, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, cpu_access_type)". More...
 
 array (int e0, int e1, int e2, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, cpu_access_type)". More...
 
template<typename InputIter >
 array (int e0, InputIter srcBegin, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)". More...
 
template<typename InputIter >
 array (int e0, InputIter srcBegin, InputIter srcEnd, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)". More...
 
template<typename InputIter >
 array (int e0, int e1, InputIter srcBegin, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)". More...
 
template<typename InputIter >
 array (int e0, int e1, InputIter srcBegin, InputIter srcEnd, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)". More...
 
template<typename InputIter >
 array (int e0, int e1, int e2, InputIter srcBegin, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)". More...
 
template<typename InputIter >
 array (int e0, int e1, int e2, InputIter srcBegin, InputIter srcEnd, accelerator_view av, access_type cpu_access_type=access_type_auto)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)". More...
 
 array (int e0, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, associated_av)". More...
 
 array (int e0, int e1, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, associated_av)". More...
 
 array (int e0, int e1, int e2, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, associated_av)". More...
 
template<typename InputIter >
 array (const extent< N > &ext, InputIter srcBegin, accelerator_view av, accelerator_view associated_av)
 Constructs a staging array with the given extent, which acts as a staging area between accelerator_views "av" (which must be the CPU accelerator) and "associated_av". More...
 
template<typename InputIter >
 array (const extent< N > &ext, InputIter srcBegin, InputIter srcEnd, accelerator_view av, accelerator_view associated_av)
 Constructs a staging array with the given extent, which acts as a staging area between accelerator_views "av" (which must be the CPU accelerator) and "associated_av". More...
 
template<typename InputIter >
 array (int e0, InputIter srcBegin, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)". More...
 
template<typename InputIter >
 array (int e0, InputIter srcBegin, InputIter srcEnd, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)". More...
 
template<typename InputIter >
 array (int e0, int e1, InputIter srcBegin, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)". More...
 
template<typename InputIter >
 array (int e0, int e1, InputIter srcBegin, InputIter srcEnd, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)". More...
 
template<typename InputIter >
 array (int e0, int e1, int e2, InputIter srcBegin, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)". More...
 
template<typename InputIter >
 array (int e0, int e1, int e2, InputIter srcBegin, InputIter srcEnd, accelerator_view av, accelerator_view associated_av)
 Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)". More...
 
T & operator[] (const index< N > &idx) __CPU__ __HC__
 Returns a reference to the element of this array that is at the location in N-dimensional space specified by "idx". More...
 
T & operator() (const index< N > &idx) __CPU__ __HC__
 Returns a reference to the element of this array that is at the location in N-dimensional space specified by "idx". More...
 
const T & operator[] (const index< N > &idx) const __CPU__ __HC__
 Returns a const reference to the element of this array that is at the location in N-dimensional space specified by "idx". More...
 
const T & operator() (const index< N > &idx) const __CPU__ __HC__
 Returns a const reference to the element of this array that is at the location in N-dimensional space specified by "idx". More...
 
T & operator() (int i0, int i1) __CPU__ __HC__
 Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]]))". More...
 
T & operator() (int i0, int i1, int i2) __CPU__ __HC__
 Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]]))". More...
 
const T & operator() (int i0, int i1) const __CPU__ __HC__
 Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const". More...
 
const T & operator() (int i0, int i1, int i2) const __CPU__ __HC__
 Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const". More...
 
array_projection_helper< T, N >::result_type operator[] (int i) __CPU__ __HC__
 This overload is defined for array<T,N> where $N \ge 2$. More...
 
array_projection_helper< T, N >::result_type operator() (int i0) __CPU__ __HC__
 Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const". More...
 
array_projection_helper< T, N >::const_result_type operator[] (int i) const __CPU__ __HC__
 Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const". More...
 
array_projection_helper< T, N >::const_result_type operator() (int i0) const __CPU__ __HC__
 Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const". More...
 
array_view< T, N > section (const index< N > &origin, const extent< N > &ext) __CPU__ __HC__
 Returns a subsection of the source array view at the origin specified by "idx" and with the extent specified by "ext". More...
 
array_view< const T, N > section (const index< N > &origin, const extent< N > &ext) const __CPU__ __HC__
 Returns a subsection of the source array view at the origin specified by "idx" and with the extent specified by "ext". More...
 
array_view< T, N > section (const index< N > &idx) __CPU__ __HC__
 Equivalent to "section(idx, this->extent – idx)".
 
array_view< const T, N > section (const index< N > &idx) const __CPU__ __HC__
 Equivalent to "section(idx, this->extent – idx)".
 
array_view< T, N > section (const extent< N > &ext) __CPU__ __HC__
 Equivalent to "section(index<N>(), ext)".
 
array_view< const T, N > section (const extent< N > &ext) const __CPU__ __HC__
 Equivalent to "section(index<N>(), ext)".
 
array_view< T, 1 > section (int i0, int e0) __CPU__ __HC__
 Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const". More...
 
array_view< const T, 1 > section (int i0, int e0) const __CPU__ __HC__
 Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const". More...
 
array_view< T, 2 > section (int i0, int i1, int e0, int e1) const __CPU__ __HC__
 Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const". More...
 
array_view< T, 2 > section (int i0, int i1, int e0, int e1) __CPU__ __HC__
 Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const". More...
 
array_view< T, 3 > section (int i0, int i1, int i2, int e0, int e1, int e2) __CPU__ __HC__
 Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const". More...
 
array_view< const T, 3 > section (int i0, int i1, int i2, int e0, int e1, int e2) const __CPU__ __HC__
 Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const". More...
 
template<typename ElementType >
array_view< ElementType, 1 > reinterpret_as () __CPU__ __HC__
 Sometimes it is desirable to view the data of an N-dimensional array as a linear array, possibly with a (unsafe) reinterpretation of the element type. More...
 
template<typename ElementType >
array_view< const ElementType, 1 > reinterpret_as () const __CPU__ __HC__
 Sometimes it is desirable to view the data of an N-dimensional array as a linear array, possibly with a (unsafe) reinterpretation of the element type. More...
 
template<int K>
array_view< T, K > view_as (const extent< K > &viewExtent) __CPU__ __HC__
 An array of higher rank can be reshaped into an array of lower rank, or vice versa, using the view_as member function. More...
 
template<int K>
array_view< const T, K > view_as (const extent< K > &viewExtent) const __CPU__ __HC__
 An array of higher rank can be reshaped into an array of lower rank, or vice versa, using the view_as member function. More...
 

Static Public Attributes

static const int rank = N
 The rank of this array.
 

Friends

template<typename K , int Q>
struct projection_helper
 
template<typename K , int Q>
struct array_projection_helper
 
template<typename Q , int K>
void copy (const array< Q, K > &, const array_view< Q, K > &)
 
template<typename Q , int K>
void copy (const array_view< const Q, K > &, array< Q, K > &)
 

Detailed Description

template<typename T, int N = 1>
class hc::array< T, N >

Represents an N-dimensional region of memory (with type T) located on an accelerator.

Template Parameters
TThe element type of this array
NThe dimensionality of the array, defaults to 1 if elided.

Constructor & Destructor Documentation

template<typename T, int N = 1>
hc::array< T, N >::array ( const array< T, N > &  other)
inline

Copy constructor.

Constructs a new array<T,N> from the supplied argument other. The new array is located on the same accelerator_view as the source array. A deep copy is performed.

Parameters
[in]otherAn object of type array<T,N> from which to initialize this new array.

References hc::copy().

template<typename T, int N = 1>
hc::array< T, N >::array ( array< T, N > &&  other)
inline

Move constructor.

Constructs a new array<T,N> by moving from the supplied argument other.

Parameters
[in]otherAn object of type array<T,N> from which to initialize this new array.
template<typename T, int N = 1>
hc::array< T, N >::array ( const extent< N > &  ext)
inlineexplicit

Constructs a new array with the supplied extent, located on the default view of the default accelerator.

If any components of the extent are non-positive, an exception will be thrown.

Parameters
[in]extThe extent in each dimension of this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0)
inlineexplicit

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]))".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
int  e1 
)
inlineexplicit

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]))".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2 
)
inlineexplicit

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]))".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( const extent< N > &  ext,
InputIter  srcBegin 
)
inline

Constructs a new array with the supplied extent, located on the default accelerator, initialized with the contents of a source container specified by a beginning and optional ending iterator.

The source data is copied by value into this array as if by calling "copy()".

If the number of available container elements is less than this->extent.size(), undefined behavior results.

Parameters
[in]extThe extent in each dimension of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( const extent< N > &  ext,
InputIter  srcBegin,
InputIter  srcEnd 
)
inline

Constructs a new array with the supplied extent, located on the default accelerator, initialized with the contents of a source container specified by a beginning and optional ending iterator.

The source data is copied by value into this array as if by calling "copy()".

If the number of available container elements is less than this->extent.size(), undefined behavior results.

Parameters
[in]extThe extent in each dimension of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
InputIter  srcBegin 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
InputIter  srcBegin,
InputIter  srcEnd 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
InputIter  srcBegin 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
InputIter  srcBegin,
InputIter  srcEnd 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
InputIter  srcBegin 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
InputIter  srcBegin,
InputIter  srcEnd 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
template<typename T, int N = 1>
hc::array< T, N >::array ( const array_view< const T, N > &  src)
inlineexplicit

Constructs a new array, located on the default view of the default accelerator, initialized with the contents of the array_view "src".

The extent of this array is taken from the extent of the source array_view. The "src" is copied by value into this array as if by calling "copy(src, *this)".

Parameters
[in]srcAn array_view object from which to copy the data into this array (and also to determine the extent of this array).

References hc::copy().

template<typename T, int N = 1>
hc::array< T, N >::array ( const extent< N > &  ext,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Constructs a new array with the supplied extent, located on the accelerator bound to the accelerator_view "av".

Users can optionally specify the type of CPU access desired for "this" array thus requesting creation of an array that is accessible both on the specified accelerator_view "av" as well as the CPU (with the specified CPU access_type). If a value other than access_type_auto or access_type_none is specified for the cpu_access_type parameter and the accelerator corresponding to the accelerator_view "av" does not support cpu_shared_memory, a runtime_exception is thrown. The cpu_access_type parameter has a default value of access_type_auto which leaves it up to the implementation to decide what type of allowed CPU access should the array be created with. The actual CPU access_type allowed for the created array can be queried using the get_cpu_access_type member method.

Parameters
[in]extThe extent in each dimension of this array.
[in]avAn accelerator_view object which specifies the location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( const extent< N > &  ext,
accelerator_view  av,
void *  accelerator_pointer,
access_type  cpu_access_type = access_type_auto 
)
inlineexplicit

Constructs an array instance based on the given pointer on the device memory.

Parameters
[in]extThe extent in each dimension of this array.
[in]avAn accelerator_view object which specifies the location of this array.
[in]accelerator_pointerThe pointer to the device memory.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]avAn accelerator_view object which specifies the location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
int  e1,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]avAn accelerator_view object which specifies the location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]avAn accelerator_view object which specifies the location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( const extent< N > &  ext,
InputIter  srcBegin,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Constructs a new array with the supplied extent, located on the accelerator bound to the accelerator_view "av", initialized with the contents of the source container specified by a beginning and optional ending iterator.

The data is copied by value into this array as if by calling "copy()".

Users can optionally specify the type of CPU access desired for "this" array thus requesting creation of an array that is accessible both on the specified accelerator_view "av" as well as the CPU (with the specified CPU access_type). If a value other than access_type_auto or access_type_none is specified for the cpu_access_type parameter and the accelerator corresponding to the accelerator_view "av" does not support cpu_shared_memory, a runtime_exception is thrown. The cpu_access_type parameter has a default value of access_type_auto which leaves it upto the implementation to decide what type of allowed CPU access should the array be created with. The actual CPU access_type allowed for the created array can be queried using the get_cpu_access_type member method.

Parameters
[in]extThe extent in each dimension of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.

References hc::copy(), and hc::extent< N >::size().

template<typename T, int N = 1>
hc::array< T, N >::array ( const array_view< const T, N > &  src,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Constructs a new array initialized with the contents of the array_view "src".

The extent of this array is taken from the extent of the source array_view. The "src" is copied by value into this array as if by calling "copy(src, *this)". The new array is located on the accelerator bound to the accelerator_view "av".

Users can optionally specify the type of CPU access desired for "this" array thus requesting creation of an array that is accessible both on the specified accelerator_view "av" as well as the CPU (with the specified CPU access_type). If a value other than access_type_auto or access_type_none is specified for the cpu_access_type parameter and the accelerator corresponding to the accelerator_view “av” does not support cpu_shared_memory, a runtime_exception is thrown. The cpu_access_type parameter has a default value of access_type_auto which leaves it upto the implementation to decide what type of allowed CPU access should the array be created with. The actual CPU access_type allowed for the created array can be queried using the get_cpu_access_type member method.

Parameters
[in]srcAn array_view object from which to copy the data into this array (and also to determine the extent of this array).
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.

References hc::copy().

template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
InputIter  srcBegin,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
InputIter  srcBegin,
InputIter  srcEnd,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
InputIter  srcBegin,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
InputIter  srcBegin,
InputIter  srcEnd,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
InputIter  srcBegin,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
InputIter  srcBegin,
InputIter  srcEnd,
accelerator_view  av,
access_type  cpu_access_type = access_type_auto 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), srcBegin [, srcEnd], av, cpu_access_type)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]access_typeThe type of CPU access desired for this array.
template<typename T, int N = 1>
hc::array< T, N >::array ( const extent< N > &  ext,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Constructs a staging array with the given extent, which acts as a staging area between accelerator views "av" and "associated_av".

If "av" is a cpu accelerator view, this will construct a staging array which is optimized for data transfers between the CPU and "associated_av".

Parameters
[in]extThe extent in each dimension of this array.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
int  e1,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( const extent< N > &  ext,
InputIter  srcBegin,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Constructs a staging array with the given extent, which acts as a staging area between accelerator_views "av" (which must be the CPU accelerator) and "associated_av".

The staging array will be initialized with the data specified by "src" as if by calling "copy(src, *this)".

Parameters
[in]extThe extent in each dimension of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.

References hc::copy().

template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( const extent< N > &  ext,
InputIter  srcBegin,
InputIter  srcEnd,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Constructs a staging array with the given extent, which acts as a staging area between accelerator_views "av" (which must be the CPU accelerator) and "associated_av".

The staging array will be initialized with the data specified by "src" as if by calling "copy(src, *this)".

Parameters
[in]extThe extent in each dimension of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.

References hc::copy(), and hc::extent< N >::size().

template<typename T, int N = 1>
hc::array< T, N >::array ( const array_view< const T, N > &  src,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Constructs a staging array initialized with the array_view given by "src", which acts as a staging area between accelerator_views "av" (which must be the CPU accelerator) and "associated_av".

The extent of this array is taken from the extent of the source array_view. The staging array will be initialized from "src" as if by calling "copy(src, *this)".

Parameters
[in]srcAn array_view object from which to copy the data into this array (and also to determine the extent of this array).
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.

References hc::copy().

template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
InputIter  srcBegin,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
InputIter  srcBegin,
InputIter  srcEnd,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
InputIter  srcBegin,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
InputIter  srcBegin,
InputIter  srcEnd,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
InputIter  srcBegin,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.
template<typename T, int N = 1>
template<typename InputIter >
hc::array< T, N >::array ( int  e0,
int  e1,
int  e2,
InputIter  srcBegin,
InputIter  srcEnd,
accelerator_view  av,
accelerator_view  associated_av 
)
inline

Equivalent to construction using "array(extent<N>(e0 [, e1 [, e2 ]]), src, av, associated_av)".

Parameters
[in]e0,e1,e2The component values that will form the extent of this array.
[in]srcBeginA beginning iterator into the source container.
[in]srcEndAn ending iterator into the source container.
[in]avAn accelerator_view object which specifies the home location of this array.
[in]associated_avAn accelerator_view object which specifies a target device accelerator.

Member Function Documentation

template<typename T, int N = 1>
T* hc::array< T, N >::accelerator_pointer ( ) const
inline

Returns a pointer to the device memory underlying this array.

Returns
A (const) pointer to the first element in the array on the device memory.
template<typename T, int N = 1>
void hc::array< T, N >::copy_to ( array< T, N > &  dest) const
inline

Copies the contents of this array to the array given by "dest", as if by calling "copy(*this, dest)".

Parameters
[out]destAn object of type array<T,N> to which to copy data from this array.

References hc::copy().

template<typename T, int N = 1>
void hc::array< T, N >::copy_to ( const array_view< T, N > &  dest) const
inline

Copies the contents of this array to the array_view given by "dest", as if by calling "copy(*this, dest)".

Parameters
[out]destAn object of type array_view<T,N> to which to copy data from this array.

References hc::copy().

template<typename T, int N = 1>
T* hc::array< T, N >::data ( ) const
inline

Returns a pointer to the raw data underlying this array.

Returns
A (const) pointer to the first element in the linearized array.
template<typename T, int N = 1>
hc::array< T, N >::operator std::vector< T > ( ) const
inline

Implicitly converts an array to a std::vector, as if by "copy(*this, vector)".

Returns
An object of type vector<T> which contains a copy of the data contained on the array.

References hc::copy(), and hc::extent< N >::size().

template<typename T, int N = 1>
T& hc::array< T, N >::operator() ( const index< N > &  idx)
inline

Returns a reference to the element of this array that is at the location in N-dimensional space specified by "idx".

Accessing array data on a location where it is not resident (e.g. from the CPU when it is resident on a GPU) results in an exception (in cpu context) or undefined behavior (in GPU context).

Parameters
[in]idxAn object of type index<N> from that specifies the location of the element.
template<typename T, int N = 1>
const T& hc::array< T, N >::operator() ( const index< N > &  idx) const
inline

Returns a const reference to the element of this array that is at the location in N-dimensional space specified by "idx".

Accessing array data on a location where it is not resident (e.g. from the CPU when it is resident on a GPU) results in an exception (in cpu context) or undefined behavior (in GPU context).

Parameters
[in]idxAn object of type index<N> from that specifies the location of the element.
template<typename T, int N = 1>
T& hc::array< T, N >::operator() ( int  i0,
int  i1 
)
inline

Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]]))".

Parameters
[in]i0,i1,i2The component values that will form the index into this array.
template<typename T, int N = 1>
T& hc::array< T, N >::operator() ( int  i0,
int  i1,
int  i2 
)
inline

Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]]))".

Parameters
[in]i0,i1,i2The component values that will form the index into this array.
template<typename T, int N = 1>
const T& hc::array< T, N >::operator() ( int  i0,
int  i1 
) const
inline

Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the index into this array.
template<typename T, int N = 1>
const T& hc::array< T, N >::operator() ( int  i0,
int  i1,
int  i2 
) const
inline

Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the index into this array.
template<typename T, int N = 1>
array_projection_helper<T, N>::result_type hc::array< T, N >::operator() ( int  i0)
inline

Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the index into this array.
template<typename T, int N = 1>
array_projection_helper<T, N>::const_result_type hc::array< T, N >::operator() ( int  i0) const
inline

Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the index into this array.
template<typename T, int N = 1>
array& hc::array< T, N >::operator= ( const array< T, N > &  other)
inline

Assigns the contents of the array "other" to this array, using a deep copy.

Parameters
[in]otherAn object of type array<T,N> from which to copy into this array.
Returns
Returns *this.
template<typename T, int N = 1>
array& hc::array< T, N >::operator= ( array< T, N > &&  other)
inline

Moves the contents of the array "other" to this array.

Parameters
[in]otherAn object of type array<T,N> from which to move into this array.
Returns
Returns *this.

References hc::extent< N >::extent().

template<typename T, int N = 1>
array& hc::array< T, N >::operator= ( const array_view< T, N > &  src)
inline

Assigns the contents of the array_view "src", as if by calling "copy(src, *this)".

Parameters
[in]srcAn object of type array_view<T,N> from which to copy into this array.
Returns
Returns *this.
template<typename T, int N = 1>
T& hc::array< T, N >::operator[] ( const index< N > &  idx)
inline

Returns a reference to the element of this array that is at the location in N-dimensional space specified by "idx".

Accessing array data on a location where it is not resident (e.g. from the CPU when it is resident on a GPU) results in an exception (in cpu context) or undefined behavior (in GPU context).

Parameters
[in]idxAn object of type index<N> from that specifies the location of the element.
template<typename T, int N = 1>
const T& hc::array< T, N >::operator[] ( const index< N > &  idx) const
inline

Returns a const reference to the element of this array that is at the location in N-dimensional space specified by "idx".

Accessing array data on a location where it is not resident (e.g. from the CPU when it is resident on a GPU) results in an exception (in cpu context) or undefined behavior (in GPU context).

Parameters
[in]idxAn object of type index<N> from that specifies the location of the element.
template<typename T, int N = 1>
array_projection_helper<T, N>::result_type hc::array< T, N >::operator[] ( int  i)
inline

This overload is defined for array<T,N> where $N \ge 2$.

This mode of indexing is equivalent to projecting on the most-significant dimension. It allows C-style indexing. For example:

array<float,4> myArray(myExtents, …);
myArray[index<4>(5,4,3,2)] = 7;
assert(myArray[5][4][3][2] == 7);
Parameters
i0An integer that is the index into the most-significant dimension of this array.
Returns
Returns an array_view whose dimension is one lower than that of this array.
template<typename T, int N = 1>
array_projection_helper<T, N>::const_result_type hc::array< T, N >::operator[] ( int  i) const
inline

Equivalent to "array<T,N>::operator()(index<N>(i0 [, i1 [, i2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the index into this array.
template<typename T, int N = 1>
template<typename ElementType >
array_view<ElementType, 1> hc::array< T, N >::reinterpret_as ( )
inline

Sometimes it is desirable to view the data of an N-dimensional array as a linear array, possibly with a (unsafe) reinterpretation of the element type.

This can be achieved through the reinterpret_as member function. Example:

struct RGB { float r; float g; float b; };
array<RGB,3> a = ...;
array_view<float,1> v = a.reinterpret_as<float>();
assert(v.extent == 3*a.extent);

The size of the reinterpreted ElementType must evenly divide into the total size of this array.

Returns
Returns an array_view from this array<T,N> with the element type reinterpreted from T to ElementType, and the rank reduced from N to 1.

References hc::extent< N >::size().

template<typename T, int N = 1>
template<typename ElementType >
array_view<const ElementType, 1> hc::array< T, N >::reinterpret_as ( ) const
inline

Sometimes it is desirable to view the data of an N-dimensional array as a linear array, possibly with a (unsafe) reinterpretation of the element type.

This can be achieved through the reinterpret_as member function. Example:

struct RGB { float r; float g; float b; };
array<RGB,3> a = ...;
array_view<float,1> v = a.reinterpret_as<float>();
assert(v.extent == 3*a.extent);

The size of the reinterpreted ElementType must evenly divide into the total size of this array.

Returns
Returns an array_view from this array<T,N> with the element type reinterpreted from T to ElementType, and the rank reduced from N to 1.

References hc::extent< N >::size().

template<typename T, int N = 1>
array_view<T, N> hc::array< T, N >::section ( const index< N > &  origin,
const extent< N > &  ext 
)
inline

Returns a subsection of the source array view at the origin specified by "idx" and with the extent specified by "ext".

Example:

array<float,2> a(extent<2>(200,100));
array_view<float,2> v1(a); // v1.extent = <200,100>
array_view<float,2> v2 = v1.section(index<2>(15,25), extent<2>(40,50));
assert(v2(0,0) == v1(15,25));
Parameters
[in]originProvides the offset/origin of the resulting section.
[in]extProvides the extent of the resulting section.
Returns
Returns a subsection of the source array at specified origin, and with the specified extent.

References hc::array_view< T, N >::section().

template<typename T, int N = 1>
array_view<const T, N> hc::array< T, N >::section ( const index< N > &  origin,
const extent< N > &  ext 
) const
inline

Returns a subsection of the source array view at the origin specified by "idx" and with the extent specified by "ext".

Example:

array<float,2> a(extent<2>(200,100));
array_view<float,2> v1(a); // v1.extent = <200,100>
array_view<float,2> v2 = v1.section(index<2>(15,25), extent<2>(40,50));
assert(v2(0,0) == v1(15,25));
Parameters
[in]originProvides the offset/origin of the resulting section.
[in]extProvides the extent of the resulting section.
Returns
Returns a subsection of the source array at specified origin, and with the specified extent.

References hc::array_view< const T, N >::section().

template<typename T, int N = 1>
array_view<T, 1> hc::array< T, N >::section ( int  i0,
int  e0 
)
inline

Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the origin of the section
[in]e0,e1,e2The component values that will form the extent of the section
template<typename T, int N = 1>
array_view<const T, 1> hc::array< T, N >::section ( int  i0,
int  e0 
) const
inline

Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the origin of the section
[in]e0,e1,e2The component values that will form the extent of the section
template<typename T, int N = 1>
array_view<T, 2> hc::array< T, N >::section ( int  i0,
int  i1,
int  e0,
int  e1 
) const
inline

Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the origin of the section
[in]e0,e1,e2The component values that will form the extent of the section
template<typename T, int N = 1>
array_view<T, 2> hc::array< T, N >::section ( int  i0,
int  i1,
int  e0,
int  e1 
)
inline

Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the origin of the section
[in]e0,e1,e2The component values that will form the extent of the section
template<typename T, int N = 1>
array_view<T, 3> hc::array< T, N >::section ( int  i0,
int  i1,
int  i2,
int  e0,
int  e1,
int  e2 
)
inline

Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the origin of the section
[in]e0,e1,e2The component values that will form the extent of the section
template<typename T, int N = 1>
array_view<const T, 3> hc::array< T, N >::section ( int  i0,
int  i1,
int  i2,
int  e0,
int  e1,
int  e2 
) const
inline

Equivalent to "array<T,N>::section(index<N>(i0 [, i1 [, i2 ]]), extent<N>(e0 [, e1 [, e2 ]])) const".

Parameters
[in]i0,i1,i2The component values that will form the origin of the section
[in]e0,e1,e2The component values that will form the extent of the section
template<typename T, int N = 1>
template<int K>
array_view<T, K> hc::array< T, N >::view_as ( const extent< K > &  viewExtent)
inline

An array of higher rank can be reshaped into an array of lower rank, or vice versa, using the view_as member function.

Example:

array<float,1> a(100);
array_view<float,2> av = a.view_as(extent<2>(2,50));
Returns
Returns an array_view from this array<T,N> with the rank changed to K from N.

References hc::extent< N >::size().

template<typename T, int N = 1>
template<int K>
array_view<const T, K> hc::array< T, N >::view_as ( const extent< K > &  viewExtent) const
inline

An array of higher rank can be reshaped into an array of lower rank, or vice versa, using the view_as member function.

Example:

array<float,1> a(100);
array_view<float,2> av = a.view_as(extent<2>(2,50));
Returns
Returns an array_view from this array<T,N> with the rank changed to K from N.

References hc::copy(), and hc::extent< N >::size().


The documentation for this class was generated from the following file: