1#ifndef _BBM_NATIVE_HORIZONTAL_H_
2#define _BBM_NATIVE_HORIZONTAL_H_
11#include "backbone/math.h"
23 template<
typename T>
requires std::is_scalar_v<T>
24 inline T
hsum(
const T& t) {
return t; }
26 template<
typename T>
requires std::is_scalar_v<T>
27 inline T
hprod(
const T& t) {
return t; }
29 template<
typename T>
requires std::is_scalar_v<T>
30 inline T
hmax(
const T& t) {
return t; }
32 template<
typename T>
requires std::is_scalar_v<T>
33 inline T
hmin(
const T& t) {
return t; }
35 template<
typename T>
requires std::is_scalar_v<T>
36 inline T
dot(
const T& a,
const T& b) {
return a*b; }
38 template<
typename T>
requires std::is_scalar_v<T>
39 inline T
norm(
const T& t) {
return std::abs(t); }
41 template<
typename T>
requires std::is_scalar_v<T>
44 template<
typename T>
requires std::is_scalar_v<T>
49 template<
typename T>
requires std::convertible_to<T, bool>
50 inline bool all(
const T& t) {
return t; }
52 template<
typename T>
requires std::convertible_to<T, bool>
53 inline bool any(
const T& t) {
return t; }
55 template<
typename T>
requires std::convertible_to<T, bool>
56 inline bool none(
const T& t) {
return !t; }
58 template<
typename T>
requires std::convertible_to<T, bool>
59 inline size_t count(
const T& t) {
return t; }
63 template<
typename T,
size_t N>
66 return std::accumulate(std::begin(t), std::end(t), std::decay_t<T>(0));
69 template<
typename T,
size_t N>
72 return std::accumulate(std::begin(t), std::end(t), std::decay_t<T>(1), std::multiplies<
value_t<T>>());
75 template<
typename T,
size_t N>
78 return *std::max_element(std::begin(t), std::end(t));
81 template<
typename T,
size_t N>
84 return *std::min_element(std::begin(t), std::end(t));
87 template<
typename T,
typename U,
size_t N>
90 return std::inner_product(std::begin(a), std::end(a), std::begin(b), std::decay_t<T>(0));
93 template<
typename T,
size_t N>
99 template<
typename T,
size_t N>
105 template<
typename T,
size_t N>
116 return std::all_of(std::begin(t), std::end(t), std::identity());
122 return std::any_of(std::begin(t), std::end(t), std::identity());
128 return std::none_of(std::begin(t), std::end(t), std::identity());
Random number generator; built on top of Drjit.
Definition: backbone.h:53
size_t count(const T &t)
Definition: horizontal.h:59
auto hprod(const T &t)
Definition: horizontal.h:54
typename backbone::detail::value< std::decay_t< T > >::type value_t
Value trait.
Definition: type_traits.h:35
bool none(const T &t)
Definition: horizontal.h:56
bool all(const T &t)
Definition: horizontal.h:50
constexpr auto rsqrt(T a)
Definition: math.h:112
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
bool any(const T &t)
Definition: horizontal.h:53
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