Skip to content

ArrayImpl

#include <ncarray/array_impl.hh>
template<typename Layout, typename Storage>
class ArrayImpl

Defined in src/lib/ncarray/array_impl.hh:148

Inherits: Layout, Storage

The ArrayImpl provides the mean entry point for all array types. It is a templated class inheriting from Layout and Storage classes, allowing it to be customized to different kinds of array setups. E.g. suboffsets and NCArray style classes are both accessed via the ArrayImpl.

The class provides indexing operations as well as utilities such as repr. Class member functions are implemented in array_operations and the two headers must be combined, in the include order, array_impl then array_operations.

Name Kind Owner
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
operator= function Declared here
operator= function Declared here
operator= function Declared here
operator= function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
ArrayImpl function Declared here
nbytes function Declared here
operator() function Declared here
operator[] function Declared here
operator[] function Declared here
lin_to_md function Declared here
md_to_lin function Declared here
operator[] function Declared here
operator[] function Declared here
operator[] function Declared here
operator[] function Declared here
view_from_indices function Declared here
out_from_axes_ptr function Declared here
view function Declared here
copy_into function Declared here
copy_into_astype function Declared here
to_contiguous function Declared here
is_contiguous function Declared here
astype function Declared here
fill function Declared here
assign function Declared here
squeeze function Declared here
reshape function Declared here
copy_as_shape function Declared here
sum function Declared here
max function Declared here
argmax function Declared here
min function Declared here
argmin function Declared here
mean function Declared here
var function Declared here
std function Declared here
all function Declared here
any function Declared here
sum function Declared here
max function Declared here
argmax function Declared here
min function Declared here
argmin function Declared here
mean function Declared here
var function Declared here
std function Declared here
all function Declared here
any function Declared here
get_scalar function Declared here
operator= function Declared here
iota function Declared here
operator- function Declared here
operator++ function Declared here
operator-- function Declared here
operator! function Declared here
operator+ function Declared here
operator- function Declared here
operator* function Declared here
operator/ function Declared here
operator% function Declared here
operator+= function Declared here
operator-= function Declared here
operator*= function Declared here
operator/= function Declared here
operator== function Declared here
operator!= function Declared here
operator< function Declared here
operator<= function Declared here
operator> function Declared here
operator>= function Declared here
operator&& function Declared here
[`operator `](#operator-34)
operator&= function Declared here
[`operator =`](#operator-36) function
begin function Declared here
end function Declared here
begin function Declared here
end function Declared here
repr function Declared here
iota function Declared here
class_name function Declared here
repr_recursive function Declared here
repr_recursive_dispatched function Declared here
StoragePolicy typedef Declared here
LayoutPolicy typedef Declared here
MemType typedef Declared here
VPolicy typedef Declared here
OPolicy typedef Declared here
ViewType typedef Declared here
OwnerType typedef Declared here
ExprResult typedef Declared here
Iterator typedef Declared here
ConstIterator typedef Declared here
Return Name Description
ArrayImpl Defaulted constructor.
ArrayImpl inline requires std::is_base_of_v<OwnerTag, Storage> Copy constructor for owner type arrays.
ArrayImpl inline noexcept requires std::is_base_of_v<OwnerTag, Storage> Move constructor for owner type arrays.
NCA_HD ArrayImpl inline requires (!hd_std::is_base_of_v<OwnerTag, Storage>) Copy constructor for view/reference type interconversion.
NCA_HD ArrayImpl inline noexcept requires (!hd_std::is_base_of_v<OwnerTag, Storage>) Move constructor for view/reference type interconversion.
NCA_HD ArrayImpl inline requires hd_std::is_base_of_v<ViewTag, Storage> Universal copy to view constructor.
NCA_HD ArrayImpl inline noexcept requires hd_std::is_base_of_v<ViewTag, Storage> Universal move to view constructor.
ArrayImpl & operator= inline requires hd_std::is_base_of_v<OwnerTag, Storage> Copy constructor for Owner type arrays.
ArrayImpl & operator= inline noexcept requires hd_std::is_base_of_v<OwnerTag, Storage> Move constructor for Owner type arrays.
NCA_HDArrayImpl & operator= inline requires (!hd_std::is_base_of_v<OwnerTag, Storage>) Copy constructor for non-Owner type arrays.
NCA_HDArrayImpl & operator= inline noexcept requires (!hd_std::is_base_of_v<OwnerTag, Storage>) Move constructor for non-Owner type arrays.
NCA_HD ArrayImpl inline Construct a new array (generally view type). This constructor allows passing explicit offsets/suboffsets.
NCA_HD ArrayImpl inline Construct a new array (generally view type).
NCA_HD ArrayImpl inline Construct a new reference-style array given a shape and datatype.
ArrayImpl inline Construct a new array given a shape and datatype. This will generally be used for Owner type arrays.
ArrayImpl inline Construct a new array given a shape and datatype. This will generally be used for Owner type arrays.
ArrayImpl inline Construct a new array given a shape and datatype. This will generally be used for Owner type arrays.
ArrayImpl inline Expression-materializing constructor.
NCA_HD ssize_t nbytes const inline The total number of bytes contained in the array (shape * itemsize).
NCA_HDViewType operator() const inline requires (sizeof...(Args) >= 0 && (IndexArg<Args> && ...)) Variadic, multi-element operator() for indexing to an array view.
NCA_HDArrayElementProxy operator[] inline
NCA_HD const ArrayElementProxy operator[] const inline
NCA_HD void lin_to_md inline Convert a linearized ravel index into a multi-dimensional coords struct.
NCA_HD ssize_t md_to_lin inline Convert a multi-dimensional coords struct to a linearized index.
NCA_HDArrayElementProxy operator[] inline A single Coords struct operator[] overload to index to proxy reference.
NCA_HD const ArrayElementProxy operator[] const inline A single Coords struct operator[] overload to index to proxy reference.
NCA_HDArrayElementProxy operator[] inline The initializer list overloader are for indexing down to a proxy reference.
NCA_HD const ArrayElementProxy operator[] const inline The initializer list overloader are for indexing down to a proxy reference.
NCA_HDViewType view_from_indices const inline Provided a set of indices, construct a new ViewType of array.
NCA_HD VT out_from_axes_ptr const inline Traverse a data pointer using per axis specifications for shapes, strides, and offsets/suboffsets etc.
NCA_HDViewType view const inline Construct a view of any array.
void copy_into const Copy the array’s data into the provided buffer.
void copy_into_astype const Copy the array’s data into the provided buffer while casting.
OwnerType to_contiguous const Convert an array to a new contiguous array.
NCA_HD bool is_contiguous const inline Check whether the array’s current data is a contiguous block.
OwnerType astype const Convert an array to an array of a new DType.
void fill Fill all elements of an array with the provided value. The array must not be read-only.
void assign Fill all elements of an array with the elements of the input array.
ViewType squeeze const inline Return a new array view with axes of size 1 “squeezed” (removed).
NCA_HDViewType reshape const inline This function for reshaping assumes contiguity. It is user responsibility to ensure that this is true!
OwnerType copy_as_shape const inline For non-contiguous arrays, there is no mathematical formula to reshape in the general case. This function provides a copy and reshape utility to return a new array of the specified shape.
OwnerType sum const Perform a sum along the set of provided axes.
OwnerType max const Calculate the maximum along the set of provided axes.
OwnerType argmax const Determine the index of the maximum along the set of provided axes.
OwnerType min const Calculate the minimum along the set of provided axes.
OwnerType argmin const Determine the index of the minima along the set of provided axes.
OwnerType mean const Calculate the mean along the set of provided axes.
OwnerType var const Calculate the variance along the set of provided axes.
OwnerType std const Calculate the standard deviation along the set of provided axes.
OwnerType all const Return true along the provided axes if all values are “truthy.”
OwnerType any const Return true along the provided axes if any value is “truthy.”
Scalar sum const Perform a sum of all array elements.
Scalar max const Find the maximum of all array elements.
Scalar argmax const Find the index of the maximum of all array elements.
Scalar min const Find the minimum of all array elements.
Scalar argmin const Find the index of the minimum of all array elements.
Scalar mean const Find the mean of all array elements.
Scalar var const Find the variance of all array elements.
Scalar std const Find the standard deviation of all array elements.
Scalar all const Return truthy if all elements of the array are truthy.
Scalar any const Return truthy if any element of the array is truthy.
Scalar get_scalar const inline Return the underlying pointer to an array element as a Scalar variant.
ArrayImpl & operator= Evaluate an expression object into the array.
ExprResult iota const inline Generate an array using the APL-style index generator.
ExprResult operator- const inline Return an expression for the negation of the array.
ArrayImpl & operator++ inline Inplace increment each element of the array.
ArrayImpl & operator-- inline Inplace decrement each element of the array.
ExprResult operator! const inline Return an expression for the logical not of the array.
ExprResult operator+ const inline Return an expression for the sum of the array and the provided expression.
ExprResult operator- const Return an expression for the difference of an expression from the array.
ExprResult operator* const inline Return an expression for the product of the array and the provided expression.
ExprResult operator/ const inline Return an expression for the quotient of array over the provided expression.
ExprResult operator% const inline Return an expression for the remainder (modulo) of array over the provided expression.
ArrayImpl & operator+= inline Add an expression into an array inplace.
ArrayImpl & operator-= inline Subtract an expression from an array inplace.
ArrayImpl & operator*= inline Calculate the product of an expression into an array inplace.
ArrayImpl & operator/= inline Divide an expression into an array inplace.
ExprResult operator== const inline Return an expression for the elementwise equality test between the expression and array.
ExprResult operator!= const inline Return an expression for the elementwise inequality test between the expression and array.
ExprResult operator< const inline Return an expression for the elementwise less than test between the expression and array.
ExprResult operator<= const inline Return an expression for the elementwise less than or equal test between the expression and array.
ExprResult operator> const inline Return an expression for the elementwise greater than test between the expression and array.
ExprResult operator>= const inline Return an expression for the elementwise greater than or equal test between the expression and array.
ExprResult operator&& const inline Return an expression for the logical AND of the expression and array.
ExprResult [`operator
ArrayImpl & operator&= inline Calculate the logical AND of an expression and array in place.
ArrayImpl & [`operator =](#operator-36) inline`
Iterator begin Construct a non-const Iterator pointing to the first subview of the array.
Iterator end Construct a non-const Iterator pointing to the past the last subview of the array.
ConstIterator begin const Construct a const Iterator pointing to the first subview of the array.
ConstIterator end const Construct a const Iterator pointing to the past the last subview of the array.
std::string repr const inline Return a string representation of the data elements of the array.

ArrayImpl() = default

Defined in src/lib/ncarray/array_impl.hh:164

Defaulted constructor.


inline requires std::is_base_of_v<OwnerTag, Storage>

inline ArrayImpl(const ArrayImpl & other) requires std::is_base_of_v<OwnerTag, Storage>

Defined in src/lib/ncarray/array_impl.hh:184

Copy constructor for owner type arrays.

Unlike the constructors that follow, this is a deep copy. The actual data will be copied!


inline noexcept requires std::is_base_of_v<OwnerTag, Storage>

inline ArrayImpl(ArrayImpl && other) noexcept requires std::is_base_of_v<OwnerTag, Storage>

Defined in src/lib/ncarray/array_impl.hh:202

Move constructor for owner type arrays.


inline requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

inline NCA_HD ArrayImpl(const ArrayImpl & other) requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

Defined in src/lib/ncarray/array_impl.hh:220

Copy constructor for view/reference type interconversion.


inline noexcept requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

inline NCA_HD ArrayImpl(ArrayImpl && other) noexcept requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

Defined in src/lib/ncarray/array_impl.hh:243

Move constructor for view/reference type interconversion.


inline requires hd_std::is_base_of_v<ViewTag, Storage>

template<class OtherStorage> inline NCA_HD ArrayImpl(const ArrayImpl< Layout, OtherStorage > & other) requires hd_std::is_base_of_v<ViewTag, Storage>

Defined in src/lib/ncarray/array_impl.hh:269

Universal copy to view constructor.

All array’s can be copy constructed as their corresponding view.


inline noexcept requires hd_std::is_base_of_v<ViewTag, Storage>

template<class OtherStorage> inline NCA_HD ArrayImpl(ArrayImpl< Layout, OtherStorage > && other) noexcept requires hd_std::is_base_of_v<ViewTag, Storage>

Defined in src/lib/ncarray/array_impl.hh:287

Universal move to view constructor.

All array’s can be move constructed as their corresponding view.


inline requires hd_std::is_base_of_v<OwnerTag, Storage>

inline ArrayImpl & operator=(const ArrayImpl & other) requires hd_std::is_base_of_v<OwnerTag, Storage>

Defined in src/lib/ncarray/array_impl.hh:306

Copy constructor for Owner type arrays.


inline noexcept requires hd_std::is_base_of_v<OwnerTag, Storage>

inline ArrayImpl & operator=(ArrayImpl && other) noexcept requires hd_std::is_base_of_v<OwnerTag, Storage>

Defined in src/lib/ncarray/array_impl.hh:321

Move constructor for Owner type arrays.


inline requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

inline NCA_HDArrayImpl & operator=(const ArrayImpl & other) requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

Defined in src/lib/ncarray/array_impl.hh:342

Copy constructor for non-Owner type arrays.


inline noexcept requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

inline NCA_HDArrayImpl & operator=(ArrayImpl && other) noexcept requires (!hd_std::is_base_of_v<OwnerTag, Storage>)

Defined in src/lib/ncarray/array_impl.hh:357

Move constructor for non-Owner type arrays.


inline

inline NCA_HD ArrayImpl(void * data_, const Metadata shape_, const Metadata strides_, const Metadata offsets_, DType dtype_, ssize_t pointer_axis_, bool read_only_)

Defined in src/lib/ncarray/array_impl.hh:390

Construct a new array (generally view type). This constructor allows passing explicit offsets/suboffsets.

Parameter Type Description
data_ void * The underlying array data.
shape_ const [Metadata](api-ncarray.md#metadata) A pointer to the shape. Should be valid through ndim derefernces.
strides_ const [Metadata](api-ncarray.md#metadata) A pointer to the strides. Should be valid through ndim derefernces.
offsets_ const [Metadata](api-ncarray.md#metadata) A pointer to the offsets. Should be valid through ndim derefernces.
dtype_ [DType](api-ncarray.md#dtype) The datatype of the elements of the new array.
pointer_axis_ ssize_t Which if any axis is a pointer axis.
read_only_ bool Whether the underlying data is read-only.

inline

inline NCA_HD ArrayImpl(void * data_, const Metadata::value_type ndim, const Metadata::value_type * shape_, const Metadata::value_type * strides_, DType dtype_, Metadata::value_type pointer_axis_, bool read_only_)

Defined in src/lib/ncarray/array_impl.hh:429

Construct a new array (generally view type).

Parameter Type Description
data_ void * The underlying array data.
ndim const [Metadata::value_type](api-ncarray-FixedMetadata.md#value_type-2) The number of dimensions in the array.
shape_ const [Metadata::value_type](api-ncarray-FixedMetadata.md#value_type-2) * A pointer to the shape. Should be valid through ndim derefernces.
strides_ const [Metadata::value_type](api-ncarray-FixedMetadata.md#value_type-2) * A pointer to the strides. Should be valid through ndim derefernces.
dtype_ [DType](api-ncarray.md#dtype) The datatype of the elements of the new array.
pointer_axis_ [Metadata::value_type](api-ncarray-FixedMetadata.md#value_type-2) Which if any axis is a pointer axis.
read_only_ bool Whether the underlying data is read-only.

inline

inline NCA_HD ArrayImpl(const std::vector< void * > & data_ptrs, const std::vector< ssize_t > & shape_, const std::vector< ssize_t > & strides_, DType dtype_, Metadata::value_type pointer_axis_, bool read_only_)

Defined in src/lib/ncarray/array_impl.hh:469

Construct a new reference-style array given a shape and datatype.

Parameter Type Description
data_ptrs const std::vector< void * > & A vector of data pointers that makeup the array.
shape_ const std::vector< ssize_t > & The shape of the new ref array (using a std::vector).
strides_ const std::vector< ssize_t > & The strides of the new ref array (using a std::vector).
dtype_ [DType](api-ncarray.md#dtype) The datatype of the elements of the new array.
pointer_axis_ [Metadata::value_type](api-ncarray-FixedMetadata.md#value_type-2) Which if any axis is a pointer axis.
read_only_ bool Whether the underlying data is read-only.

inline

inline ArrayImpl(const std::vector< ssize_t > & shape_, DType dtype_)

Defined in src/lib/ncarray/array_impl.hh:520

Construct a new array given a shape and datatype. This will generally be used for Owner type arrays.

Parameter Type Description
shape_ const std::vector< ssize_t > & The shape of the new array (using a std::vector).
dtype_ [DType](api-ncarray.md#dtype) The datatype of the elements of the new array.

inline

inline ArrayImpl(const Metadata & shape_, DType dtype_)

Defined in src/lib/ncarray/array_impl.hh:565

Construct a new array given a shape and datatype. This will generally be used for Owner type arrays.

Parameter Type Description
shape_ const [Metadata](api-ncarray.md#metadata) & The shape of the new array (using the metadata struct).
dtype_ [DType](api-ncarray.md#dtype) The datatype of the elements of the new array.

inline

inline ArrayImpl(ssize_t ndim, const ssize_t * shape_, DType dtype_)

Defined in src/lib/ncarray/array_impl.hh:612

Construct a new array given a shape and datatype. This will generally be used for Owner type arrays.

Parameter Type Description
ndim ssize_t The number of dimensions (to properly increment the pointer).
shape_ const ssize_t * The shape of the new array (using a raw pointer).
dtype_ [DType](api-ncarray.md#dtype) The datatype of the elements of the new array.

inline

template<Expression Expr> inline ArrayImpl(const Expr & expr)

Defined in src/lib/ncarray/array_impl.hh:656

Expression-materializing constructor.

An array constructed via an expression object will have shape, and metadata determined by the expression. The expression will be evaluated into the array.

Parameter Type Description
expr const Expr & The expression to be evaluated.

const inline

inline NCA_HD ssize_t nbytes() const

Defined in src/lib/ncarray/array_impl.hh:667

The total number of bytes contained in the array (shape * itemsize).

The number of bytes.


const inline requires (sizeof...(Args) >= 0 && (IndexArg<Args> && ...))

template<typename... Args> inline NCA_HDViewType operator()(Args &&... idx_args) const requires (sizeof...(Args) >= 0 && (IndexArg<Args> && ...))

Defined in src/lib/ncarray/array_impl.hh:719

Variadic, multi-element operator() for indexing to an array view.

Index arguments must be either:

The subview array determined by the provided indices.


inline

inline NCA_HDArrayElementProxy operator[](ssize_t idx)

Defined in src/lib/ncarray/array_impl.hh:735


const inline

inline NCA_HD const ArrayElementProxy operator[](ssize_t idx) const

Defined in src/lib/ncarray/array_impl.hh:758


inline

template<typename Coords> inline NCA_HD void lin_to_md(ssize_t idx, Coords & coords)

Defined in src/lib/ncarray/array_impl.hh:791

Convert a linearized ravel index into a multi-dimensional coords struct.

Parameter Type Description
idx ssize_t The linearized input index.
coords Coords & The pre-created coords struct to be populated.

inline

template<typename Coords> inline NCA_HD ssize_t md_to_lin(Coords & coords)

Defined in src/lib/ncarray/array_impl.hh:822

Convert a multi-dimensional coords struct to a linearized index.

idx The linearized index.

Parameter Type Description
coords Coords & The pre-created coords struct with multi-dimensional indices.

inline

template<typename Coords> inline NCA_HDArrayElementProxy operator[](const Coords & coords)

Defined in src/lib/ncarray/array_impl.hh:847

A single Coords struct operator[] overload to index to proxy reference.

The StaticCoords object should be the correct dimensionality to match the array’s dimensionality. This is NOT checked in this function for performance reasons!

The proxy reference pointed to by the provided coords.

Parameter Type Description
coords const Coords & The coords to use to index to proxy reference.

const inline

template<typename Coords> inline NCA_HD const ArrayElementProxy operator[](const Coords & coords) const

Defined in src/lib/ncarray/array_impl.hh:871

A single Coords struct operator[] overload to index to proxy reference.

The StaticCoords object should be the correct dimensionality to match the array’s dimensionality. This is NOT checked in this function for performance reasons!

The const proxy reference pointed to by the provided coords.

Parameter Type Description
coords const Coords & The coords to use to index to proxy reference.

inline

inline NCA_HDArrayElementProxy operator[](hd_std::initializer_list< hd_std::uint64_t > coords)

Defined in src/lib/ncarray/array_impl.hh:893

The initializer list overloader are for indexing down to a proxy reference.

For view semantics, you can make use of the variadic operator[] (C++23) or for NVCC, C++20, code, the variadic operator().

The proxy reference pointed to by the provided coords.

Parameter Type Description
coords hd_std::initializer_list< hd_std::uint64_t > The coords to use to index to proxy reference.

const inline

inline NCA_HD const ArrayElementProxy operator[](hd_std::initializer_list< hd_std::uint64_t > coords) const

Defined in src/lib/ncarray/array_impl.hh:916

The initializer list overloader are for indexing down to a proxy reference.

For view semantics, you can make use of the variadic operator[] (C++23) or for NVCC, C++20, code, the variadic operator().

The proxy reference pointed to by the provided coords.

Parameter Type Description
coords hd_std::initializer_list< hd_std::uint64_t > The coords to use to index to proxy reference.

const inline

inline NCA_HDViewType view_from_indices(const IndexItem * indices, ssize_t num_indices) const

Defined in src/lib/ncarray/array_impl.hh:941

Provided a set of indices, construct a new ViewType of array.

The new view of the data.

Parameter Type Description
indices const [IndexItem](api-ncarray-IndexItem.md#indexitem) * The index specification. Each item contains a type (like Slice, or integer) and the axis it belongs to.
num_indices ssize_t The number of indices that were provided for traversing the pointer.

const inline

template<class VT> inline NCA_HD VT out_from_axes_ptr(void * data_ptr, const AxisDescr * axes, ssize_t ndim = -1) const

Defined in src/lib/ncarray/array_impl.hh:965

Traverse a data pointer using per axis specifications for shapes, strides, and offsets/suboffsets etc.

This function in general is not likely to be used directly. It correctly traverses the data pointer, accumulating offsets as needed, to produce a final view that matches the input axes specifications.

Using the view_from_indices function is more user friendly.

The new view of the data.

Parameter Type Description
data_ptr void * The data to traverse.
axes const [AxisDescr](api-ncarray-AxisDescr.md#axisdescr) * The specification for each axis in the new view.

const inline

inline NCA_HDViewType view() const

Defined in src/lib/ncarray/array_impl.hh:1050

Construct a view of any array.

Some functions, and in particular device code, require views only, to avoid allocations when dealing with OwnerType arrays. This function will provide a view over the data from any array, so it can be used easily with all APIs.

E.g.:

gpu_kernel<<<blocks, TPB>>>(my_array.view());

The view of the array.


const

void copy_into(void * dest_buffer) const

Defined in src/lib/ncarray/array_impl.hh:1059

Copy the array’s data into the provided buffer.

This will copy data using the array’s datatype.

Parameter Type Description
dest_buffer void * The destination for the copied data.

const

template<typename OutT> void copy_into_astype(OutT * dest_buffer) const

Defined in src/lib/ncarray/array_impl.hh:1071

Copy the array’s data into the provided buffer while casting.

This will perform the appropriate casts from the array’s datatype to the requested datatype.

Parameter Type Description
dest_buffer OutT * The destination for the copied data.

const

OwnerType to_contiguous() const

Defined in src/lib/ncarray/array_impl.hh:1083

Convert an array to a new contiguous array.

Todo: Consider the logic in this function to avoid a copy if the array is contiguous.

A new contiguous array with the same data.


const inline

inline NCA_HD bool is_contiguous() const

Defined in src/lib/ncarray/array_impl.hh:1090

Check whether the array’s current data is a contiguous block.

is_contiguous Whether the data is contiguous.


const

OwnerType astype(DType & dtype_out) const

Defined in src/lib/ncarray/array_impl.hh:1119

Convert an array to an array of a new DType.

A new contiguous array with the same data.

Parameter Type Description
dtype_out [DType](api-ncarray.md#dtype) & The DType to convert the array to.

void fill(Scalar val)

Defined in src/lib/ncarray/array_impl.hh:1129

Fill all elements of an array with the provided value. The array must not be read-only.

Parameter Type Description
val [Scalar](api-ncarray.md#scalar) The value to assign to the array elements.

void assign(const ArrayLike auto & arr)

Defined in src/lib/ncarray/array_impl.hh:1142

Fill all elements of an array with the elements of the input array.

Parameter Type Description
arr const ArrayLike auto & The array to use for assignment.

const inline

inline ViewType squeeze() const

Defined in src/lib/ncarray/array_impl.hh:1149

Return a new array view with axes of size 1 “squeezed” (removed).

The squeezed output array view.


const inline

inline NCA_HDViewType reshape(const ssize_t * new_shape, ssize_t ndim) const

Defined in src/lib/ncarray/array_impl.hh:1185

This function for reshaping assumes contiguity. It is user responsibility to ensure that this is true!

The reshaped view.

Parameter Type Description
new_shape const ssize_t * The new shape that is requested.
ndim ssize_t The number of dimensions in the new shape.

const inline

inline OwnerType copy_as_shape(const ssize_t * new_shape, ssize_t ndim) const

Defined in src/lib/ncarray/array_impl.hh:1224

For non-contiguous arrays, there is no mathematical formula to reshape in the general case. This function provides a copy and reshape utility to return a new array of the specified shape.

Because this function allocates an OwnerType, it can only be called from the host.

A new contiguous owning array of the specified shape.

Parameter Type Description
new_shape const ssize_t * The new shape that is requested.
ndim ssize_t The number of dimensions in the new shape.

const

OwnerType sum(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1250

Perform a sum along the set of provided axes.

An owning type array with the per-axis sums.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to sum along.

const

OwnerType max(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1261

Calculate the maximum along the set of provided axes.

An owning type array with the per-axis maxima.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to find the maximum along.

const

OwnerType argmax(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1271

Determine the index of the maximum along the set of provided axes.

An owning type array with the indices of the per-axis maxima.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to find the index of the maximum along.

const

OwnerType min(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1282

Calculate the minimum along the set of provided axes.

An owning type array with the per-axis maxima.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to find the minimum along.

const

OwnerType argmin(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1292

Determine the index of the minima along the set of provided axes.

An owning type array with the indices of the per-axis minima.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to find the index of the minimum along.

const

OwnerType mean(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1303

Calculate the mean along the set of provided axes.

An owning type array with the indices of the per-axis means.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to find the mean along.

const

OwnerType var(const std::vector< ssize_t > & axes, ssize_t ddof = 0) const

Defined in src/lib/ncarray/array_impl.hh:1314

Calculate the variance along the set of provided axes.

An owning type array with the indices of the per-axis variance.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to find the variance along.
ddof ssize_t The delta degrees of freedom. Divisor in the calculation is N-ddof.

const

OwnerType std(const std::vector< ssize_t > & axes, ssize_t ddof = 0) const

Defined in src/lib/ncarray/array_impl.hh:1325

Calculate the standard deviation along the set of provided axes.

An owning type array with the indices of the per-axis standard deviation.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to find the standard deviation along.
ddof ssize_t The delta degrees of freedom. Divisor in the calculation is N-ddof.

const

OwnerType all(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1336

Return true along the provided axes if all values are “truthy.”

An owning type array with a truthy value if all values were truthy.

Parameter Type Description
axes const std::vector< ssize_t > & The axes to determine truthiness along.

const

OwnerType any(const std::vector< ssize_t > & axes) const

Defined in src/lib/ncarray/array_impl.hh:1346

Return true along the provided axes if any value is “truthy.”

An owning type array with a truthy value if any value was truthy.

Parameter Type Description
axes const std::vector< ssize_t > & The axes along which to determine if any value is “truthy.”

const

Scalar sum() const

Defined in src/lib/ncarray/array_impl.hh:1358

Perform a sum of all array elements.

The full sum of the array.


const

Scalar max() const

Defined in src/lib/ncarray/array_impl.hh:1368

Find the maximum of all array elements.

The maximum of the array.


const

Scalar argmax() const

Defined in src/lib/ncarray/array_impl.hh:1379

Find the index of the maximum of all array elements.

The linearized ravel index for the maximum of the array.


const

Scalar min() const

Defined in src/lib/ncarray/array_impl.hh:1389

Find the minimum of all array elements.

The minimum of the array.


const

Scalar argmin() const

Defined in src/lib/ncarray/array_impl.hh:1400

Find the index of the minimum of all array elements.

The linearized ravel index for the minimum of the array.


const

Scalar mean() const

Defined in src/lib/ncarray/array_impl.hh:1410

Find the mean of all array elements.

The mean of the array.


const

Scalar var(ssize_t ddof = 0) const

Defined in src/lib/ncarray/array_impl.hh:1421

Find the variance of all array elements.

The variance of the array.

Parameter Type Description
ddof ssize_t The delta degrees of freedom. Divisor in the calculation is N-ddof.

const

Scalar std(ssize_t ddof = 0) const

Defined in src/lib/ncarray/array_impl.hh:1431

Find the standard deviation of all array elements.

The standard deviation of the array.

Parameter Type Description
ddof ssize_t The delta degrees of freedom. Divisor in the calculation is N-ddof.

const

Scalar all() const

Defined in src/lib/ncarray/array_impl.hh:1441

Return truthy if all elements of the array are truthy.

Truthy if all elements are truthy, otherwise falsey.


const

Scalar any() const

Defined in src/lib/ncarray/array_impl.hh:1450

Return truthy if any element of the array is truthy.

Truthy if any element of the array is truthy, otherwise falsey.


const inline

inline Scalar get_scalar(void * ptr) const

Defined in src/lib/ncarray/array_impl.hh:1461

Return the underlying pointer to an array element as a Scalar variant.

A scalar for the provided array element.

Parameter Type Description
ptr void * The pointer to an element of the array.

template<Expression Expr> ArrayImpl & operator=(const Expr & expr)

Defined in src/lib/ncarray/array_impl.hh:1478

Evaluate an expression object into the array.


const inline

inline ExprResult iota() const

Defined in src/lib/ncarray/array_impl.hh:1492

Generate an array using the APL-style index generator.

Use the ravel index to populate the values of the array based on the shape of the instance it is called on.

An expression to be evaluated which will create the ravel index array.


const inline

inline ExprResult operator-() const

Defined in src/lib/ncarray/array_impl.hh:1522

Return an expression for the negation of the array.

An expression for the negation of the array.


inline

inline ArrayImpl & operator++()

Defined in src/lib/ncarray/array_impl.hh:1526

Inplace increment each element of the array.


inline

inline ArrayImpl & operator--()

Defined in src/lib/ncarray/array_impl.hh:1530

Inplace decrement each element of the array.


const inline

inline ExprResult operator!() const

Defined in src/lib/ncarray/array_impl.hh:1536

Return an expression for the logical not of the array.

An expression for the logical not of the array.


const inline

inline ExprResult operator+(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1548

Return an expression for the sum of the array and the provided expression.

An expression for the sum of the array and the provided expression.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to sum with the array.

const

ExprResult operator-(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1558

Return an expression for the difference of an expression from the array.

An expression for the difference of the provided expression from the array.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to subtract from the array.

const inline

inline ExprResult operator*(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1568

Return an expression for the product of the array and the provided expression.

An expression for the product of the array and the provided expression.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to multiply with the array.

const inline

inline ExprResult operator/(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1578

Return an expression for the quotient of array over the provided expression.

An expression for the quotient of array and expression.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression that will be the denominator.

const inline

inline ExprResult operator%(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1588

Return an expression for the remainder (modulo) of array over the provided expression.

An expression for the remainder (modulo) of array and expression.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression that will be the denominator.

inline

inline ArrayImpl & operator+=(const ExprResult & right)

Defined in src/lib/ncarray/array_impl.hh:1599

Add an expression into an array inplace.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to sum with the array.

inline

inline ArrayImpl & operator-=(const ExprResult & right)

Defined in src/lib/ncarray/array_impl.hh:1608

Subtract an expression from an array inplace.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to subtract from the array.

inline

inline ArrayImpl & operator*=(const ExprResult & right)

Defined in src/lib/ncarray/array_impl.hh:1617

Calculate the product of an expression into an array inplace.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to multiply with the array.

inline

inline ArrayImpl & operator/=(const ExprResult & right)

Defined in src/lib/ncarray/array_impl.hh:1626

Divide an expression into an array inplace.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to divide the array by.

const inline

inline ExprResult operator==(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1638

Return an expression for the elementwise equality test between the expression and array.

An expression for the elementwise equality comparison.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to compare with the array.

const inline

inline ExprResult operator!=(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1648

Return an expression for the elementwise inequality test between the expression and array.

An expression for the elementwise inequality comparison.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to compare with the array.

const inline

inline ExprResult operator<(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1658

Return an expression for the elementwise less than test between the expression and array.

An expression for the elementwise less than comparison.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to compare with the array.

const inline

inline ExprResult operator<=(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1668

Return an expression for the elementwise less than or equal test between the expression and array.

An expression for the elementwise less than or equal comparison.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to compare with the array.

const inline

inline ExprResult operator>(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1678

Return an expression for the elementwise greater than test between the expression and array.

An expression for the elementwise greater than comparison.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to compare with the array.

const inline

inline ExprResult operator>=(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1688

Return an expression for the elementwise greater than or equal test between the expression and array.

An expression for the elementwise greater than or equal comparison.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to compare with the array.

const inline

inline ExprResult operator&&(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1700

Return an expression for the logical AND of the expression and array.

An expression for the logical AND.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to calculate the logical AND of with the array.

const inline

inline ExprResult operator||(const ExprResult & right) const

Defined in src/lib/ncarray/array_impl.hh:1710

Return an expression for the logical OR of the expression and array.

An expression for the logical OR.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to calculate the logical OR of with the array.

inline

inline ArrayImpl & operator&=(const ExprResult & right)

Defined in src/lib/ncarray/array_impl.hh:1722

Calculate the logical AND of an expression and array in place.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to calculate the logical AND of with the array.

inline

inline ArrayImpl & operator|=(const ExprResult & right)

Defined in src/lib/ncarray/array_impl.hh:1732

Calculate the logical OR of an expression and array in place.

Parameter Type Description
right const [ExprResult](#exprresult) & The expression to calculate the logical OR of with the array.

Iterator begin()

Defined in src/lib/ncarray/array_impl.hh:1802

Construct a non-const Iterator pointing to the first subview of the array.

A non-const iterator pointing to the first subview of the array.


Iterator end()

Defined in src/lib/ncarray/array_impl.hh:1808

Construct a non-const Iterator pointing to the past the last subview of the array.

A non-const iterator pointing past the last subview of the array.


const

ConstIterator begin() const

Defined in src/lib/ncarray/array_impl.hh:1815

Construct a const Iterator pointing to the first subview of the array.

A const iterator pointing to the first subview of the array.


const

ConstIterator end() const

Defined in src/lib/ncarray/array_impl.hh:1821

Construct a const Iterator pointing to the past the last subview of the array.

A const iterator pointing past the last subview of the array.


const inline

inline std::string repr() const

Defined in src/lib/ncarray/array_impl.hh:1841

Return a string representation of the data elements of the array.

This routine returns a string of data elements of the array, formatted in a manner very similar to how NumPy prints its NDArrays. If there are too many elements, the first 3 and last 3 are shown with the truncated elements replaced by an elipsis on all axes this has occurred.

The string representation.

Return Name Description
OwnerType iota static inline Generate an array of the specified type using the APL-style index generator.

static inline

static inline OwnerType iota(const std::vector< ssize_t > & shape, DType dtype = DType::int64)

Defined in src/lib/ncarray/array_impl.hh:1508

Generate an array of the specified type using the APL-style index generator.

Use the ravel index to populate the values of the array based on the shape of the instance it is called on.

An array with elements populated by the index generator.

Parameter Type Description
shape const std::vector< ssize_t > & The shape of the array to construct.
dtype [DType](api-ncarray.md#dtype) The datatype for the final array.
Return Name Description
std::string class_name const inline Return a class name primarily for the repr routine.
void repr_recursive const inline Dispatcher for the recursive helper for repr() that handles arbitrary dimensions.
void repr_recursive_dispatched const inline Recursive helper for repr() that handles arbitrary dimensions.

const inline

inline std::string class_name() const

Defined in src/lib/ncarray/array_impl.hh:1883

Return a class name primarily for the repr routine.

This provides a unique name for the class that combines the layout and storage specifications for easy identification when printing to console.

The class name.


const inline

inline void repr_recursive(std::ostringstream & oss, void * current_data, ssize_t axis, ssize_t indent, ssize_t edge_items) const

Defined in src/lib/ncarray/array_impl.hh:1898

Dispatcher for the recursive helper for repr() that handles arbitrary dimensions.

This function only dispatches the true recurser based on the datatype.

Parameter Type Description
oss std::ostringstream & The stream to write the array representation to.
current_data void * A pointer to the current data element of the array.
axis ssize_t The current array axis being traversed.
indent ssize_t The current indentation level to add to the string representation.
edge_items ssize_t The current number of items to be shown when truncating for length.

const inline

template<class T> inline void repr_recursive_dispatched(std::ostringstream & oss, void * current_data, ssize_t axis, ssize_t indent, ssize_t edge_items) const

Defined in src/lib/ncarray/array_impl.hh:1921

Recursive helper for repr() that handles arbitrary dimensions.

Parameter Type Description
oss std::ostringstream & The stream to write the array representation to.
current_data void * A pointer to the current data element of the array.
axis ssize_t The current array axis being traversed.
indent ssize_t The current indentation level to add to the string representation.
edge_items ssize_t The current number of items to be shown when truncating for length.
Name Description
StoragePolicy
LayoutPolicy
MemType
VPolicy
OPolicy
ViewType
OwnerType
ExprResult
Iterator
ConstIterator

using StoragePolicy = Storage

Defined in src/lib/ncarray/array_impl.hh:151


using LayoutPolicy = Layout

Defined in src/lib/ncarray/array_impl.hh:152


using MemType = typename Storage::MemType

Defined in src/lib/ncarray/array_impl.hh:157


using VPolicy = typename StoragePolicyTraits< MemType >::View

Defined in src/lib/ncarray/array_impl.hh:158


using OPolicy = typename StoragePolicyTraits< MemType >::Owner

Defined in src/lib/ncarray/array_impl.hh:159


using ViewType = ArrayImpl< Layout, VPolicy >

Defined in src/lib/ncarray/array_impl.hh:161


using OwnerType = ArrayImpl< Layout, OPolicy >

Defined in src/lib/ncarray/array_impl.hh:162


using ExprResult = ExprMVNode< MemType >

Defined in src/lib/ncarray/array_impl.hh:1480


using Iterator = IteratorImpl< ViewType >

Defined in src/lib/ncarray/array_impl.hh:1794


using ConstIterator = IteratorImpl< const ViewType >

Defined in src/lib/ncarray/array_impl.hh:1795