Collection of fast math functions and plethora of constants known from other math libraries.
Based on Primitive Math by Zach Tellman several operators are introduced and replace clojure.core
functions. All operators are macros and can't be used as functions. List includes:
Known from Clojure: *
+
-
/
>
<
>=
<=
==
rem
quot
mod
bit-or
bit-and
bit-xor
bit-and-not
bit-set
bit-clear
bit-test
bit-flip
bit-not
bit-shift-left
bit-shift-right
unsigned-bit-shift-right
inc
dec
zero?
neg?
pos?
min
max
even?
odd?
abs
And additionally:
<<
- bit shift left>>
- signed bit shift right>>>
- unsigned bit shift rightnot==
- not equalWarning: All bool-
evaluate all parameters.
To turn on primitive math on your namespace call use-primitive-operators
.
To turn off and revert original versions call unuse-primitive-operators
Almost all math functions are backed by FastMath library. Most of them are macros. Some of them are wrapped in Clojure functions. Almost all operates on primitive double
and returns double
(with an exception round
or qround
which returns long
).
Additionally namespace contains functions which are common in frameworks like OpenFrameworks and Processing.
Collection of fast math functions and plethora of constants known from other math libraries. ### Primitive math operators Based on [Primitive Math by Zach Tellman](https://github.com/ztellman/primitive-math) several operators are introduced and replace `clojure.core` functions. All operators are macros and can't be used as functions. List includes: Known from Clojure: `*` `+` `-` `/` `>` `<` `>=` `<=` `==` `rem` `quot` `mod` `bit-or` `bit-and` `bit-xor` `bit-and-not` `bit-set` `bit-clear` `bit-test` `bit-flip` `bit-not` `bit-shift-left` `bit-shift-right` `unsigned-bit-shift-right` `inc` `dec` `zero?` `neg?` `pos?` `min` `max` `even?` `odd?` `abs` And additionally: * `<<` - bit shift left * `>>` - signed bit shift right * `>>>` - unsigned bit shift right * `not==` - not equal Warning: All `bool-` evaluate all parameters. To turn on primitive math on your namespace call [[use-primitive-operators]]. To turn off and revert original versions call [[unuse-primitive-operators]] ### Fast Math Almost all math functions are backed by [FastMath](https://github.com/jeffhain/jafama) library. Most of them are macros. Some of them are wrapped in Clojure functions. Almost all operates on primitive `double` and returns `double` (with an exception [[round]] or [[qround]] which returns `long`). ### Other functions Additionally namespace contains functions which are common in frameworks like OpenFrameworks and Processing.
(* x)
(* x y)
(* x y & rest)
A primitive math version of *
A primitive math version of `*`
(+ x)
(+ x y)
(+ x y & rest)
A primitive math version of +
A primitive math version of `+`
(- x)
(- x y)
(- x y & rest)
A primitive math version of -
A primitive math version of `-`
(/ x)
(/ x y)
(/ x y & rest)
A primitive math version of /
A primitive math version of `/`
(< x)
(< x y)
(< x y & rest)
A primitive math version of <
A primitive math version of `<`
(<< x y)
fastmath.java.PrimitiveMath/shiftLeft function wrapped in macro.
fastmath.java.PrimitiveMath/shiftLeft function wrapped in macro.
(<= x)
(<= x y)
(<= x y & rest)
A primitive math version of <=
A primitive math version of `<=`
(== x)
(== x y)
(== x y & rest)
Equality. See also eq
for function version.
Equality. See also [[eq]] for function version.
(> x)
(> x y)
(> x y & rest)
A primitive math version of >
A primitive math version of `>`
(>= x)
(>= x y)
(>= x y & rest)
A primitive math version of >=
A primitive math version of `>=`
(>> x y)
fastmath.java.PrimitiveMath/shiftRight function wrapped in macro.
fastmath.java.PrimitiveMath/shiftRight function wrapped in macro.
(>>> x y)
fastmath.java.PrimitiveMath/unsignedShiftRight function wrapped in macro.
fastmath.java.PrimitiveMath/unsignedShiftRight function wrapped in macro.
(abs x)
\(|x|\) - double
version. See iabs
.
\\(|x|\\) - `double` version. See [[iabs]].
(acos x)
net.jafama.FastMath/acos function wrapped in macro.
net.jafama.FastMath/acos function wrapped in macro.
(acosh x)
net.jafama.FastMath/acosh function wrapped in macro.
net.jafama.FastMath/acosh function wrapped in macro.
(approx v)
(approx v digits)
Round v
to specified (default: 2) decimal places. Be aware of double
number accuracy.
Round `v` to specified (default: 2) decimal places. Be aware of `double` number accuracy.
(approx-eq a b)
(approx-eq a b digits)
Checks equality approximately. See approx
.
Checks equality approximately. See [[approx]].
(asin x)
net.jafama.FastMath/asin function wrapped in macro.
net.jafama.FastMath/asin function wrapped in macro.
(asinh x)
net.jafama.FastMath/asinh function wrapped in macro.
net.jafama.FastMath/asinh function wrapped in macro.
(atan x)
net.jafama.FastMath/atan function wrapped in macro.
net.jafama.FastMath/atan function wrapped in macro.
(atan2 x y)
net.jafama.FastMath/atan2 function wrapped in macro.
net.jafama.FastMath/atan2 function wrapped in macro.
(atanh x)
net.jafama.FastMath/atanh function wrapped in macro.
net.jafama.FastMath/atanh function wrapped in macro.
(bessel-j x y)
Bessel J function value for given order and argument.
Bessel J function value for given order and argument.
(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].
(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].
(bit-and x)
(bit-and x y)
(bit-and x y & rest)
A primitive math version of bit-and
A primitive math version of `bit-and`
(bit-and-not x)
(bit-and-not x y)
(bit-and-not x y & rest)
A primitive math version of bit-and-not
A primitive math version of `bit-and-not`
(bit-clear x y)
fastmath.java.PrimitiveMath/bitClear function wrapped in macro.
fastmath.java.PrimitiveMath/bitClear function wrapped in macro.
(bit-flip x y)
fastmath.java.PrimitiveMath/bitFlip function wrapped in macro.
fastmath.java.PrimitiveMath/bitFlip function wrapped in macro.
(bit-nand x)
(bit-nand x y)
(bit-nand x y & rest)
A primitive math version of bit-nand
A primitive math version of `bit-nand`
(bit-nor x)
(bit-nor x y)
(bit-nor x y & rest)
A primitive math version of bit-nor
A primitive math version of `bit-nor`
(bit-not x)
fastmath.java.PrimitiveMath/bitNot function wrapped in macro.
fastmath.java.PrimitiveMath/bitNot function wrapped in macro.
(bit-or x)
(bit-or x y)
(bit-or x y & rest)
A primitive math version of bit-or
A primitive math version of `bit-or`
(bit-set x y)
fastmath.java.PrimitiveMath/bitSet function wrapped in macro.
fastmath.java.PrimitiveMath/bitSet function wrapped in macro.
(bit-shift-left x y)
fastmath.java.PrimitiveMath/shiftLeft function wrapped in macro.
fastmath.java.PrimitiveMath/shiftLeft function wrapped in macro.
(bit-shift-right x y)
fastmath.java.PrimitiveMath/shiftRight function wrapped in macro.
fastmath.java.PrimitiveMath/shiftRight function wrapped in macro.
(bit-test x y)
fastmath.java.PrimitiveMath/bitTest function wrapped in macro.
fastmath.java.PrimitiveMath/bitTest function wrapped in macro.
(bit-xor x)
(bit-xor x y)
(bit-xor x y & rest)
A primitive math version of bit-xor
A primitive math version of `bit-xor`
(bits->double v)
Convert 64 bits to double
Convert 64 bits to double
(bool-and x)
(bool-and x y)
(bool-and x y & rest)
A primitive math version of bool-and
A primitive math version of `bool-and`
(bool-not x)
fastmath.java.PrimitiveMath/not function wrapped in macro.
fastmath.java.PrimitiveMath/not function wrapped in macro.
(bool-or x)
(bool-or x y)
(bool-or x y & rest)
A primitive math version of bool-or
A primitive math version of `bool-or`
(bool-xor x)
(bool-xor x y)
(bool-xor x y & rest)
A primitive math version of bool-xor
A primitive math version of `bool-xor`
(ceil x)
(ceil x scale)
\(\lceil x \rceil\). See: qceil
.
Rounding is done to a multiply of scale value (when provided).
\\(\lceil x \rceil\\). See: [[qceil]]. Rounding is done to a multiply of scale value (when provided).
(Ci x)
Negative of integral of cos(t)/t from x to inf
Negative of integral of cos(t)/t from x to inf
(co-intervals data)
(co-intervals data number)
(co-intervals data number overlap)
Divide sequence to overlaping intervals containing similar number of values. Same as R's co.intervals()
Divide sequence to overlaping intervals containing similar number of values. Same as R's `co.intervals()`
(combinations n k)
Binomial coefficient (n choose k)
Binomial coefficient (n choose k)
(constrain value mn mx)
Clamp value
to the range [mn,mx]
.
Clamp `value` to the range `[mn,mx]`.
(copy-sign x y)
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.
(cos x)
net.jafama.FastMath/cos function wrapped in macro.
net.jafama.FastMath/cos function wrapped in macro.
(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]].
(cosh x)
net.jafama.FastMath/cosh function wrapped in macro.
net.jafama.FastMath/cosh function wrapped in macro.
(cut data breaks)
(cut x1 x2 breaks)
Cut range or sequence into intervals
Cut range or sequence into intervals
(dec x)
fastmath.java.PrimitiveMath/dec function wrapped in macro.
fastmath.java.PrimitiveMath/dec function wrapped in macro.
(degrees rad)
Convert radians into degrees.
Convert radians into degrees.
(delta-eq a b)
(delta-eq a b accuracy)
(delta-eq a b abs-tol rel-tol)
Checks equality for given absolute accuracy (default 1.0e-6
).
Version with 4-arity accepts absolute and relative accuracy.
Checks equality for given absolute accuracy (default `1.0e-6`). Version with 4-arity accepts absolute and relative accuracy.
(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.
(digamma x)
Logarithmic derivative of \(\Gamma\).
Logarithmic derivative of \\(\Gamma\\).
(dist [x1 y1] [x2 y2])
(dist x1 y1 x2 y2)
Euclidean distance between points (x1,y1)
and (x2,y2)
. See fastmath.vector
namespace to see other metrics which work on vectors.
Euclidean distance between points `(x1,y1)` and `(x2,y2)`. See [[fastmath.vector]] namespace to see other metrics which work on vectors.
Convert double array into sequence.
Alias for seq
.
Convert double array into sequence. Alias for `seq`.
(double-bits v)
Returns double as 64-bits (long)
Returns double as 64-bits (long)
(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.
(double-exponent v)
Extract exponent information from double
Extract exponent information from double
(double-high-bits v)
Returns high word from double as bits
Returns high word from double as bits
(double-low-bits v)
Returns low word from double as bits
Returns low word from double as bits
Value of 0x1.fffffffffffffp-1d = 0.(9)
Value of 0x1.fffffffffffffp-1d = 0.(9)
(double-significand v)
Extract significand from double
Extract significand from double
(eq _)
(eq a b)
(eq a b c)
(eq a b c d)
Primitive math equality function for doubles. See ==
.
Primitive math equality function for doubles. See [[==]].
(erf x)
(erf x y)
Error function. For two arguments return difference between (erf x)
and (erf y)
.
Error function. For two arguments return difference between `(erf x)` and `(erf y)`.
(even? x)
fastmath.java.PrimitiveMath/isEven function wrapped in macro.
fastmath.java.PrimitiveMath/isEven function wrapped in macro.
(exp x)
net.jafama.FastMath/exp function wrapped in macro.
net.jafama.FastMath/exp function wrapped in macro.
(expm1 x)
net.jafama.FastMath/expm1 function wrapped in macro.
net.jafama.FastMath/expm1 function wrapped in macro.
(factorial20 n)
Factorial table up to 20!
Factorial table up to 20!
(fast* a b)
Primitive *
for two doubles as function.
Primitive `*` for two doubles as function.
(fast+ a b)
Primitive +
for two doubles as function.
Primitive `+` for two doubles as function.
(fast- a b)
Primitive -
for two doubles as function.
Primitive `-` for two doubles as function.
(fast-max a b)
Primitive max
for two doubles as function.
Primitive `max` for two doubles as function.
(fast-min a b)
Primitive min
for two doubles as function
Primitive `min` for two doubles as function
(floor x)
(floor x scale)
\(\lfloor x \rfloor\). See: qfloor
.
Rounding is done to a multiply of scale value (when provided).
\\(\lfloor x \rfloor\\). See: [[qfloor]]. Rounding is done to a multiply of scale value (when provided).
(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+
(fpow x y)
Fast version of pow where exponent is integer.
Fast version of pow where exponent is integer.
(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.
(gamma x)
Gamma function \(\Gamma(x)\)
Gamma function \\(\Gamma(x)\\)
(gcd a b)
Fast binary greatest common divisor (Stein's algorithm)
Fast binary greatest common divisor (Stein's algorithm)
(group-by-intervals coll)
(group-by-intervals intervals coll)
Group sequence of values into given intervals.
If intervals
are missing, use co-intervals
to find some.
Group sequence of values into given intervals. If `intervals` are missing, use [[co-intervals]] to find some.
(haversin v)
(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.
(haversine-dist [lat1 lon1] [lat2 lon2])
(haversine-dist lat1 lon1 lat2 lon2)
Haversine distance d
for r=1
Haversine distance `d` for `r=1`
(high-2-exp v)
Find lowest exponent (power of 2) which is greater or equal x
. See low-2-exp
.
Find lowest exponent (power of 2) which is greater or equal `x`. See [[low-2-exp]].
(high-exp b x)
Find lowest exponent for base b
which is higher or equalx
. See also low-exp
.
Find lowest exponent for base `b` which is higher or equal`x`. See also [[low-exp]].
(hypot-sqrt x y)
(hypot-sqrt x y z)
Hypot, sqrt version: \(\sqrt{x^2+y^2}\) or \(\sqrt{x^2+y^2+z^2}\).
Should be faster than hypot
.
Hypot, sqrt version: \\(\sqrt{x^2+y^2}\\) or \\(\sqrt{x^2+y^2+z^2}\\). Should be faster than [[hypot]].
(I0 x)
Modified Bessel function of the first kind, order 0.
Modified Bessel function of the first kind, order 0.
(iabs x)
\(|x|\) - long
version. See abs
.
\\(|x|\\) - `long` version. See [[abs]].
(inc x)
fastmath.java.PrimitiveMath/inc function wrapped in macro.
fastmath.java.PrimitiveMath/inc function wrapped in macro.
(inv-factorial n)
Inverse of factorial, 1/n!
Inverse of factorial, 1/n!
(inv-gamma-1pm1 x)
\(\frac{1}{\Gamma(1+x)}-1\).
\\(\frac{1}{\Gamma(1+x)}-1\\).
(invalid-double? v)
Check if number is invalid
Check if number is invalid
(itrunc v)
Truncate fractional part, keep sign. Returns long
.
Truncate fractional part, keep sign. Returns `long`.
(lcm a b)
Fast binary least common multiplier.
Fast binary least common multiplier.
(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]].
(ln x)
net.jafama.FastMath/log function wrapped in macro.
net.jafama.FastMath/log function wrapped in macro.
(log x)
net.jafama.FastMath/log function wrapped in macro.
net.jafama.FastMath/log function wrapped in macro.
(log-beta x y)
Logarithm of Beta function.
Logarithm of Beta function.
(log-combinations n k)
Log of binomial coefficient (n choose k)
Log of binomial coefficient (n choose k)
(log-factorial x)
Log factorial, alias to log-gamma
Log factorial, alias to log-gamma
(log-gamma x)
Log of Gamma function \(\ln\Gamma(x)\)
Log of Gamma function \\(\ln\Gamma(x)\\)
(log-gamma-1p x)
Log of Gamma function \(\ln\Gamma(1+x)\)
Log of Gamma function \\(\ln\Gamma(1+x)\\)
(log1p x)
net.jafama.FastMath/log1p function wrapped in macro.
net.jafama.FastMath/log1p function wrapped in macro.
(log2 x)
Logarithm with base 2.
\(\ln_2{x}\)
Logarithm with base 2. \\(\ln_2{x}\\)
(log2int v)
Fast and integer version of log2, returns long
Fast and integer version of log2, returns long
(logb b x)
Logarithm with base b
.
\(\ln_b{x}\)
Logarithm with base `b`. \\(\ln_b{x}\\)
(low-2-exp x)
Find greatest exponent (power of 2) which is lower or equal x
. See high-2-exp
.
Find greatest exponent (power of 2) which is lower or equal `x`. See [[high-2-exp]].
(low-exp b x)
Find greatest exponent for base b
which is lower or equal x
. See also high-exp
.
Find greatest exponent for base `b` which is lower or equal `x`. See also [[high-exp]].
Smallest machine number. Value is calculated during evaluation and may differ on different processors.
Smallest machine number. Value is calculated during evaluation and may differ on different processors.
(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`.
(makepoly coeffs)
Create polynomial function for given coefficients
Create polynomial function for given coefficients
(max x)
(max x y)
(max x y & rest)
A primitive math version of max
A primitive math version of `max`
(mevalpoly x & coeffs)
Evaluate polynomial macro version in the form coeffs[0]+coeffs[1]*x+coeffs[2]*x^2+....
Evaluate polynomial macro version in the form coeffs[0]+coeffs[1]*x+coeffs[2]*x^2+....
(min x)
(min x y)
(min x y & rest)
A primitive math version of min
A primitive math version of `min`
(minkowski x)
Minkowski's question mark function ?(x)
Minkowski's question mark function ?(x)
(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]].
(mnorm v start stop)
(mnorm v start1 stop1 start2 stop2)
Macro version of norm
.
Macro version of [[norm]].
(mod x y)
fastmath.java.PrimitiveMath/modulus function wrapped in macro.
fastmath.java.PrimitiveMath/modulus function wrapped in macro.
(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+
(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.
(neg-inf? v)
Check if number is negatively infinite
Check if number is negatively infinite
(neg? x)
fastmath.java.PrimitiveMath/isNeg function wrapped in macro.
fastmath.java.PrimitiveMath/isNeg function wrapped in macro.
(negative-zero? x)
Check if zero is negative, ie. -0.0
Check if zero is negative, ie. -0.0
(negmuladd x y z)
[x y z]
-> (+ z (* -1.0 x y)
`[x y z]` -> `(+ z (* -1.0 x y)`
(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.
(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]].
(not-neg? x)
fastmath.java.PrimitiveMath/isNNeg function wrapped in macro.
fastmath.java.PrimitiveMath/isNNeg function wrapped in macro.
(not-pos? x)
fastmath.java.PrimitiveMath/isNPos function wrapped in macro.
fastmath.java.PrimitiveMath/isNPos function wrapped in macro.
(not== x)
(not== x y)
(not== x y & rest)
A primitive math version of not==
A primitive math version of `not==`
(odd? x)
fastmath.java.PrimitiveMath/isOdd function wrapped in macro.
fastmath.java.PrimitiveMath/isOdd function wrapped in macro.
(one? x)
fastmath.java.PrimitiveMath/isOne function wrapped in macro.
fastmath.java.PrimitiveMath/isOne function wrapped in macro.
(order vs)
(order vs decreasing?)
Ordering permutation. See R docs
Order uses 0 based indexing.
Ordering permutation. See [R docs](https://www.rdocumentation.org/packages/base/versions/3.6.1/topics/order) Order uses 0 based indexing.
(pos-inf? v)
Check if number is positively infinite
Check if number is positively infinite
(pos? x)
fastmath.java.PrimitiveMath/isPos function wrapped in macro.
fastmath.java.PrimitiveMath/isPos function wrapped in macro.
(pow x y)
net.jafama.FastMath/pow function wrapped in macro.
net.jafama.FastMath/pow function wrapped in macro.
(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.
(qexp x)
Quick and less accurate version of exp
.
Quick and less accurate version of [[exp]].
(qlog x)
Fast and less accurate version of log
.
Fast and less accurate version of [[log]].
(qpow x y)
Fast and less accurate version of pow
.
Fast and less accurate version of [[pow]].
(qsqrt x)
Approximated sqrt
using binary operations with error 1.0E-2
.
Approximated [[sqrt]] using binary operations with error `1.0E-2`.
(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]].
(quot x y)
fastmath.java.PrimitiveMath/quotient function wrapped in macro.
fastmath.java.PrimitiveMath/quotient function wrapped in macro.
(radians deg)
Convert degrees into radians.
Convert degrees into radians.
(rank vs)
(rank vs ties)
(rank vs ties desc?)
Sample ranks. See R docs.
Rank uses 0 based indexing.
Possible tie strategies: :average
, :first
, :last
, :random
, :min
, :max
, :dense
.
:dense
is the same as in data.table::frank
from R
Sample ranks. See [R docs](https://www.rdocumentation.org/packages/base/versions/3.6.1/topics/rank). Rank uses 0 based indexing. Possible tie strategies: `:average`, `:first`, `:last`, `:random`, `:min`, `:max`, `:dense`. `:dense` is the same as in `data.table::frank` from R
(regularized-beta x y z)
Regularized Beta
.
Regularized `Beta`.
(regularized-gamma-p x y)
Regularized gamma
P
Regularized `gamma` P
(regularized-gamma-q x y)
Regularized gamma
Q
Regularized `gamma` Q
(rem x y)
fastmath.java.PrimitiveMath/remainder function wrapped in macro.
fastmath.java.PrimitiveMath/remainder function wrapped in macro.
(remainder x y)
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]`
(round-even x)
Round evenly (like in round in R), IEEE / IEC rounding
Round evenly (like in round in R), IEEE / IEC rounding
(round-up-pow2 v)
Round long to the next power of 2
Round long to the next power of 2
(rqsqrt x)
Inversed version of qsqrt
. Quick and less accurate.
Inversed version of [[qsqrt]]. Quick and less accurate.
(safe-sqrt value)
Safe sqrt, for value <= 0 result is 0.
\( \left\{ \begin{array}{lr} 0 & : x \leq 0\\ \sqrt{x} & : x > 0 \end{array} \right. \)
Safe sqrt, for value <= 0 result is 0. \\( \left\\{ \begin{array}{lr} 0 & : x \leq 0\\\\ \sqrt{x} & : x > 0 \end{array} \\right. \\)
(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?)
Sample function f
and return sequence of values.
range-min
defaults to 0.0, range-max
to 1.0.
Range is inclusive.
When optional domain?
is set to true (default: false) function returns pairs [x,(f x)]
.
Sample function `f` and return sequence of values. `range-min` defaults to 0.0, `range-max` to 1.0. Range is inclusive. When optional `domain?` is set to true (default: false) function returns pairs `[x,(f x)]`.
(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.
(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`
(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.
(sgn value)
Return -1 when value
is negative, 1 otherwise. See also signum
.
\( \left\{ \begin{array}{lr} 1.0 & : x \geq 0\\ -1.0 & : x < 0\\ \end{array} \right. \)
Return -1 when `value` is negative, 1 otherwise. See also [[signum]]. \\( \left\\{ \begin{array}{lr} 1.0 & : x \geq 0\\\\ -1.0 & : x < 0\\\\ \end{array} \\right. \\)
(signum value)
Return 1 if value
is > 0, 0 if it is 0, -1 otherwise. See also sgn
.
\( \left\{ \begin{array}{lr} 1.0 & : x > 0\\ -1.0 & : x < 0\\ 0.0 & : x = 0 \end{array} \right. \)
Return 1 if `value` is > 0, 0 if it is 0, -1 otherwise. See also [[sgn]]. \\( \left\\{ \begin{array}{lr} 1.0 & : x > 0\\\\ -1.0 & : x < 0\\\\ 0.0 & : x = 0 \end{array} \\right. \\)
(sin x)
net.jafama.FastMath/sin function wrapped in macro.
net.jafama.FastMath/sin function wrapped in macro.
(sinh x)
net.jafama.FastMath/sinh function wrapped in macro.
net.jafama.FastMath/sinh function wrapped in macro.
(slice-range cnt)
(slice-range start end cnt)
Slice range to get cnt
number of points evenly distanced.
Slice range to get `cnt` number of points evenly distanced.
(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]].
(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 > 0Smooth 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
(smoothstep edge0 edge1 x)
GL smoothstep.
GL [smoothstep](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/smoothstep.xhtml).
(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.
(tan x)
net.jafama.FastMath/tan function wrapped in macro.
net.jafama.FastMath/tan function wrapped in macro.
(tanh x)
net.jafama.FastMath/tanh function wrapped in macro.
net.jafama.FastMath/tanh function wrapped in macro.
(trunc v)
Truncate fractional part, keep sign. Returns double
.
Truncate fractional part, keep sign. Returns `double`.
(ulp v)
Unit in the Last Place, distance between next value larger than v
and v
Unit in the Last Place, distance between next value larger than `v` and `v`
(unsigned-bit-shift-right x y)
fastmath.java.PrimitiveMath/unsignedShiftRight function wrapped in macro.
fastmath.java.PrimitiveMath/unsignedShiftRight function wrapped in macro.
(unuse-primitive-operators)
Undoes the work of use-primitive-operators
. This is idempotent.
Undoes the work of [[use-primitive-operators]]. This is idempotent.
(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]].
(valid-double? v)
Check if number is invalid
Check if number is invalid
(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).
(zero? x)
fastmath.java.PrimitiveMath/isZero function wrapped in macro.
fastmath.java.PrimitiveMath/isZero function wrapped in macro.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close