pbpt
Loading...
Searching...
No Matches
pbpt::math::detail Namespace Reference

Contains internal implementation details for the math library. More...

Functions

template<typename T>
constexpr T sqrt_newton_raphson (T x, T curr, T prev)
 A constexpr implementation of the square root function using the Newton-Raphson method.
template<typename T>
constexpr T sin_taylor (T x)
 A constexpr implementation of the sine function using a Taylor series expansion.
template<typename T>
constexpr T cos_taylor (T x)
 A constexpr implementation of the cosine function using a Taylor series expansion.

Detailed Description

Contains internal implementation details for the math library.

Warning
Users should not directly use anything from this namespace.

Function Documentation

◆ cos_taylor()

template<typename T>
T pbpt::math::detail::cos_taylor ( T x)
constexpr

A constexpr implementation of the cosine function using a Taylor series expansion.

This is intended for compile-time use. For best precision, the input angle x should be in the range [-PI/2, PI/2].

Template Parameters
TFloating-point type.
Parameters
xThe angle in radians.
Returns
The cosine of x.

◆ sin_taylor()

template<typename T>
T pbpt::math::detail::sin_taylor ( T x)
constexpr

A constexpr implementation of the sine function using a Taylor series expansion.

This is intended for compile-time use. For best precision, the input angle x should be in the range [-PI/2, PI/2].

Template Parameters
TFloating-point type.
Parameters
xThe angle in radians.
Returns
The sine of x.

◆ sqrt_newton_raphson()

template<typename T>
T pbpt::math::detail::sqrt_newton_raphson ( T x,
T curr,
T prev )
constexpr

A constexpr implementation of the square root function using the Newton-Raphson method.

This function recursively approximates the square root. It is intended for compile-time use only and is called by the public pbpt::math::sqrt function.

Template Parameters
TThe floating-point or integral type of the number.
Parameters
xThe non-negative number to find the square root of.
currThe current guess for the square root.
prevThe previous guess, used to check for convergence.
Returns
The approximate square root of x.