Liking cljdoc? Tell your friends :D
Clojure only.

fastmath.core

High-performance mathematical functions and constants for Clojure, optimized for primitive double and long types.

Key features:

  • Most functions are specialized for primitive types (double and long) and are inlined for performance.
  • Primarily backed by the FastMath library and custom primitive implementations.
  • Provides an option to replace clojure.core's standard numerical operators with primitive-specialized macros.

This namespace contains functions for:

  • Basic arithmetic (+, -, *, /, etc.)
  • Comparisons and predicates (==, <, zero?, pos?, etc.)
  • Bitwise operations
  • Trigonometric and hyperbolic functions
  • Exponents, logarithms, and powers
  • Floating-point specific operations (ulp, bits manipulation)
  • Combinatorics (factorial, combinations)
  • Distance calculations
  • Interpolation and mapping
  • Utility functions (gcd, lcm, error calculation, etc.)

Primitive Math Operators:

A set of inlined macros designed to replace selected clojure.core arithmetic, comparison, and bitwise operators for potential performance gains with primitive arguments. These macros operate on double and long primitives and generally return primitive values.

Replaced operators:

  • * + - / > < >= <= == rem quot mod
  • bit-or bit-and bit-xor bit-not bit-and-not
  • bit-shift-left bit-shift-right unsigned-bit-shift-right
  • bit-set bit-clear bit-flip bit-test
  • inc dec
  • zero? neg? pos? even? odd?
  • min max
  • abs
  • Additionally: << >> >>> not==

To enable these primitive operators in your namespace, call use-primitive-operators. To revert to the original clojure.core functions, call unuse-primitive-operators. Note that the fastmath.core versions are not a complete drop-in replacement due to their primitive-specific behavior (e.g., return types), and calling unuse-primitive-operators at the end of the namespace is recommended, especially in Clojure 1.12+.

High-performance mathematical functions and constants for Clojure,
optimized for primitive `double` and `long` types.

Key features:

- Most functions are specialized for primitive types (`double` and `long`) and are inlined for performance.
- Primarily backed by the [FastMath](https://github.com/jeffhain/jafama) library and custom primitive implementations.
- Provides an option to replace `clojure.core`'s standard numerical operators with primitive-specialized macros.

This namespace contains functions for:

- Basic arithmetic (`+`, `-`, `*`, `/`, etc.)
- Comparisons and predicates (`==`, `<`, `zero?`, `pos?`, etc.)
- Bitwise operations
- Trigonometric and hyperbolic functions
- Exponents, logarithms, and powers
- Floating-point specific operations (ulp, bits manipulation)
- Combinatorics (factorial, combinations)
- Distance calculations
- Interpolation and mapping
- Utility functions (gcd, lcm, error calculation, etc.)

Primitive Math Operators:

A set of inlined macros designed to replace selected `clojure.core` arithmetic, comparison, and bitwise operators for potential performance gains with primitive arguments. These macros operate on `double` and `long` primitives and generally return primitive values.

Replaced operators:

- `* + - / > < >= <= == rem quot mod`
- `bit-or bit-and bit-xor bit-not bit-and-not`
- `bit-shift-left bit-shift-right unsigned-bit-shift-right`
- `bit-set bit-clear bit-flip bit-test`
- `inc dec`
- `zero? neg? pos? even? odd?`
- `min max`
- `abs`
- Additionally: `<< >> >>> not==`

To enable these primitive operators in your namespace, call [[use-primitive-operators]].
To revert to the original `clojure.core` functions, call [[unuse-primitive-operators]].
Note that the `fastmath.core` versions are not a complete drop-in replacement due to their primitive-specific behavior (e.g., return types), and calling `unuse-primitive-operators` at the end of the namespace is recommended, especially in Clojure 1.12+.
raw docstring

*clj

(*)
(* a)
(* a b)
(* a b c)
(* a b c d)
(* a b c d & r)

Primitive and inlined *.

Primitive and inlined `*`.
sourceraw docstring

+clj

(+)
(+ a)
(+ a b)
(+ a b c)
(+ a b c d)
(+ a b c d & r)

Primitive and inlined +.

Primitive and inlined `+`.
sourceraw docstring

-clj

(- a)
(- a b)
(- a b c)
(- a b c d)
(- a b c d & r)

Primitive and inlined -.

Primitive and inlined `-`.
sourceraw docstring

-Eclj

Value of $-\mathrm{e}$

Value of $-\mathrm{e}$
sourceraw docstring

-HALF_PIclj

Value of $\frac{\pi}{2}$

Value of $\frac{\pi}{2}$
sourceraw docstring

-PIclj

Value of $-\pi$

Value of $-\pi$
sourceraw docstring

-QUARTER_PIclj

Value of $\frac{\pi}{4}$

Value of $\frac{\pi}{4}$
sourceraw docstring

-TAUclj

Value of $-2\pi$

Value of $-2\pi$
sourceraw docstring

-THIRD_PIclj

Value of $\frac{\pi}{3}$

Value of $\frac{\pi}{3}$
sourceraw docstring

-TWO_PIclj

Value of $-2\pi$

Value of $-2\pi$
sourceraw docstring

/clj

(/ a)
(/ a b)
(/ a b c)
(/ a b c d)
(/ a b c d & r)

Primitive and inlined /.

Primitive and inlined `/`.
sourceraw docstring

<clj

(< _)
(< a b)
(< a b & r)

Primitive math less-then function.

Primitive math less-then function.
sourceraw docstring

<<clj

(<< x shift)

Shift bits left

Shift bits left
sourceraw docstring

<=clj

(<= _)
(<= a b)
(<= a b & r)

Primitive math less-and-equal function.

Primitive math less-and-equal function.
sourceraw docstring

==clj

(== _)
(== a b)
(== a b & r)

Primitive math equality function.

Primitive math equality function.
sourceraw docstring

>clj

(> _)
(> a b)
(> a b & r)

Primitive math greater-than function.

Primitive math greater-than function.
sourceraw docstring

>=clj

(>= _)
(>= a b)
(>= a b & r)

Primitive math greater-and-equal function.

Primitive math greater-and-equal function.
sourceraw docstring

>>clj

(>> x shift)

Shift bits right and keep most significant bit unchanged

Shift bits right and keep most significant bit unchanged
sourceraw docstring

>>>clj

(>>> x shift)

Shift bits right and set most significant bit to 0

Shift bits right and set most significant bit to `0`
sourceraw docstring

absclj

(abs x)

Absolute value.

Absolute value.
sourceraw docstring

absolute-errorclj

(absolute-error v v-approx)

Absolute error between two values

Absolute error between two values
sourceraw docstring

acosclj

(acos x)

acos(x)

acos(x)
sourceraw docstring

acoshclj

(acosh x)

acosh(x)

acosh(x)
sourceraw docstring

acotclj

(acot x)

acot(x)

acot(x)
sourceraw docstring

acothclj

(acoth x)

Area hyperbolic cotangent

Area hyperbolic cotangent
sourceraw docstring

acovercosclj

(acovercos x)

Arc covercosine

Arc covercosine
sourceraw docstring

acoversinclj

(acoversin x)

Arc coversine

Arc coversine
sourceraw docstring

acrdclj

(acrd x)

Inverse chord

Inverse chord
sourceraw docstring

acscclj

(acsc x)

acsc(x)

acsc(x)
sourceraw docstring

acschclj

(acsch v)

Area hyperbolic cosecant

Area hyperbolic cosecant
sourceraw docstring

aexcscclj

(aexcsc x)

Arc excosecant

Arc excosecant
sourceraw docstring

aexsecclj

(aexsec x)

Arc exsecant

Arc exsecant
sourceraw docstring

ahacovercosclj

(ahacovercos x)

Arc hacovercosine

Arc hacovercosine
sourceraw docstring

ahacoversinclj

(ahacoversin x)

Arc hacoversine

Arc hacoversine
sourceraw docstring

ahavercosclj

(ahavercos x)

Arc havecosine

Arc havecosine
sourceraw docstring

ahaversinclj

(ahaversin x)

Arc haversine

Arc haversine
sourceraw docstring

approxclj

(approx v)
(approx v digits)

Round v to specified (default: 2) decimal places. Be aware of floating point number accuracy.

Round `v` to specified (default: 2) decimal places. Be aware of floating point number accuracy.
sourceraw docstring

approx-eqclj

(approx-eq a b)
(approx-eq a b digits)

Checks equality approximately up to selected number of digits (2 by default).

It can be innacurate due to the algorithm used. Use delta-eq instead.

See approx.

Checks equality approximately up to selected number of digits (2 by default).

It can be innacurate due to the algorithm used. Use [[delta-eq]] instead.  

See [[approx]].
sourceraw docstring

approx=clj

Alias for approx-eq

Alias for [[approx-eq]]
sourceraw docstring

asecclj

(asec x)

asec(x)

asec(x)
sourceraw docstring

asechclj

(asech x)

Area hyperbolic secant

Area hyperbolic secant
sourceraw docstring

asinclj

(asin x)

asin(x)

asin(x)
sourceraw docstring

asinhclj

(asinh x)

asinh(x)

asinh(x)
sourceraw docstring

atanclj

(atan x)

atan(x)

atan(x)
sourceraw docstring

atan2clj

(atan2 x y)

atan2(x,y)

atan2(x,y)
sourceraw docstring

atanhclj

(atanh x)

atanh(x)

atanh(x)
sourceraw docstring

avercosclj

(avercos x)

Arc vecosine

Arc vecosine
sourceraw docstring

aversinclj

(aversin x)

Arc versine

Arc versine
sourceraw docstring

between-?clj

(between-? [x y] v)
(between-? x y v)

Check if given number is within the range (x,y].

Check if given number is within the range (x,y].
sourceraw docstring

between?clj

(between? [x y] v)
(between? x y v)

Check if given number is within the range [x,y].

Check if given number is within the range [x,y].
sourceraw docstring

bit-andclj

(bit-and x)
(bit-and x y)
(bit-and x y & r)

x ∧ y - bitwise AND

x ∧ y - bitwise AND
sourceraw docstring

bit-and-notclj

(bit-and-not x)
(bit-and-not x y)
(bit-and-not x y & r)

x ∧ ~y - bitwise AND (with complement second argument)

x ∧ ~y - bitwise AND (with complement second argument)
sourceraw docstring

bit-clearclj

(bit-clear x bit)

Clear bit (set to 0).

Clear bit (set to `0`).
sourceraw docstring

bit-flipclj

(bit-flip x bit)

Flip bit (set to 0 when 1 or to 1 when 0).

Flip bit (set to `0` when `1` or to `1` when `0`).
sourceraw docstring

bit-nandclj

(bit-nand x)
(bit-nand x y)
(bit-nand x y & r)

~(x ∧ y) - bitwise NAND

~(x ∧ y) - bitwise NAND
sourceraw docstring

bit-norclj

(bit-nor x)
(bit-nor x y)
(bit-nor x y & r)

~(x ∨ y) - bitwise NOR

~(x ∨ y) - bitwise NOR
sourceraw docstring

bit-notclj

(bit-not x)

~x - bitwise NOT

~x - bitwise NOT
sourceraw docstring

bit-orclj

(bit-or x)
(bit-or x y)
(bit-or x y & r)

x ∨ y - bitwise OR

x ∨ y - bitwise OR
sourceraw docstring

bit-setclj

(bit-set x bit)

Set bit (set to 1).

Set bit (set to `1`).
sourceraw docstring

bit-shift-leftclj

(bit-shift-left x shift)

Shift bits left

Shift bits left
sourceraw docstring

bit-shift-rightclj

(bit-shift-right x shift)

Shift bits right and keep most significant bit unchanged

Shift bits right and keep most significant bit unchanged
sourceraw docstring

bit-testclj

(bit-test x bit)

Test bit (return to true when 1 or false when 0).

Test bit (return to `true` when `1` or `false` when `0`).
sourceraw docstring

bit-xnorclj

(bit-xnor x)
(bit-xnor x y)
(bit-xnor x y & r)

~(x⊕y) - bitwise XNOR

~(x⊕y) - bitwise XNOR
sourceraw docstring

bit-xorclj

(bit-xor x)
(bit-xor x y)
(bit-xor x y & r)

x⊕y - bitwise XOR

x⊕y - bitwise XOR
sourceraw docstring

bits->doubleclj

(bits->double v)

Convert 64 bits to double

Convert 64 bits to double
sourceraw docstring

bool-notclj

(bool-not x)

Primitive boolean not

Primitive boolean not
sourceraw docstring

bool-xorclj

(bool-xor x y)
(bool-xor x y & r)

Primitive boolean xor

Primitive boolean xor
sourceraw docstring

CATALAN_Gclj

Catalan G

Catalan G
sourceraw docstring

cbclj

(cb x)

x^3

x^3
sourceraw docstring

cbrtclj

(cbrt x)

cubic root, cbrt(x)

cubic root, cbrt(x)
sourceraw docstring

ceilclj

(ceil x)
(ceil x scale)

Calculates the ceiling of a number.

With a scale argument, rounds to the nearest multiple of scale towards positive infinity.

See also: qceil.

Calculates the ceiling of a number.

With a `scale` argument, rounds to the nearest multiple of `scale` towards positive infinity.

See also: [[qceil]].
sourceraw docstring

cexpexpclj

(cexpexp x)

1-exp(-exp(x))

1-exp(-exp(x))
sourceraw docstring

cloglogclj

(cloglog x)

log(-log(1-x))

log(-log(1-x))
sourceraw docstring

cnormclj

(cnorm v start stop)
(cnorm v start1 stop1 start2 stop2)

Constrained version of norm. Result of norm is applied to constrain to [0,1] or [start2,stop2] ranges.

Constrained version of norm. Result of [[norm]] is applied to [[constrain]] to `[0,1]` or `[start2,stop2]` ranges.
sourceraw docstring

co-intervalsclj

(co-intervals data)
(co-intervals data number)
(co-intervals data number overlap)

Divides a sequence of numerical data into number (default 6) overlapping intervals.

The intervals are constructed such that each contains a similar number of values from the sorted data, aiming to replicate the behavior of R's co.intervals() function. Invalid doubles (NaN, infinite) are removed from the input data before processing.

Arguments:

  • data: A collection of numbers.
  • number: The desired number of intervals (default 6, long).
  • overlap: The desired overlap proportion between consecutive intervals (default 0.5, double).

Returns a sequence of intervals, where each interval is represented as a 2-element vector [lower-bound upper-bound].

Divides a sequence of numerical `data` into `number` (default 6) overlapping intervals.

The intervals are constructed such that each contains a similar number of values from the sorted data, aiming to replicate the behavior of R's `co.intervals()` function. Invalid doubles (NaN, infinite) are removed from the input data before processing.

Arguments:
- `data`: A collection of numbers.
- `number`: The desired number of intervals (default 6, long).
- `overlap`: The desired overlap proportion between consecutive intervals (default 0.5, double).

Returns a sequence of intervals, where each interval is represented as a 2-element vector `[lower-bound upper-bound]`.
sourceraw docstring

combinationsclj

(combinations n k)

Binomial coefficient (n choose k)

Binomial coefficient (n choose k)
sourceraw docstring

constraincljmacro

(constrain value mn mx)

Clamp value to the range [mn,mx].

Clamp `value` to the range `[mn,mx]`.
sourceraw docstring

copy-signclj

(copy-sign magnitude sign)

Returns a value with a magnitude of first argument and sign of second.

Returns a value with a magnitude of first argument and sign of second.
sourceraw docstring

cosclj

(cos x)

cos(x)

cos(x)
sourceraw docstring

cos-interpolationclj

(cos-interpolation start stop t)

oF interpolateCosine interpolation. See also lerp/mlerp, quad-interpolation or smooth-interpolation.

oF interpolateCosine interpolation. See also [[lerp]]/[[mlerp]], [[quad-interpolation]] or [[smooth-interpolation]].
sourceraw docstring

coshclj

(cosh x)

cosh(x)

cosh(x)
sourceraw docstring

cospiclj

(cospi x)

cos(pi*x)

cos(pi*x)
sourceraw docstring

cotclj

(cot x)

cot(x)

cot(x)
sourceraw docstring

cothclj

(coth x)

Hyperbolic cotangent

Hyperbolic cotangent
sourceraw docstring

cotpiclj

(cotpi x)

cot(pi*x)

cot(pi*x)
sourceraw docstring

covercosclj

(covercos x)

Covercosine

Covercosine
sourceraw docstring

coversinclj

(coversin x)

Coversine

Coversine
sourceraw docstring

crdclj

(crd x)

Chord

Chord
sourceraw docstring

cscclj

(csc x)

csc(x)

csc(x)
sourceraw docstring

cschclj

(csch x)

Hyperbolic cosecant

Hyperbolic cosecant
sourceraw docstring

cscpiclj

(cscpi x)

csc(pi*x)

csc(pi*x)
sourceraw docstring

cutclj

(cut data breaks)
(cut x1 x2 breaks)

Divides a numerical range or a sequence of numbers into a specified number of equally spaced intervals.

Given data and breaks, the range is determined by the minimum and maximum finite values in data. Invalid doubles (NaN, infinite) are ignored. Given x1, x2, and breaks, the range is explicitly [x1, x2].

The function generates breaks + 1 equally spaced points within the range using slice-range, and then forms breaks intervals from these points.

The intervals are returned as a sequence of 2-element vectors [lower-bound upper-bound]. Specifically, if the generated points are p0, p1, ..., p_breaks, the intervals are formed as: [[(prev-double p0), p1], [p1, p2], ..., [p_breaks-1, p_breaks]].

This means intervals are generally closed on the right, [a, b], with the first interval's lower bound slightly adjusted downwards to ensure inclusion of the exact minimum value if necessary due to floating point precision.

Arguments:

  • data: A collection of numbers (used to determine range).
  • x1, x2: The start and end points of the range.
  • breaks: The desired number of intervals (a positive long).
Divides a numerical range or a sequence of numbers into a specified number of equally spaced intervals.

Given `data` and `breaks`, the range is determined by the minimum and maximum finite values in `data`. Invalid doubles (NaN, infinite) are ignored.
Given `x1`, `x2`, and `breaks`, the range is explicitly `[x1, x2]`.

The function generates `breaks + 1` equally spaced points within the range using [[slice-range]], and then forms `breaks` intervals from these points.

The intervals are returned as a sequence of 2-element vectors `[lower-bound upper-bound]`.
Specifically, if the generated points are `p0, p1, ..., p_breaks`, the intervals are formed as:
`[[(prev-double p0), p1], [p1, p2], ..., [p_breaks-1, p_breaks]]`.

This means intervals are generally closed on the right, `[a, b]`, with the first interval's lower bound slightly adjusted downwards to ensure inclusion of the exact minimum value if necessary due to floating point precision.

Arguments:
- `data`: A collection of numbers (used to determine range).
- `x1`, `x2`: The start and end points of the range.
- `breaks`: The desired number of intervals (a positive long).
sourceraw docstring

decclj

(dec x)

Primitive and inlined dec

Primitive and inlined `dec`
sourceraw docstring

deg-in-radclj

$\frac{\pi}{180}$

$\frac{\pi}{180}$
sourceraw docstring

degreesclj

(degrees rad)

Convert radians into degrees.

Convert radians into degrees.
sourceraw docstring

delta-eqclj

(delta-eq a b)
(delta-eq a b accuracy)
(delta-eq a b abs-tol rel-tol)

Checks if two floating-point numbers a and b are approximately equal within given tolerances.

The check returns true if abs(a - b) is less than a combined tolerance, or if (== a b).

  • 2-arity (delta-eq a b): Uses a default absolute tolerance of 1.0e-6.
  • 3-arity (delta-eq a b abs-tol): Uses the provided absolute tolerance abs-tol.
  • 4-arity (delta-eq a b abs-tol rel-tol): Uses both absolute and relative tolerances. The combined tolerance is max(abs-tol, rel-tol * max(abs(a), abs(b))).

This function is useful for comparing floating-point numbers where exact equality checks (==) may fail due to precision issues.

Checks if two floating-point numbers `a` and `b` are approximately equal within given tolerances.

The check returns true if `abs(a - b)` is less than a combined tolerance, or if `(== a b)`.

- 2-arity `(delta-eq a b)`: Uses a default absolute tolerance of `1.0e-6`.
- 3-arity `(delta-eq a b abs-tol)`: Uses the provided absolute tolerance `abs-tol`.
- 4-arity `(delta-eq a b abs-tol rel-tol)`: Uses both absolute and relative tolerances. The combined tolerance is `max(abs-tol, rel-tol * max(abs(a), abs(b)))`.

This function is useful for comparing floating-point numbers where exact equality checks (`==`) may fail due to precision issues.
sourceraw docstring

delta=clj

Alias for delta-eq

Alias for [[delta-eq]]
sourceraw docstring

difference-of-productsclj

(difference-of-products a b c d)

Kahan's algorithm for (ab)-(cd) to avoid catastrophic cancellation.

Kahan's algorithm for (a*b)-(c*d) to avoid catastrophic cancellation.
sourceraw docstring

distclj

(dist [x1 y1] [x2 y2])
(dist x1 y1 x2 y2)

Euclidean distance between points (x1,y1) and (x2,y2).

Euclidean distance between points `(x1,y1)` and `(x2,y2)`.
sourceraw docstring

double-array->seqclj

Convert double array into sequence.

Alias for seq.

Convert double array into sequence.

Alias for `seq`.
sourceraw docstring

double-array-typeclj

source

double-bitsclj

(double-bits v)

Returns double as 64-bits (long)

Returns double as 64-bits (long)
sourceraw docstring

double-double-array->seqclj

(double-double-array->seq res)

Convert double array of double arrays into sequence of sequences.

Convert double array of double arrays into sequence of sequences. 
sourceraw docstring

double-double-array-typeclj

source

double-exponentclj

(double-exponent v)

Extract exponent information from double

Extract exponent information from double
sourceraw docstring

double-high-bitsclj

(double-high-bits v)

Returns high word from double as bits

Returns high word from double as bits
sourceraw docstring

double-low-bitsclj

(double-low-bits v)

Returns low word from double as bits

Returns low word from double as bits
sourceraw docstring

double-one-minus-epsilonclj

Value of 0x1.fffffffffffffp-1d = 0.(9)

Value of 0x1.fffffffffffffp-1d = 0.(9)
sourceraw docstring

double-significandclj

(double-significand v)

Extract significand from double

Extract significand from double
sourceraw docstring

Eclj

Value of $\mathrm{e}$

Value of $\mathrm{e}$
sourceraw docstring

EPSILONclj

$\varepsilon$, a small number

$\varepsilon$, a small number
sourceraw docstring

eqclj

(eq _)
(eq a b)
(eq a b & r)

Primitive math equality function.

Primitive math equality function.
sourceraw docstring

even?clj

(even? x)

Primitive and inlined even?

Primitive and inlined `even?`
sourceraw docstring

excscclj

(excsc x)

Excosecant

Excosecant
sourceraw docstring

expclj

(exp x)

exp(x) = e^x

exp(x) = e^x
sourceraw docstring

exp10clj

(exp10 x)

exp10(x) = 10^x

exp10(x) = 10^x
sourceraw docstring

exp2clj

(exp2 x)

exp2(x) = 2^x

exp2(x) = 2^x
sourceraw docstring

expexpclj

(expexp x)

exp(-exp(-x))

exp(-exp(-x))
sourceraw docstring

expm1clj

(expm1 x)

exp(x)-1 for small x

exp(x)-1 for small x
sourceraw docstring

exprelclj

(exprel x)

(exp(x)-1)/x

(exp(x)-1)/x
sourceraw docstring

exsecclj

(exsec x)

Exsecant

Exsecant
sourceraw docstring

factorialclj

(factorial n)

Factorial

Factorial
sourceraw docstring

factorial20clj

(factorial20 n)

Factorial table up to 20!

Factorial table up to 20!
sourceraw docstring

falling-factorialclj

(falling-factorial n x)

Falling (descending) factorial.

Falling (descending) factorial.
sourceraw docstring

falling-factorial-intclj

(falling-factorial-int n x)

Falling (descending) factorial for integer n.

Falling (descending) factorial for integer n.
sourceraw docstring

fast*cljdeprecated

(fast*)
(fast* a)
(fast* a b)
(fast* a b & r)

Primitive and inlined * as a function

Primitive and inlined `*` as a function
sourceraw docstring

fast+cljdeprecated

(fast+)
(fast+ a)
(fast+ a b)
(fast+ a b & r)

Primitive and inlined + as a function

Primitive and inlined `+` as a function
sourceraw docstring

fast-cljdeprecated

(fast-)
(fast- a)
(fast- a b)
(fast- a b & r)

Primitive and inlined - as a function

Primitive and inlined `-` as a function
sourceraw docstring

fast-divcljdeprecated

(fast-div)
(fast-div a)
(fast-div a b)
(fast-div a b & r)

Primitive and inlined / as a function

Primitive and inlined `/` as a function
sourceraw docstring

fast-identitycljdeprecated

(fast-identity a)

Identity on double.

Identity on double.
sourceraw docstring

fast-maxcljdeprecated

(fast-max a)
(fast-max a b)
(fast-max a b & r)

Primitive and inlined max as a function

Primitive and inlined `max` as a function
sourceraw docstring

fast-mincljdeprecated

(fast-min a)
(fast-min a b)
(fast-min a b & r)

Primitive and inlined min as a function

Primitive and inlined `min` as a function
sourceraw docstring

floorclj

(floor x)
(floor x scale)

Calculates the floor of a number.

With a scale argument, rounds to the nearest multiple of scale towards negative infinity.

See also: qfloor.

Calculates the floor of a number.

With a `scale` argument, rounds to the nearest multiple of `scale` towards negative infinity.

See also: [[qfloor]].
sourceraw docstring

fmaclj

(fma x y z)

(x y z) -> (+ z (* x y)) or Math/fma for java 9+

`(x y z)` -> `(+ z (* x y))` or `Math/fma` for java 9+
sourceraw docstring

FOUR_INV_PIclj

Value of $\frac{4}{\pi}$

Value of $\frac{4}{\pi}$
sourceraw docstring

fpowclj

(fpow x exponent)

Fast version of pow where exponent is integer.

Fast version of pow where exponent is integer.
sourceraw docstring

fracclj

(frac v)

Fractional part, always returns values from 0.0 to 1.0 (exclusive). See sfrac for signed version.

Fractional part, always returns values from 0.0 to 1.0 (exclusive). See [[sfrac]] for signed version.
sourceraw docstring

GAMMAclj

$\gamma$, Euler-Mascheroni constant

$\gamma$, Euler-Mascheroni constant
sourceraw docstring

gcdclj

(gcd a b)

Fast binary greatest common divisor (Stein's algorithm)

Fast binary greatest common divisor (Stein's algorithm)
sourceraw docstring

group-by-intervalsclj

(group-by-intervals coll)
(group-by-intervals intervals coll)

Groups values from a sequence coll into specified intervals.

The function partitions the values in coll based on which interval they fall into. Each interval is a 2-element vector [lower upper]. Values are included in an interval if they are strictly greater than the lower bound and less than or equal to the upper bound, using between-?.

Arguments:

  • intervals: A sequence of 2-element vectors representing the intervals [lower upper].
  • coll: A collection of numerical values to be grouped.

If intervals are not provided, the function first calculates overlapping intervals using co-intervals from the values in coll, and then groups the values into these generated intervals.

Returns a map where keys are the interval vectors and values are sequences of the numbers from coll that fall within that interval.

Groups values from a sequence `coll` into specified intervals.

The function partitions the values in `coll` based on which interval they fall into.
Each interval is a 2-element vector `[lower upper]`. Values are included in an interval if they are strictly greater than the `lower` bound and less than or equal to the `upper` bound, using [[between-?]].

Arguments:
- `intervals`: A sequence of 2-element vectors representing the intervals `[lower upper]`.
- `coll`: A collection of numerical values to be grouped.

If `intervals` are not provided, the function first calculates overlapping intervals using [[co-intervals]] from the values in `coll`, and then groups the values into these generated intervals.

Returns a map where keys are the interval vectors and values are sequences of the numbers from `coll` that fall within that interval.
sourceraw docstring

hacovercosclj

(hacovercos x)

Hacovercosine

Hacovercosine
sourceraw docstring

hacoversinclj

(hacoversin x)

Hacoversine

Hacoversine
sourceraw docstring

HALF_PIclj

Value of $\frac{\pi}{2}$

Value of $\frac{\pi}{2}$
sourceraw docstring

havercosclj

(havercos x)

Havercosine

Havercosine
sourceraw docstring

haversinclj

(haversin x)
(haversin [lat1 lon1] [lat2 lon2])
(haversin lat1 lon1 lat2 lon2)

Haversine formula for value or lattitude and longitude pairs.

Haversine formula for value or lattitude and longitude pairs.
sourceraw docstring

haversineclj

Haversine (haversin alias)

Haversine ([[haversin]] alias)
sourceraw docstring

haversine-distclj

(haversine-dist [lat1 lon1] [lat2 lon2])
(haversine-dist lat1 lon1 lat2 lon2)

Haversine distance d for r=1

Haversine distance `d` for `r=1`
sourceraw docstring

high-2-expclj

(high-2-exp x)

Finds the smallest integer n such that 2^n >= |x|. See low-2-exp.

Finds the smallest integer `n` such that `2^n >= |x|`. See [[low-2-exp]].
sourceraw docstring

high-expclj

(high-exp b x)

Finds the smallest integer n such that b^n >= |x|. See also low-exp.

Finds the smallest integer `n` such that `b^n >= |x|`. See also [[low-exp]].
sourceraw docstring

hypotclj

(hypot x y)
(hypot x y z)

Calculates the Euclidean norm (distance from the origin) for 2 or 3 arguments.

It uses a numerically stable algorithm to avoid intermediate overflow or underflow.

See also hypot-sqrt for the direct calculation.

Calculates the Euclidean norm (distance from the origin) for 2 or 3 arguments.

It uses a numerically stable algorithm to avoid intermediate overflow or underflow.

See also [[hypot-sqrt]] for the direct calculation.
sourceraw docstring

hypot-sqrtclj

(hypot-sqrt x y)
(hypot-sqrt x y z)

Calculates the Euclidean norm (distance from the origin) using a direct sqrt of sum of squares.

Note: This method can be less numerically stable than hypot for inputs with vastly different magnitudes.

Calculates the Euclidean norm (distance from the origin) using a direct sqrt of sum of squares.

Note: This method can be less numerically stable than [[hypot]] for inputs with vastly different magnitudes.
sourceraw docstring

iabscljdeprecated

(iabs x)

Absolute value, long version. See abs.

Absolute value, `long` version. See [[abs]].
sourceraw docstring

identity-doubleclj

(identity-double a)

Identity on double.

Identity on double.
sourceraw docstring

identity-longclj

(identity-long a)

Identity on long.

Identity on long.
sourceraw docstring

incclj

(inc x)

Primitive and inlined inc

Primitive and inlined `inc`
sourceraw docstring

inf?clj

(inf? v)

Check if a number is an infinite (positive or negative).

Check if a number is an infinite (positive or negative).
sourceraw docstring

integer?clj

(integer? v)

Check if given real number is an integer.

Check if given real number is an integer.
sourceraw docstring

inv-factorialclj

(inv-factorial n)

Inverse of factorial, 1/n!

Inverse of factorial, 1/n!
sourceraw docstring

INV_FOUR_PIclj

Value of $\frac{2}{2\pi}$

Value of $\frac{2}{2\pi}$
sourceraw docstring

INV_LN2clj

Value of $\frac{1}{\ln{2}}$

Value of $\frac{1}{\ln{2}}$
sourceraw docstring

INV_LOG_HALFclj

Value of $\frac{1}{\ln{\frac{1}{2}}}$

Value of $\frac{1}{\ln{\frac{1}{2}}}$
sourceraw docstring

INV_PIclj

Value of $\frac{1}{\pi}$

Value of $\frac{1}{\pi}$
sourceraw docstring

INV_SQRT2PIclj

Value of $\frac{1}{\sqrt{2\pi}}$

Value of $\frac{1}{\sqrt{2\pi}}$
sourceraw docstring

INV_SQRT_2clj

Value of $\frac{1}{\sqrt{2}}$

Value of $\frac{1}{\sqrt{2}}$
sourceraw docstring

INV_SQRTPIclj

Value of $\frac{1}{\sqrt\pi}$

Value of $\frac{1}{\sqrt\pi}$
sourceraw docstring

INV_TWO_PIclj

Value of $\frac{1}{2\pi}$

Value of $\frac{1}{2\pi}$
sourceraw docstring

invalid-double?clj

(invalid-double? v)

Check if a number is not finite double (NaN or ±Inf).

Check if a number is not finite double (NaN or ±Inf).
sourceraw docstring

itruncclj

(itrunc v)

Truncate fractional part, keep sign. Returns long.

Truncate fractional part, keep sign. Returns `long`.
sourceraw docstring

jvm-versionclj

source

LANCZOS_Gclj

Lanchos approximation of g constant

Lanchos approximation of `g` constant
sourceraw docstring

lcmclj

(lcm a b)

Fast binary least common multiplier.

Fast binary least common multiplier.
sourceraw docstring

lerpclj

(lerp start stop t)

Linear interpolation between start and stop for amount t. See also mlerp, cos-interpolation, quad-interpolation or smooth-interpolation.

Linear interpolation between `start` and `stop` for amount `t`. See also [[mlerp]], [[cos-interpolation]], [[quad-interpolation]] or [[smooth-interpolation]].
sourceraw docstring

lnclj

(ln x)

log(x)=ln(x)

log(x)=ln(x)
sourceraw docstring

LN10clj

Value of $\ln{10}$

Value of $\ln{10}$
sourceraw docstring

LN2clj

Value of $\ln{2}$

Value of $\ln{2}$
sourceraw docstring

LN2_2clj

Value of $\frac{\ln{2}}{2}$

Value of $\frac{\ln{2}}{2}$
sourceraw docstring

logclj

(log x)
(log base x)

log(x)=ln(x) or logarithm with given base.

log(x)=ln(x) or logarithm with given `base`.
sourceraw docstring

log-combinationsclj

(log-combinations n k)

Log of binomial coefficient (n choose k)

Log of binomial coefficient (n choose k)
sourceraw docstring

log-factorialclj

(log-factorial x)

Log factorial, alias to log-gamma

Log factorial, alias to log-gamma
sourceraw docstring

log10clj

(log10 x)

log_10(x)

log_10(x)
sourceraw docstring

LOG10Eclj

$\log_{10}{\mathrm{e}}$

$\log_{10}{\mathrm{e}}$
sourceraw docstring

log1mexpclj

(log1mexp x)

log(1-exp(x)), x<0

log(1-exp(x)), x<0
sourceraw docstring

log1pclj

(log1p x)

log(1+x) for small x

log(1+x) for small x
sourceraw docstring

log1pexpclj

(log1pexp x)

log(1+exp(x))

log(1+exp(x))
sourceraw docstring

log1pmxclj

(log1pmx x)

log(1+x)-x

log(1+x)-x
sourceraw docstring

log1psqclj

(log1psq x)

log(1+x^2))

log(1+x^2))
sourceraw docstring

log2clj

(log2 x)

Logarithm with base 2.

\(\ln_2{x}\)

Logarithm with base 2.

\\(\ln_2{x}\\)
sourceraw docstring

LOG2Eclj

$\log_{2}{\mathrm{e}}$

$\log_{2}{\mathrm{e}}$
sourceraw docstring

log2intclj

(log2int v)

Fast and integer version of log2, returns long

Fast and integer version of log2, returns long
sourceraw docstring

log2mexpclj

(log2mexp x)

log(2-exp(x))

log(2-exp(x))
sourceraw docstring

LOG_HALFclj

Value of $\ln{\frac{1}{2}}$

Value of $\ln{\frac{1}{2}}$
sourceraw docstring

LOG_PIclj

Value of $\ln{\pi}$

Value of $\ln{\pi}$
sourceraw docstring

LOG_TWO_PIclj

Value of $\ln{2\pi}$

Value of $\ln{2\pi}$
sourceraw docstring

logaddexpclj

(logaddexp x y)

log(exp(x)+exp(y))

log(exp(x)+exp(y))
sourceraw docstring

logbclj

(logb b x)

Logarithm with base b.

\(\ln_b{x}\)

Logarithm with base `b`.

\\(\ln_b{x}\\)
sourceraw docstring

logcoshclj

(logcosh x)

log(cosh(x))

log(cosh(x))
sourceraw docstring

logexpm1clj

(logexpm1 x)

log(exp(x)-1))

log(exp(x)-1))
sourceraw docstring

logisticclj

Alias for sigmoid

Alias for [[sigmoid]]
sourceraw docstring

logitclj

(logit x)

Logit function

Logit function
sourceraw docstring

loglogclj

(loglog x)

-log(-log(x))

-log(-log(x))
sourceraw docstring

logmxp1clj

(logmxp1 x)

log(x)-x+1

log(x)-x+1
sourceraw docstring

logsubexpclj

(logsubexp x y)

log(abs(exp(x)-exp(y)))

log(abs(exp(x)-exp(y)))
sourceraw docstring

logsumexpclj

(logsumexp xs)

log(exp(x1)+...+exp(xn))

log(exp(x1)+...+exp(xn))
sourceraw docstring

long-absclj

(long-abs x)

Absolut value, long version. See abs.

Absolut value, `long` version. See [[abs]].
sourceraw docstring

long-addclj

(long-add)
(long-add a)
(long-add a b)
(long-add a b c)
(long-add a b c d)
(long-add a b c d & r)

Primitive and inlined +. Coerces arguments and returned value to a long.

Primitive and inlined `+`. Coerces arguments and returned value to a long.
sourceraw docstring

long-decclj

(long-dec x)

Primitive and inlined dec coerced to a long

Primitive and inlined `dec` coerced to a long
sourceraw docstring

long-divclj

(long-div a)
(long-div a b)
(long-div a b c)
(long-div a b c d)
(long-div a b c d & r)

Primitive and inlined /. Coerces to arguments and returned value to a long.

Primitive and inlined `/`. Coerces to arguments and returned value to a long.
sourceraw docstring

long-incclj

(long-inc x)

Primitive and inlined inc coerced to a long

Primitive and inlined `inc` coerced to a long
sourceraw docstring

long-maxclj

(long-max a)
(long-max a b)
(long-max a b c)
(long-max a b c d)
(long-max a b c d & r)

Primitive and inlined max. Coerces arguments and returned values to longs.

Primitive and inlined `max`. Coerces arguments and returned values to longs.
sourceraw docstring

long-minclj

(long-min a)
(long-min a b)
(long-min a b c)
(long-min a b c d)
(long-min a b c d & r)

Primitive and inlined min. Coerces arguments and returned values to longs.

Primitive and inlined `min`. Coerces arguments and returned values to longs.
sourceraw docstring

long-modclj

(long-mod x y)

Primitive and inlined mod coerced to longs

Primitive and inlined `mod` coerced to longs
sourceraw docstring

long-multclj

(long-mult)
(long-mult a)
(long-mult a b)
(long-mult a b c)
(long-mult a b c d)
(long-mult a b c d & r)

Primitive and inlined *. Coerces arguments and returned value to a long.

Primitive and inlined `*`. Coerces arguments and returned value to a long.
sourceraw docstring

long-quotclj

(long-quot x y)

Primitive and inlined quot coerced to longs

Primitive and inlined `quot` coerced to longs
sourceraw docstring

long-remclj

(long-rem x y)

Primitive and inlined rem coerced to longs

Primitive and inlined `rem` coerced to longs
sourceraw docstring

long-subclj

(long-sub a)
(long-sub a b)
(long-sub a b c)
(long-sub a b c d)
(long-sub a b c d & r)

Primitive and inlined -. Coerces arguments and returned value to a long.

Primitive and inlined `-`. Coerces arguments and returned value to a long.
sourceraw docstring

low-2-expclj

(low-2-exp x)

Finds the greatest integer n such that 2^n <= |x|. See high-2-exp.

Finds the greatest integer `n` such that `2^n <= |x|`. See [[high-2-exp]].
sourceraw docstring

low-expclj

(low-exp b x)

Finds the greatest integer n such that b^n <= |x|. See also high-exp.

Finds the greatest integer `n` such that `b^n <= |x|`. See also [[high-exp]].
sourceraw docstring

M_1_PIclj

Value of $\frac{1}{\pi}$

Value of $\frac{1}{\pi}$
sourceraw docstring

M_2_PIclj

Value of $\frac{2}{\pi}$

Value of $\frac{2}{\pi}$
sourceraw docstring

M_2_SQRTPIclj

Value of $\frac{2}{\sqrt\pi}$

Value of $\frac{2}{\sqrt\pi}$
sourceraw docstring

M_3PI_4clj

Value of $\frac{3\pi}{4}$

Value of $\frac{3\pi}{4}$
sourceraw docstring

M_Eclj

Value of $\mathrm{e}$

Value of $\mathrm{e}$
sourceraw docstring

M_INVLN2clj

Value of $\frac{1}{\ln{2}}$

Value of $\frac{1}{\ln{2}}$
sourceraw docstring

M_IVLN10clj

Value of $\frac{1}{\ln{10}}$

Value of $\frac{1}{\ln{10}}$
sourceraw docstring

M_LN10clj

Value of $\ln{10}$

Value of $\ln{10}$
sourceraw docstring

M_LN2clj

Value of $\ln{2}$

Value of $\ln{2}$
sourceraw docstring

M_LOG10Eclj

Value of $\log_{10}{e}$

Value of $\log_{10}{e}$
sourceraw docstring

M_LOG2_Eclj

Value of $\ln{2}$

Value of $\ln{2}$
sourceraw docstring

M_LOG2Eclj

Value of $\log_{2}{e}$

Value of $\log_{2}{e}$
sourceraw docstring

M_PIclj

Value of $\pi$

Value of $\pi$
sourceraw docstring

M_PI_2clj

Value of $\frac{\pi}{2}$

Value of $\frac{\pi}{2}$
sourceraw docstring

M_PI_4clj

Value of $\frac{\pi}{4}$

Value of $\frac{\pi}{4}$
sourceraw docstring

M_SQRT1_2clj

Value of $\frac{1}{\sqrt{2}}$

Value of $\frac{1}{\sqrt{2}}$
sourceraw docstring

M_SQRT2clj

Value of $\sqrt{2}$

Value of $\sqrt{2}$
sourceraw docstring

M_SQRT3clj

Value of $\sqrt{3}$

Value of $\sqrt{3}$
sourceraw docstring

M_SQRT_PIclj

Value of $\sqrt\pi$

Value of $\sqrt\pi$
sourceraw docstring

M_TWOPIclj

Value of $2\pi$

Value of $2\pi$
sourceraw docstring

MACHINE-EPSILONclj

ulp(1)/2

ulp(1)/2
sourceraw docstring

MACHINE-EPSILON10clj

5ulp(1)

5ulp(1)
sourceraw docstring

make-normclj

(make-norm start stop)
(make-norm start stop dstart dstop)

Make norm function for given range. Resulting function accepts double value (with optional target [dstart,dstop] range) and returns double.

Make [[norm]] function for given range. Resulting function accepts `double` value (with optional target `[dstart,dstop]` range) and returns `double`.
sourceraw docstring

maxclj

(max a)
(max a b)
(max a b c)
(max a b c d)
(max a b c d & r)

Primitive and inlined max.

Primitive and inlined `max`.
sourceraw docstring

minclj

(min a)
(min a b)
(min a b c)
(min a b c d)
(min a b c d & r)

Primitive and inlined min.

Primitive and inlined `min`.
sourceraw docstring

mlerpcljmacro

(mlerp start stop t)

lerp as macro. For inline code. See also lerp, cos-interpolation, quad-interpolation or smooth-interpolation.

[[lerp]] as macro. For inline code. See also [[lerp]], [[cos-interpolation]], [[quad-interpolation]] or [[smooth-interpolation]].
sourceraw docstring

mnormcljmacro

(mnorm v start stop)
(mnorm v start1 stop1 start2 stop2)

Macro version of norm.

Macro version of [[norm]].
sourceraw docstring

modclj

(mod x y)

Primitive and inlined mod

Primitive and inlined `mod`
sourceraw docstring

mpowclj

(mpow x e m)

Calculates the modular exponentiation $(x^e \pmod m)$.

Computes the remainder of x raised to the power of e, when divided by m. Uses binary exponentiation.

x: Base (long). e: Exponent (long, non-negative). m: Modulus (long, positive).

Calculates the modular exponentiation $(x^e \pmod m)$.

Computes the remainder of `x` raised to the power of `e`, when divided by `m`.
Uses binary exponentiation.

`x`: Base (long).
`e`: Exponent (long, non-negative).
`m`: Modulus (long, positive).
sourceraw docstring

muladdclj

(muladd x y z)

(x y z) -> (+ z (* x y)) or Math/fma for java 9+

`(x y z)` -> `(+ z (* x y))` or `Math/fma` for java 9+
sourceraw docstring

nan?clj

(nan? v)

Check if a number is a NaN

Check if a number is a NaN
sourceraw docstring

near-zero?clj

(near-zero? x)
(near-zero? x abs-tol)
(near-zero? x abs-tol rel-tol)

Checks if given value is near zero with absolute (default: 1.0e-6) and/or relative (default 0.0) tolerance.

Checks if given value is near zero with absolute (default: `1.0e-6`) and/or relative (default `0.0`) tolerance.
sourceraw docstring

neg-inf?clj

(neg-inf? v)

Check if a number is negatively infinite.

Check if a number is negatively infinite.
sourceraw docstring

neg?clj

(neg? x)

Primitive and inlined neg?

Primitive and inlined `neg?`
sourceraw docstring

negative-zero?clj

(negative-zero? x)

Check if zero is negative, ie. -0.0

Check if zero is negative, ie. -0.0
sourceraw docstring

negmuladdclj

(negmuladd x y z)

(x y z) -> (+ z (* -x y)) or Math/fma for java 9+

`(x y z)` -> `(+ z (* -x y))` or `Math/fma` for java 9+
sourceraw docstring

next-doubleclj

(next-double v)
(next-double v delta)

Next double value. Optional value delta sets step amount.

Next double value. Optional value `delta` sets step amount.
sourceraw docstring

normclj

(norm v start stop)
(norm v start1 stop1 start2 stop2)

Normalize v from the range [start,stop] to the range [0,1] or map v from the range [start1,stop1] to the range [start2,stop2]. See also make-norm.

Normalize `v` from the range `[start,stop]` to the range `[0,1]` or map `v` from the range `[start1,stop1]` to the range `[start2,stop2]`. See also [[make-norm]].
sourceraw docstring

not-neg?clj

(not-neg? x)

Primitive and inlined not-neg? (x>=0.0)

Primitive and inlined `not-neg?` (x>=0.0)
sourceraw docstring

not-pos?clj

(not-pos? x)

Primitive and inlined not-pos? (x<=0.0)

Primitive and inlined `not-pos?` (x<=0.0)
sourceraw docstring

not-zero?clj

(not-zero? x)

Primitive and inlined x<>0.0

Primitive and inlined x<>0.0
sourceraw docstring

not==clj

(not== _)
(not== a b)
(not== a b & r)

Not equality. For more than two arguments, returns true when all values are unique.

(not== 1 2 1) === (and (not= 1 1) (not= 1 2))

Not equality. For more than two arguments, returns `true` when all values are unique.

`(not== 1 2 1)` === `(and (not= 1 1) (not= 1 2))`
sourceraw docstring

odd?clj

(odd? x)

Primitive and inlined odd?

Primitive and inlined `odd?`
sourceraw docstring

one?clj

(one? x)

Primitive and inlined one? (x==1.0)

Primitive and inlined `one?` (x==1.0)
sourceraw docstring

ONE_SIXTHclj

Value of $\frac{1}{6}$

Value of $\frac{1}{6}$
sourceraw docstring

ONE_THIRDclj

Value of $\frac{1}{3}$

Value of $\frac{1}{3}$
sourceraw docstring

orderclj

(order vs)
(order vs decreasing?)

Computes the permutation of indices that would sort the input collection vs.

The result is a sequence of 0-based indices such that applying them to the original collection using (map #(nth vs %) result) yields a sorted sequence.

Arguments:

  • vs: A collection of comparable values.
  • decreasing?: Optional boolean (default false). If true, the indices permute for a descending sort.

Returns: A sequence of 0-based indices.

Computes the permutation of indices that would sort the input collection `vs`.

The result is a sequence of 0-based indices such that applying them to the original collection
using `(map #(nth vs %) result)` yields a sorted sequence.

Arguments:

- `vs`: A collection of comparable values.
- `decreasing?`: Optional boolean (default false). If true, the indices permute for a descending sort.

Returns: A sequence of 0-based indices.
sourceraw docstring

PHIclj

Golden ratio $\phi$

Golden ratio $\phi$
sourceraw docstring

PIclj

Value of $\pi$

Value of $\pi$
sourceraw docstring

pos-inf?clj

(pos-inf? v)

Check if a number is positively infinite.

Check if a number is positively infinite.
sourceraw docstring

pos?clj

(pos? x)

Primitive and inlined pos?

Primitive and inlined `pos?`
sourceraw docstring

powclj

(pow x exponent)

Power of a number

Power of a number
sourceraw docstring

pow10clj

(pow10 x)

x^10

x^10
sourceraw docstring

pow2clj

(pow2 x)

x^2, x*x

x^2, x*x
sourceraw docstring

pow3clj

(pow3 x)

x^3

x^3
sourceraw docstring

prev-doubleclj

(prev-double v)
(prev-double v delta)

Next double value. Optional value delta sets step amount.

Next double value. Optional value `delta` sets step amount.
sourceraw docstring

qceilclj

(qceil x)

Fast version of ceil. Returns long.

Fast version of [[ceil]]. Returns `long`.
sourceraw docstring

qcosclj

(qcos x)

Fast and less accurate cos(x)

Fast and less accurate cos(x)
sourceraw docstring

qdistclj

(qdist [x1 y1] [x2 y2])
(qdist x1 y1 x2 y2)

Quick version of Euclidean distance between points. qsqrt is used instead of sqrt.

Quick version of Euclidean distance between points. [[qsqrt]] is used instead of [[sqrt]].
sourceraw docstring

qexpclj

(qexp x)

Quick and less accurate version of exp.

Quick and less accurate version of [[exp]].
sourceraw docstring

qfloorclj

(qfloor x)

Fast version of floor. Returns long.

Fast version of [[floor]]. Returns `long`.
sourceraw docstring

qlogclj

(qlog x)

Fast and less accurate version of log.

Fast and less accurate version of [[log]].
sourceraw docstring

qpowclj

(qpow x exponent)

Fast and less accurate version of pow.

Fast and less accurate version of [[pow]].
sourceraw docstring

qroundclj

(qround x)

Fast version of round. Returns long

Fast version of [[round]]. Returns `long`
sourceraw docstring

qsinclj

(qsin x)

Fast and less accurate sin(x)

Fast and less accurate sin(x)
sourceraw docstring

qsqrtclj

(qsqrt x)

Approximated sqrt using binary operations with error 1.0E-2.

Approximated [[sqrt]] using binary operations with error `1.0E-2`.
sourceraw docstring

quad-interpolationclj

(quad-interpolation start stop t)

Quad interpolation. See also lerp/mlerp, cos-interpolation or smooth-interpolation.

Quad interpolation. See also [[lerp]]/[[mlerp]], [[cos-interpolation]] or [[smooth-interpolation]].
sourceraw docstring

QUARTER_PIclj

Value of $\frac{\pi}{4}$

Value of $\frac{\pi}{4}$
sourceraw docstring

quotclj

(quot x y)

Primitive and inlined quot

Primitive and inlined `quot`
sourceraw docstring

rad-in-degclj

$\frac{180}{\pi}$

$\frac{180}{\pi}$
sourceraw docstring

radiansclj

(radians deg)

Convert degrees into radians.

Convert degrees into radians.
sourceraw docstring

rankclj

(rank vs)
(rank vs ties)
(rank vs ties desc?)

Assigns ranks to values in a collection, handling ties according to a specified strategy. Ranks are 0-based indices indicating the position of each element in the sorted collection.

Arguments:

  • vs: A collection of comparable values.
  • ties: The tie-breaking strategy (keyword, optional, default :average). Supported strategies:
    • :average: Assign the average rank to all tied values.
    • :first: Assign ranks based on their appearance order in the input.
    • :last: Assign ranks based on their appearance order in the input (reverse of :first).
    • :random: Assign random ranks to tied values.
    • :min: Assign the minimum rank to all tied values.
    • :max: Assign the maximum rank to all tied values.
    • :dense: Assign consecutive ranks without gaps (like data.table::frank in R).
  • desc?: If true, rank in descending order (boolean, optional, default false).

Returns a sequence of rank values corresponding to the input elements.

Assigns ranks to values in a collection, handling ties according to a specified strategy.
Ranks are 0-based indices indicating the position of each element in the sorted collection.

Arguments:

- `vs`: A collection of comparable values.
- `ties`: The tie-breaking strategy (keyword, optional, default `:average`).
  Supported strategies:
  - `:average`: Assign the average rank to all tied values.
  - `:first`: Assign ranks based on their appearance order in the input.
  - `:last`: Assign ranks based on their appearance order in the input (reverse of `:first`).
  - `:random`: Assign random ranks to tied values.
  - `:min`: Assign the minimum rank to all tied values.
  - `:max`: Assign the maximum rank to all tied values.
  - `:dense`: Assign consecutive ranks without gaps (like `data.table::frank` in R).
- `desc?`: If true, rank in descending order (boolean, optional, default `false`).

Returns a sequence of rank values corresponding to the input elements.
sourceraw docstring

rank1clj

source

relative-errorclj

(relative-error v v-approx)

Relative error between two values

Relative error between two values
sourceraw docstring

remclj

(rem x y)

Primitive and inlined rem

Primitive and inlined `rem`
sourceraw docstring

remainderclj

(remainder dividend divisor)

From FastMath doc: returns dividend - divisor * n, where n is the mathematical integer closest to dividend/divisor. Returned value in [-|divisor|/2,|divisor|/2]

From `FastMath` doc: returns dividend - divisor * n,
where n is the mathematical integer closest to dividend/divisor. Returned value in `[-|divisor|/2,|divisor|/2]`
sourceraw docstring

rintclj

(rint x)
(rint x scale)

Round to a double value. See round, qround.

Rounding is done to a multiply of scale value (when provided).

Round to a `double` value. See [[round]], [[qround]].

Rounding is done to a multiply of scale value (when provided).
sourceraw docstring

rising-factorialclj

(rising-factorial n x)

Rising (Pochhammer) factorial.

Rising (Pochhammer) factorial.
sourceraw docstring

rising-factorial-intclj

(rising-factorial-int n x)

Rising (Pochhammer) factorial for integer n.

Rising (Pochhammer) factorial for integer n.
sourceraw docstring

roundclj

(round x)

Round to a long value. See: rint, qround.

Round to a `long` value. See: [[rint]], [[qround]].
sourceraw docstring

round-evenclj

(round-even x)

Round evenly, IEEE / IEC rounding

Round evenly, IEEE / IEC rounding
sourceraw docstring

round-up-pow2clj

(round-up-pow2 v)

Rounds a positive long integer up to the smallest power of 2 greater than or equal to the input value.

Rounds a positive `long` integer up to the smallest power of 2 greater than or equal to the input value.
sourceraw docstring

rqsqrtclj

(rqsqrt x)

Reciprocal of qsqrt. Quick and less accurate.

Reciprocal of [[qsqrt]]. Quick and less accurate.
sourceraw docstring

safe-sqrtclj

(safe-sqrt value)

Safe sqrt, for value <= 0 result is 0.

Safe sqrt, for value <= 0 result is 0.
sourceraw docstring

sampleclj

(sample f number-of-values)
(sample f number-of-values domain?)
(sample f domain-min domain-max number-of-values)
(sample f domain-min domain-max number-of-values domain?)

Samples a function f by evaluating it at evenly spaced points within a numerical range.

Generates number-of-values points in the specified range [domain-min, domain-max] (inclusive) and applies f to each point.

Arguments:

  • f: The function to sample. Should accept a single double argument.
  • number-of-values: The total number of points to generate (a positive long).
  • domain-min: The lower bound of the sampling range (a double). Defaults to 0.0.
  • domain-max: The upper bound of the sampling range (a double). Defaults to 1.0.
  • domain?: A boolean flag. If true, returns pairs [x, (f x)]. If false (default), returns just (f x).

Arities:

  • [f number-of-values]: Samples f in [0.0, 1.0]. Returns (f x) values.
  • [f number-of-values domain?]: Samples f in [0.0, 1.0]. Returns [x, (f x)] pairs if domain? is true, otherwise (f x) values.
  • [f domain-min domain-max number-of-values]: Samples f in [domain-min, domain-max]. Returns (f x) values.
  • [f domain-min domain-max number-of-values domain?]: Samples f in [domain-min, domain-max]. Returns [x, (f x)] pairs if domain? is true, otherwise (f x) values.

The points are generated linearly from domain-min to domain-max. If number-of-values is 1, it samples only the midpoint of the range.

Returns a sequence of double values or vectors [double, double] depending on domain?.

Samples a function `f` by evaluating it at evenly spaced points within a numerical range.

Generates `number-of-values` points in the specified range `[domain-min, domain-max]` (inclusive) and applies `f` to each point.

Arguments:

- `f`: The function to sample. Should accept a single `double` argument.
- `number-of-values`: The total number of points to generate (a positive `long`).
- `domain-min`: The lower bound of the sampling range (a `double`). Defaults to `0.0`.
- `domain-max`: The upper bound of the sampling range (a `double`). Defaults to `1.0`.
- `domain?`: A boolean flag. If `true`, returns pairs `[x, (f x)]`. If `false` (default), returns just `(f x)`.

Arities:

- `[f number-of-values]`: Samples `f` in `[0.0, 1.0]`. Returns `(f x)` values.
- `[f number-of-values domain?]`: Samples `f` in `[0.0, 1.0]`. Returns `[x, (f x)]` pairs if `domain?` is true, otherwise `(f x)` values.
- `[f domain-min domain-max number-of-values]`: Samples `f` in `[domain-min, domain-max]`. Returns `(f x)` values.
- `[f domain-min domain-max number-of-values domain?]`: Samples `f` in `[domain-min, domain-max]`. Returns `[x, (f x)]` pairs if `domain?` is true, otherwise `(f x)` values.

The points are generated linearly from `domain-min` to `domain-max`. If `number-of-values` is 1, it samples only the midpoint of the range.

Returns a sequence of `double` values or vectors `[double, double]` depending on `domain?`.
sourceraw docstring

secclj

(sec x)

sec(x)

sec(x)
sourceraw docstring

sechclj

(sech x)

Hyperbolic secant

Hyperbolic secant
sourceraw docstring

secpiclj

(secpi x)

sec(pi*x)

sec(pi*x)
sourceraw docstring

seq->double-arrayclj

(seq->double-array vs)

Convert sequence to double array. Returns input if vs is double array already.

Convert sequence to double array. Returns input if `vs` is double array already.
sourceraw docstring

seq->double-double-arrayclj

(seq->double-double-array vss)

Convert sequence to double-array of double-arrays.

If sequence is double-array of double-arrays returns vss

Convert sequence to double-array of double-arrays.

If sequence is double-array of double-arrays returns `vss`
sourceraw docstring

sfracclj

(sfrac v)

Fractional part, always returns values from -1.0 to 1.0 (exclusive). See frac for unsigned version.

Fractional part, always returns values from -1.0 to 1.0 (exclusive). See [[frac]] for unsigned version.
sourceraw docstring

sgnclj

(sgn value)

Returns -1 when value is negative, 1 otherwise. See also signum.

Returns -1 when `value` is negative, 1 otherwise. See also [[signum]].
sourceraw docstring

sigmoidclj

(sigmoid x)

Sigmoid function

Sigmoid function
sourceraw docstring

signumclj

(signum value)

Returns 1 if value is > 0, 0 if it is 0, -1 otherwise. See also sgn.

Returns 1 if `value` is > 0, 0 if it is 0, -1 otherwise. See also [[sgn]].
sourceraw docstring

SILVERclj

Silver ratio $\delta_S$

Silver ratio $\delta_S$
sourceraw docstring

sinclj

(sin x)

sin(x)

sin(x)
sourceraw docstring

sincclj

(sinc v)

Sinc function.

Sinc function.
sourceraw docstring

sinhclj

(sinh x)

sinh(x)

sinh(x)
sourceraw docstring

sinpiclj

(sinpi x)

sin(pi*x)

sin(pi*x)
sourceraw docstring

SIXTHclj

Value of $\frac{1}{6}$

Value of $\frac{1}{6}$
sourceraw docstring

slice-rangeclj

(slice-range cnt)
(slice-range data cnt)
(slice-range start end cnt)

Generates cnt evenly spaced points within a numerical range.

  • (slice-range cnt): Generates cnt points in the range [0.0, 1.0].
  • (slice-range data cnt): Generates cnt points in the range [(min data), (max data)].
  • (slice-range start end cnt): Generates cnt points in the range [start, end].

The range is inclusive, meaning the first point is start and the last is end (unless cnt is 1). If cnt is 1, it returns a single value which is the midpoint (start + end) / 2 of the range. Returns a sequence of cnt double values.

Generates `cnt` evenly spaced points within a numerical range.

- `(slice-range cnt)`: Generates `cnt` points in the range `[0.0, 1.0]`.
- `(slice-range data cnt)`: Generates `cnt` points in the range `[(min data), (max data)]`.
- `(slice-range start end cnt)`: Generates `cnt` points in the range `[start, end]`.

The range is inclusive, meaning the first point is `start` and the last is `end` (unless `cnt` is 1).
If `cnt` is 1, it returns a single value which is the midpoint `(start + end) / 2` of the range.
Returns a sequence of `cnt` double values.
sourceraw docstring

smooth-interpolationclj

(smooth-interpolation start stop t)

Smoothstep based interpolation. See also lerp/mlerp, quad-interpolation or cos-interpolation.

Smoothstep based interpolation. See also [[lerp]]/[[mlerp]], [[quad-interpolation]] or [[cos-interpolation]].
sourceraw docstring

smooth-maxclj

(smooth-max xs)
(smooth-max xs alpha)
(smooth-max xs alpha family)

Smooth maximum function.

A smooth function with alpha argument. When alpha goes to infinity, function returns maximum value of xs.

Family:

  • :lse - LogSumExp (default)
  • :boltzmann - Boltzmann operator, works for small alpha values
  • :mellowmax
  • :p-norm
  • :smu - smooth maximum unit, epsilon = 1/alpha > 0
Smooth maximum function.

A smooth function with `alpha` argument. When `alpha` goes to infinity, function returns maximum value of `xs`.

Family:

* `:lse` - LogSumExp (default)
* `:boltzmann` - Boltzmann operator, works for small alpha values
* `:mellowmax`
* `:p-norm`
* `:smu` - smooth maximum unit, epsilon = 1/alpha > 0
sourceraw docstring

smoothstepclj

(smoothstep edge0 edge1 x)
GL [smoothstep](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/smoothstep.xhtml).
sourceraw docstring

spowclj

(spow x exponent)

Symmetric power of a number (keeping a sign of the argument.

Symmetric power of a number (keeping a sign of the argument.
sourceraw docstring

sqclj

(sq x)

x^2, x*x

x^2, x*x
sourceraw docstring

sqrtclj

(sqrt x)

square root, sqrt(x)

square root, sqrt(x)
sourceraw docstring

SQRT2clj

Value of $\sqrt{2}$

Value of $\sqrt{2}$
sourceraw docstring

SQRT2_2clj

Value of $\frac{\sqrt{2}}{2}$

Value of $\frac{\sqrt{2}}{2}$
sourceraw docstring

SQRT2PIclj

Value of $\sqrt{2\pi}$

Value of $\sqrt{2\pi}$
sourceraw docstring

SQRT3clj

Value of $\sqrt{3}$

Value of $\sqrt{3}$
sourceraw docstring

SQRT3_2clj

Value of $\frac{\sqrt{3}}{2}$

Value of $\frac{\sqrt{3}}{2}$
sourceraw docstring

SQRT3_3clj

Value of $\frac{\sqrt{3}}{3}$

Value of $\frac{\sqrt{3}}{3}$
sourceraw docstring

SQRT3_4clj

Value of $\frac{\sqrt{3}}{4}$

Value of $\frac{\sqrt{3}}{4}$
sourceraw docstring

SQRT5clj

Value of $\sqrt{5}$

Value of $\sqrt{5}$
sourceraw docstring

SQRT_2_PIclj

Value of $\sqrt{\frac{2}{\pi}}$

Value of $\sqrt{\frac{2}{\pi}}$
sourceraw docstring

SQRT_HALFPIclj

Value of $\sqrt{\frac{1}{2}\pi}$

Value of $\sqrt{\frac{1}{2}\pi}$
sourceraw docstring

SQRTPIclj

Value of $\sqrt{\pi}$

Value of $\sqrt{\pi}$
sourceraw docstring

sum-of-productsclj

(sum-of-products a b c d)

Kahan's algorithm for (ab)+(cd) to avoid catastrophic cancellation.

Kahan's algorithm for (a*b)+(c*d) to avoid catastrophic cancellation.
sourceraw docstring

tanclj

(tan x)

tan(x)

tan(x)
sourceraw docstring

tanhclj

(tanh x)

tanh(x)

tanh(x)
sourceraw docstring

tanpiclj

(tanpi x)

tan(pi*x)

tan(pi*x)
sourceraw docstring

TAUclj

Value of $2\pi$

Value of $2\pi$
sourceraw docstring

THIRDclj

Value of $\frac{1}{3}$

Value of $\frac{1}{3}$
sourceraw docstring

THIRD_PIclj

Value of $\frac{\pi}{3}$

Value of $\frac{\pi}{3}$
sourceraw docstring

tpowclj

(tpow x exponent)
(tpow x exponent shift)

Calculates truncated power.

For x >= shift returns (x-shift)^exponent, 0.0 otherwise.

Calculates truncated power.

For x >= shift returns (x-shift)^exponent, 0.0 otherwise.
sourceraw docstring

truncclj

(trunc v)

Truncate fractional part, keep sign. Returns double.

Truncate fractional part, keep sign. Returns `double`.
sourceraw docstring

TWO_INV_PIclj

Value of $\frac{2}{\pi}$

Value of $\frac{2}{\pi}$
sourceraw docstring

TWO_PIclj

Value of $2\pi$

Value of $2\pi$
sourceraw docstring

TWO_THIRDclj

Value of $\frac{2}{3}$

Value of $\frac{2}{3}$
sourceraw docstring

TWO_THIRDSclj

Value of $\frac{2}{3}$

Value of $\frac{2}{3}$
sourceraw docstring

ulpclj

(ulp x)

Unit in the Last Place, distance between next value larger than x and x

Unit in the Last Place, distance between next value larger than `x` and `x`
sourceraw docstring

unsigned-bit-shift-rightclj

(unsigned-bit-shift-right x shift)

Shift bits right and set most significant bit to 0

Shift bits right and set most significant bit to `0`
sourceraw docstring

unuse-primitive-operatorsclj

(unuse-primitive-operators)
(unuse-primitive-operators skip-set)

Undoes the work of use-primitive-operators. This is idempotent.

Undoes the work of [[use-primitive-operators]]. This is idempotent.
sourceraw docstring

use-primitive-operatorsclj

(use-primitive-operators)
(use-primitive-operators skip-set)

Replaces Clojure's arithmetic and number coercion functions with primitive equivalents. These are defined as macros, so they cannot be used as higher-order functions. This is an idempotent operation. Undo with unuse-primitive-operators.

Replaces Clojure's arithmetic and number coercion functions with primitive equivalents.  These are
defined as macros, so they cannot be used as higher-order functions. This is an idempotent operation. Undo with [[unuse-primitive-operators]].
sourceraw docstring

valid-double?clj

(valid-double? v)

Check if a number is finite double.

Check if a number is finite double.
sourceraw docstring

vercosclj

(vercos x)

Vercosine

Vercosine
sourceraw docstring

versinclj

(versin x)

Versine

Versine
sourceraw docstring

wrapclj

(wrap [start stop] value)
(wrap start stop value)

Wrap overflowed value into the range, similar to ofWrap.

Wrap overflowed value into the range, similar to [ofWrap](http://openframeworks.cc/documentation/math/ofMath/#!show_ofWrap).
sourceraw docstring

xexpxclj

(xexpx x)

x * exp(x)

x * exp(x)
sourceraw docstring

xexpyclj

(xexpy x y)

x * exp(x)

x * exp(x)
sourceraw docstring

xlog1pyclj

(xlog1py x y)

x * log(1+y)

x * log(1+y)
sourceraw docstring

xlogxclj

(xlogx x)

x * log(x)

x * log(x)
sourceraw docstring

xlogyclj

(xlogy x y)

x * log(y)

x * log(y)
sourceraw docstring

xorclj

(xor x y)
(xor x y & r)

Primitive boolean xor

Primitive boolean xor
sourceraw docstring

zero?clj

(zero? x)

Primitive and inlined zero?

Primitive and inlined `zero?`
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close