Loading...
Searching...
No Matches
Namespaces | Macros | Typedefs
math.h File Reference

Extend basic math function to scalar STL and backbone::array types. More...

#include <cmath>
#include <utility>
#include "concepts/util.h"
#include "util/iterator_util.h"
#include "util/poly.h"
#include "backbone/vec.h"

Go to the source code of this file.

Namespaces

namespace  backbone
 Random number generator; built on top of Drjit.
 

Macros

#define BBM_ARRAY_FUNC(Func)
 Helper Macro for defining functions on arrays.
 

Typedefs

template<typename... T>
using result_t = typename detail::result_impl< T... >::type
 determine the mathematical result type; reverts to first argument if '+' is not defined on T...
 

Functions

STL math extensions
template<typename T , typename U >
requires (!is_array_v<T>) && requires(T a, U b) { { std::atan2(result_t<T, U>(a), result_t<T,U>(b)) }; }
constexpr auto atan2 (T a, U b)
 
template<typename T , typename U >
requires (!is_array_v<T>) && requires(T a, U b) { { std::fmod(result_t<T, U>(a), result_t<T,U>(b)) }; }
constexpr auto fmod (T a, U b)
 
template<typename T , typename U , typename V >
requires (!is_array_v<T>) && requires(T a, U b, V c) { { std::lerp(result_t<T, U, V>(a), result_t<T,U,V>(b), result_t<T,U,V>(c)) }; }
constexpr auto lerp (T a, U b, V c)
 
template<typename T , typename U >
requires (!is_array_v<T>) && requires(T a, U b) { { std::pow(result_t<T, U>(a), result_t<T,U>(b)) }; }
constexpr auto pow (T a, U b)
 
template<typename T , typename U >
requires (!is_array_v<T>) && requires(T a, U b) { { std::fmax(result_t<T,U>(a), result_t<T,U>(b)) }; }
constexpr auto max (T a, U b)
 
template<typename T , typename U >
requires (!is_array_v<T>) && requires(T a, U b) { { std::fmin(result_t<T,U>(a), result_t<T,U>(b)) }; }
constexpr auto min (T a, U b)
 
template<typename T , typename L , typename U >
requires (!is_array_v<T>) && requires(const T& a, const L& l, const U& u) { { std::clamp(a, T(l), T(u)) }; }
constexpr auto clamp (const T &a, const L &l, const U &u)
 
template<typename T >
constexpr auto rcp (T a)
 
template<typename T >
requires requires(const T& a) {{std::sqrt(a)};}
constexpr auto rsqrt (T a)
 
template<typename T >
requires requires(const T& a) {{std::log(a)};}
constexpr auto erfinv (T a)
 
template<typename T >
requires requires(T a) { { std::copysign(T(1), a) }; }
constexpr auto sign (T a)
 
template<typename T >
requires requires(T a) { { std::cos(a) }; { std::sin(a) }; }
constexpr vec2d< T > cossin (T a)
 
template<typename T >
requires requires(T a) { { std::sqrt(std::fmax(a,T(0))) }; }
constexpr auto safe_sqrt (T a)
 
template<typename T >
requires requires(T a) { { std::asin(std::fmin(T(1), std::fmax(T(-1), a))) }; }
constexpr auto safe_asin (T a)
 
template<typename T >
requires requires(T a) { { std::acos(std::fmin(T(1), std::fmax(T(-1), a))) }; }
constexpr auto safe_acos (T a)
 
template<typename T , typename U >
requires std::is_scalar_v<T> && std::is_scalar_v<U>
constexpr auto eq (T a, U b)
 
template<typename T , typename U >
requires std::is_scalar_v<T> && std::is_scalar_v<U>
constexpr auto neq (T a, U b)
 
 BBM_ARRAY_FUNC (exp)
 Math Functions on iterable containers.
 
 BBM_ARRAY_FUNC (log)
 
 BBM_ARRAY_FUNC (sin)
 
 BBM_ARRAY_FUNC (asin)
 
 BBM_ARRAY_FUNC (cos)
 
 BBM_ARRAY_FUNC (acos)
 
 BBM_ARRAY_FUNC (tan)
 
 BBM_ARRAY_FUNC (atan)
 
 BBM_ARRAY_FUNC (sinh)
 
 BBM_ARRAY_FUNC (asinh)
 
 BBM_ARRAY_FUNC (cosh)
 
 BBM_ARRAY_FUNC (acosh)
 
 BBM_ARRAY_FUNC (tanh)
 
 BBM_ARRAY_FUNC (atanh)
 
 BBM_ARRAY_FUNC (ceil)
 
 BBM_ARRAY_FUNC (floor)
 
 BBM_ARRAY_FUNC (round)
 
 BBM_ARRAY_FUNC (abs)
 
 BBM_ARRAY_FUNC (sign)
 
 BBM_ARRAY_FUNC (sqrt)
 
 BBM_ARRAY_FUNC (cbrt)
 
 BBM_ARRAY_FUNC (rcp)
 
 BBM_ARRAY_FUNC (rsqrt)
 
 BBM_ARRAY_FUNC (safe_sqrt)
 
 BBM_ARRAY_FUNC (safe_asin)
 
 BBM_ARRAY_FUNC (safe_acos)
 
 BBM_ARRAY_FUNC (erf)
 
 BBM_ARRAY_FUNC (erfc)
 
 BBM_ARRAY_FUNC (erfinv)
 
 BBM_ARRAY_FUNC (tgamma)
 
 BBM_ARRAY_FUNC (lgamma)
 
 BBM_ARRAY_FUNC (eq)
 
 BBM_ARRAY_FUNC (neq)
 
 BBM_ARRAY_FUNC (atan2)
 
 BBM_ARRAY_FUNC (max)
 
 BBM_ARRAY_FUNC (min)
 
 BBM_ARRAY_FUNC (fmod)
 
 BBM_ARRAY_FUNC (copysign)
 
 BBM_ARRAY_FUNC (pow)
 
 BBM_ARRAY_FUNC (lerp)
 
 BBM_ARRAY_FUNC (clamp)
 
 BBM_ARRAY_FUNC (isnan)
 
 BBM_ARRAY_FUNC (isinf)
 
 BBM_ARRAY_FUNC (isfinite)
 
template<typename T >
requires is_array_v<T> && requires(const T& t) {{ cos(t) }; { sin(t) }; }
vec2d< T > cossin (const T &a)
 

Detailed Description

Extend basic math function to scalar STL and backbone::array types.

Satisfies concepts::backbone::has_math_functions

Macro Definition Documentation

◆ BBM_ARRAY_FUNC

#define BBM_ARRAY_FUNC (   Func)
Value:
template<typename T, typename... U> requires requires(const T& t, const U&... u) {{backbone::detail::array_invoke([](auto&t, auto&... u) { return Func(t, u...); }, t, u...)};} \
inline auto Func(const T& t, const U&... u) \
{ \
return backbone::detail::array_invoke([](auto& t, auto&... u) { return Func(t, u...); }, t, u...); \
} \
constexpr decltype(auto) u(bbm::vec2d< T > &v)
Definition: vec.h:37

Helper Macro for defining functions on arrays.