Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.1.0/v0.9.0/cpp
DOLFINx  0.1.0
DOLFINx C++ interface
Public Member Functions | Public Attributes | List of all members
dolfinx::array2d< T, Allocator > Class Template Reference

This class provides a dynamic 2-dimensional row-wise array data structure. More...

#include <array2d.h>

Public Member Functions

 array2d (std::array< size_type, 2 > shape, value_type value=T(), const Allocator &alloc=Allocator())
 Construct a two dimensional array. More...
 
 array2d (size_type rows, size_type cols, value_type value=T(), const Allocator &alloc=Allocator())
 Construct a two dimensional array. More...
 
template<typename Vector >
 array2d (std::array< size_type, 2 > shape, Vector &&x)
 
constexpr array2d (std::initializer_list< std::initializer_list< T >> list)
 Construct a two dimensional array using nested initializer lists. More...
 
 array2d (const array2d &x)=default
 Copy constructor.
 
 array2d (array2d &&x)=default
 Move constructor.
 
 ~array2d ()=default
 Destructor.
 
array2doperator= (const array2d &x)=default
 Copy assignment.
 
array2doperator= (array2d &&x)=default
 Move assignment.
 
constexpr reference operator() (size_type i, size_type j)
 Return a reference to the element at specified location (i, j) More...
 
constexpr const_reference operator() (size_type i, size_type j) const
 Return a reference to the element at specified location (i, j) (const version) More...
 
constexpr xtl::span< value_type > row (size_type i)
 Access a row in the array. More...
 
constexpr xtl::span< const value_type > row (size_type i) const
 Access a row in the array (const version) More...
 
constexpr value_type * data () noexcept
 Get pointer to the first element of the underlying storage. More...
 
constexpr const value_type * data () const noexcept
 Get pointer to the first element of the underlying storage (const version) More...
 
constexpr size_type size () const noexcept
 Returns the number of elements in the array. More...
 
constexpr std::array< size_type, 2 > strides () const noexcept
 Returns the strides of the array.
 
constexpr bool empty () const noexcept
 Checks whether the container is empty. More...
 

Public Attributes

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

Detailed Description

template<typename T, class Allocator = std::allocator<T>>
class dolfinx::array2d< T, Allocator >

This class provides a dynamic 2-dimensional row-wise array data structure.

Constructor & Destructor Documentation

◆ array2d() [1/4]

template<typename T , class Allocator = std::allocator<T>>
dolfinx::array2d< T, Allocator >::array2d ( std::array< size_type, 2 >  shape,
value_type  value = T(),
const Allocator &  alloc = Allocator() 
)
inline

Construct a two dimensional array.

Parameters
[in]shapeThe shape the array {rows, cols}
[in]valueInitial value for all entries
[in]allocThe memory allocator for the data storage

◆ array2d() [2/4]

template<typename T , class Allocator = std::allocator<T>>
dolfinx::array2d< T, Allocator >::array2d ( size_type  rows,
size_type  cols,
value_type  value = T(),
const Allocator &  alloc = Allocator() 
)
inline

Construct a two dimensional array.

Parameters
[in]rowsThe number of rows
[in]colsThe number of columns
[in]valueInitial value for all entries
[in]allocThe memory allocator for the data storage

◆ array2d() [3/4]

template<typename T , class Allocator = std::allocator<T>>
template<typename Vector >
dolfinx::array2d< T, Allocator >::array2d ( std::array< size_type, 2 >  shape,
Vector &&  x 
)
inline
Todo:
Use suitable std::enable_if to make this more general (and correct) Constructs a two dimensional array from a vector

◆ array2d() [4/4]

template<typename T , class Allocator = std::allocator<T>>
constexpr dolfinx::array2d< T, Allocator >::array2d ( std::initializer_list< std::initializer_list< T >>  list)
inlineconstexpr

Construct a two dimensional array using nested initializer lists.

Parameters
[in]listThe nested initializer list

Member Function Documentation

◆ data() [1/2]

template<typename T , class Allocator = std::allocator<T>>
constexpr const value_type* dolfinx::array2d< T, Allocator >::data ( ) const
inlineconstexprnoexcept

Get pointer to the first element of the underlying storage (const version)

Warning
Use this with caution - the data storage may be strided

◆ data() [2/2]

template<typename T , class Allocator = std::allocator<T>>
constexpr value_type* dolfinx::array2d< T, Allocator >::data ( )
inlineconstexprnoexcept

Get pointer to the first element of the underlying storage.

Warning
Use this with caution - the data storage may be strided

◆ empty()

template<typename T , class Allocator = std::allocator<T>>
constexpr bool dolfinx::array2d< T, Allocator >::empty ( ) const
inlineconstexprnoexcept

Checks whether the container is empty.

Returns
Returns true if underlying storage is empty

◆ operator()() [1/2]

template<typename T , class Allocator = std::allocator<T>>
constexpr reference dolfinx::array2d< T, Allocator >::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 , class Allocator = std::allocator<T>>
constexpr const_reference dolfinx::array2d< T, Allocator >::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 , class Allocator = std::allocator<T>>
constexpr xtl::span<value_type> dolfinx::array2d< T, Allocator >::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 , class Allocator = std::allocator<T>>
constexpr xtl::span<const value_type> dolfinx::array2d< T, Allocator >::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 , class Allocator = std::allocator<T>>
constexpr size_type dolfinx::array2d< T, Allocator >::size ( ) const
inlineconstexprnoexcept

Returns the number of elements in the array.

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: