Math
class in package klyn.math

    public class Math:

Math

Basic mathematical constants and functions.

The public floating-point API is generic on `AbstractFloat`, with `Double` as the default type argument when a call only provides integer operands. This lets the compiler keep a compact native runtime limited to `Double` kernels while preserving `Float` and `Double` on explicitly floating calls.

    import klyn.math

    print(Math.sqrt(9.0))
    print(Math.sin(0.0))
    print(Math.log(Math.E))

Fields

Modifier and Type | Member | Description
--- | --- | ---
public static const | E `E as Double = 2.718281828459045` | Euler's number.
public static const | PI `PI as Double = 3.141592653589793` | PI: the ratio of a circle's circumference to its diameter.
public static const | TAU `TAU as Double = 2.0 * PI` | TAU: the ratio of a circle's circumference to its radius.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public static | abs `abs(value as Complex<Double>) as Double:` | Returns the magnitude of a complex number.
public static | abs `abs(value as Complex<Float>) as Double:` | Returns the magnitude of a single-precision complex number.
public static | abs `abs<NUMBER_TYPE>(value as NUMBER_TYPE) as NUMBER_TYPE:` | Returns the absolute value of a scalar number.
public static | abs `abs<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<NUMBER_TYPE>:` | Returns the element-wise absolute value of an array.
public static | acos `acos<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the arccosine of a value.
public static | acos `acos<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | acos `acos<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise arccosine of an array.
public static | acosh `acosh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the inverse hyperbolic cosine of a value.
public static | acosh `acosh<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | asin `asin<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the arcsine of a value.
public static | asin `asin<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | asin `asin<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise arcsine of an array.
public static | asinh `asinh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the inverse hyperbolic sine of a value.
public static | asinh `asinh<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | atan `atan<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the arctangent of a value.
public static | atan `atan<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | atan `atan<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise arctangent of an array.
public static | atan2 `atan2<FLOAT_TYPE>(y as FLOAT_TYPE, x as FLOAT_TYPE) as FLOAT_TYPE:` | Returns `atan2(y, x)` in radians.
public static | atan2 `atan2<LEFT_TYPE, RIGHT_TYPE>(y as NDArray<LEFT_TYPE>, x as NDArray<RIGHT_TYPE>) as NDArray<Double>:` | Returns the element-wise `atan2(y, x)` for two arrays.
public static | atan2 `atan2<LEFT_TYPE, RIGHT_TYPE>(y as NDArray<LEFT_TYPE>, x as RIGHT_TYPE) as NDArray<Double>:` | Returns the element-wise `atan2(y, x)` between an array and a scalar.
public static | atanh `atanh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the inverse hyperbolic tangent of a value.
public static | atanh `atanh<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | cbrt `cbrt<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the cube root of a floating-point value.
public static | cbrt `cbrt<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | cbrt `cbrt<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise cube root of an array.
public static | ceil `ceil<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the smallest integer greater than or equal to `value`, preserved in the same floating-point type.
public static | ceil `ceil<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<NUMBER_TYPE>:` | Applies `ceil` element-wise on an array while preserving the array element type.
public static | cos `cos<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the cosine of an angle in radians.
public static | cos `cos<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | cos `cos<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise cosine of an array expressed in radians.
public static | cosh `cosh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the hyperbolic cosine of a value.
public static | cosh `cosh<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | cosh `cosh<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise hyperbolic cosine of an array.
public static | degrees `degrees<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Converts radians to degrees.
public static | degrees `degrees<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Converts the elements of an array from radians to degrees.
public static | exp `exp<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns `e` raised to the specified power.
public static | exp `exp<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | exp `exp<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise exponential of an array.
public static | exp2 `exp2<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns `2` raised to the specified power.
public static | exp2 `exp2<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | exp2 `exp2<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise power of two of an array.
public static | expm1 `expm1<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns `e^value - 1`.
public static | expm1 `expm1<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | expm1 `expm1<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise `e^value - 1` of an array.
public static | fact `fact<INT_TYPE>(value as INT_TYPE) as INT_TYPE:` | Computes the factorial of an integer.
public static | floor `floor<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the greatest integer less than or equal to `value`, preserved in the same floating-point type.
public static | floor `floor<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<NUMBER_TYPE>:` | Applies `floor` element-wise on an array while preserving the array element type.
public static | fmod `fmod<FLOAT_TYPE>(value as FLOAT_TYPE, divisor as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the floating-point remainder of the division.
public static | fmod `fmod<LEFT_TYPE, RIGHT_TYPE>(value as NDArray<LEFT_TYPE>, divisor as NDArray<RIGHT_TYPE>) as NDArray<Double>:` | Returns the element-wise floating-point remainder of two arrays.
public static | fmod `fmod<LEFT_TYPE, RIGHT_TYPE>(value as NDArray<LEFT_TYPE>, divisor as RIGHT_TYPE) as NDArray<Double>:` | Returns the element-wise floating-point remainder of an array by a scalar.
public static | gcd `gcd<INT_TYPE>(first as INT_TYPE, second as INT_TYPE, values... as INT_TYPE) as INT_TYPE:` | Computes the greatest common divisor of one or more integers.
public static | gcd `gcd<INT_TYPE>(left as INT_TYPE, right as INT_TYPE) as INT_TYPE:` | Computes the greatest common divisor of one or more integers.
public static | hypot `hypot<FLOAT_TYPE>(x as FLOAT_TYPE, y as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the Euclidean distance `sqrt(x*x + y*y)`.
public static | hypot `hypot<LEFT_TYPE, RIGHT_TYPE>(x as NDArray<LEFT_TYPE>, y as NDArray<RIGHT_TYPE>) as NDArray<Double>:` | Returns the element-wise Euclidean distance of two arrays.
public static | hypot `hypot<LEFT_TYPE, RIGHT_TYPE>(x as NDArray<LEFT_TYPE>, y as RIGHT_TYPE) as NDArray<Double>:` | Returns the element-wise Euclidean distance between an array and a scalar.
public static | log `log<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | No summary.
public static | log `log<INT_TYPE>(value as INT_TYPE) as Double:` | Returns the natural logarithm of a value.
public static | log `log<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise natural logarithm of an array.
public static | log10 `log10<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the base-10 logarithm of a value.
public static | log10 `log10<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | log10 `log10<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise base-10 logarithm of an array.
public static | log1p `log1p<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns `log(1 + value)` with improved precision near zero.
public static | log1p `log1p<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | log1p `log1p<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise `log(1 + value)` of an array.
public static | log2 `log2<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the base-2 logarithm of a value.
public static | log2 `log2<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | log2 `log2<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise base-2 logarithm of an array.
public static | pow `pow<FLOAT_TYPE>(value as FLOAT_TYPE, power as FLOAT_TYPE) as FLOAT_TYPE:` | Raises a floating-point value to the specified power.
public static | pow `pow<LEFT_TYPE, RIGHT_TYPE>(value as LEFT_TYPE, power as RIGHT_TYPE) as Double:` | No summary.
public static | pow `pow<LEFT_TYPE, RIGHT_TYPE>(value as NDArray<LEFT_TYPE>, power as NDArray<RIGHT_TYPE>) as NDArray<Double>:` | Raises each element of an array to the matching powers of another array.
public static | pow `pow<LEFT_TYPE, RIGHT_TYPE>(value as NDArray<LEFT_TYPE>, power as RIGHT_TYPE) as NDArray<Double>:` | Raises each element of an array to the specified scalar power.
public static | radians `radians<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Converts degrees to radians.
public static | radians `radians<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Converts the elements of an array from degrees to radians.
public static | round `round<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Rounds a floating-point value to the nearest integer value, returned in the same floating-point type.
public static | round `round<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<NUMBER_TYPE>:` | Rounds each element of an array while preserving the array element type.
public static | sin `sin<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the sine of an angle in radians.
public static | sin `sin<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | sin `sin<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise sine of an array expressed in radians.
public static | sinh `sinh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the hyperbolic sine of a value.
public static | sinh `sinh<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | sinh `sinh<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise hyperbolic sine of an array.
public static | sqrt `sqrt<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the square root of a floating-point value.
public static | sqrt `sqrt<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | sqrt `sqrt<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise square root of an array.
public static | tan `tan<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the tangent of an angle in radians.
public static | tan `tan<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | tan `tan<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise tangent of an array expressed in radians.
public static | tanh `tanh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the hyperbolic tangent of a value.
public static | tanh `tanh<INT_TYPE>(value as INT_TYPE) as Double:` | No summary.
public static | tanh `tanh<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<Double>:` | Returns the element-wise hyperbolic tangent of an array.
public static | trunc `trunc<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE:` | Returns the integral part of `value`, preserved in the same floating-point type.
public static | trunc `trunc<NUMBER_TYPE>(values as NDArray<NUMBER_TYPE>) as NDArray<NUMBER_TYPE>:` | Applies `trunc` element-wise on an array while preserving the array element type.