auto-opti.maths

Implements all mathematical basics functions compatible both with clj and cljs compiler and aiming at return the same results.

abs

(abs x)

Absolute value of x.

abs-double

(abs-double x)

Absolute value of x, optimized for x∊ℝ.

abs-int

(abs-int x)

Absolute value of x, optimized for x∊ℕ.

approx=

(approx= e x y)

Returns true for an approximate numerical equality.

atan

(atan x)

Returns the arctangeant of x, where x as a multiple of PI.

ceil

(ceil x)

Returns the ceiling of x (the upper rounded value).

clamp

(clamp lower upper x)

Returns the clamped value between lower and upper.

clamp-double

(clamp-double lower upper x)

Returns the clamped value between lower and upper, where x∊ℝ.

clamp-integer

(clamp-integer lower upper x)

Returns the clamped value between lower and upper, where (x,n)∊ℕ².

cos

(cos x)

Returns the cosinus of x, where x is a multiple of PI.

D-0x1p-53

exp

(exp x)

Returns the exponential of x, where x∊ℝ.

floor

(floor x)

Returns the floor of x (the lower rounded value).

HALF_LOG_2_PI

Half of log of twice PI

HALF_PI

Half PI

infinite?

(infinite? x)

Returns true if x is infinite.

infinity

Returns infinite for reals.

infinity-integer

Returns infinite for integer.

infinity-long

Returns infinite for integer.

interop-max-integer

Returns same int value that’s highest possible and equal for both clj and cljs. For refernce look at Integer/MAX_VALUE clojure interop documentation

interop-min-integer

same as interop-max-integer but for smallest

interval-affine-fn

(interval-affine-fn a b x1 x2 x)

Returns an affine function with coefficient a and b, defined in [x1; x2[.

If * x1 if not a number (typically nil), is interprated like an interval starting at -infinite * x2 if not a number (typically nil), is interprated like a non ending interval (infinite)

LANCZOS_G

The Lanczos constant.

log

(log x)

Returns the neperian logarithm of x, where x∊ℝ.

log1p

(log1p x)

Returns (ln 1+x) the natural logarithm of 1+x, where x∊ℝ.

long->unit-double

(long->unit-double l)

Returns a unit float (a floating number between 0 and 1), based on the value of l.

max

Like clojure.core/max, but transducer and nil-friendly.

max-double

Like clojure.core/max, but transducer and nil-friendly.

max-long

Like clojure.core/max, but transducer and nil-friendly.

min

Like clojure.core/min, but transducer and nil-friendly.

min-double

Like clojure.core/min, but transducer and nil-friendly.

min-long

Like clojure.core/min, but transducer and nil-friendly.

mod

(mod n d)

Returns the modulus of dividing numerator n by denominator d.

nan

Returns nan.

negative-infinity

Returns minus infinite for reals.

negative-infinity-integer

Returns minus infinite for integer.

negative-infinity-long

Returns minus infinite for integer.

PI

Value of PI based on platform constant value

According to maths.com, the first values are: 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989

polynomial-value

(polynomial-value x coefficients)

Evaluates a polynomial at the given value x, for the coefficients given in descending order (so the last element of coefficients is the constant term).

pow

(pow x n)

Power n of x, where (x,n)∊ℝ².

proportion

(proportion f coll)

Calculates the proportion of inputs for which pred returns true.

root

(root x n)

Return the n root of x, where (x,n)∊ℝ².

signum

(signum x)

Returns the sign of x for double and float numbers.

sin

(sin x)

Returns the sinus of x, where x as a multiple of PI.

sqrt

(sqrt x)

Square root of x, where x∊[0;+∞[.

SQRT_2_PI

Square root of twice pi.

square

(square x)

Square of x.

square-double

(square-double x)

Square of x, optimized for x as a double.

square-int

(square-int x)

Square of x, optimized for x as an integer.

tan

(tan x)

Returns the tangeant of x, where x as a multiple of PI.