ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
NDArray< T > Class Template Reference

under the restriction of C++11, a simple alternative to std::vector<T> + std::mdspan. In source_base/module_container/ATen/tensor.h, tensor class provides a cross-device container, but std::string is not supported. Therefore, this class is to provide a general (but CPU-only) container for multi-dimensional data. It can easily convert to container::Tensor. More...

#include <ndarray.h>

Collaboration diagram for NDArray< T >:

Public Member Functions

 NDArray ()=delete
 Construct a new NDArray object.
 
 NDArray (std::initializer_list< size_t > il)
 
 NDArray (std::initializer_list< int > il)
 
template<typename... Args>
 NDArray (const size_t idx, Args... args)
 
template<typename... Args>
 NDArray (const int &idx, Args... args)
 
 NDArray (const NDArray &other)
 
 NDArray (NDArray &&other)
 
 ~NDArray ()
 
NDArrayoperator= (const NDArray &other)
 = operator, copy assignment
 
NDArrayoperator= (NDArray &&other)
 = operator, move assignment
 
bool operator== (const NDArray &other) const
 == operator
 
bool operator!= (const NDArray &other) const
 != operator
 
template<typename... Args>
Tat (const size_t idx, Args... args)
 at function
 
template<typename... Args>
const Tat (const size_t idx, Args... args) const
 
template<typename... Args>
Toperator() (const size_t idx, Args... args)
 [] operator
 
template<typename... Args>
const Toperator() (const size_t idx, Args... args) const
 
Tfront ()
 
const Tfront () const
 
Tback ()
 
const Tback () const
 
Tdata ()
 
const Tdata () const
 
Tbegin ()
 
Tend ()
 
const Tcbegin () const
 
const Tcend () const
 
size_t size () const
 
size_t size (const size_t &dim) const
 
bool empty () const
 
const std::vector< size_t > & shape () const
 
template<typename... Args>
void reshape (Args... args)
 
template<typename... Args>
size_t index (const size_t idx, Args... args) const
 SFINAE (Substitution Failure Is Not An Error) to_tensor function, only if T is int, double, float, std::complex<float>, std::complex<double>, otherwise there is no such function.
 

Private Attributes

std::vector< size_t > shape_
 
std::vector< Tdata_
 

Detailed Description

template<typename T>
class NDArray< T >

under the restriction of C++11, a simple alternative to std::vector<T> + std::mdspan. In source_base/module_container/ATen/tensor.h, tensor class provides a cross-device container, but std::string is not supported. Therefore, this class is to provide a general (but CPU-only) container for multi-dimensional data. It can easily convert to container::Tensor.

Template Parameters
T

Constructor & Destructor Documentation

◆ NDArray() [1/7]

template<typename T >
NDArray< T >::NDArray ( )
delete

Construct a new NDArray object.

◆ NDArray() [2/7]

template<typename T >
NDArray< T >::NDArray ( std::initializer_list< size_t >  il)
inline

◆ NDArray() [3/7]

template<typename T >
NDArray< T >::NDArray ( std::initializer_list< int >  il)
inline

◆ NDArray() [4/7]

template<typename T >
template<typename... Args>
NDArray< T >::NDArray ( const size_t  idx,
Args...  args 
)
inline

◆ NDArray() [5/7]

template<typename T >
template<typename... Args>
NDArray< T >::NDArray ( const int &  idx,
Args...  args 
)
inline

◆ NDArray() [6/7]

template<typename T >
NDArray< T >::NDArray ( const NDArray< T > &  other)
inline

◆ NDArray() [7/7]

template<typename T >
NDArray< T >::NDArray ( NDArray< T > &&  other)
inline

◆ ~NDArray()

template<typename T >
NDArray< T >::~NDArray ( )
inline

Member Function Documentation

◆ at() [1/2]

template<typename T >
template<typename... Args>
T & NDArray< T >::at ( const size_t  idx,
Args...  args 
)
inline

at function

Template Parameters
Args
Parameters
argsindices of the element
Returns
T& or const T&
Here is the call graph for this function:
Here is the caller graph for this function:

◆ at() [2/2]

template<typename T >
template<typename... Args>
const T & NDArray< T >::at ( const size_t  idx,
Args...  args 
) const
inline
Here is the call graph for this function:

◆ back() [1/2]

template<typename T >
T & NDArray< T >::back ( )
inline

◆ back() [2/2]

template<typename T >
const T & NDArray< T >::back ( ) const
inline

◆ begin()

template<typename T >
T * NDArray< T >::begin ( )
inline

◆ cbegin()

template<typename T >
const T * NDArray< T >::cbegin ( ) const
inline

◆ cend()

template<typename T >
const T * NDArray< T >::cend ( ) const
inline

◆ data() [1/2]

template<typename T >
T * NDArray< T >::data ( )
inline

◆ data() [2/2]

template<typename T >
const T * NDArray< T >::data ( ) const
inline

◆ empty()

template<typename T >
bool NDArray< T >::empty ( ) const
inline
Here is the caller graph for this function:

◆ end()

template<typename T >
T * NDArray< T >::end ( )
inline

◆ front() [1/2]

template<typename T >
T & NDArray< T >::front ( )
inline

◆ front() [2/2]

template<typename T >
const T & NDArray< T >::front ( ) const
inline

◆ index()

template<typename T >
template<typename... Args>
size_t NDArray< T >::index ( const size_t  idx,
Args...  args 
) const
inline

SFINAE (Substitution Failure Is Not An Error) to_tensor function, only if T is int, double, float, std::complex<float>, std::complex<double>, otherwise there is no such function.

Returns
container::Tensor, only if T is int, double, float, std::complex<float>, std::complex<double>
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

template<typename T >
bool NDArray< T >::operator!= ( const NDArray< T > &  other) const
inline

!= operator

Parameters
other
Returns
true if the data and shape are different
false otherwise

◆ operator()() [1/2]

template<typename T >
template<typename... Args>
T & NDArray< T >::operator() ( const size_t  idx,
Args...  args 
)
inline

[] operator

Template Parameters
Args
Parameters
argsindices of the element
Returns
T& or const T&
Here is the call graph for this function:

◆ operator()() [2/2]

template<typename T >
template<typename... Args>
const T & NDArray< T >::operator() ( const size_t  idx,
Args...  args 
) const
inline
Here is the call graph for this function:

◆ operator=() [1/2]

template<typename T >
NDArray & NDArray< T >::operator= ( const NDArray< T > &  other)
inline

= operator, copy assignment

Parameters
other
Returns
NDArray&

◆ operator=() [2/2]

template<typename T >
NDArray & NDArray< T >::operator= ( NDArray< T > &&  other)
inline

= operator, move assignment

◆ operator==()

template<typename T >
bool NDArray< T >::operator== ( const NDArray< T > &  other) const
inline

== operator

Parameters
other
Returns
true if the data and shape are the same
false otherwise

◆ reshape()

template<typename T >
template<typename... Args>
void NDArray< T >::reshape ( Args...  args)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shape()

template<typename T >
const std::vector< size_t > & NDArray< T >::shape ( ) const
inline
Here is the caller graph for this function:

◆ size() [1/2]

template<typename T >
size_t NDArray< T >::size ( ) const
inline
Here is the caller graph for this function:

◆ size() [2/2]

template<typename T >
size_t NDArray< T >::size ( const size_t &  dim) const
inline

Member Data Documentation

◆ data_

template<typename T >
std::vector<T> NDArray< T >::data_
private

◆ shape_

template<typename T >
std::vector<size_t> NDArray< T >::shape_
private

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