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

#include <ArrayTable.hpp>

Public Member Functions

 ArrayTable ()
 
template<typename... Sizes>
 ArrayTable (Sizes... sizes)
 
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 - 1, Indices...>()>>
Arrayoperator() (Indices... indices)
 
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
double operator() (Indices... indices) const
 
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N - 1, Indices...>()>>
const Arrayoperator() (Indices... indices) const
 
template<typename Index , typename = std::enable_if_t<N == 2 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
Arrayoperator[] (Index index)
 
template<typename Index , typename = std::enable_if_t<N == 2 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
const Arrayoperator[] (Index index) const
 
template<typename... Sizes, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Sizes...>()>>
void resize (Sizes... sizes)
 
size_t rowSize () const
 
void setToZero ()
 
size_t size () const
 
size_t size (size_t dim) const
 

Private Attributes

std::vector< Array_rows
 
std::array< size_t, N > _sizes
 

Detailed Description

template<size_t N>
class ArrayTable< N >

The ArrayTable<N> class template implements multi-dimensional tables with special support for rows in the last table dimension. Specifically, a ArrayTable<N> instance holds an N-dimensional table of double values. The combination of the first N-1 indices addresses a row in an (N-1)-dimensional table of rows; the last index addresses a column within a row. The values are stored as a list of Array objects, allowing read and write access to individual values as well as to rows of values as a whole.

It is possible and allowed to resize the rows individually through their reference. In that case the caller should ensure that all rows end up with the same size (the ArrayTable implementation does not check this requirement and does not rely on it). Note that the size(N-1) function returns the original row size as it has been specified in the constructor or in the most recent resize() invocation. The rowsize() function returns the size of the first row in the table, or zero if the table is empty.

Constructor & Destructor Documentation

◆ ArrayTable() [1/2]

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

The default constructor constructs an empty table.

◆ ArrayTable() [2/2]

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

This constructor constructs a table holding the specified number of items in each of the N dimensions. If the last dimension in the list is nonzero, the arrays holding the data are resized correspondingly and all values are set to zero. If the last dimension is zero, the arrays remain empty and should be appropriately resized by the client code.

Member Function Documentation

◆ operator()() [1/4]

template<size_t N>
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
double & ArrayTable< 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/4]

template<size_t N>
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N - 1, Indices...>()>>
Array & ArrayTable< N >::operator() ( Indices...  indices)
inline

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

◆ operator()() [3/4]

template<size_t N>
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N, Indices...>()>>
double ArrayTable< 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()() [4/4]

template<size_t N>
template<typename... Indices, typename = std::enable_if_t<CompileTimeUtils::isIntegralArgList<N - 1, Indices...>()>>
const Array & ArrayTable< N >::operator() ( Indices...  indices) const
inline

This function returns a read-only reference to the row at the specified N-1 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 == 2 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
Array & ArrayTable< N >::operator[] ( Index  index)
inline

This function returns a writable reference to the row at the specified index (for a 2-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 == 2 && CompileTimeUtils::isIntegralArgList<1, Index>()>>
const Array & ArrayTable< N >::operator[] ( Index  index) const
inline

This function returns a read-only reference to the row at the specified index (for a 2-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 ArrayTable< 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. If the last dimension in the list is nonzero, the arrays holding the data are resized correspondingly and all values are set to zero. If the last dimension is zero, the arrays are emptied and should be appropriately resized by the client code. In any case, any values that were previously in the table are lost.

◆ rowSize()

template<size_t N>
size_t ArrayTable< N >::rowSize ( ) const
inline

This function returns the number of columns in a row, i.e. the number of items in the last dimension, defined as the size of the first row in the table, or zero if the table is empty.

◆ setToZero()

template<size_t N>
void ArrayTable< 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 ArrayTable< N >::size ( ) const
inline

This function returns an estimate for the total number of items in the table, obtained by multiplying the total number of rows in the table by the size of the first row. In other words, the estimate assumes that all rows have the same size.

◆ size() [2/2]

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

This function returns the number of items in the dimension indicated by the specified zero-based index. For the last dimension, the function returns the number of items as it has been specified in the constructor or in the most recent resize() invocation, even if the underlying arrays have since been resized by cient code.


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