Volume Cartographer 2.27.0
Functions | Variables

A small derivative library that handles calculating derivatives up to the second order. More...

Collaboration diagram for Derivative Library:

Functions

template<typename T >
volcart::segmentation::D1Forward (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the first derivative for a sampled point. More...
 
template<typename T >
volcart::segmentation::D1Backward (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the first derivative for a sampled point. More...
 
template<typename T >
volcart::segmentation::D1Central (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the first derivative for a sampled point. More...
 
template<typename T >
volcart::segmentation::D1FivePointStencil (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the first derivative for a sampled point using a five-point stencil. More...
 
template<typename T >
volcart::segmentation::D1At (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the first derivative for a sampled point. More...
 
template<typename T >
std::vector< T > volcart::segmentation::D1 (const std::vector< T > &vs, int hstep=1)
 Calculate the first derivative for a vector of sampled points. More...
 
template<typename T >
volcart::segmentation::D2Forward (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the second derivative for a sampled point. More...
 
template<typename T >
volcart::segmentation::D2Backward (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the second derivative for a sampled point. More...
 
template<typename T >
volcart::segmentation::D2Central (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the second derivative for a sampled point. More...
 
template<typename T >
volcart::segmentation::D2FivePointStencil (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the second derivative for a sampled point using a five-point stencil. More...
 
template<typename T >
volcart::segmentation::D2At (const std::vector< T > &vs, int index, int hstep=1)
 Calculate the second derivative for a sampled point. More...
 
template<typename T >
std::vector< T > volcart::segmentation::D2 (const std::vector< T > &vs, int hstep=1)
 Calculate the second derivative for a vector of sampled points. More...
 

Variables

static constexpr std::array< std::array< double, 9 >, 4 > volcart::segmentation::D1_CENTRAL_DIFF_COEFFS
 
static constexpr std::array< std::array< double, 9 >, 4 > volcart::segmentation::D2_CENTRAL_DIFF_COEFFS
 

Detailed Description

A small derivative library that handles calculating derivatives up to the second order.

Function Documentation

◆ D1()

template<typename T >
std::vector< T > volcart::segmentation::D1 ( const std::vector< T > &  vs,
int  hstep = 1 
)

Calculate the first derivative for a vector of sampled points.

Parameters
vsInput samples
hstepOffset step
Returns
Vector of the first derivatives

Definition at line 164 of file Derivative.hpp.

◆ D1At()

template<typename T >
T volcart::segmentation::D1At ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the first derivative for a sampled point.

Uses D1Forward(), D1Backward(), D1Central(), or D1FivePointStencil() based on hstep and the size of vs.

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepOffset step

Definition at line 141 of file Derivative.hpp.

◆ D1Backward()

template<typename T >
T volcart::segmentation::D1Backward ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the first derivative for a sampled point.

Derivative is calculated from vs[index - hstep] to vs[index]

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepBackward offset step

Definition at line 71 of file Derivative.hpp.

◆ D1Central()

template<typename T >
T volcart::segmentation::D1Central ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the first derivative for a sampled point.

Derivative is calculated from vs[index - hstep] to vs[index + hstep]

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepOffset step

Definition at line 89 of file Derivative.hpp.

◆ D1FivePointStencil()

template<typename T >
T volcart::segmentation::D1FivePointStencil ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the first derivative for a sampled point using a five-point stencil.

See also
https://en.wikipedia.org/wiki/Five-point_stencil
Parameters
vsInput samples
indexIndex of sampled point in vector
hstepOffset step

Definition at line 112 of file Derivative.hpp.

◆ D1Forward()

template<typename T >
T volcart::segmentation::D1Forward ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the first derivative for a sampled point.

Derivative is calculated from vs[index] to vs[index + hstep]

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepForward offset step

Definition at line 53 of file Derivative.hpp.

◆ D2()

template<typename T >
std::vector< T > volcart::segmentation::D2 ( const std::vector< T > &  vs,
int  hstep = 1 
)

Calculate the second derivative for a vector of sampled points.

Parameters
vsInput samples
hstepOffset step
Returns
Vector of the first derivatives

Definition at line 283 of file Derivative.hpp.

◆ D2At()

template<typename T >
T volcart::segmentation::D2At ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the second derivative for a sampled point.

Uses D2Forward(), D2Backward(), D2Central(), or D2FivePointStencil() based on hstep and the size of vs.

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepOffset step

Definition at line 263 of file Derivative.hpp.

◆ D2Backward()

template<typename T >
T volcart::segmentation::D2Backward ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the second derivative for a sampled point.

Derivative is calculated from vs[index - hstep] to vs[index]

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepBackward offset step

Definition at line 198 of file Derivative.hpp.

◆ D2Central()

template<typename T >
T volcart::segmentation::D2Central ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the second derivative for a sampled point.

Derivative is calculated from vs[index - hstep] to vs[index + hstep]

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepOffset step

Definition at line 214 of file Derivative.hpp.

◆ D2FivePointStencil()

template<typename T >
T volcart::segmentation::D2FivePointStencil ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the second derivative for a sampled point using a five-point stencil.

See also
https://en.wikipedia.org/wiki/Five-point_stencil
Parameters
vsInput samples
indexIndex of sampled point in vector
hstepOffset step

Definition at line 233 of file Derivative.hpp.

◆ D2Forward()

template<typename T >
T volcart::segmentation::D2Forward ( const std::vector< T > &  vs,
int  index,
int  hstep = 1 
)

Calculate the second derivative for a sampled point.

Derivative is calculated from vs[index] to vs[index + hstep]

Parameters
vsInput samples
indexIndex of sampled point in vector
hstepForward offset step

Definition at line 181 of file Derivative.hpp.

Variable Documentation

◆ D1_CENTRAL_DIFF_COEFFS

constexpr std::array<std::array<double, 9>, 4> volcart::segmentation::D1_CENTRAL_DIFF_COEFFS
staticconstexpr
Initial value:
= {
0, 0, 0, -1/2, 0, 1/2, 0, 0, 0,
0, 0, 1/12, -2/3, 0, 2/3, -1/12, 0, 0,
0, -1/60, 3/20, -3/4, 0, 3/4, -3/20, 1/60, 0,
1/280, -4/105, 1/5, -4/5, 0, 4/5, -1/5, 4/105, -1/280
}

Central difference coefficients for first derivatives

Definition at line 23 of file Derivative.hpp.

◆ D2_CENTRAL_DIFF_COEFFS

constexpr std::array<std::array<double, 9>, 4> volcart::segmentation::D2_CENTRAL_DIFF_COEFFS
staticconstexpr
Initial value:
= {
0, 0, 0, 1, -2, 1, 0, 0, 0,
0, 0, -1/12, 4/3, -5/2, 4/3, -1/12, 0, 0,
0, 1/90, -3/20, 3/2, -49/18, 3/2, -3/20, 1/90, 0,
-1/560, 8/315, -1/5, 8/5, -205/72, 8/5, -1/5, 8/315, -1/560
}

Central difference coefficients for second derivatives

Definition at line 34 of file Derivative.hpp.