public class 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))
| Modifier and Type | Member | Description |
|---|---|---|
| public static const | EE as Double = 2.718281828459045 |
Euler's number. |
| public static const | PIPI as Double = 3.141592653589793 |
PI: the ratio of a circle's circumference to its diameter. |
| public static const | TAUTAU as Double = 2.0 * PI |
TAU: the ratio of a circle's circumference to its radius. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | abs | Returns the magnitude of a complex number. |
| public static | abs | Returns the magnitude of a single-precision complex number. |
| public static | absabs<NUMBER_TYPE>(value as NUMBER_TYPE) as NUMBER_TYPE: |
Returns the absolute value of a scalar number. |
| public static | abs | Returns the element-wise absolute value of an array. |
| public static | acosacos<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the arccosine of a value. |
| public static | acosacos<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | acos | Returns the element-wise arccosine of an array. |
| public static | acoshacosh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the inverse hyperbolic cosine of a value. |
| public static | acoshacosh<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | asinasin<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the arcsine of a value. |
| public static | asinasin<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | asin | Returns the element-wise arcsine of an array. |
| public static | asinhasinh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the inverse hyperbolic sine of a value. |
| public static | asinhasinh<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | atanatan<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the arctangent of a value. |
| public static | atanatan<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | atan | Returns the element-wise arctangent of an array. |
| public static | atan2atan2<FLOAT_TYPE>(y as FLOAT_TYPE, x as FLOAT_TYPE) as FLOAT_TYPE: |
Returns `atan2(y, x)` in radians. |
| public static | atan2 | Returns the element-wise `atan2(y, x)` for two arrays. |
| public static | atan2 | Returns the element-wise `atan2(y, x)` between an array and a scalar. |
| public static | atanhatanh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the inverse hyperbolic tangent of a value. |
| public static | atanhatanh<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | cbrtcbrt<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the cube root of a floating-point value. |
| public static | cbrtcbrt<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | cbrt | Returns the element-wise cube root of an array. |
| public static | ceilceil<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 | Applies `ceil` element-wise on an array while preserving the array element type. |
| public static | coscos<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the cosine of an angle in radians. |
| public static | coscos<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | cos | Returns the element-wise cosine of an array expressed in radians. |
| public static | coshcosh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the hyperbolic cosine of a value. |
| public static | coshcosh<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | cosh | Returns the element-wise hyperbolic cosine of an array. |
| public static | degreesdegrees<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Converts radians to degrees. |
| public static | degrees | Converts the elements of an array from radians to degrees. |
| public static | expexp<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns `e` raised to the specified power. |
| public static | expexp<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | exp | Returns the element-wise exponential of an array. |
| public static | exp2exp2<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns `2` raised to the specified power. |
| public static | exp2exp2<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | exp2 | Returns the element-wise power of two of an array. |
| public static | expm1expm1<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns `e^value - 1`. |
| public static | expm1expm1<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | expm1 | Returns the element-wise `e^value - 1` of an array. |
| public static | factfact<INT_TYPE>(value as INT_TYPE) as INT_TYPE: |
Computes the factorial of an integer. |
| public static | floorfloor<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 | Applies `floor` element-wise on an array while preserving the array element type. |
| public static | fmodfmod<FLOAT_TYPE>(value as FLOAT_TYPE, divisor as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the floating-point remainder of the division. |
| public static | fmod | Returns the element-wise floating-point remainder of two arrays. |
| public static | fmod | Returns the element-wise floating-point remainder of an array by a scalar. |
| public static | gcdgcd<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 | gcdgcd<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 | hypothypot<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 | Returns the element-wise Euclidean distance of two arrays. |
| public static | hypot | Returns the element-wise Euclidean distance between an array and a scalar. |
| public static | loglog<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
No summary. |
| public static | loglog<INT_TYPE>(value as INT_TYPE) as Double: |
Returns the natural logarithm of a value. |
| public static | log | Returns the element-wise natural logarithm of an array. |
| public static | log10log10<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the base-10 logarithm of a value. |
| public static | log10log10<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | log10 | Returns the element-wise base-10 logarithm of an array. |
| public static | log1plog1p<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns `log(1 + value)` with improved precision near zero. |
| public static | log1plog1p<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | log1p | Returns the element-wise `log(1 + value)` of an array. |
| public static | log2log2<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the base-2 logarithm of a value. |
| public static | log2log2<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | log2 | Returns the element-wise base-2 logarithm of an array. |
| public static | powpow<FLOAT_TYPE>(value as FLOAT_TYPE, power as FLOAT_TYPE) as FLOAT_TYPE: |
Raises a floating-point value to the specified power. |
| public static | powpow<LEFT_TYPE, RIGHT_TYPE>(value as LEFT_TYPE, power as RIGHT_TYPE) as Double: |
No summary. |
| public static | pow | Raises each element of an array to the matching powers of another array. |
| public static | pow | Raises each element of an array to the specified scalar power. |
| public static | radiansradians<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Converts degrees to radians. |
| public static | radians | Converts the elements of an array from degrees to radians. |
| public static | roundround<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 | Rounds each element of an array while preserving the array element type. |
| public static | sinsin<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the sine of an angle in radians. |
| public static | sinsin<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | sin | Returns the element-wise sine of an array expressed in radians. |
| public static | sinhsinh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the hyperbolic sine of a value. |
| public static | sinhsinh<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | sinh | Returns the element-wise hyperbolic sine of an array. |
| public static | sqrtsqrt<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the square root of a floating-point value. |
| public static | sqrtsqrt<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | sqrt | Returns the element-wise square root of an array. |
| public static | tantan<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the tangent of an angle in radians. |
| public static | tantan<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | tan | Returns the element-wise tangent of an array expressed in radians. |
| public static | tanhtanh<FLOAT_TYPE>(value as FLOAT_TYPE) as FLOAT_TYPE: |
Returns the hyperbolic tangent of a value. |
| public static | tanhtanh<INT_TYPE>(value as INT_TYPE) as Double: |
No summary. |
| public static | tanh | Returns the element-wise hyperbolic tangent of an array. |
| public static | trunctrunc<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 | Applies `trunc` element-wise on an array while preserving the array element type. |