nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
Elementary Math Functions (elfun)

Trigonometric, hyperbolic, exponential, logarithmic, complex, and rounding operations. More...

Files

file  elfun.hpp
 Elementary mathematical functions (trigonometry, exp, log, complex numbers, rounding).

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)).

Detailed Description

Trigonometric, hyperbolic, exponential, logarithmic, complex, and rounding operations.

Function Documentation

◆ abs()

Value nk::builtin::abs ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Absolute value / complex magnitude (y = abs(x)).

Computes |x| for real numbers and sqrt(re^2 + im^2) for complex numbers. Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing magnitude |x|.
See also
angle, hypot, sign

◆ acos()

Value nk::builtin::acos ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse cosine in radians (y = acos(x)).

Computes arccosine. Returns real values in [0, pi] for domain [-1, 1]; generates complex outputs for values outside the real domain.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acos(x).
See also
cos, asin, atan, acosd

◆ acosd()

Value nk::builtin::acosd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse cosine in degrees (y = acosd(x)).

Returns values in [0, 180] degrees.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acosd(x).
See also
acos, cosd, asind, atand

◆ acosh()

Value nk::builtin::acosh ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Inverse hyperbolic cosine (y = acosh(x)).

Computes log(x + sqrt(x^2 - 1)) elementwise for real values x >= 1 (and complex outputs for x < 1).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acosh(x).
See also
cosh, asinh, atanh

◆ acot()

Value nk::builtin::acot ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse cotangent in radians (y = acot(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acot(x).
See also
cot, asec, acsc, acotd

◆ acotd()

Value nk::builtin::acotd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse cotangent in degrees (y = acotd(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acotd(x) in degrees.
See also
acot, cotd, asecd, acscd

◆ acoth()

Value nk::builtin::acoth ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Inverse hyperbolic cotangent (y = acoth(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acoth(x).
See also
coth, asech, acsch

◆ acsc()

Value nk::builtin::acsc ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse cosecant in radians (y = acsc(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acsc(x).
See also
csc, asec, acot, acscd

◆ acscd()

Value nk::builtin::acscd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse cosecant in degrees (y = acscd(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acscd(x) in degrees.
See also
acsc, cscd, asecd, acotd

◆ acsch()

Value nk::builtin::acsch ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Inverse hyperbolic cosecant (y = acsch(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing acsch(x).
See also
csch, asech, acoth

◆ angle()

Value nk::builtin::angle ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Phase angle of complex numbers in radians (y = angle(x)).

Computes atan2(imag(x), real(x)) in the range [-pi, pi].

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing phase angles in radians.
See also
abs, unwrap, atan2

◆ asec()

Value nk::builtin::asec ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse secant in radians (y = asec(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing asec(x).
See also
sec, acsc, acot, asecd

◆ asecd()

Value nk::builtin::asecd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse secant in degrees (y = asecd(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing asecd(x) in degrees.
See also
asec, secd, acscd, acotd

◆ asech()

Value nk::builtin::asech ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Inverse hyperbolic secant (y = asech(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing asech(x).
See also
sech, acsch, acoth

◆ asin()

Value nk::builtin::asin ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse sine in radians (y = asin(x)).

Computes arcsine. Returns real values in [-pi/2, pi/2] for domain [-1, 1]; generates complex outputs for values outside the real domain.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing asin(x).
See also
sin, acos, atan, asind

◆ asind()

Value nk::builtin::asind ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse sine in degrees (y = asind(x)).

Returns values in [-90, 90] degrees.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing asind(x).
See also
asin, sind, acosd, atand

◆ asinh()

Value nk::builtin::asinh ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Inverse hyperbolic sine (y = asinh(x)).

Computes log(x + sqrt(x^2 + 1)) elementwise.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing asinh(x).
See also
sinh, acosh, atanh

◆ atan()

Value nk::builtin::atan ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse tangent in radians (y = atan(x)).

Computes arctangent. Returns real values in (-pi/2, pi/2).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing atan(x).
See also
atan2, tan, asin, acos, atand

◆ atan2()

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)).

Computes the angle in the Euclidean plane between the positive x-axis and the point (x, y). Handles broadcast shapes between y and x.

Parameters
yY coordinates.
xX coordinates.
mrMemory resource for allocations (nullptr for default).
Returns
Broadcast array containing atan2(y, x) in [-pi, pi].
See also
atan, atan2d, cart2pol

◆ atan2d()

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)).

Computes angle in degrees in [-180, 180]. Handles broadcast shapes.

Parameters
yY coordinates.
xX coordinates.
mrMemory resource for allocations (nullptr for default).
Returns
Broadcast array containing atan2d(y, x) in [-180, 180] degrees.
See also
atan2, atand

◆ atand()

Value nk::builtin::atand ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise inverse tangent in degrees (y = atand(x)).

Returns values in (-90, 90) degrees.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing atand(x).
See also
atan, tand, atan2d, asind

◆ atanh()

Value nk::builtin::atanh ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Inverse hyperbolic tangent (y = atanh(x)).

Computes 0.5 * log((1 + x) / (1 - x)) elementwise for real values |x| < 1.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing atanh(x).
See also
tanh, asinh, acosh

◆ cart2pol() [1/3]

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)).

Parameters
xX Cartesian coordinates.
yY Cartesian coordinates.
zZ Cartesian coordinates.
mrMemory resource for allocations (nullptr for default).
Returns
CylTriple containing theta, rho, and z.
See also
pol2cart, cart2sph, sph2cart

◆ cart2pol() [2/3]

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)).

Computes theta = atan2(y, x) and rho = hypot(x, y) elementwise.

Parameters
xX Cartesian coordinates.
yY Cartesian coordinates.
mrMemory resource for allocations (nullptr for default).
Returns
PolarPair containing angle theta (radians) and radius rho.
See also
pol2cart, cart2sph, sph2cart

◆ cart2pol() [3/3]

Value nk::builtin::cart2pol ( Span< const Value > args,
std::pmr::memory_resource * mr = nullptr )

Transforms 2D Cartesian coordinates to polar coordinates (span wrapper).

Parameters
argsSpan containing x and y.
mrMemory resource.
Returns
Struct containing {th, r}.

◆ cart2sph() [1/2]

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)).

Computes az = atan2(y, x), el = atan2(z, hypot(x, y)), and r = sqrt(x^2 + y^2 + z^2).

Parameters
xX Cartesian coordinates.
yY Cartesian coordinates.
zZ Cartesian coordinates.
mrMemory resource for allocations (nullptr for default).
Returns
SphTriple containing azimuth az, elevation el, and radius r.
See also
sph2cart, cart2pol, pol2cart

◆ cart2sph() [2/2]

Value nk::builtin::cart2sph ( Span< const Value > args,
std::pmr::memory_resource * mr = nullptr )

Transforms 3D Cartesian coordinates to spherical coordinates (span wrapper).

Parameters
argsSpan containing x, y, z.
mrMemory resource.
Returns
Struct containing {az, el, r}.

◆ cbrt()

Value nk::builtin::cbrt ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Cube root (y = cbrt(x)).

Computes real cube root elementwise.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cbrt(x).
See also
sqrt, nthroot

◆ ceil()

Value nk::builtin::ceil ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Rounds up towards positive infinity (y = ceil(x)).

Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing ceil(x).
See also
floor, round, fix

◆ complex() [1/2]

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)).

Parameters
reReal components.
imImaginary components.
mrMemory resource for allocations (nullptr for default).
Returns
Complex array re + im * 1i.
See also
real, imag, conj

◆ complex() [2/2]

Value nk::builtin::complex ( const Value & re,
std::pmr::memory_resource * mr = nullptr )

Constructs complex array from real part (complex(re)).

Parameters
reReal components (imaginary set to zero).
mrMemory resource for allocations (nullptr for default).
Returns
Complex array re + 0i.
See also
real, imag, isreal

◆ conj()

Value nk::builtin::conj ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Complex conjugate (y = conj(x)).

Inverts the sign of the imaginary component (a + bi -> a - bi).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing conj(x).
See also
real, imag, abs, angle

◆ cos()

Value nk::builtin::cos ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise cosine in radians (y = cos(x)).

Computes trigonometric cosine for real and complex input arrays. Accelerated with Highway SIMD vectorization.

Parameters
xInput array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cos(x).
See also
sin, tan, acos, cosd, cospi

◆ cosd()

Value nk::builtin::cosd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise cosine in degrees (y = cosd(x)).

Computes trigonometric cosine for angles specified in degrees.

Parameters
xInput array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cosd(x).
See also
cos, sind, tand, acosd

◆ cosh()

Value nk::builtin::cosh ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Hyperbolic cosine (y = cosh(x)).

Computes (exp(x) + exp(-x)) / 2 elementwise for real and complex arrays. Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cosh(x).
See also
sinh, tanh, acosh, sech

◆ cospi()

Value nk::builtin::cospi ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise cosine of pi times input (y = cos(pi * x)).

Computes cos(pi * x) with exact zeros at odd half-integers.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cos(pi * x).
See also
cos, sinpi

◆ cot()

Value nk::builtin::cot ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise cotangent in radians (y = cot(x) = 1 / tan(x)).

Parameters
xInput array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cot(x).
See also
tan, sec, csc, cotd

◆ cotd()

Value nk::builtin::cotd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise cotangent in degrees (y = cotd(x)).

Parameters
xInput array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cotd(x).
See also
cot, tand, secd, cscd

◆ coth()

Value nk::builtin::coth ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Hyperbolic cotangent (y = coth(x) = 1 / tanh(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing coth(x).
See also
tanh, csch, acoth

◆ csc()

Value nk::builtin::csc ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise cosecant in radians (y = csc(x) = 1 / sin(x)).

Parameters
xInput array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing csc(x).
See also
sin, sec, cot, cscd

◆ cscd()

Value nk::builtin::cscd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise cosecant in degrees (y = cscd(x)).

Parameters
xInput array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing cscd(x).
See also
csc, sind, secd, cotd

◆ csch()

Value nk::builtin::csch ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Hyperbolic cosecant (y = csch(x) = 1 / sinh(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing csch(x).
See also
sinh, sech, acsch

◆ deg2rad()

Value nk::builtin::deg2rad ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts angles from degrees to radians (y = deg2rad(x)).

Computes x * (pi / 180).

Parameters
xAngle array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Angle array in radians.
See also
rad2deg, sin, cos

◆ exp()

Value nk::builtin::exp ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Natural exponential (y = exp(x)).

Computes e^x elementwise for real and complex input arrays. Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing exp(x).
See also
expm1, log, log10, log2, pow2

◆ expm1()

Value nk::builtin::expm1 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Computes exp(x) - 1 accurately for small x.

Preserves numerical precision for values of x very close to 0.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing exp(x) - 1.
See also
exp, log1p

◆ fix()

Value nk::builtin::fix ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Rounds towards zero / truncate (y = fix(x)).

Truncates fractional part towards zero.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing fix(x).
See also
floor, ceil, round

◆ floor()

Value nk::builtin::floor ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Rounds down towards negative infinity (y = floor(x)).

Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing floor(x).
See also
ceil, round, fix

◆ hypot()

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)).

Computes the hypotenuse accurately without intermediate overflow or underflow.

Parameters
xFirst argument array.
ySecond argument array.
mrMemory resource for allocations (nullptr for default).
Returns
Broadcast array containing sqrt(x^2 + y^2).
See also
sqrt, abs, cart2pol

◆ imag()

Value nk::builtin::imag ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Imaginary part of complex array (y = imag(x)).

Extracts the imaginary component of each element.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Real array containing imag(x) (zeros for real inputs).
See also
real, conj, complex, angle

◆ isreal()

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).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Scalar logical Value (true if real, false if complex).
See also
real, imag, isnumeric

◆ log()

Value nk::builtin::log ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Natural logarithm (ln(x)).

Computes natural logarithm elementwise. Produces complex results for negative real inputs.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing log(x).
See also
exp, log10, log2, log1p, reallog

◆ log10()

Value nk::builtin::log10 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Base-10 logarithm (log10(x)).

Computes common logarithm elementwise.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing log10(x).
See also
log, log2

◆ log1p()

Value nk::builtin::log1p ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Computes log(1 + x) accurately for small x.

Preserves precision when |x| << 1.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing log(1 + x).
See also
log, expm1

◆ log2()

Value nk::builtin::log2 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Base-2 logarithm (log2(x)).

Computes binary logarithm elementwise.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing log2(x).
See also
log, log10, pow2, nextpow2

◆ mod()

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)).

Computes x - y .* floor(x ./ y) elementwise.

Parameters
xDividend array.
yDivisor array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing mod(x, y).
See also
rem, floor

◆ nextpow2()

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)).

Useful for determining optimal FFT buffer lengths.

Parameters
nInput array or scalar.
mrMemory resource for allocations (nullptr for default).
Returns
Exponent array p = ceil(log2(abs(n))).
See also
pow2, log2

◆ nthroot()

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)).

Computes the real nth root of elements in x. Handles negative x for odd integer n.

Parameters
xReal base array.
nReal root degree.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing nthroot(x, n).
See also
sqrt, cbrt, pow

◆ pol2cart() [1/3]

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)).

Parameters
thetaAzimuth angle array in radians.
rhoRadial distance in xy-plane array.
zHeight coordinate array.
mrMemory resource for allocations (nullptr for default).
Returns
CartTriple containing x, y, and z.
See also
cart2pol, sph2cart, cart2sph

◆ pol2cart() [2/3]

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)).

Computes x = rho .* cos(theta) and y = rho .* sin(theta) elementwise.

Parameters
thetaAngle array in radians.
rhoRadial distance array.
mrMemory resource for allocations (nullptr for default).
Returns
CartPair containing x and y coordinates.
See also
cart2pol, sph2cart, cart2sph

◆ pol2cart() [3/3]

Value nk::builtin::pol2cart ( Span< const Value > args,
std::pmr::memory_resource * mr = nullptr )

Transforms 2D polar coordinates to Cartesian coordinates (span wrapper).

Parameters
argsSpan containing th and r.
mrMemory resource.
Returns
Struct containing {x, y}.

◆ pow()

Value nk::builtin::pow ( const Value & x,
const Value & y,
std::pmr::memory_resource * mr = nullptr )

Elementwise power (z = x .

^ y).

Computes x raised to the power y elementwise. Supports scalar-array and array-array broadcasting.

Parameters
xBase array.
yExponent array.
mrMemory resource for allocations (nullptr for default).
Returns
Broadcast array containing x .^ y.
See also
exp, pow2, realpow

◆ pow2() [1/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 .

  • 2.^e

).

Equivalent to standard ldexp(f, e) elementwise.

Parameters
fMantissa array.
eExponent array.
mrMemory resource for allocations (nullptr for default).
Returns
Scaled values f .* 2.^e.
See also
log2, pow2

◆ pow2() [2/2]

Value nk::builtin::pow2 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Base-2 power scaling (y = 2.

^x).

Parameters
xPower exponent array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing 2.^x.
See also
log2, pow, nextpow2

◆ rad2deg()

Value nk::builtin::rad2deg ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts angles from radians to degrees (y = rad2deg(x)).

Computes x * (180 / pi).

Parameters
xAngle array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Angle array in degrees.
See also
deg2rad, sind, cosd

◆ real()

Value nk::builtin::real ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Real part of complex array (y = real(x)).

Extracts the real component of each element.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Real array containing real(x).
See also
imag, conj, complex, isreal

◆ reallog()

Value nk::builtin::reallog ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Real natural logarithm with domain error check (y = reallog(x)).

Computes natural log elementwise, raising a runtime error if any element is non-positive.

Parameters
xInput array of positive real numbers.
mrMemory resource for allocations (nullptr for default).
Returns
Real array containing log(x).
See also
log, realsqrt, realpow

◆ realpow()

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)).

Computes x .^ y, raising a runtime error if the result would be complex.

Parameters
xBase array.
yExponent array.
mrMemory resource for allocations (nullptr for default).
Returns
Array containing x .^ y.
See also
pow, realsqrt, reallog

◆ realsqrt()

Value nk::builtin::realsqrt ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Real square root with domain error check (y = realsqrt(x)).

Computes square root elementwise, raising a runtime domain error if any element is negative.

Parameters
xInput array of non-negative real numbers.
mrMemory resource for allocations (nullptr for default).
Returns
Real array containing sqrt(x).
See also
sqrt, reallog, realpow

◆ rem()

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)).

Computes x - y .* fix(x ./ y) elementwise.

Parameters
xDividend array.
yDivisor array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing rem(x, y).
See also
mod, fix

◆ round()

Value nk::builtin::round ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Rounds elements to the nearest integer (y = round(x)).

Rounds half-integers away from zero (MATLAB round semantics). Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape with rounded elements.
See also
floor, ceil, fix, roundN

◆ roundN()

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)).

Parameters
xInput array.
nNumber of decimal or significant digits.
significantTrue to round to significant digits, false for decimal places.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape with rounded elements.
See also
round, floor, ceil

◆ sec()

Value nk::builtin::sec ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise secant in radians (y = sec(x) = 1 / cos(x)).

Parameters
xInput array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sec(x).
See also
cos, csc, cot, secd

◆ secd()

Value nk::builtin::secd ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise secant in degrees (y = secd(x)).

Parameters
xInput array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing secd(x).
See also
sec, cosd, cscd, cotd

◆ sech()

Value nk::builtin::sech ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Hyperbolic secant (y = sech(x) = 1 / cosh(x)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sech(x).
See also
cosh, csch, asech

◆ sign()

Value nk::builtin::sign ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Signum function (-1, 0, 1 or unit complex phasor).

For real numbers, returns 1 for x > 0, -1 for x < 0, and 0 for x == 0. For complex numbers, returns x ./ abs(x).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sign(x).
See also
abs

◆ sin()

Value nk::builtin::sin ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise sine in radians (y = sin(x)).

Computes trigonometric sine for real and complex input arrays. Accelerated with Highway SIMD vectorization.

Parameters
xInput array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sin(x).
See also
cos, tan, asin, sind, sinpi

◆ sind()

Value nk::builtin::sind ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise sine in degrees (y = sind(x)).

Computes trigonometric sine for angles specified in degrees.

Parameters
xInput array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sind(x).
See also
sin, cosd, tand, asind

◆ sinh()

Value nk::builtin::sinh ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Hyperbolic sine (y = sinh(x)).

Computes (exp(x) - exp(-x)) / 2 elementwise for real and complex arrays. Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sinh(x).
See also
cosh, tanh, asinh, csch

◆ sinpi()

Value nk::builtin::sinpi ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise sine of pi times input (y = sin(pi * x)).

Computes sin(pi * x) with exact zeros at all integer inputs.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sin(pi * x).
See also
sin, cospi

◆ sph2cart() [1/2]

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)).

Computes x = r .* cos(el) .* cos(az), y = r .* cos(el) .* sin(az), and z = r .* sin(el).

Parameters
azAzimuth angle in radians.
elElevation angle in radians.
rRadial distance from origin.
mrMemory resource for allocations (nullptr for default).
Returns
CartTriple containing x, y, and z.
See also
cart2sph, pol2cart, cart2pol

◆ sph2cart() [2/2]

Value nk::builtin::sph2cart ( Span< const Value > args,
std::pmr::memory_resource * mr = nullptr )

Transforms 3D spherical coordinates to Cartesian coordinates (span wrapper).

Parameters
argsSpan containing az, el, r.
mrMemory resource.
Returns
Struct containing {x, y, z}.

◆ sqrt()

Value nk::builtin::sqrt ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Square root (y = sqrt(x)).

Computes square root elementwise. Produces complex numbers for negative inputs. Accelerated with Highway SIMD vectorization.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing sqrt(x).
See also
realsqrt, cbrt, nthroot, hypot

◆ subplus()

Value nk::builtin::subplus ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Positive part / rectifier (y = max(x, 0)).

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape with negative elements clamped to zero.
See also
max, fix

◆ tan()

Value nk::builtin::tan ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise tangent in radians (y = tan(x)).

Computes trigonometric tangent (sin(x) / cos(x)).

Parameters
xInput array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing tan(x).
See also
sin, cos, atan, tand

◆ tand()

Value nk::builtin::tand ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Elementwise tangent in degrees (y = tand(x)).

Computes trigonometric tangent for angles specified in degrees.

Parameters
xInput array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing tand(x).
See also
tan, sind, cosd, atand

◆ tanh()

Value nk::builtin::tanh ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Hyperbolic tangent (y = tanh(x)).

Computes sinh(x) / cosh(x) elementwise for real and complex arrays.

Parameters
xInput array.
mrMemory resource for allocations (nullptr for default).
Returns
Array of same shape containing tanh(x).
See also
sinh, cosh, atanh, coth

◆ unwrap()

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.

Corrects the radian phase angles in p by adding multiples of ±2*pi whenever jump discontinuities exceed tol.

Parameters
pPhase angle array in radians.
tolJump tolerance threshold (default: pi).
dimDimension along which to operate (-1 for first non-singleton dimension).
mrMemory resource for allocations (nullptr for default).
Returns
Array with unwrapped continuous phase.
See also
angle, wrapToPi

◆ wrapTo180()

Value nk::builtin::wrapTo180 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Wraps angles in degrees to interval [-180, 180].

Parameters
xAngle array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Wrapped angle array in [-180, 180].
See also
wrapTo360, wrapToPi

◆ wrapTo2Pi()

Value nk::builtin::wrapTo2Pi ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Wraps angles in radians to interval [0, 2*pi).

Parameters
xAngle array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Wrapped angle array in [0, 2*pi).
See also
wrapToPi, wrapTo360

◆ wrapTo360()

Value nk::builtin::wrapTo360 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Wraps angles in degrees to interval [0, 360).

Parameters
xAngle array in degrees.
mrMemory resource for allocations (nullptr for default).
Returns
Wrapped angle array in [0, 360).
See also
wrapTo180, wrapTo2Pi

◆ wrapToPi()

Value nk::builtin::wrapToPi ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Wraps angles in radians to interval [-pi, pi].

Parameters
xAngle array in radians.
mrMemory resource for allocations (nullptr for default).
Returns
Wrapped angle array in [-pi, pi].
See also
wrapTo2Pi, wrapTo180, wrapTo360