Skip to content

ArrayImpl

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

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

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 (!is_base_of_v<OwnerTag, Storage>) Copy constructor for view/reference type interconversion.
NCA_HD ArrayImpl inline noexcept requires (!is_base_of_v<OwnerTag, Storage>) Move constructor for view/reference type interconversion.
NCA_HD ArrayImpl inline requires is_base_of_v<ViewTag, Storage> Universal copy to view constructor.
NCA_HD ArrayImpl inline noexcept requires is_base_of_v<ViewTag, Storage> Universal move to view constructor.
ArrayImpl & operator= inline requires is_base_of_v<OwnerTag, Storage> Copy constructor for Owner type arrays.
ArrayImpl & operator= inline noexcept requires is_base_of_v<OwnerTag, Storage> Move constructor for Owner type arrays.
NCA_HDArrayImpl & operator= inline requires (!is_base_of_v<OwnerTag, Storage>) Copy constructor for non-Owner type arrays.
NCA_HDArrayImpl & operator= inline noexcept requires (!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:172

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:192

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:210

Move constructor for owner type arrays.


inline requires (!is_base_of_v<OwnerTag, Storage>)

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

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

Copy constructor for view/reference type interconversion.


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

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

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

Move constructor for view/reference type interconversion.


inline requires is_base_of_v<ViewTag, Storage>

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

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

Universal copy to view constructor.

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


inline noexcept requires is_base_of_v<ViewTag, Storage>

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

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

Universal move to view constructor.

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


inline requires is_base_of_v<OwnerTag, Storage>

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

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

Copy constructor for Owner type arrays.


inline noexcept requires is_base_of_v<OwnerTag, Storage>

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

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

Move constructor for Owner type arrays.


inline requires (!is_base_of_v<OwnerTag, Storage>)

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

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

Copy constructor for non-Owner type arrays.


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

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

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

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:398

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

  • data_ The underlying array data.

  • ndim The number of dimensions in the array.

  • shape_ A pointer to the shape. Should be valid through ndim derefernces.

  • strides_ A pointer to the strides. Should be valid through ndim derefernces.

  • offsets_ A pointer to the offsets. Should be valid through ndim derefernces.

  • dtype_ The datatype of the elements of the new array.

  • pointer_axis_ Which if any axis is a pointer axis.

  • read_only_ 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:437

Construct a new array (generally view type).

  • data_ The underlying array data.

  • ndim The number of dimensions in the array.

  • shape_ A pointer to the shape. Should be valid through ndim derefernces.

  • strides_ A pointer to the strides. Should be valid through ndim derefernces.

  • dtype_ The datatype of the elements of the new array.

  • pointer_axis_ Which if any axis is a pointer axis.

  • read_only_ 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:477

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

  • data_ptrs A vector of data pointers that makeup the array.

  • shape_ The shape of the new ref array (using a std::vector).

  • strides_ The strides of the new ref array (using a std::vector).

  • dtype_ The datatype of the elements of the new array.

  • pointer_axis_ Which if any axis is a pointer axis.

  • read_only_ 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:528

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

  • shape_ The shape of the new array (using a std::vector).

  • 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:573

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

  • shape_ The shape of the new array (using the metadata struct).

  • 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:620

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

  • ndim The number of dimensions (to properly increment the pointer).

  • shape_ The shape of the new array (using a raw pointer).

  • 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:664

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.

  • Expr The type of the expression to be evaluated.
  • expr The expression to be evaluated.

const inline

inline NCA_HD ssize_t nbytes() const

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

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:727

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:743


const inline

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

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


inline

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

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

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

  • idx The linearized input index.

  • 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:830

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

  • coords The pre-created coords struct with multi-dimensional indices.

idx The linearized index.


inline

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

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

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!

  • Coords The type of the StaticCoords object (templated on dimension and integer width.)
  • coords The coords to use to index to proxy reference.

The proxy reference pointed to by the provided coords.


const inline

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

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

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!

  • Coords The type of the StaticCoords object (templated on dimension and integer width.)
  • coords The coords to use to index to proxy reference.

The const proxy reference pointed to by the provided coords.


inline

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

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

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().

  • coords The coords to use to index to proxy reference.

The proxy reference pointed to by the provided coords.


const inline

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

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

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().

  • coords The coords to use to index to proxy reference.

The proxy reference pointed to by the provided coords.


const inline

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

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

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

  • indices The index specification. Each item contains a type (like Slice, or integer) and the axis it belongs to.

  • num_indices The number of indices that were provided for traversing the pointer.

The new view of the data.


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:973

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.

  • VT The type of the array view.
  • data_ptr The data to traverse.

  • axes The specification for each axis in the new view.

The new view of the data.


const inline

inline NCA_HDViewType view() const

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

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:1067

Copy the array’s data into the provided buffer.

This will copy data using the array’s datatype.

  • dest_buffer 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:1079

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.

  • OutT The output/destination datatype.
  • dest_buffer The destination for the copied data.

const

OwnerType to_contiguous() const

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

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:1098

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:1127

Convert an array to an array of a new DType.

  • dtype_out The DType to convert the array to.

A new contiguous array with the same data.


void fill(Scalar val)

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

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

  • val The value to assign to the array elements.

void assign(const ArrayLike auto & arr)

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

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

  • arr The array to use for assignment.

const inline

inline ViewType squeeze() const

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

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:1193

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

  • new_shape The new shape that is requested.

  • ndim The number of dimensions in the new shape.

The reshaped view.


const inline

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

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

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.

  • new_shape The new shape that is requested.

  • ndim The number of dimensions in the new shape.

A new contiguous owning array of the specified shape.


const

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

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

Perform a sum along the set of provided axes.

  • axes The axes to sum along.

An owning type array with the per-axis sums.


const

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

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

Calculate the maximum along the set of provided axes.

  • axes The axes to find the maximum along.

An owning type array with the per-axis maxima.


const

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

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

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

  • axes The axes to find the index of the maximum along.

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


const

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

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

Calculate the minimum along the set of provided axes.

  • axes The axes to find the minimum along.

An owning type array with the per-axis maxima.


const

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

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

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

  • axes The axes to find the index of the minimum along.

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


const

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

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

Calculate the mean along the set of provided axes.

  • axes The axes to find the mean along.

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


const

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

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

Calculate the variance along the set of provided axes.

  • axes The axes to find the variance along.

  • ddof The delta degrees of freedom. Divisor in the calculation is N-ddof.

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


const

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

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

Calculate the standard deviation along the set of provided axes.

  • axes The axes to find the standard deviation along.

  • ddof The delta degrees of freedom. Divisor in the calculation is N-ddof.

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


const

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

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

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

  • axes The axes to determine truthiness along.

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


const

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

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

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

  • axes The axes along which to determine if any value is “truthy.”

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


const

Scalar sum() const

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

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:1376

Find the maximum of all array elements.

The maximum of the array.


const

Scalar argmax() const

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

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:1397

Find the minimum of all array elements.

The minimum of the array.


const

Scalar argmin() const

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

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:1418

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:1429

Find the variance of all array elements.

  • ddof The delta degrees of freedom. Divisor in the calculation is N-ddof.

The variance of the array.


const

Scalar std(ssize_t ddof = 0) const

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

Find the standard deviation of all array elements.

  • ddof The delta degrees of freedom. Divisor in the calculation is N-ddof.

The standard deviation of the array.


const

Scalar all() const

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

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:1458

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:1469

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

  • ptr The pointer to an element of the array.

A scalar for the provided array element.


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

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

Evaluate an expression object into the array.

  • The expression to evaluate into the array.

const inline

inline ExprResult iota() const

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

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:1530

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:1534

Inplace increment each element of the array.


inline

inline ArrayImpl & operator--()

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

Inplace decrement each element of the array.


const inline

inline ExprResult operator!() const

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

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:1556

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

  • right The expression to sum with the array.

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


const

ExprResult operator-(const ExprResult & right) const

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

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

  • right The expression to subtract from the array.

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


const inline

inline ExprResult operator*(const ExprResult & right) const

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

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

  • right The expression to multiply with the array.

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


const inline

inline ExprResult operator/(const ExprResult & right) const

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

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

  • right The expression that will be the denominator.

An expression for the quotient of array and expression.


const inline

inline ExprResult operator%(const ExprResult & right) const

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

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

  • right The expression that will be the denominator.

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


inline

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

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

Add an expression into an array inplace.

  • right The expression to sum with the array.

inline

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

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

Subtract an expression from an array inplace.

  • right The expression to subtract from the array.

inline

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

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

Calculate the product of an expression into an array inplace.

  • right The expression to multiply with the array.

inline

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

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

Divide an expression into an array inplace.

  • right The expression to divide the array by.

const inline

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

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

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

  • right The expression to compare with the array.

An expression for the elementwise equality comparison.


const inline

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

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

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

  • right The expression to compare with the array.

An expression for the elementwise inequality comparison.


const inline

inline ExprResult operator<(const ExprResult & right) const

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

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

  • right The expression to compare with the array.

An expression for the elementwise less than comparison.


const inline

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

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

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

  • right The expression to compare with the array.

An expression for the elementwise less than or equal comparison.


const inline

inline ExprResult operator>(const ExprResult & right) const

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

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

  • right The expression to compare with the array.

An expression for the elementwise greater than comparison.


const inline

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

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

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

  • right The expression to compare with the array.

An expression for the elementwise greater than or equal comparison.


const inline

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

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

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

  • right The expression to calculate the logical AND of with the array.

An expression for the logical AND.


const inline

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

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

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

  • right The expression to calculate the logical OR of with the array.

An expression for the logical OR.


inline

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

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

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

  • right 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:1740

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

  • right The expression to calculate the logical OR of with the array.

Iterator begin()

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

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:1816

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:1823

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:1829

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:1849

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:1516

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.

  • shape The shape of the array to construct.

  • dtype The datatype for the final array.

An array with elements populated by the index generator.

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:1891

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:1906

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

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

  • oss The stream to write the array representation to.

  • current_data A pointer to the current data element of the array.

  • axis The current array axis being traversed.

  • indent The current indentation level to add to the string representation.

  • edge_items 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:1929

Recursive helper for repr() that handles arbitrary dimensions.

  • T The type of the array elements.
  • oss The stream to write the array representation to.

  • current_data A pointer to the current data element of the array.

  • axis The current array axis being traversed.

  • indent The current indentation level to add to the string representation.

  • edge_items 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:159


using LayoutPolicy = Layout

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


using MemType = typename Storage::MemType

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


using VPolicy = typename StoragePolicyTraits< MemType >::View

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


using OPolicy = typename StoragePolicyTraits< MemType >::Owner

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


using ViewType = ArrayImpl< Layout, VPolicy >

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


using OwnerType = ArrayImpl< Layout, OPolicy >

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


using ExprResult = ExprMVNode< MemType >

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


using Iterator = IteratorImpl< ViewType >

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


using ConstIterator = IteratorImpl< const ViewType >

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