Template Numerical Library version\ main:1437bf49
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
TNL::Containers::NDArray< Value, SizesHolder, Permutation, Device, Index, Overlaps, Allocator > Class Template Reference

Dynamic N-dimensional array. More...

#include <TNL/Containers/NDArray.h>

Inheritance diagram for TNL::Containers::NDArray< Value, SizesHolder, Permutation, Device, Index, Overlaps, Allocator >:
Inheritance graph
[legend]
Collaboration diagram for TNL::Containers::NDArray< Value, SizesHolder, Permutation, Device, Index, Overlaps, Allocator >:
Collaboration graph
[legend]

Public Types

using AllocatorType = Allocator
 Allocator type used for allocating the array.
 
- Public Types inherited from TNL::Containers::NDArrayStorage< Array, Indexer, Device >
using ConstViewType = NDArrayView< std::add_const_t< ValueType >, DeviceType, IndexerType >
 Compatible constant NDArrayView type.
 
using DeviceType = Device
 Type of the device used for running operations on the array.
 
using IndexerType = Indexer
 Type of the N-dimensional indexer, NDArrayIndexer.
 
using IndexType = typename Indexer::IndexType
 Type of indices used for addressing the array elements.
 
using OverlapsType = typename Indexer::OverlapsType
 Sequence of integers representing the overlaps in each dimension of a distributed N-dimensional array.
 
using PermutationType = typename Indexer::PermutationType
 Permutation that is applied to indices when accessing the array elements.
 
using SizesHolderType = typename Indexer::SizesHolderType
 Type of the underlying object which represents the sizes of the N-dimensional array.
 
using StorageArray = Array
 Type of the underlying one-dimensional array storing the elements.
 
using ValueType = typename Array::ValueType
 Type of the values stored in the array.
 
using ViewType = NDArrayView< ValueType, DeviceType, IndexerType >
 Compatible NDArrayView type.
 

Public Member Functions

 NDArray ()=default
 Constructs an empty array with zero size.
 
 NDArray (const AllocatorType &allocator)
 Constructs an empty array and sets the provided allocator.
 
 NDArray (const NDArray &other, const AllocatorType &allocator)
 Copy constructor with a specific allocator (makes a deep copy).
 
AllocatorType getAllocator () const
 Returns the allocator associated with the array.
 
NDArrayStorageoperator= (const NDArrayStorage &other)=default
 Copy-assignment operator for deep-copying data from another array. Mismatched sizes cause reallocations.
 
template<typename OtherArray >
NDArrayStorageoperator= (const OtherArray &other)
 Templated copy-assignment operator for deep-copying data from another array.
 
NDArrayStorageoperator= (NDArrayStorage &&) noexcept(false)=default
 Move-assignment operator for acquiring data from rvalues.
 
- Public Member Functions inherited from TNL::Containers::NDArrayStorage< Array, Indexer, Device >
 NDArrayStorage ()=default
 Constructs an empty storage with zero size.
 
 NDArrayStorage (const NDArrayStorage &)=default
 Copy constructor (makes a deep copy).
 
 NDArrayStorage (NDArrayStorage &&) noexcept=default
 Move constructor for initialization from rvalues.
 
template<typename Device2 = DeviceType, typename Func >
void forAll (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const
 Evaluates the function f in parallel for all elements of the array.
 
template<typename Device2 = DeviceType, typename SkipBegins , typename SkipEnds , typename Func >
void forBoundary (const SkipBegins &skipBegins, const SkipEnds &skipEnds, Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const
 Evaluates the function f in parallel for all elements of the array outside the N-dimensional interval [skipBegins, skipEnds).
 
template<typename Device2 = DeviceType, typename Func >
void forBoundary (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const
 Evaluates the function f in parallel for all boundary elements of the array.
 
template<typename Device2 = DeviceType, typename Begins , typename Ends , typename Func >
void forInterior (const Begins &begins, const Ends &ends, Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const
 Evaluates the function f in parallel for all elements of the array inside the N-dimensional interval [begins, ends).
 
template<typename Device2 = DeviceType, typename Func >
void forInterior (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const
 Evaluates the function f in parallel for all internal elements of the array.
 
__cuda_callable__ ConstViewType getConstView () const
 Returns a non-modifiable view of the array.
 
__cuda_callable__ ValueTypegetData ()
 Returns a raw pointer to the data.
 
__cuda_callable__ std::add_const_t< ValueType > * getData () const
 Returns a const-qualified raw pointer to the data.
 
template<typename... IndexTypes>
ValueType getElement (IndexTypes &&... indices) const
 A "safe" accessor for array elements.
 
__cuda_callable__ const IndexerTypegetIndexer () const
 Returns a const-qualified reference to the underlying indexer.
 
StorageArraygetStorageArray ()
 Returns a reference to the underlying storage array.
 
const StorageArraygetStorageArray () const
 Returns a constant reference to the underlying storage array.
 
template<std::size_t... Dimensions, typename... IndexTypes>
__cuda_callable__ auto getSubarrayView (IndexTypes &&... indices)
 Returns a modifiable view of a subarray.
 
__cuda_callable__ ViewType getView ()
 Returns a modifiable view of the array.
 
bool operator!= (const NDArrayStorage &other) const
 Compares the array with another N-dimensional array.
 
template<typename... IndexTypes>
__cuda_callable__ ValueTypeoperator() (IndexTypes &&... indices)
 Accesses an element of the array.
 
template<typename... IndexTypes>
__cuda_callable__ const ValueTypeoperator() (IndexTypes &&... indices) const
 Accesses an element of the array.
 
NDArrayStorageoperator= (const NDArrayStorage &other)=default
 Copy-assignment operator for deep-copying data from another array. Mismatched sizes cause reallocations.
 
template<typename OtherArray >
NDArrayStorageoperator= (const OtherArray &other)
 Templated copy-assignment operator for deep-copying data from another array.
 
NDArrayStorageoperator= (NDArrayStorage &&) noexcept(false)=default
 Move-assignment operator for acquiring data from rvalues.
 
bool operator== (const NDArrayStorage &other) const
 Compares the array with another N-dimensional array.
 
__cuda_callable__ ValueTypeoperator[] (IndexType index)
 Accesses an element in a one-dimensional array.
 
__cuda_callable__ const ValueTypeoperator[] (IndexType index) const
 Accesses an element in a one-dimensional array.
 
void reset ()
 Resets the array to the empty state.
 
void setLike (const NDArrayStorage &other)
 Sets sizes of the array to the sizes of an existing array.
 
void setSize (const SizesHolderType &sizes)
 Sets sizes of the array using an instance of SizesHolder.
 
template<typename... IndexTypes>
void setSizes (IndexTypes &&... sizes)
 Sets sizes of the array using raw integers.
 
void setValue (ValueType value)
 Sets all elements of the array to given value.
 

Additional Inherited Members

- Protected Attributes inherited from TNL::Containers::NDArrayStorage< Array, Indexer, Device >
StorageArray array
 Underlying one-dimensional array which stores the data.
 
IndexerType indexer
 Object which transforms the multi-dimensional indices to a one-dimensional index.
 

Detailed Description

template<typename Value, typename SizesHolder, typename Permutation = std::make_index_sequence< SizesHolder::getDimension() >, typename Device = Devices::Host, typename Index = typename SizesHolder::IndexType, typename Overlaps = ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >, typename Allocator = typename Allocators::Default< Device >::template Allocator< Value >>
class TNL::Containers::NDArray< Value, SizesHolder, Permutation, Device, Index, Overlaps, Allocator >

Dynamic N-dimensional array.

Template Parameters
ValueType of the values stored in the array.
SizesHolderInstance of SizesHolder that will represent the array sizes.
PermutationPermutation that will be applied to indices when accessing the array elements. The identity permutation is used by default.
DeviceType of the device that will be used for running operations on the array.
IndexType of indices used for addressing the array elements.
OverlapsSequence of integers representing the overlaps in each dimension a distributed N-dimensional array.
AllocatorType of the allocator that will be used for allocating elements of the array.

See also the Users' Guide.


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