Tensorium
Loading...
Searching...
No Matches
tensorium::DerivateND< K, Rank > Class Template Reference

A multi-dimensional aligned tensor for numerical derivatives. More...

#include <Derivate.hpp>

Collaboration diagram for tensorium::DerivateND< K, Rank >:

Public Types

using reg = typename Simd::reg
using reg = typename Simd::reg

Public Member Functions

 DerivateND (const std::array< size_t, Rank > &dims)
 Construct a tensor with a given shape.
size_t flatten_index (const std::array< size_t, Rank > &indices) const
K & operator() (const std::array< size_t, Rank > &indices)
 Mutable access to a tensor element.
const K & operator() (const std::array< size_t, Rank > &indices) const
 Const access to a tensor element.
size_t size () const
 Total number of elements in the tensor.
 __attribute__ ((always_inline, hot, flatten)) inline void centered_derivative(const DerivateND< K
 Compute second-order centered derivative along an axis.
 for (int i=Rank - 2;i >=0;--i) strides[i]
 for (size_t flat=0;flat< total;flat+=simd_width)
 __attribute__ ((always_inline, hot, flatten)) inline void centered_derivative_order4_rank(const DerivateND< K
 Compute fourth-order centered derivative along an axis.
 for (int i=Rank - 2;i >=0;--i) strides[i]
 for (size_t flat=0;flat< total;flat+=W)

Public Attributes

std::array< size_t, Rank > shape = input.shape
aligned_vector< K > data
size_t block_size
Rank & input
Rank DerivateND< K, Rank > & output
Rank DerivateND< K, Rank > size_t axis
Rank DerivateND< K, Rank > size_t K dx const
const size_t simd_width = Simd::width
const auto & shape = input.shape
const size_t total = input.size()
constinv_2dx = K(1) / (K(2) * dx)
const reg inv2dx = Simd::set1(inv_2dx)
std::array< size_t, Rank > strides
 strides [Rank - 1] = 1
const size_t stride_axis = strides[axis]
const size_t dim_axis = shape[axis]
constexpr size_t W = Simd::width
constinv_12dx = K(1) / (K(12) * dx)
const reg inv = Simd::set1(inv_12dx)

Detailed Description

template<typename K, size_t Rank>
class tensorium::DerivateND< K, Rank >

A multi-dimensional aligned tensor for numerical derivatives.

Template Parameters
KScalar type.
RankTensor rank (dimensionality).

Member Typedef Documentation

◆ reg [1/2]

template<typename K, size_t Rank>
using tensorium::DerivateND< K, Rank >::reg = typename Simd::reg

◆ reg [2/2]

template<typename K, size_t Rank>
using tensorium::DerivateND< K, Rank >::reg = typename Simd::reg

Constructor & Destructor Documentation

◆ DerivateND()

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::DerivateND ( const std::array< size_t, Rank > & dims)
inline

Construct a tensor with a given shape.

Parameters
dimsTensor dimensions.

References block_size, data, detect_optimal_block_size(), and shape.

Referenced by __attribute__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ __attribute__() [1/2]

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::__attribute__ ( (always_inline, hot, flatten) ) const

Compute second-order centered derivative along an axis.

Parameters
inputInput tensor.
outputOutput tensor.
axisAxis to differentiate.
dxGrid spacing.

◆ __attribute__() [2/2]

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::__attribute__ ( (always_inline, hot, flatten) ) const

Compute fourth-order centered derivative along an axis.

Parameters
inputInput tensor.
outputOutput tensor.
axisAxis to differentiate.
dxGrid spacing.

References axis, DerivateND(), input, and output.

Here is the call graph for this function:

◆ flatten_index()

template<typename K, size_t Rank>
size_t tensorium::DerivateND< K, Rank >::flatten_index ( const std::array< size_t, Rank > & indices) const
inline

References shape.

Referenced by operator()(), and operator()().

Here is the caller graph for this function:

◆ for() [1/4]

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::for ( int i = Rank - 2;i >=0;--i)

References axis, dim_axis, shape, stride_axis, and strides.

◆ for() [2/4]

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::for ( int i = Rank - 2;i >=0;--i)

References shape, and strides.

◆ for() [3/4]

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::for ( )
inline

◆ for() [4/4]

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::for ( )
inline

References dim_axis, input, inv, inv_12dx, output, stride_axis, total, and W.

◆ operator()() [1/2]

template<typename K, size_t Rank>
K & tensorium::DerivateND< K, Rank >::operator() ( const std::array< size_t, Rank > & indices)
inline

Mutable access to a tensor element.

Parameters
indicesMulti-index.
Returns
Reference to the element.

References data, and flatten_index().

Here is the call graph for this function:

◆ operator()() [2/2]

template<typename K, size_t Rank>
const K & tensorium::DerivateND< K, Rank >::operator() ( const std::array< size_t, Rank > & indices) const
inline

Const access to a tensor element.

Parameters
indicesMulti-index.
Returns
Const reference to the element.

References data, and flatten_index().

Here is the call graph for this function:

◆ size()

template<typename K, size_t Rank>
size_t tensorium::DerivateND< K, Rank >::size ( ) const
inline

Total number of elements in the tensor.

Returns
Total size.

References data.

Member Data Documentation

◆ axis

template<typename K, size_t Rank>
Rank DerivateND< K, Rank > size_t tensorium::DerivateND< K, Rank >::axis

Referenced by __attribute__(), and for().

◆ block_size

template<typename K, size_t Rank>
size_t tensorium::DerivateND< K, Rank >::block_size

Referenced by DerivateND().

◆ const

template<typename K, size_t Rank>
Rank DerivateND< K, Rank > size_t K dx tensorium::DerivateND< K, Rank >::const
Initial value:
{
Definition SIMD.hpp:54

◆ data

template<typename K, size_t Rank>
aligned_vector<K> tensorium::DerivateND< K, Rank >::data

◆ dim_axis

template<typename K, size_t Rank>
const size_t tensorium::DerivateND< K, Rank >::dim_axis = shape[axis]

Referenced by for(), for(), and for().

◆ input

template<typename K, size_t Rank>
Rank & tensorium::DerivateND< K, Rank >::input

Referenced by __attribute__(), for(), and for().

◆ inv

template<typename K, size_t Rank>
const reg tensorium::DerivateND< K, Rank >::inv = Simd::set1(inv_12dx)

Referenced by for().

◆ inv2dx

template<typename K, size_t Rank>
const reg tensorium::DerivateND< K, Rank >::inv2dx = Simd::set1(inv_2dx)

Referenced by for().

◆ inv_12dx

template<typename K, size_t Rank>
const K tensorium::DerivateND< K, Rank >::inv_12dx = K(1) / (K(12) * dx)

Referenced by for().

◆ inv_2dx

template<typename K, size_t Rank>
const K tensorium::DerivateND< K, Rank >::inv_2dx = K(1) / (K(2) * dx)

Referenced by for().

◆ output

template<typename K, size_t Rank>
Rank DerivateND< K, Rank > & tensorium::DerivateND< K, Rank >::output

Referenced by __attribute__(), for(), and for().

◆ shape [1/2]

template<typename K, size_t Rank>
const auto& tensorium::DerivateND< K, Rank >::shape = input.shape

◆ shape [2/2]

template<typename K, size_t Rank>
const auto & tensorium::DerivateND< K, Rank >::shape = input.shape

Referenced by DerivateND(), flatten_index(), and for().

◆ simd_width

template<typename K, size_t Rank>
const size_t tensorium::DerivateND< K, Rank >::simd_width = Simd::width

Referenced by for().

◆ stride_axis

template<typename K, size_t Rank>
const size_t tensorium::DerivateND< K, Rank >::stride_axis = strides[axis]

Referenced by for(), for(), and for().

◆ strides [1/2]

template<typename K, size_t Rank>
tensorium::DerivateND< K, Rank >::strides[Rank - 1] = 1

◆ strides [2/2]

template<typename K, size_t Rank>
std::array< size_t, Rank > tensorium::DerivateND< K, Rank >::strides

Referenced by for().

◆ total

template<typename K, size_t Rank>
const size_t tensorium::DerivateND< K, Rank >::total = input.size()

Referenced by for(), and for().

◆ W

template<typename K, size_t Rank>
size_t tensorium::DerivateND< K, Rank >::W = Simd::width
constexpr

Referenced by for().


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