Description

Provides:

Author

John Cowan and Kon Lovett

Usage

(require-extension mathh)

Download

mathh.egg

Documentation

Floating-point Functions

The following procedures are provided, with their usual meaning.

Windows does not provide native implementations of log1p, lgamma, tgamma. However log1p is approximated.

The Bessel functions are prefixed by 'bessel-' to distinguish the names from common variables.

procedure: (bessel-j0 N)
procedure: (bessel-j1 N)
procedure: (bessel-jn O N)
procedure: (bessel-y0 N)
procedure: (bessel-y1 N)
procedure: (bessel-yn O N)
procedure: (cosh N)
procedure: (sinh N)
procedure: (tanh N)
procedure: (hypot N1 N2)
procedure: (gamma N)
procedure: (lgamma N)
procedure: (log10 N)
procedure: (log2 N)
procedure: (log1p N)
procedure: (make-log/base BASE)

Returns a procedure of one argument, the logarithm function for BASE.

procedure: (ldexp N)
procedure: (scalbn N)
procedure: (fpmod N M)

Returns the modulus of N for M.

procedure: (modf N)

Returns two values, the integral and fractional part of N.

procedure: (frexp N)

Returns two values, the fraction and the exponent part of N.

Float Classification

Usage

(require-extension matth-fpclass)
procedure: (fpclassify N)

Returns a symbol denoting the kind of floating-point number.

Float Class
infinite
nan
normal
subnormal
zero
unclassified
procedure: (fpclass N)

Returns a symbol denoting the kind of floating-point number.

Float Class
positive-infinite
negative-infinite
quiet-nan
signaling-nan
positive-normal
negative-normal
positive-subnormal
negative-subnormal
positive-zero
negative-zero
unclassified

Integer Constants

Usage

(require-extension matth-int)
most-positive-fixnum Largest positive fixnum
most-negative-fixnum Smallest negative fixnum
fixnum-precision Number of bits in fixnum
machine-word-bits Number of bits in machine word - C_word
maximum-machine-word Largest machine word value - C_uword
most-negative-machine-word Smallest negative machine word value - C_word
most-positive-machine-word Largest positive machine word value - C_word
unsigned-integer32-size Sizeof uint32_t
maximum-unsigned-integer32 Largest value for uint32_t
unsigned-char-size Sizeof the C type
unsigned-short-size Sizeof the C type
unsigned-int-size Sizeof the C type
unsigned-long-size Sizeof the C type
unsigned-long-long-size Sizeof the C type, 0 when unsupported
char-size Sizeof the C type
short-size Sizeof the C type
int-size Sizeof the C type
long-size Sizeof the C type
long-long-size Sizeof the C type, 0 when unsupported

Floating-point Constants

Usage

(require-extension matth-float)
float-radix Representation base of floating point number
maximum-float Largest floating point number
minimum-float Smallest floating point number
float-epsilon The difference between 1.0 and the least value > 1.0 of a floating point number
float-precision Number of digits in mantissa base radix of floating point number
float-decimal-precision Number of digits in mantissa base 10 of floating point number
float-maximum-exponent Largest exponent in base radix of floating point number
float-minimum-exponent Smallest exponent in base radix of floating point number
float-maximum-decimal-exponent Largest exponent in base 10 of floating point number
float-minimum-decimal-exponent Smallest exponent in base 10 of floating point number
maximum-double Largest floating point number
minimum-double Smallest floating point number
double-epsilon The difference between 1.0 and the least value > 1.0 of a floating point number
double-precision Number of digits in mantissa base radix of floating point number
double-decimal-precision Number of digits in mantissa base 10 of floating point number
double-maximum-exponent Largest exponent in base radix of floating point number
double-minimum-exponent Smallest exponent in base radix of floating point number
double-maximum-decimal-exponent Largest exponent in base 10 of floating point number
double-minimum-decimal-exponent Smallest exponent in base 10 of floating point number
maximum-long-double Largest floating point number
minimum-long-double Smallest floating point number
long-double-epsilon The difference between 1.0 and the least value > 1.0 of a floating point number
long-double-precision Number of digits in mantissa base radix of floating point number
long-double-decimal-precision Number of digits in mantissa base 10 of floating point number
long-double-maximum-exponent Largest exponent in base radix of floating point number
long-double-minimum-exponent Smallest exponent in base radix of floating point number
long-double-maximum-decimal-exponent Largest exponent in base 10 of floating point number
long-double-minimum-decimal-exponent Smallest exponent in base 10 of floating point number
long-double-radix Representation base of floating point number
maximum-flonum Largest floating point number
minimum-flonum Smallest floating point number
flonum-epsilon The difference between 1.0 and the least value > 1.0 of a floating point number
flonum-precision Number of digits in mantissa base radix of floating point number
flonum-decimal-precision Number of digits in mantissa base 10 of floating point number
flonum-maximum-exponent Largest exponent in base radix of floating point number
flonum-minimum-exponent Smallest exponent in base radix of floating point number
flonum-maximum-decimal-exponent Largest exponent in base 10 of floating point number
flonum-minimum-decimal-exponent Smallest exponent in base 10 of floating point number

Math Constants

Usage

(include "mathh-constants")

Common constants, using 'define-constant'. As such they must be textually included.

E e
1/E 1/e
E^2 e^2
E^PI/4 e^(pi/4)
LOG2E log2(e)
LOG10E log10(e)
LN2 log(2)
LN3 ln(3)
LNPI ln(pi)
LN10 log(10)
1/LN2 1/ln(2)
1/LN10 1/ln(10)
PI pi
PI/2 pi/2
PI/4 pi/4
1/PI 1/pi
2/PI 2/pi
2/SQRTPI 2/sqrt(pi)
SQRTPI sqrt(pi)
PI^2 pi^2
DEGREE pi/180
SQRT2 sqrt(2)
1/SQRT2 1/sqrt(2)
SQRT3 sqrt(3)
SQRT5 sqrt(5)
SQRT10 sqrt(10)
CUBERT2 cubert(2)
CUBERT3 cubert(3)
4THRT2 fourthrt(2)
GAMMA1/2 gamma(1/2)
GAMMA1/3 gamma(1/3)
GAMMA2/3 gamma(2/3)
PHI phi
LNPHI ln(phi)
1/LNPHI 1/ln(phi)
EULER euler
E^EULER e^euler
SIN1 sin(1)
COS1 cos(1)
ZETA3 theta(3)

Fixnum Procedures

Usage

(require-extension fixnum-extras)

R6RS fixnum functions. The "*" prefixed functions are variable arity versions of the built-in Chicken Scheme functions. This naming convention violates R6RS.

procedure: (fixnum-width)

procedure: (least-fixnum)

procedure: (greatest-fixnum)

procedure: (fx=? FX ...)

procedure: (fx<? FX ...)

procedure: (fx>? FX ...)

procedure: (fx<=? FX ...)

procedure: (fx>=? FX ...)

procedure: (fxcompare FX1 FX2)

procedure: (fxzero? FX)

procedure: (fxpositive? FX)

procedure: (fxnegative? FX)

procedure: (fxodd? FX)

procedure: (fxeven? FX)

procedure: (*fxmax FX ...)

procedure: (*fxmin FX ...)

procedure: (fxmax-and-min FX ...)

procedure: (fxmodulo FX-N FX-D)

procedure: (fxabs FX)

procedure: (fxpow2log2 FX)

procedure: (fxdiv FX-N FX-D)

procedure: (fxdiv-and-mod FX-N FX-D)

procedure: (fxdiv0 FX-N FX-D)

procedure: (fxmod0 FX-N FX-D)

procedure: (fxdiv0-and-mod0 FX-N FX-D)

procedure: (fx*/carry FX1 FX2 FX3)

procedure: (fx+/carry FX1 FX2 FX3)

procedure: (fx-/carry FX1 FX2 FX3)

procedure: (fxadd1 FX)

procedure: (fxsub1 FX)

procedure: (fxquotient FX-N FX-D)

procedure: (fxremainder FX-N FX-D)

procedure: (fxarithmetic-shift FX DIRECTIONAL-AMOUNT)

procedure: (fxarithmetic-shift-left FX AMOUNT)

procedure: (fxarithmetic-shift-right FX AMOUNT)

procedure: (*fx- FX [FX2])

procedure: (*fxand FX ...)

procedure: (*fxior FX ...)

procedure: (*fxxor FX ...)

procedure: (fxif MASK TRUE FALSE)

procedure: (fxbit-count FX)

procedure: (fxlength FX)

procedure: (fxfirst-bit-set FX)

procedure: (fxlast-bit-set FX)

procedure: (fxbit-set? FX INDEX)

procedure: (fxcopy-bit FX INDEX BIT)

procedure: (fxbit-field FX START END)

procedure: (fxcopy-bit-field FX-TO START END FX-FROM)

procedure: (fxrotate-bit-field FX START END COUNT)

procedure: (fxreverse-bit-field FX START END)

Flonum Procedures

Usage

(require-extension flonum-extras)

R6RS flonum functions.

procedure: (real->flonum VALUE)

procedure: (fixnum->flonum VALUE)

procedure: (fl=? FL ...)

procedure: (fl<? FL ...)

procedure: (fl>? FL ...)

procedure: (fl<=? FL ...)

procedure: (fl>=? FL ...)

procedure: (flcompare FL1 FL2)

procedure: (flinteger? FL)

procedure: (flzero? FL)

procedure: (flpositive? FL)

procedure: (flnegative? FL)

procedure: (flodd? FL)

procedure: (fleven? FL)

procedure: (flfinite? FL)

procedure: (flinfinite? FL)

procedure: (flnan? FL)

procedure: (fl+ FL ...)

procedure: (fl* FL ...)

procedure: (fl- FL ...)

procedure: (fl/ FL ...)

procedure: (flmax FL ...)

procedure: (flmin FL ...)

procedure: (flmax-and-min FL ...)

procedure: (flabs FL)

procedure: (flfraction FL)

procedure: (fltruncate FL)

procedure: (flfloor FL)

procedure: (flceiling FL)

procedure: (flround FL)

procedure: (fldiv FL-N FL-D)

procedure: (flmod FL-N FL-D)

procedure: (fldiv-and-mod FL-N FL-D)

procedure: (fldiv0 FL-N FL-D)

procedure: (flmod0 FL-N FL-D)

procedure: (fldiv0-and-mod0 FL-N FL-D)

procedure: (flexp FL)

procedure: (fllog FL [BASE])

procedure: (flsin FL)

procedure: (flcos FL)

procedure: (fltan FL)

procedure: (flasin FL)

procedure: (flacos FL)

procedure: (flatan FL [FL2])

procedure: (flsqrt FL)

procedure: (flexpt FL EXP)

procedure: (flnumerator FL)

procedure: (fldenominator FL)

Bitwise Procedures

Usage

(require-extension bitwise-extras)

R6RS bitwise functions.

Unchecked variants of the following procedures are supplied, named as the checked version but with a "%" prefix.

procedure: (pow2log2 VALUE)

Returns 2 ** log2 (VALUE).

procedure: (boolean->bit OBJECT)

Returns 1 for truth values and 0 for false or zero.

procedure: (bitwise-if MASK TRUE FALSE)

Merge under mask.

procedure: (bitwise-if-not MASK TRUE FALSE)

Merge under not mask.

procedure: (bitwise-test? VALUE1 VALUE2)

Any bits set in both VALUE1 and VALUE2?

procedure: (bitwise-bit-count VALUE)

Count of set bits.

procedure: (bitwise-length VALUE)

Minimum number of bits to represent.

procedure: (bitwise-first-bit-set VALUE)

Least significant bit set.

procedure: (bitwise-last-bit-set VALUE)

Most significant bit set.

procedure: (bitwise-bit-set? VALUE INDEX)

Specific bit set?

procedure: (bitwise-copy-bit TO START BIT)

Set bit.

procedure: (bitwise-bit-field VALUE START END)

Get bits.

procedure: (bitwise-copy-bit-field TO START END FROM)

Set bits.

procedure: (bitwise-rotate-bit-field VALUE START END COUNT)

Rotate bits.

procedure: (bitwise-reverse VALUE COUNT)

Reverse low-order bits.

procedure: (bitwise-reverse-bit-field VALUE START END)

Reverse bits.

procedure: (bitwise-list->integer LIST)

Converts list of boolean, least-significant to most-significant, to integer.

procedure: (bitwise-integer->list VALUE [LENGTH])

Converts integer to list of boolean, least-significant to most-significant.

procedure: (bitwise-arithmetic-shift VALUE DIRECTIONAL-AMOUNT)

(arithmetic-shift VALUE DIRECTIONAL-AMOUNT)

procedure: (bitwise-arithmetic-shift-left VALUE AMOUNT)

(arithmetic-shift VALUE AMOUNT)

procedure: (bitwise-arithmetic-shift-right VALUE AMOUNT)

(arithmetic-shift VALUE (- AMOUNT))

Version

License

This code is in the public domain