Basix
Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
basix::ndspan< T, N > Class Template Reference

This class provides a view into an n-dimensional row-wise array of data. More...

#include <ndarray.h>

Public Member Functions

constexpr ndspan (T *data, std::array< size_type, N > shape)
 
template<typename Array , typename = std::enable_if_t<has_shape<Array>::value>>
constexpr ndspan (Array &x)
 Construct an n-dimensional span from an n-dimensional array.
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr reference operator() (size_type i, size_type j)
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr reference operator() (size_type i, size_type j) const
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 3>>
constexpr reference operator() (size_type i, size_type j, size_type k)
 Return a reference to the element at specified location (i, j, k)
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 3>>
constexpr const_reference operator() (size_type i, size_type j, size_type k) const
 Return a reference to the element at specified location (i, j, k)
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr tcb::span< value_type > row (size_type i)
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr tcb::span< const value_type > row (size_type i) const
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 3>>
constexpr ndspan< value_type, 2 > row (size_type i)
 Access a row in the array.
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 3>>
constexpr ndspan< const value_type, 2 > row (size_type i) const
 Access a row in the array (const version)
 
constexpr value_type * data () const noexcept
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr size_type size () const noexcept
 
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr std::array< size_type, 2 > strides () const noexcept
 Returns the strides of the span.
 

Public Attributes

std::array< size_type, N > shape
 The shape of the span.
 

Static Public Attributes

static constexpr size_type rank = size_type(N)
 The rank of the span.
 

Friends

template<typename Span >
std::ostream & operator<< (std::ostream &out, const Span &array)
 Pretty printing, useful for debuging.
 

Detailed Description

template<typename T, std::size_t N = 2>
class basix::ndspan< T, N >

This class provides a view into an n-dimensional row-wise array of data.

Constructor & Destructor Documentation

◆ ndspan()

template<typename T , std::size_t N = 2>
constexpr basix::ndspan< T, N >::ndspan ( T *  data,
std::array< size_type, N >  shape 
)
inlineconstexpr

Construct an n-dimensional array

Parameters
[in]datapointer to the array to construct a view for
[in]shapeThe shape the array {rows, cols}

Member Function Documentation

◆ data()

template<typename T , std::size_t N = 2>
constexpr value_type* basix::ndspan< T, N >::data ( ) const
inlineconstexprnoexcept

Get pointer to the first element of the underlying storage

Warning
Use this with caution - the data storage may be strided Get pointer to the first element of the underlying storage (const version)
Use this with caution - the data storage may be strided

◆ operator()() [1/2]

template<typename T , std::size_t N = 2>
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr reference basix::ndspan< T, N >::operator() ( size_type  i,
size_type  j 
)
inlineconstexpr

Return a reference to the element at specified location (i, j)

Parameters
[in]iRow index
[in]jColumn index
Returns
Reference to the (i, j) item
Note
No bounds checking is performed

◆ operator()() [2/2]

template<typename T , std::size_t N = 2>
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr reference basix::ndspan< T, N >::operator() ( size_type  i,
size_type  j 
) const
inlineconstexpr

Return a reference to the element at specified location (i, j) (const version)

Parameters
[in]iRow index
[in]jColumn index
Returns
Reference to the (i, j) item
Note
No bounds checking is performed

◆ row() [1/2]

template<typename T , std::size_t N = 2>
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr tcb::span<value_type> basix::ndspan< T, N >::row ( size_type  i)
inlineconstexpr

Access a row in the array

Parameters
[in]iRow index
Returns
Span of the row data

◆ row() [2/2]

template<typename T , std::size_t N = 2>
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr tcb::span<const value_type> basix::ndspan< T, N >::row ( size_type  i) const
inlineconstexpr

Access a row in the array (const version)

Parameters
[in]iRow index
Returns
Span of the row data

◆ size()

template<typename T , std::size_t N = 2>
template<std::size_t _N = N, typename = std::enable_if_t<_N == 2>>
constexpr size_type basix::ndspan< T, N >::size ( ) const
inlineconstexprnoexcept

Returns the number of elements in the span

Warning
Use this caution - the data storage may be strided, i.e. the size of the underlying storage may be greater than sizeof(T)*(rows * cols)

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