Loading...
Searching...
No Matches
horizontal.h
Go to the documentation of this file.
1#ifndef _BBM_DRJIT_HORIZONTAL_H_
2#define _BBM_DRJIT_HORIZONTAL_H_
3
4/************************************************************************/
5/*! \file horizontal.h
6
7 \brief Map bbm horizontal methods to corresponding DrJIT methods
8
9*************************************************************************/
10
11namespace backbone {
12
13 /**********************************************************************/
14 /*! @{ Direct mapping to DrJIT methods if not a scalar
15 *********************************************************************/
16 template<typename T>
17 inline auto dot(const T& a, const T& b)
18 {
19 if constexpr (std::is_scalar_v<T>) return a*b;
20 else return drjit::dot(a, b);
21 }
22
23 template<typename T>
24 inline auto norm(const T& a)
25 {
26 if constexpr (std::is_scalar_v<T>) return drjit::abs(a);
27 else return drjit::norm(a);
28 }
29
30 template<typename T>
31 inline auto squared_norm(const T& a)
32 {
33 if constexpr (std::is_scalar_v<T>) return a*a;
34 else return drjit::squared_norm(a);
35 }
36
37 template<typename T>
38 inline auto normalize(const T& a)
39 {
40 if constexpr (std::is_scalar_v<T>) return T(1);
41 else return drjit::normalize(a);
42 }
43
44 using drjit::all;
45 using drjit::any;
46 using drjit::none;
47 using drjit::count;
48 //! @}
49
50 /**********************************************************************/
51 /*! @{ \name Passthough to DrJIT (name change)
52 **********************************************************************/
53 template<typename T> inline auto hsum(const T& t) { return drjit::sum(t); }
54 template<typename T> inline auto hprod(const T& t) { return drjit::prod(t); }
55 template<typename T> inline auto hmax(const T& t) { return drjit::max(t); }
56 template<typename T> inline auto hmin(const T& t) { return drjit::min(t); }
57 //! @}
58
59} // end backbone namespace
60
61#endif /* _BBM_DRJIT_HORIZONTAL_H_ */
Random number generator; built on top of Drjit.
Definition: backbone.h:53
auto hprod(const T &t)
Definition: horizontal.h:54
auto hsum(const T &t)
Definition: horizontal.h:53
auto dot(const T &a, const T &b)
Definition: horizontal.h:17
auto norm(const T &a)
Definition: horizontal.h:24
auto squared_norm(const T &a)
Definition: horizontal.h:31
auto hmax(const T &t)
Definition: horizontal.h:55
auto normalize(const T &a)
Definition: horizontal.h:38
auto hmin(const T &t)
Definition: horizontal.h:56