/usr/share/genius/gel/functions/numerical.gel is in genius-common 1.0.23-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Numerical functions
#FIXME: these need to be cleaned up!
#Indeed, some of these should probably be built-in
#just for somewhat of "source compatibility"
SetHelp ("AbsoluteValue", "numeric", "Absolute value");
function AbsoluteValue (x) = |x|
SetHelpAlias ("AbsoluteValue", "abs")
abs = AbsoluteValue
SetHelp("Sign","numeric","Return the sign (-1,0,1)");
function Sign (x) = (
if IsMatrix (x) then
return ApplyOverMatrix (x, Sign)
else if not IsValue (x) then
(error("Sign: argument not a value");bailout);
if IsComplex (x) then (
x / |x|
) else if x > 0 then (
1
) else if x < 0 then (
-1
) else 0
);
SetHelpAlias ("Sign", "sign")
sign = Sign
#-----
SetHelp ("FractionalPart", "numeric", "Return the fractional part of a number")
function FractionalPart(x) =
(
if not IsValue(x) then
(error("FractionalPart: argument not a value");bailout)
else
x - IntegerPart (x)
)
# Chop replaces very small number with zero
parameter ChopTolerance = 10.0^(-10);
SetHelp ("ChopTolerance", "parameters", "Tolerance of the Chop function")
SetHelp ("Chop", "numeric", "Replace very small number with zero")
function Chop(x) =
(
if not IsValue(x) then
(error("Chop: argument not a value");bailout)
else if |x| < ChopTolerance then
0
else
x
)
#-----
# Mod (built-in)
# FIXME: Mod with offset (m mod n offset d = something in [d,d+n-1])
# IntergerQuotient w/offset (such that d <= m-r*n < d+n
# IntegerDigits = (convert interger to its list of digits, base b, of length len)
# IntegerExponent = (number of trailing zeros in base b expansion = heighest power
# of b that divides n)
|