Elementary mathematical functions (trigonometry, exp, log, complex numbers, rounding). More...
#include <memory_resource>#include <nk/value/value.hpp>#include <nk/value/span.hpp>Go to the source code of this file.
Classes | |
| struct | nk::builtin::PolarPair |
| Result of 2D Cartesian to polar conversion ([theta, rho] = cart2pol(x, y)). More... | |
| struct | nk::builtin::CylTriple |
| Result of 3D Cartesian to cylindrical conversion ([theta, rho, z] = cart2pol(x, y, z)). More... | |
| struct | nk::builtin::CartPair |
| Result of 2D polar to Cartesian conversion ([x, y] = pol2cart(theta, rho)). More... | |
| struct | nk::builtin::CartTriple |
| Result of 3D cylindrical/spherical to Cartesian conversion ([x, y, z]). More... | |
| struct | nk::builtin::SphTriple |
| Result of 3D Cartesian to spherical conversion ([az, el, r] = cart2sph(x, y, z)). More... | |
Functions | |
| Value | nk::builtin::sin (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise sine in radians (y = sin(x)). | |
| Value | nk::builtin::cos (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise cosine in radians (y = cos(x)). | |
| Value | nk::builtin::tan (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise tangent in radians (y = tan(x)). | |
| Value | nk::builtin::asin (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse sine in radians (y = asin(x)). | |
| Value | nk::builtin::acos (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse cosine in radians (y = acos(x)). | |
| Value | nk::builtin::atan (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse tangent in radians (y = atan(x)). | |
| Value | nk::builtin::atan2 (const Value &y, const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Four-quadrant inverse tangent in radians (theta = atan2(y, x)). | |
| Value | nk::builtin::sec (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise secant in radians (y = sec(x) = 1 / cos(x)). | |
| Value | nk::builtin::csc (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise cosecant in radians (y = csc(x) = 1 / sin(x)). | |
| Value | nk::builtin::cot (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise cotangent in radians (y = cot(x) = 1 / tan(x)). | |
| Value | nk::builtin::asec (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse secant in radians (y = asec(x)). | |
| Value | nk::builtin::acsc (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse cosecant in radians (y = acsc(x)). | |
| Value | nk::builtin::acot (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse cotangent in radians (y = acot(x)). | |
| Value | nk::builtin::sind (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise sine in degrees (y = sind(x)). | |
| Value | nk::builtin::cosd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise cosine in degrees (y = cosd(x)). | |
| Value | nk::builtin::tand (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise tangent in degrees (y = tand(x)). | |
| Value | nk::builtin::asind (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse sine in degrees (y = asind(x)). | |
| Value | nk::builtin::acosd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse cosine in degrees (y = acosd(x)). | |
| Value | nk::builtin::atand (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse tangent in degrees (y = atand(x)). | |
| Value | nk::builtin::atan2d (const Value &y, const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Four-quadrant inverse tangent in degrees (theta = atan2d(y, x)). | |
| Value | nk::builtin::secd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise secant in degrees (y = secd(x)). | |
| Value | nk::builtin::cscd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise cosecant in degrees (y = cscd(x)). | |
| Value | nk::builtin::cotd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise cotangent in degrees (y = cotd(x)). | |
| Value | nk::builtin::asecd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse secant in degrees (y = asecd(x)). | |
| Value | nk::builtin::acscd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse cosecant in degrees (y = acscd(x)). | |
| Value | nk::builtin::acotd (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inverse cotangent in degrees (y = acotd(x)). | |
| Value | nk::builtin::sinpi (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise sine of pi times input (y = sin(pi * x)). | |
| Value | nk::builtin::cospi (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Elementwise cosine of pi times input (y = cos(pi * x)). | |
| Value | nk::builtin::deg2rad (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Converts angles from degrees to radians (y = deg2rad(x)). | |
| Value | nk::builtin::rad2deg (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Converts angles from radians to degrees (y = rad2deg(x)). | |
| Value | nk::builtin::wrapToPi (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Wraps angles in radians to interval [-pi, pi]. | |
| Value | nk::builtin::wrapTo2Pi (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Wraps angles in radians to interval [0, 2*pi). | |
| Value | nk::builtin::wrapTo180 (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Wraps angles in degrees to interval [-180, 180]. | |
| Value | nk::builtin::wrapTo360 (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Wraps angles in degrees to interval [0, 360). | |
| Value | nk::builtin::sinh (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Hyperbolic sine (y = sinh(x)). | |
| Value | nk::builtin::cosh (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Hyperbolic cosine (y = cosh(x)). | |
| Value | nk::builtin::tanh (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Hyperbolic tangent (y = tanh(x)). | |
| Value | nk::builtin::asinh (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Inverse hyperbolic sine (y = asinh(x)). | |
| Value | nk::builtin::acosh (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Inverse hyperbolic cosine (y = acosh(x)). | |
| Value | nk::builtin::atanh (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Inverse hyperbolic tangent (y = atanh(x)). | |
| Value | nk::builtin::sech (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Hyperbolic secant (y = sech(x) = 1 / cosh(x)). | |
| Value | nk::builtin::csch (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Hyperbolic cosecant (y = csch(x) = 1 / sinh(x)). | |
| Value | nk::builtin::coth (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Hyperbolic cotangent (y = coth(x) = 1 / tanh(x)). | |
| Value | nk::builtin::asech (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Inverse hyperbolic secant (y = asech(x)). | |
| Value | nk::builtin::acsch (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Inverse hyperbolic cosecant (y = acsch(x)). | |
| Value | nk::builtin::acoth (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Inverse hyperbolic cotangent (y = acoth(x)). | |
| PolarPair | nk::builtin::cart2pol (const Value &x, const Value &y, std::pmr::memory_resource *mr=nullptr) |
| Transforms 2D Cartesian coordinates to polar coordinates ([theta, rho] = cart2pol(x, y)). | |
| CylTriple | nk::builtin::cart2pol (const Value &x, const Value &y, const Value &z, std::pmr::memory_resource *mr=nullptr) |
| Transforms 3D Cartesian coordinates to cylindrical coordinates ([theta, rho, z] = cart2pol(x, y, z)). | |
| CartPair | nk::builtin::pol2cart (const Value &theta, const Value &rho, std::pmr::memory_resource *mr=nullptr) |
| Transforms 2D polar coordinates to Cartesian coordinates ([x, y] = pol2cart(theta, rho)). | |
| CartTriple | nk::builtin::pol2cart (const Value &theta, const Value &rho, const Value &z, std::pmr::memory_resource *mr=nullptr) |
| Transforms 3D cylindrical coordinates to Cartesian coordinates ([x, y, z] = pol2cart(theta, rho, z)). | |
| SphTriple | nk::builtin::cart2sph (const Value &x, const Value &y, const Value &z, std::pmr::memory_resource *mr=nullptr) |
| Transforms 3D Cartesian coordinates to spherical coordinates ([az, el, r] = cart2sph(x, y, z)). | |
| CartTriple | nk::builtin::sph2cart (const Value &az, const Value &el, const Value &r, std::pmr::memory_resource *mr=nullptr) |
| Transforms 3D spherical coordinates to Cartesian coordinates ([x, y, z] = sph2cart(az, el, r)). | |
| Value | nk::builtin::cart2pol (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Transforms 2D Cartesian coordinates to polar coordinates (span wrapper). | |
| Value | nk::builtin::pol2cart (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Transforms 2D polar coordinates to Cartesian coordinates (span wrapper). | |
| Value | nk::builtin::cart2sph (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Transforms 3D Cartesian coordinates to spherical coordinates (span wrapper). | |
| Value | nk::builtin::sph2cart (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Transforms 3D spherical coordinates to Cartesian coordinates (span wrapper). | |
| Value | nk::builtin::exp (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Natural exponential (y = exp(x)). | |
| Value | nk::builtin::expm1 (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Computes exp(x) - 1 accurately for small x. | |
| Value | nk::builtin::log (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Natural logarithm (ln(x)). | |
| Value | nk::builtin::log10 (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Base-10 logarithm (log10(x)). | |
| Value | nk::builtin::log2 (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Base-2 logarithm (log2(x)). | |
| Value | nk::builtin::log1p (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Computes log(1 + x) accurately for small x. | |
| Value | nk::builtin::pow2 (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Base-2 power scaling (y = 2.
| |
| Value | nk::builtin::pow2 (const Value &f, const Value &e, std::pmr::memory_resource *mr=nullptr) |
| Base-2 power scaling with mantissa and exponent (y = f .
| |
| Value | nk::builtin::nextpow2 (const Value &n, std::pmr::memory_resource *mr=nullptr) |
| Smallest integer exponent such that 2^p >= abs(n) (p = nextpow2(n)). | |
| Value | nk::builtin::sqrt (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Square root (y = sqrt(x)). | |
| Value | nk::builtin::realsqrt (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Real square root with domain error check (y = realsqrt(x)). | |
| Value | nk::builtin::reallog (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Real natural logarithm with domain error check (y = reallog(x)). | |
| Value | nk::builtin::cbrt (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Cube root (y = cbrt(x)). | |
| Value | nk::builtin::nthroot (const Value &x, const Value &n, std::pmr::memory_resource *mr=nullptr) |
| Real nth root of real numbers (y = nthroot(x, n)). | |
| Value | nk::builtin::hypot (const Value &x, const Value &y, std::pmr::memory_resource *mr=nullptr) |
| Square root of sum of squares (hypot(x, y) = sqrt(x^2 + y^2)). | |
| Value | nk::builtin::pow (const Value &x, const Value &y, std::pmr::memory_resource *mr=nullptr) |
| Elementwise power (z = x .
| |
| Value | nk::builtin::realpow (const Value &x, const Value &y, std::pmr::memory_resource *mr=nullptr) |
| Real power with complex error check (y = realpow(x, y)). | |
| Value | nk::builtin::real (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Real part of complex array (y = real(x)). | |
| Value | nk::builtin::imag (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Imaginary part of complex array (y = imag(x)). | |
| Value | nk::builtin::conj (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Complex conjugate (y = conj(x)). | |
| Value | nk::builtin::angle (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Phase angle of complex numbers in radians (y = angle(x)). | |
| Value | nk::builtin::abs (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Absolute value / complex magnitude (y = abs(x)). | |
| Value | nk::builtin::complex (const Value &re, std::pmr::memory_resource *mr=nullptr) |
| Constructs complex array from real part (complex(re)). | |
| Value | nk::builtin::complex (const Value &re, const Value &im, std::pmr::memory_resource *mr=nullptr) |
| Constructs complex array from real and imaginary parts (complex(re, im)). | |
| Value | nk::builtin::sign (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Signum function (-1, 0, 1 or unit complex phasor). | |
| Value | nk::builtin::unwrap (const Value &p, double tol=3.14159265358979323846, int dim=-1, std::pmr::memory_resource *mr=nullptr) |
| Unwraps phase angles across array dimensions. | |
| Value | nk::builtin::isreal (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Tests if array contains real values (false if complex storage is active). | |
| Value | nk::builtin::round (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Rounds elements to the nearest integer (y = round(x)). | |
| Value | nk::builtin::roundN (const Value &x, int n, bool significant=false, std::pmr::memory_resource *mr=nullptr) |
| Rounds elements to N decimal digits or N significant digits (round(x, n, type)). | |
| Value | nk::builtin::floor (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Rounds down towards negative infinity (y = floor(x)). | |
| Value | nk::builtin::ceil (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Rounds up towards positive infinity (y = ceil(x)). | |
| Value | nk::builtin::fix (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Rounds towards zero / truncate (y = fix(x)). | |
| Value | nk::builtin::subplus (const Value &x, std::pmr::memory_resource *mr=nullptr) |
| Positive part / rectifier (y = max(x, 0)). | |
| Value | nk::builtin::mod (const Value &x, const Value &y, std::pmr::memory_resource *mr=nullptr) |
| Modulo operation where sign of result matches divisor (y = mod(x, y)). | |
| Value | nk::builtin::rem (const Value &x, const Value &y, std::pmr::memory_resource *mr=nullptr) |
| Remainder after division where sign of result matches dividend (y = rem(x, y)). | |
Elementary mathematical functions (trigonometry, exp, log, complex numbers, rounding).
Provides an engine-free, highly optimized C++ interface for MATLAB-compatible elementary mathematical functions, featuring Highway SIMD vector acceleration and thread parallelism.
Definition in file elfun.hpp.