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

Connect the bbm math functions to the corresponding enoki methods. More...

#include "backbone/vec.h"
#include "backbone/array.h"
#include "enoki/special.h"
#include "core/attribute.h"

Go to the source code of this file.

Namespaces

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

Macros

#define BBM_ENOKI_MATHOP(OpName)
 Helper Macro for mapping math operations to enoki. Takes in account to pass the 'value' of variables and to cast scalars to the correct type to preserve differentiability.
 
#define BBM_ENOKI_BINARY_OP(OpName)
 Helper Macro for that ensures that binary math operators with rvalues do not cast the non-rvalue operant.
 

Functions

template<typename T >
vec2d< T > cossin (const T &a)
 cossin
 
Map math operations to Enoki functions
 BBM_ENOKI_MATHOP (exp)
 
 BBM_ENOKI_MATHOP (log)
 
 BBM_ENOKI_MATHOP (sin)
 
 BBM_ENOKI_MATHOP (asin)
 
 BBM_ENOKI_MATHOP (cos)
 
 BBM_ENOKI_MATHOP (acos)
 
 BBM_ENOKI_MATHOP (tan)
 
 BBM_ENOKI_MATHOP (atan)
 
 BBM_ENOKI_MATHOP (atan2)
 
 BBM_ENOKI_MATHOP (sinh)
 
 BBM_ENOKI_MATHOP (asinh)
 
 BBM_ENOKI_MATHOP (cosh)
 
 BBM_ENOKI_MATHOP (acosh)
 
 BBM_ENOKI_MATHOP (tanh)
 
 BBM_ENOKI_MATHOP (atanh)
 
 BBM_ENOKI_MATHOP (ceil)
 
 BBM_ENOKI_MATHOP (floor)
 
 BBM_ENOKI_MATHOP (round)
 
 BBM_ENOKI_MATHOP (clamp)
 
 BBM_ENOKI_MATHOP (fmod)
 
 BBM_ENOKI_MATHOP (copysign)
 
 BBM_ENOKI_MATHOP (sign)
 
 BBM_ENOKI_MATHOP (lerp)
 
 BBM_ENOKI_MATHOP (abs)
 
 BBM_ENOKI_MATHOP (sqrt)
 
 BBM_ENOKI_MATHOP (cbrt)
 
 BBM_ENOKI_MATHOP (pow)
 
 BBM_ENOKI_MATHOP (max)
 
 BBM_ENOKI_MATHOP (min)
 
 BBM_ENOKI_MATHOP (safe_sqrt)
 
 BBM_ENOKI_MATHOP (safe_asin)
 
 BBM_ENOKI_MATHOP (safe_acos)
 
 BBM_ENOKI_MATHOP (erf)
 
 BBM_ENOKI_MATHOP (erfc)
 
 BBM_ENOKI_MATHOP (erfinv)
 
 BBM_ENOKI_MATHOP (tgamma)
 
 BBM_ENOKI_MATHOP (lgamma)
 
 BBM_ENOKI_MATHOP (eq)
 
 BBM_ENOKI_MATHOP (neq)
 
 BBM_ENOKI_MATHOP (rcp)
 
 BBM_ENOKI_MATHOP (rsqrt)
 
 BBM_ENOKI_MATHOP (isnan)
 
 BBM_ENOKI_MATHOP (isinf)
 
 BBM_ENOKI_MATHOP (isfinite)
 

Detailed Description

Connect the bbm math functions to the corresponding enoki methods.

Satisfies concepts::backbone::has_math_functions

Macro Definition Documentation

◆ BBM_ENOKI_BINARY_OP

#define BBM_ENOKI_BINARY_OP (   OpName)
Value:
template<typename T, typename D> \
inline constexpr auto OpName(T&& t, D&& d) -> decltype( enoki::OpName< enoki::detail::binary_cast_t<T,D>, enoki::detail::binary_cast_t<D,T> >( t, d ) ) \
{ \
return enoki::OpName<enoki::detail::binary_cast_t<T,D>, enoki::detail::binary_cast_t<D,T>>(t, d); \
} \

Helper Macro for that ensures that binary math operators with rvalues do not cast the non-rvalue operant.

◆ BBM_ENOKI_MATHOP

#define BBM_ENOKI_MATHOP (   OpName)
Value:
template<typename... Ts> requires requires(const Ts&... t) {{enoki::OpName(bbm::value(t)...)};} \
inline constexpr auto OpName(const Ts&... t) \
{ \
constexpr bool has_floating_scalar = (( std::is_scalar_v< std::decay_t<decltype(bbm::value(t))> > && std::is_floating_point_v< std::decay_t<decltype(bbm::value(t))> > ) || ...); \
\
if constexpr (has_floating_scalar) \
{ \
using base_type = decltype( (std::declval<std::conditional_t< std::is_scalar_v< std::decay_t<decltype(bbm::value(t))> >, float, decltype(bbm::value(t)) >>() + ...) ); \
using type = enoki::scalar_t<base_type>; \
return enoki::OpName( std::conditional_t<std::is_scalar_v<std::decay_t<decltype(bbm::value(t))>>, type, decltype(bbm::value(t))>(bbm::value(t))... ); \
} \
else return enoki::OpName( bbm::value(t)... ); \
} \
decltype(auto) value(T &&t)
return the value of an attribute, or if not an attribute the object
Definition: attribute_value.h:20

Helper Macro for mapping math operations to enoki. Takes in account to pass the 'value' of variables and to cast scalars to the correct type to preserve differentiability.