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

Active the current backbone. More...

#include "concepts/util.h"
#include "util/tuple.h"
#include "util/named.h"
#include "util/reflection.h"
#include "util/apply_all.h"
#include "concepts/macro.h"
#include "concepts/backbone/type_traits.h"
#include "concepts/backbone/ordered.h"
#include "concepts/backbone/math.h"
#include "concepts/backbone/horizontal.h"
#include "concepts/backbone/control.h"
#include "concepts/backbone/gradient.h"
#include "concepts/backbone/complex.h"
#include "concepts/backbone/random.h"
#include "concepts/backbone/stringconvert.h"

Go to the source code of this file.

Classes

struct  string_converter< T >
 string convert of backbone types More...
 

Namespaces

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

Macros

#define BBM_BACKBONE_IMPORT(Config)
 BBM_BACKBONE_IMPORT: will be called each time BBM_IMPORT_CONFIG is called; default do nothing.
 
#define BBM_VALIDATE_BACKBONE(TYPE)
 Helper Macro to validate the backbone for a given type.
 
#define BBM_CALL_BACKBONE_OP(OpName)
 Helper macro: extend existing methods to support attribute types.
 
control methods
#define BBM_CALL_BACKBONE_FUNC(FuncName)
 

Functions

template<typename T >
remove_diff_t< T > & detach_gradient (T &)
 
template<typename T >
void track_gradient (T &, bool)
 
template<typename T >
bool is_gradient_tracked (T &)
 
template<typename T >
const remove_diff_t< T > & gradient (T &)
 
template<typename T >
void forward_gradient (T &)
 
template<typename T >
void backward_gradient (T &)
 
template<typename T >
requires false
std::string toString (const T &)
 regular drjit::array types
 
template<typename T >
requires false
fromString (const std::string &)
 
template<typename RET , typename C , typename Index >
requires std::ranges::range<C> && ((std::constructible_from<RET> && // (trivially constructible AND ((is_tuple_v<RET> && is_tuple_v<std::ranges::range_value_t<C>>) || // (tuple OR (named_equivalence_v<RET, std::ranges::range_value_t<C>>) || // named OR (concepts::reflection::supported<RET> && concepts::reflection::supported<std::ranges::range_value_t<C>>))) || // unnamed)) OR requires(C&& c, Index i, index_mask_t<Index> m) {{backbone::lookup<RET>(c,i,m)};})
RET lookup (C &&container, const Index &idx, const index_mask_t< Index > &mask=true)
 Generalize backbone::lookup to include containers of tuples/named tuples/reflection-supported types.
 
template<typename Value , typename C , typename Index >
void set (C &&container, const Index &idx, Value &&value, const index_mask_t< Index > &mask=true)
 Generalization of backbone::set to include tuples/named/reflection-supported objects.
 
math functions
 BBM_CALL_BACKBONE_OP (cossin)
 
 BBM_CALL_BACKBONE_OP (eq)
 
 BBM_CALL_BACKBONE_OP (neq)
 
 BBM_CALL_BACKBONE_OP (isnan)
 
 BBM_CALL_BACKBONE_OP (isinf)
 
 BBM_CALL_BACKBONE_OP (isfinite)
 
complex functions
 BBM_CALL_BACKBONE_OP (real)
 
 BBM_CALL_BACKBONE_OP (imag)
 
 BBM_CALL_BACKBONE_OP (conj)
 
horizontal methods
 BBM_CALL_BACKBONE_OP (hsum)
 
 BBM_CALL_BACKBONE_OP (hprod)
 
 BBM_CALL_BACKBONE_OP (hmax)
 
 BBM_CALL_BACKBONE_OP (hmin)
 
 BBM_CALL_BACKBONE_OP (dot)
 
 BBM_CALL_BACKBONE_OP (norm)
 
 BBM_CALL_BACKBONE_OP (squared_norm)
 
 BBM_CALL_BACKBONE_OP (normalize)
 
 BBM_CALL_BACKBONE_OP (all)
 
 BBM_CALL_BACKBONE_OP (any)
 
 BBM_CALL_BACKBONE_OP (none)
 
 BBM_CALL_BACKBONE_OP (count)
 
select generalization to (named) tuples and types with reflection support
template<typename MASK , typename A >
requires (concepts::reflection::supported<A> || is_tuple_v<anonymize_t<A>>)
constexpr auto select (MASK &&mask, const A &a, const A &b)
 
template<typename MASK , typename A , typename B >
requires requires(MASK m, A a, B b) {{bbm::detail::select(m,a,b)};}
constexpr auto select (MASK &&mask, A &&a, B &&b)
 
Gradient methods
template<typename T >
auto detach_gradient (T &t)
 Detach the value from the gradient computations.
 
template<typename T >
auto gradient (T &t)
 Return the gradient.
 
template<typename T >
bool is_gradient_tracked (const T &t)
 Checks if gradients are enabled for a variable.
 
template<typename T >
void track_gradient (T &t, bool toggle=true)
 Enable/disable tracking of gradients for a variable.
 
template<typename T >
void forward_gradient (T &t)
 Enable forward gradient tracking.
 
template<typename T >
void backward_gradient (T &t)
 Enable backward/reverse gradient tracking.
 

Detailed Description

Active the current backbone.

Macro Definition Documentation

◆ BBM_BACKBONE_IMPORT

#define BBM_BACKBONE_IMPORT (   Config)

BBM_BACKBONE_IMPORT: will be called each time BBM_IMPORT_CONFIG is called; default do nothing.

◆ BBM_CALL_BACKBONE_FUNC

#define BBM_CALL_BACKBONE_FUNC (   FuncName)
Value:
template<typename T, typename... U> requires requires(const T& t, const U&... u) {{apply_all([](auto& t, auto&... u) { return backbone::FuncName(t, u...); }, t, u...)};} \
inline auto FuncName (const T& t, const U&... u) \
{ \
return apply_all( [](auto& t, auto&... u) { return backbone::FuncName(t, u...); }, t, u...); \
} \
constexpr decltype(auto) u(bbm::vec2d< T > &v)
Definition: vec.h:37
auto apply_all(const FUNC &func, const T &... t)
Apply a function.
Definition: apply_all.h:42

◆ BBM_CALL_BACKBONE_OP

#define BBM_CALL_BACKBONE_OP (   OpName)
Value:
template<typename... T> requires requires(const T&... t) {{backbone::OpName(bbm::value(t)...)};} \
inline constexpr auto OpName(const T&... t) \
{ \
return backbone::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: extend existing methods to support attribute types.

◆ BBM_VALIDATE_BACKBONE

#define BBM_VALIDATE_BACKBONE (   TYPE)
Value:
BBM_CHECK_RAW_CONCEPT( std::constructible_from, TYPE ); \
BBM_CHECK_RAW_CONCEPT( std::copy_constructible, TYPE ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::has_basic_math, TYPE ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::backbone::has_math_functions, TYPE ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::backbone::ordered, TYPE ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::backbone::horizontal, TYPE ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::backbone::control, TYPE ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::backbone::is_rng, bbm::rng<TYPE> ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::has_logical_operators, bbm::mask_t<TYPE> ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::has_bit_operators, bbm::mask_t<TYPE> ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::has_basic_math, bbm::replace_scalar_t<TYPE, size_t>); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::has_increment, bbm::replace_scalar_t<TYPE, size_t> ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::has_decrement, bbm::replace_scalar_t<TYPE, size_t> ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::backbone::if_diff_gradient, TYPE ); \
BBM_CHECK_RAW_CONCEPT( bbm::concepts::stringconvert, TYPE ); \
A type T has valid control methods if:
Definition: control.h:33
Concept to check if a type has all bbm math functions.
Definition: math.h:46
A type T has horizontal functions if:
Definition: horizontal.h:39
Only check gradient concept if is_diff_v<T>
Definition: gradient.h:80
Concept to check a randum number generator.
Definition: random.h:24
Comparison operators:
Definition: ordered.h:24
Definition: util.h:97
bit operators
Definition: util.h:124
Definition: util.h:112
Definition: util.h:105
logical operators
Definition: util.h:139
Definition: stringconvert.h:68
#define BBM_CHECK_RAW_CONCEPT(CONCEPTNAME, CLASSNAME,...)
Check a class for a concept.
Definition: macro.h:32
Random generator wrapper around Drjit's PCG32.
Definition: random.h:34

Helper Macro to validate the backbone for a given type.

  • TYPE has basic_math (+, -, *, /, %)
  • TYPE supports (==, !=, <, >, <=, and >=)
  • TYPE supports horizontal operations
  • TYPE supports the control method select, lookup, and detach.
  • mask_t<TYPE> is valid (bit and logical operators)
  • replace_scalar_t<TYPE> is a valid size_t.