DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
CppUtils::Math Namespace Reference

Namespaces

namespace  details
 

Classes

class  InputSizeMismatch
 
class  Vector3D
 

Functions

template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
constexpr auto backwardsDifferenceMethod (IteratorX x_begin, IteratorX x_end, IteratorY y_begin, IteratorY y_end)
 
template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
constexpr auto backwardsDifferenceMethod (const ContainerX &x, const ContainerY &y)
 
template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
constexpr auto centeredDifferenceMethod (IteratorX x_begin, IteratorX x_end, IteratorY y_begin, IteratorY y_end, bool correctBoundaries=true)
 
template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
constexpr auto centeredDifferenceMethod (const ContainerX &x, const ContainerY &y, bool correctBoundaries=true)
 
template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
constexpr auto forwardDifferenceMethod (IteratorX x_begin, IteratorX x_end, IteratorY y_begin, IteratorY y_end)
 
template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
constexpr auto forwardDifferenceMethod (const ContainerX &x, const ContainerY &y)
 
template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
constexpr auto fivePointStencilMethod (const ContainerX &x, const ContainerY &y)
 
template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
constexpr auto sevenPointStencilMethod (const ContainerX &x, const ContainerY &y)
 
template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
constexpr auto ninePointStencilMethod (const ContainerX &x, const ContainerY &y)
 
template<typename Tx, typename Ty = Tx>
constexpr auto trapz (Tx x1, Tx x2, Ty y1, Ty y2) noexcept
 
template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
constexpr auto cumulativeTrapzIntegration (IteratorX x_begin, IteratorX x_end, IteratorY y_begin, IteratorY y_end, std::optional< decltype(*x_begin **y_begin)> initialValue=std::nullopt)
 
template<typename ContainerX, typename ContainerY = ContainerX, typename Tx = typename ContainerX::value_type, typename Ty = typename ContainerY::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
constexpr auto cumulativeTrapzIntegration (const ContainerX &x, const ContainerY &y, std::optional< decltype(std::declval< Tx >() *std::declval< Ty >())> initialValue=std::nullopt)
 
template<std::size_t Index, typename T>
decltype(auto) get (Vector3D< T > &vec)
 
template<std::size_t Index, typename T>
decltype(auto) get (const Vector3D< T > &vec)
 
template<std::size_t Index, typename T>
decltype(auto) get (Vector3D< T > &&vec)
 
template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
constexpr decltype(auto) linearLeastSquaresFitting (IteratorX x_begin, IteratorX x_end, IteratorY y_begin, IteratorY y_end)
 
template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
constexpr decltype(auto) quadraticLeastSquaresFitting (IteratorX x_begin, IteratorX x_end, IteratorY y_begin, IteratorY y_end)
 
template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr int findOrderOfMagnitude (T value) noexcept
 
template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr long double findAbsoluteError (T expectedValue, std::size_t significantFigures) noexcept
 
template<typename Iterator, typename T = typename std::iterator_traits<Iterator>::value_type, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
constexpr T calculateAverage (Iterator x_begin, Iterator x_end)
 
template<typename Iterator, typename T = typename std::iterator_traits<Iterator>::value_type, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
constexpr decltype(auto) calculateVariance (Iterator x_begin, Iterator x_end)
 
template<typename T, typename = std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool>>>
constexpr bool isEven (T value)
 
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
constexpr bool isOdd (T value)
 
template<typename T>
constexpr bool withinRange (T value, T min, T max)
 
template<int Min, int Max, typename T>
constexpr bool withinRange (T value)
 
template<typename T>
constexpr std::vector< T > linearlyInterpolate (const std::vector< T > &x, T y1, T y2)
 

Function Documentation

◆ backwardsDifferenceMethod() [1/2]

template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
auto CppUtils::Math::backwardsDifferenceMethod ( IteratorX x_begin,
IteratorX x_end,
IteratorY y_begin,
IteratorY y_end )
constexpr

A function taking the derivative (by numerical methods) of a given function y with respect to x. Each of the functions, x and y, are represeted by containers with an iterator interface. The function computes the following: \(\frac{dy}{dx} \approx \frac{y_n - y_{n-1}}{x_n - x_{n-1}}.\)

Template Parameters
IteratorX- The type of iterator used for the x container
IteratorY- The type of iterator used for the y container (defaults to the type of IteratorX)
Tx- The type of data in the x container, must be default constructible
Ty- The type of data in the y container, must be default constructible
Parameters
x_begin- The beginning of the range of x values to use
x_end- The end of the range of x values to use
y_begin- The beginning of the range of y values to use
y_end- The end of the range of y values to use
Returns
A vector with a size of one less than the input containers.
Exceptions
CppUtils::Math::InputSizeMismatchIf the sizes of the two containers don't match, we will throw an exception

Referenced by backwardsDifferenceMethod(), and centeredDifferenceMethod().

◆ backwardsDifferenceMethod() [2/2]

template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
auto CppUtils::Math::backwardsDifferenceMethod ( const ContainerX & x,
const ContainerY & y )
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References backwardsDifferenceMethod().

◆ centeredDifferenceMethod() [1/2]

template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
auto CppUtils::Math::centeredDifferenceMethod ( IteratorX x_begin,
IteratorX x_end,
IteratorY y_begin,
IteratorY y_end,
bool correctBoundaries = true )
constexpr

A function taking the derivative (by numerical methods) of a given function y with respect to x. Each of the functions, x and y, are represeted by containers with an iterator interface. The function computes the following: \(\frac{dy}{dx} \approx \frac{\frac{y_{n+1} - y_n}{x_{n+1} - x_n} + \frac{y_n - y_{n-1}}{x_n - x_{n-1}}}{2}.\)

Template Parameters
IteratorX- The type of iterator used for the x container
IteratorY- The type of iterator used for the y container (defaults to the type of IteratorX)
Tx- The type of data in the x container, must be default constructible
Ty- The type of data in the y container, must be default constructible
Parameters
x_begin- The beginning of the range of x values to use
x_end- The end of the range of x values to use
y_begin- The beginning of the range of y values to use
y_end- The end of the range of y values to use
correctBoundaries- Approximates the derivative on the ends with the forward and backwards methods
Returns
A vector with the same size as that of the input containers, however if the correctBoundaries flag is set to false, the size of the output will be two less than the input size.
Exceptions
CppUtils::Math::InputSizeMismatchIf the sizes of the two containers don't match, we will throw an exception

References backwardsDifferenceMethod(), and forwardDifferenceMethod().

Referenced by centeredDifferenceMethod(), and GTEST_TEST().

◆ centeredDifferenceMethod() [2/2]

template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
auto CppUtils::Math::centeredDifferenceMethod ( const ContainerX & x,
const ContainerY & y,
bool correctBoundaries = true )
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References centeredDifferenceMethod().

◆ forwardDifferenceMethod() [1/2]

template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
auto CppUtils::Math::forwardDifferenceMethod ( IteratorX x_begin,
IteratorX x_end,
IteratorY y_begin,
IteratorY y_end )
constexpr

A function taking the derivative (by numerical methods) of a given function y with respect to x. Each of the functions, x and y, are represeted by containers with an iterator interface. The function computes the following: \(\frac{dy}{dx} \approx \frac{y_{n+1} - y_n}{x_{n+1} - x_n}.\)

Template Parameters
IteratorX- The type of iterator used for the x container
IteratorY- The type of iterator used for the y container (defaults to the type of IteratorX)
Tx- The type of data in the x container, must be default constructible
Ty- The type of data in the y container, must be default constructible
Parameters
x_begin- The beginning of the range of x values to use
x_end- The end of the range of x values to use
y_begin- The beginning of the range of y values to use
y_end- The end of the range of y values to use
Returns
A vector with a size of one less than the input containers.
Exceptions
CppUtils::Math::InputSizeMismatchIf the sizes of the two containers don't match, we will throw an exception

Referenced by centeredDifferenceMethod(), and forwardDifferenceMethod().

◆ forwardDifferenceMethod() [2/2]

template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
auto CppUtils::Math::forwardDifferenceMethod ( const ContainerX & x,
const ContainerY & y )
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References forwardDifferenceMethod().

◆ fivePointStencilMethod()

template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
auto CppUtils::Math::fivePointStencilMethod ( const ContainerX & x,
const ContainerY & y )
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References CppUtils::Math::details::nPointStencilMethod().

◆ sevenPointStencilMethod()

template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
auto CppUtils::Math::sevenPointStencilMethod ( const ContainerX & x,
const ContainerY & y )
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References CppUtils::Math::details::nPointStencilMethod().

◆ ninePointStencilMethod()

template<typename ContainerX, typename ContainerY = ContainerX, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<typename ContainerX::value_type>, std::is_default_constructible<typename ContainerY::value_type>>>>
auto CppUtils::Math::ninePointStencilMethod ( const ContainerX & x,
const ContainerY & y )
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References CppUtils::Math::details::nPointStencilMethod().

◆ trapz()

template<typename Tx, typename Ty = Tx>
auto CppUtils::Math::trapz ( Tx x1,
Tx x2,
Ty y1,
Ty y2 )
constexprnoexcept

A simple function responsible for the main work in the cumulativeTrapzIntegration() function, this computes the following approximation for the integral: \(\displaystyle \int_{x_1}^{x_2} y \,dx \approx (x_2 - x_1) \cdot {\frac{y_1 + y_2}{2}}.\)

Template Parameters
Tx- The type of x
Ty- The type of y (defaults to the type of x)
Parameters
x1- The beginning of the range we are integrating the function over
x2- The end of the range we are integrating the function over
y1- The value of the function we are integrating at the point x1
y2- The end of the function we are integrating at the point x2
Returns
An approximation of the integral of y in the range from x1 to x2

Referenced by cumulativeTrapzIntegration().

◆ cumulativeTrapzIntegration() [1/2]

template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
auto CppUtils::Math::cumulativeTrapzIntegration ( IteratorX x_begin,
IteratorX x_end,
IteratorY y_begin,
IteratorY y_end,
std::optional< decltype(*x_begin **y_begin)> initialValue = std::nullopt )
constexpr

A function taking the integral (by numerical methods) of a given function y with respect to x. Each of the functions, x and y, are represeted by containers with an iterator interface.

Template Parameters
IteratorX- The type of iterator used for the x container
IteratorY- The type of iterator used for the y container (defaults to the type of IteratorX)
Tx- The type of data in the x container, must be default constructible
Ty- The type of data in the x container, must be default constructible
Parameters
x_begin- The beginning of the range of x values to use
x_end- The end of the range of x values to use
y_begin- The beginning of the range of y values to use
y_end- The end of the range of y values to use
initialValue- A value for use as the first point in the returned vector (optional)
Returns
A vector with a size of one less than the input containers, however if the initialValue parameter is set, the size of the output will be the same as than of the input.
Exceptions
CppUtils::Math::InputSizeMismatchIf the sizes of the two containers don't match, we will throw an exception

References trapz().

Referenced by cumulativeTrapzIntegration(), and GTEST_TEST().

◆ cumulativeTrapzIntegration() [2/2]

template<typename ContainerX, typename ContainerY = ContainerX, typename Tx = typename ContainerX::value_type, typename Ty = typename ContainerY::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
auto CppUtils::Math::cumulativeTrapzIntegration ( const ContainerX & x,
const ContainerY & y,
std::optional< decltype(std::declval< Tx >() *std::declval< Ty >())> initialValue = std::nullopt )
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References cumulativeTrapzIntegration().

◆ get() [1/3]

template<std::size_t Index, typename T>
decltype(auto) CppUtils::Math::get ( Vector3D< T > & vec)

Specific getters for use in the tuple-like API, allows for the structured binding of a Vector3D

◆ get() [2/3]

template<std::size_t Index, typename T>
decltype(auto) CppUtils::Math::get ( const Vector3D< T > & vec)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get() [3/3]

template<std::size_t Index, typename T>
decltype(auto) CppUtils::Math::get ( Vector3D< T > && vec)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ linearLeastSquaresFitting()

template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
decltype(auto) CppUtils::Math::linearLeastSquaresFitting ( IteratorX x_begin,
IteratorX x_end,
IteratorY y_begin,
IteratorY y_end )
constexpr

Calculates the linear regression of a given function y with respect to x. Each of the functions, x and y, are represeted by containers with an iterator interface.

Template Parameters
IteratorX- The type of iterator used for the x container
IteratorY- The type of iterator used for the y container (defaults to the type of IteratorX)
Tx- The type of data in the x container, must be default constructible
Ty- The type of data in the y container, must be default constructible
Parameters
x_begin- The beginning of the range of x values to use
x_end- The end of the range of x values to use
y_begin- The beginning of the range of y values to use
y_end- The end of the range of y values to use
Returns
Three pieces of information which is contained in the specialized structure, details::LinearLeastSquaresResult. However, rather than use this strucure directly, we can use structured bindings to return the slope, intercept, and variance.
Exceptions
CppUtils::Math::InputSizeMismatchIf the sizes of the two containers don't match, we will throw an exception
Todo
This is a complicated function and would probably lend itself well to a functor class
Note
We calculate the variance of the slope not the standard deviation, because for physical quantities std::sqrt() isn't overloaded properly.

References calculateAverage(), and CppUtils::Math::details::LinearLeastSquaresResult< T_slope, T_intercept, T_variance, typename >::slope.

Referenced by GTEST_TEST().

◆ quadraticLeastSquaresFitting()

template<typename IteratorX, typename IteratorY = IteratorX, typename Tx = typename std::iterator_traits<IteratorX>::value_type, typename Ty = typename std::iterator_traits<IteratorY>::value_type, typename = std::enable_if_t<std::conjunction_v<std::is_default_constructible<Tx>, std::is_default_constructible<Ty>>>>
decltype(auto) CppUtils::Math::quadraticLeastSquaresFitting ( IteratorX x_begin,
IteratorX x_end,
IteratorY y_begin,
IteratorY y_end )
constexpr

Calculates the quadratic least squares regression of a given function y with respect to x. Each of the functions, x and y, are represeted by containers with an iterator interface.

Template Parameters
IteratorX- The type of iterator used for the x container
IteratorY- The type of iterator used for the y container (defaults to the type of IteratorX)
Tx- The type of data in the x container, must be default constructible
Ty- The type of data in the y container, must be default constructible
Parameters
x_begin- The beginning of the range of x values to use
x_end- The end of the range of x values to use
y_begin- The beginning of the range of y values to use
y_end- The end of the range of y values to use
Returns
Three pieces of information which is contained in the specialized structure, details::QuadraticLeastSquaresResult. However, rather than use this strucure directly, we can use structured bindings to return the parameters a, b, and c.
Exceptions
CppUtils::Math::InputSizeMismatchIf the sizes of the two containers don't match, we will throw an exception
Todo
This is a complicated function and would probably lend itself well to a functor class

References CppUtils::Math::details::QuadraticLeastSquaresResult< T_a, T_b, T_c, typename >::a.

◆ findOrderOfMagnitude()

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
int CppUtils::Math::findOrderOfMagnitude ( T value)
constexprnoexcept

Finds the order of magnitude of a given arithmetic value.

Template Parameters
T- The type of the parameter value, must be an arithmetic type
Parameters
value- The value we are trying to find the order of magnitude of

Referenced by findAbsoluteError().

◆ findAbsoluteError()

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
long double CppUtils::Math::findAbsoluteError ( T expectedValue,
std::size_t significantFigures )
constexprnoexcept

Computes the absolute error in an expected value up to a certain amount of know significant digits.

Template Parameters
T- The type of the parameter expectedValue, must be an arithmetic type
Parameters
expectedValue- The value we want to know the absolute error of
significantFigures- The number of digits we know to be precise in expectedValue

References findOrderOfMagnitude().

Referenced by GTEST_TEST(), and GTEST_TEST().

◆ calculateAverage()

template<typename Iterator, typename T = typename std::iterator_traits<Iterator>::value_type, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
T CppUtils::Math::calculateAverage ( Iterator x_begin,
Iterator x_end )
constexpr

Computes the average of a range of values specified by input iterators.

Template Parameters
Iterator- The input iterator for the container we are iterating over
T- The type of the value the iterator points to, must be default constructible
Parameters
x_begin- The beginning of the range we are iterating over
x_end- The end of the range we are iterating over

Referenced by calculateVariance(), GTEST_TEST(), and linearLeastSquaresFitting().

◆ calculateVariance()

template<typename Iterator, typename T = typename std::iterator_traits<Iterator>::value_type, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
decltype(auto) CppUtils::Math::calculateVariance ( Iterator x_begin,
Iterator x_end )
constexpr

Computes the variance from a range of values specified by input iterators from the following equation: \( \sigma^2 = \frac{1}{N - 1} \displaystyle \sum_{i = 0}^{N} (x_i - \bar x)^2.\)

Template Parameters
Iterator- The input iterator for the container we are iterating over
T- The type of the value the iterator points to, must be default constructible
Parameters
x_begin- The beginning of the range we are iterating over
x_end- The end of the range we are iterating over

References calculateAverage().

Referenced by GTEST_TEST().

◆ isEven()

template<typename T, typename = std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool>>>
bool CppUtils::Math::isEven ( T value)
constexpr

Function to determine whether an integral type is even.

Template Parameters
T- The type of the input to check, must be an integral type
Parameters
value- The input integral to check

Referenced by isOdd().

◆ isOdd()

template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
bool CppUtils::Math::isOdd ( T value)
constexpr

Function to determine whether an integral type is odd.

Template Parameters
T- The type of the input to check, must be an integral type
Parameters
value- The input integral to check

References isEven().

◆ withinRange() [1/2]

template<typename T>
bool CppUtils::Math::withinRange ( T value,
T min,
T max )
constexpr

A function to determine whether a given value is greater than or equal to a minimum value and less than or equal to a maximum value.

Template Parameters
T- The type of the input variables
Parameters
value- The value we want to compare
min- The minimum number in the range
max- The maximum number in the range

Referenced by withinRange().

◆ withinRange() [2/2]

template<int Min, int Max, typename T>
bool CppUtils::Math::withinRange ( T value)
constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References withinRange().

◆ linearlyInterpolate()

template<typename T>
std::vector< T > CppUtils::Math::linearlyInterpolate ( const std::vector< T > & x,
T y1,
T y2 )
constexpr

A function to linearly interpolate some function over a range set by an input vector.

Template Parameters
T- The type of the values we are interpolating
Parameters
x- The input vector containing the values we are interpolating over
y1- The value of the function we are interpolating in the beginning of the range
y2- The value of the function we are interpolating in the end of the range
Returns
A vector of y values with a size equal to that of the input x