1#ifndef _BBM_NATIVE_COMPLEX_H_
2#define _BBM_NATIVE_COMPLEX_H_
5#include "backbone/array.h"
6#include "backbone/vec.h"
24 using base_type::operator=;
27 template<
typename U=T>
requires std::constructible_from<T,U>
30 template<
typename U>
requires std::constructible_from<T,U>
33 template<
typename U>
requires std::constructible_from<T, U>
38 inline constexpr auto std_complex(
void)
const ->
decltype(std::complex(std::declval<T>(), std::declval<T>()))
44 static inline constexpr auto std_complex(
complex<U> u) ->
decltype(std::complex(std::declval<T>(), std::declval<T>()))
46 using type =
typename decltype(
std_complex())::value_type;
47 return {type(
real(u)), type(
imag(u))};
52 template<
typename U>
requires std::constructible_from<T, U>
61 template<
typename U>
inline constexpr complex&
operator+=(U u) { *
this = *
this + u;
return *
this; }
69 template<
typename U>
inline constexpr complex&
operator-=(U u) { *
this = *
this - u;
return *
this; }
77 template<
typename U>
inline constexpr complex&
operator*=(U u) { *
this = *
this * u;
return *
this; }
84 template<
typename U>
inline constexpr complex&
operator/=(U u) { *
this = *
this / u;
return *
this; }
102 #define BBM_DECL_COMPLEX_OP(op) template<typename T> inline constexpr complex<T> op (complex<T> z) { return std::op (z.std_complex()); }
121 #undef BBM_DECL_COMPLEX_OP
136 template<
typename T>
struct is_complex_impl : std::false_type {};
137 template<
typename T>
struct is_complex_impl<
complex<T>> : std::true_type {};
145 template<
typename T>
struct array_size<
complex<T>> {
static constexpr size_t value = 2; };
#define BBM_DECL_COMPLEX_OP(op)
Definition: complex.h:102
Random number generator; built on top of Drjit.
Definition: backbone.h:53
constexpr bool is_complex_v
Definition: complex.h:155
constexpr complex< T > psum(complex< T > z)
Definition: complex.h:129
constexpr complex< T > conj(complex< T > z)
Definition: complex.h:91
constexpr complex< T > reverse(complex< T > z)
Definition: complex.h:128
detail::is_complex_impl< std::decay_t< T > > is_complex
Definition: complex.h:152
drjit::Complex< T > complex
Alias drjit::Complex.
Definition: complex.h:20
vec2d< T > cossin(const T &a)
cossin
Definition: math.h:107
constexpr T real(complex< T > z)
Definition: complex.h:89
drjit::Array< T, 2 > vec2d
Definition: vec.h:13
constexpr complex< T > rcp(complex< T > z)
rcp
Definition: complex.h:95
constexpr T imag(complex< T > z)
Definition: complex.h:90
auto squared_norm(const T &a)
Definition: horizontal.h:31
auto normalize(const T &a)
Definition: horizontal.h:38
bbm::detail::is_array_impl< std::decay_t< T > > is_array
Definition: type_traits.h:163
decltype(auto) value(T &&t)
return the value of an attribute, or if not an attribute the object
Definition: attribute_value.h:20
Complex numbers.
Definition: complex.h:22
friend constexpr complex operator+(T u, complex &t)
Definition: complex.h:59
constexpr complex operator/(T u) const
Definition: complex.h:81
constexpr complex operator+(complex< U > u) const
Definition: complex.h:58
constexpr complex & operator+=(U u)
Definition: complex.h:61
constexpr complex operator*(T u) const
Definition: complex.h:73
constexpr complex operator*(complex< U > u) const
Definition: complex.h:74
constexpr complex(const std::complex< U > &src)
Definition: complex.h:34
constexpr complex operator+(T u) const
Definition: complex.h:57
constexpr complex & operator*=(U u)
Definition: complex.h:77
constexpr complex operator-(complex< U > u) const
Definition: complex.h:66
constexpr complex(const array< U, 2 > &src)
Definition: complex.h:31
friend constexpr complex operator-(T u, complex &t)
Definition: complex.h:67
complex & operator=(U &&r)
Specialized assignment operator.
Definition: complex.h:53
constexpr complex & operator-=(U u)
Definition: complex.h:69
constexpr auto std_complex(void) const -> decltype(std::complex(std::declval< T >(), std::declval< T >()))
Definition: complex.h:38
static constexpr auto std_complex(complex< U > u) -> decltype(std::complex(std::declval< T >(), std::declval< T >()))
Definition: complex.h:44
constexpr complex operator-(T u) const
Definition: complex.h:65
constexpr complex(const T &r=0, const U &i=0)
Definition: complex.h:28
constexpr complex operator/(complex< U > u) const
Definition: complex.h:82
constexpr complex & operator/=(U u)
Definition: complex.h:84
friend constexpr complex operator/(T u, complex &t)
Definition: complex.h:83
friend constexpr complex operator*(T u, complex &t)
Definition: complex.h:75