Clustering
C++20 header-only: DBSCAN, HDBSCAN, k-means.
Loading...
Searching...
No Matches
clustering::NDArray< T, N, L >::Accessor Class Reference

Provides read-write access to NDArray elements. More...

#include <clustering/ndarray.h>

Inheritance diagram for clustering::NDArray< T, N, L >::Accessor:
[legend]
Collaboration diagram for clustering::NDArray< T, N, L >::Accessor:
[legend]

Public Member Functions

 Accessor (NDArray< T, N, Layout::Contig > &ndarray, std::size_t index, std::size_t dim)
 Constructs an Accessor for an NDArray.
Accessor operator[] (std::size_t index) noexcept
 Provides access to the next dimension of the NDArray.
Accessoroperator= (T value) noexcept
 Assigns a value to the element at the accessor's position.
Public Member Functions inherited from clustering::NDArray< T, N, L >::ConstAccessor
 ConstAccessor (const NDArray< T, N, Layout::Contig > &ndarray, std::size_t index, std::size_t dim)
 Constructs a ConstAccessor for a constant NDArray.
 ConstAccessor (const ConstAccessor &other)=default
 Defaulted copy constructor; accessors are lightweight and trivially copyable.
ConstAccessor operator[] (std::size_t index) const noexcept
 Provides access to the next dimension of the NDArray.
 operator T () const noexcept
 Converts the accessor to the element type T, allowing read access to the element.
size_t index () const noexcept
 Returns the flat index in the NDArray corresponding to the accessor.
Public Member Functions inherited from clustering::NDArray< T, N, L >::BaseAccessor
const T * data () const
 Returns a pointer to the element data.

Additional Inherited Members

Protected Member Functions inherited from clustering::NDArray< T, N, L >::BaseAccessor
 BaseAccessor (NDArray< T, N, Layout::Contig > *ndarray, std::size_t index, std::size_t dim)
 Constructs a BaseAccessor for a given NDArray, index, and dimension.
Protected Attributes inherited from clustering::NDArray< T, N, L >::BaseAccessor
NDArray< T, N, Layout::Contig > * m_ndarray
 Pointer to the NDArray.
std::size_t m_index
 Index in the flat representation of the array.
std::size_t m_dim
 Current dimension of the accessor.

Detailed Description

template<class T, std::size_t N, Layout L = Layout::Contig>
class clustering::NDArray< T, N, L >::Accessor

Provides read-write access to NDArray elements.

Definition at line 231 of file ndarray.h.

Constructor & Destructor Documentation

◆ Accessor()

template<class T, std::size_t N, Layout L = Layout::Contig>
clustering::NDArray< T, N, L >::Accessor::Accessor ( NDArray< T, N, Layout::Contig > & ndarray,
std::size_t index,
std::size_t dim )
inline

Constructs an Accessor for an NDArray.

Parameters
ndarrayReference to the NDArray.
indexIndex for the desired element.
dimCurrent dimension for the accessor.

Definition at line 240 of file ndarray.h.

Member Function Documentation

◆ operator=()

template<class T, std::size_t N, Layout L = Layout::Contig>
Accessor & clustering::NDArray< T, N, L >::Accessor::operator= ( T value)
inlinenoexcept

Assigns a value to the element at the accessor's position.

Asserts the underlying array is mutable: writing through an accessor produced from a read-only borrow is undefined in release and trapped in debug.

Parameters
valueThe value to be assigned.
Returns
Reference to the accessor after assignment.

Definition at line 264 of file ndarray.h.

◆ operator[]()

template<class T, std::size_t N, Layout L = Layout::Contig>
Accessor clustering::NDArray< T, N, L >::Accessor::operator[] ( std::size_t index)
inlinenoexcept

Provides access to the next dimension of the NDArray.

Parameters
indexIndex in the next dimension.
Returns
A new Accessor for the specified index in the next dimension.

Definition at line 249 of file ndarray.h.


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