83 inline double abs2(
double x) {
return x * x; }
91 inline double abs2(std::complex<double> z) {
return (
conj(z) * z).real(); }
99 inline bool isnan(std::complex<double>
const &z) {
return std::isnan(z.real()) or std::isnan(z.imag()); }
109 template <
typename T>
111 requires(std::is_integral_v<T>)
114 for (
int i = 0; i < n; ++i) r *= x;
127 auto pow(A &&a,
double p) {
128 return nda::map([p](
auto const &x) {
131 })(std::forward<A>(a));
152 return std::forward<A>(a);
Provides concepts for the nda library.
bool isnan(std::complex< double > const &z)
Check if a std::complex<double> is NaN.
double abs2(double x)
Get the squared absolute value of a double.
auto real(T t)
Get the real part of a scalar.
auto conj(T t)
Get the complex conjugate of a scalar.
T pow(T x, int n)
Calculate the integer power of an integer.
mapped< F > map(F f)
Create a lazy function call expression on arrays/views.
constexpr bool is_complex_v
Constexpr variable that is true if type T is a std::complex type.
constexpr bool is_scalar_v
Constexpr variable that is true if type S is a scalar type, i.e. arithmetic or complex.
Provides lazy function calls on arrays/views.
auto operator()(auto const &x) const
Function call operator that forwards the call to nda::conj.
Provides type traits for the nda library.