The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Private Attributes | List of all members
Table< N > Class Template Reference

#include <Table.hpp>

Public Member Functions

 Table ()
 
template<typename... Sizes>
 Table (Sizes... sizes)
 
Arraydata ()
 
const Arraydata () const
 
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
size_t flattenedIndex (Indices... indices) const
 
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
double & operator() (Indices... indices)
 
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
double operator() (Indices... indices) const
 
template<typename Index , typename = std::enable_if_t<N == 1 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
double & operator[] (Index index)
 
template<typename Index , typename = std::enable_if_t<N == 1 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
double operator[] (Index index) const
 
template<typename... Sizes, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Sizes...>()>>
void resize (Sizes... sizes)
 
void setToZero ()
 
size_t size () const
 
size_t size (size_t dim) const
 

Private Attributes

Array _data
 
std::array< size_t, N > _sizes
 

Detailed Description

template<size_t N>
class Table< N >

An instance of the Table<N> class template holds an N-dimensional table of double values, offering indexed access for reading and writing individual values. All values are stored in a single data array. Values with adjacent rightmost indices are stored next to each other.

Constructor & Destructor Documentation

◆ Table() [1/2]

template<size_t N>
Table< N >::Table ( )
inline

The default constructor constructs an empty table.

◆ Table() [2/2]

template<size_t N>
template<typename... Sizes>
Table< N >::Table ( Sizes...  sizes)
inlineexplicit

This constructor constructs a table holding the specified number of items in each of the N dimensions. All values are set to zero.

Member Function Documentation

◆ data() [1/2]

template<size_t N>
Array & Table< N >::data ( )
inline

This function returns a writable reference to the underlying data array. Resizing the array other than through the Table::resize() function results in unpredictable behavior.

◆ data() [2/2]

template<size_t N>
const Array & Table< N >::data ( ) const
inline

This function returns a read-only reference to the underlying data array.

◆ flattenedIndex()

template<size_t N>
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
size_t Table< N >::flattenedIndex ( Indices...  indices) const
inline

This template function returns the flattened index in the underlying data array for the specified N indices.

◆ operator()() [1/2]

template<size_t N>
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
double & Table< N >::operator() ( Indices...  indices)
inline

This function returns a writable reference to the value at the specified N indices. There is no range checking. Out-of-range index values cause unpredictable behavior.

◆ operator()() [2/2]

template<size_t N>
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
double Table< N >::operator() ( Indices...  indices) const
inline

This function returns a copy of the value at the specified N indices. There is no range checking. Out-of-range index values cause unpredictable behavior.

◆ operator[]() [1/2]

template<size_t N>
template<typename Index , typename = std::enable_if_t<N == 1 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
double & Table< N >::operator[] ( Index  index)
inline

This function returns a writable reference to the value at the specified index (for a one-dimensional table only). There is no range checking. Out-of-range index values cause unpredictable behavior.

◆ operator[]() [2/2]

template<size_t N>
template<typename Index , typename = std::enable_if_t<N == 1 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
double Table< N >::operator[] ( Index  index) const
inline

This function returns a copy of the value at the specified index (for a one-dimensional table only). There is no range checking. Out-of-range index values cause unpredictable behavior.

◆ resize()

template<size_t N>
template<typename... Sizes, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Sizes...>()>>
void Table< N >::resize ( Sizes...  sizes)
inline

This function resizes the table so that it holds the specified number of items in each of the N dimensions. All values are set to zero, i.e. any values that were previously in the table are lost.

◆ setToZero()

template<size_t N>
void Table< N >::setToZero ( )
inline

This function sets all values in the table to zero, without changing the number of items.

◆ size() [1/2]

template<size_t N>
size_t Table< N >::size ( ) const
inline

This function returns the total number of items in the table.

◆ size() [2/2]

template<size_t N>
size_t Table< N >::size ( size_t  dim) const
inline

This function returns the number of items in the dimension indicated by the specified zero-based index.


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