This is the ratmath Reference Manual, version 1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 06:32:55 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
ratmath
Math utilities for working with rational numbers and intervals.
Jesse Off <jesseoff@me.com>
MIT
1
package.lisp
(file).
fifo.lisp
(file).
pipe.lisp
(file).
ratmath.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
ratmath/fifo.lisp
package.lisp
(file).
ratmath
(system).
copy-fifo
(function).
fifo
(structure).
fifo-count
(function).
fifo-data
(reader).
(setf fifo-data)
(writer).
fifo-endp
(function).
fifo-get
(macro).
fifo-head
(function).
fifo-n
(reader).
(setf fifo-n)
(writer).
fifo-p
(function).
fifo-put
(macro).
fifo-tail
(reader).
(setf fifo-tail)
(writer).
make-fifo
(function).
ratmath/pipe.lisp
fifo.lisp
(file).
ratmath
(system).
list-to-pipe
(function).
pipe-append
(function).
pipe-apply
(function).
pipe-cons
(macro).
pipe-end-after
(function).
pipe-end-before
(function).
pipe-endp
(function).
pipe-filter
(function).
pipe-first
(function).
pipe-head
(function).
pipe-last
(function).
pipe-mapc
(function).
pipe-printer
(function).
pipe-rest
(function).
pipe-signaler
(function).
pipe-sink
(function).
pipe-sink-until
(function).
pipe-sink-until-condition
(macro).
pipe-to-list
(function).
pipe-transform
(function).
pipe-uniq
(function).
encapsulate
(macro).
expose
(macro).
ratmath/ratmath.lisp
pipe.lisp
(file).
ratmath
(system).
farey-pipe
(function).
fractions
(function).
hull
(function).
infsup
(macro).
interval
(function).
lower
(function).
napiers-constant-generator
(function).
parse-interval
(function).
print-object
(method).
rat
(macro).
rat-pipe
(function).
upper
(function).
with-interval-math
(macro).
~
(function).
~=
(function).
%infsup
(function).
%rat
(function).
best-convergent
(function).
best-convergent-test-fn
(macro).
calc-stern-brocot
(function).
continued-fraction-pipe
(function).
convergent
(structure).
convergent-a
(reader).
(setf convergent-a)
(writer).
convergent-cf
(reader).
(setf convergent-cf)
(writer).
convergent-denominator
(function).
convergent-equal
(function).
convergent-fract
(function).
convergent-numerator
(function).
convergent-p
(function).
convergent-q
(function).
convergent-q-offset
(reader).
(setf convergent-q-offset)
(writer).
convergent-r0
(reader).
(setf convergent-r0)
(writer).
convergent-r1
(reader).
(setf convergent-r1)
(writer).
convergent-rat
(reader).
(setf convergent-rat)
(writer).
convergent-ratio
(function).
convergent-stern-brocot
(function).
convergents-pipe
(function).
copy-convergent
(function).
copy-stern-brocot
(function).
eval-constants
(function).
functionalp
(function).
infsup-limd
(function).
infsup-tol
(function).
interval*
(function).
interval+
(function).
interval-
(function).
interval/
(function).
intervalabs
(function).
intervalexp
(function).
intervalexpt
(function).
intervallog
(function).
intervalsqrt
(function).
interval~
(macro).
make-convergent
(function).
make-semi-convergent
(function).
make-stern-brocot
(function).
my-
(function).
my-min
(function).
my/
(function).
rationalize-continued-fraction-pipe
(function).
semi-convergent-closest-to-lim
(function).
semi-convergent-iffy-p
(function).
semi-convergent-p
(function).
stern-brocot
(structure).
stern-brocot-denominator
(function).
stern-brocot-fract
(function).
stern-brocot-left-parent
(reader).
(setf stern-brocot-left-parent)
(writer).
stern-brocot-numerator
(function).
stern-brocot-p
(function).
stern-brocot-ratio
(function).
stern-brocot-right-parent
(reader).
(setf stern-brocot-right-parent)
(writer).
truncate-within-interval
(function).
Packages are listed by definition order.
ratmath
common-lisp
.
farey-pipe
(function).
fractions
(function).
hull
(function).
infsup
(macro).
interval
(function).
list-to-pipe
(function).
lower
(function).
napiers-constant-generator
(function).
parse-interval
(function).
pipe-append
(function).
pipe-apply
(function).
pipe-cons
(macro).
pipe-end-after
(function).
pipe-end-before
(function).
pipe-endp
(function).
pipe-filter
(function).
pipe-first
(function).
pipe-head
(function).
pipe-last
(function).
pipe-mapc
(function).
pipe-printer
(function).
pipe-rest
(function).
pipe-signaler
(function).
pipe-sink
(function).
pipe-sink-until
(function).
pipe-sink-until-condition
(macro).
pipe-to-list
(function).
pipe-transform
(function).
pipe-uniq
(function).
rat
(macro).
rat-pipe
(function).
upper
(function).
with-interval-math
(macro).
~
(function).
~=
(function).
%infsup
(function).
%rat
(function).
best-convergent
(function).
best-convergent-test-fn
(macro).
calc-stern-brocot
(function).
continued-fraction-pipe
(function).
convergent
(structure).
convergent-a
(reader).
(setf convergent-a)
(writer).
convergent-cf
(reader).
(setf convergent-cf)
(writer).
convergent-denominator
(function).
convergent-equal
(function).
convergent-fract
(function).
convergent-numerator
(function).
convergent-p
(function).
convergent-q
(function).
convergent-q-offset
(reader).
(setf convergent-q-offset)
(writer).
convergent-r0
(reader).
(setf convergent-r0)
(writer).
convergent-r1
(reader).
(setf convergent-r1)
(writer).
convergent-rat
(reader).
(setf convergent-rat)
(writer).
convergent-ratio
(function).
convergent-stern-brocot
(function).
convergents-pipe
(function).
copy-convergent
(function).
copy-fifo
(function).
copy-stern-brocot
(function).
encapsulate
(macro).
eval-constants
(function).
expose
(macro).
fifo
(structure).
fifo-count
(function).
fifo-data
(reader).
(setf fifo-data)
(writer).
fifo-endp
(function).
fifo-get
(macro).
fifo-head
(function).
fifo-n
(reader).
(setf fifo-n)
(writer).
fifo-p
(function).
fifo-put
(macro).
fifo-tail
(reader).
(setf fifo-tail)
(writer).
functionalp
(function).
infsup-limd
(function).
infsup-tol
(function).
interval*
(function).
interval+
(function).
interval-
(function).
interval/
(function).
intervalabs
(function).
intervalexp
(function).
intervalexpt
(function).
intervallog
(function).
intervalsqrt
(function).
interval~
(macro).
make-convergent
(function).
make-fifo
(function).
make-semi-convergent
(function).
make-stern-brocot
(function).
my-
(function).
my-min
(function).
my/
(function).
rationalize-continued-fraction-pipe
(function).
semi-convergent-closest-to-lim
(function).
semi-convergent-iffy-p
(function).
semi-convergent-p
(function).
stern-brocot
(structure).
stern-brocot-denominator
(function).
stern-brocot-fract
(function).
stern-brocot-left-parent
(reader).
(setf stern-brocot-left-parent)
(writer).
stern-brocot-numerator
(function).
stern-brocot-p
(function).
stern-brocot-ratio
(function).
stern-brocot-right-parent
(reader).
(setf stern-brocot-right-parent)
(writer).
truncate-within-interval
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Returns infimum/supremum intervals. All strings and numbers in tree are converted keeping everything else intact. Exacts are fuzzified according to :tol and :abstol first, and then potentially widened further with :limd and :limn, which performs a rational approximation. Intervals already present in the structure, whether by explicit cons or via a string, will not be fuzzified further by :abstol and :tol, but they may be widened if rational approximation is called out via :limd/:limn args. Exact rationals will only convert to intervals if 1) their numerators/denominators exceed :limn/:limd or 2) an :open t arg is given. When the arg is an exact and rational approximation is called out, a 2nd value, alpha, is returned which is a number from 0-1 representing the location of the original exact in the returned interval.
Exposes elements of pipe until one of the condition types in conds is signalled. Returns nil for end of pipe, or 3 values: #1 being the interrupted pipe, #2 being the condition object, and #3 being the particular condition clause type in the original args that matched.
Performs a rational approximation of an exact number or interval. Takes keyword args :limn and :limd to represent max numerator and max denominator. Also will parse numeric strings into intervals ala parse-interval. Always returns an exact (i.e. not another interval).
Replaces arithmetic calls like *-/+ with interval*-/+ and turns ~##.## symbols into literal rational intervals with implied precision based on the number of digits after the decimal point. (as in parse-interval)
Returns a farey sequence; 2nd value is an encapsulated reverse sequence
Prints out rational approximations, one per line, with the PPM or PPB error.
Takes exacts and intervals as arguments and returns an interval enclosure containing the min/max. If the range between min and max is 0, hull will return an exact.
Constructs an interval from the given lower/upper bounds
Returns a pipe from a list input argument.
Returns the lower limit of an interval
Returns an infinite/irrational continued fraction expansion of Euler’s number ’e’
Turns strings of rationals or floats into rational intervals. Infers interval radius from number specification. e.g. 1.000 implies an interval of [.9995, 1.0005) whereas just 1 implies [.5, 1.5). Exponent notation is also recognized; 1e3 is [500, 1500) whereas 1000 is [999.5, 1000.5). A rational specified as 22/7 is converted as (43/14, 45/14).
Runs procedure on every element as they are exposed, but does not transform the element.
Runs test on each element. When it returns t, the pipe is truncated after that element
Runs test on each element. When it returns t, the pipe is truncated before that element
If procedure returns t, that particular pipe element is removed from the sequence.
Truncates a pipe after n (default: 1) elements
Runs function on each element. Returns nothing.
Analogous to the rest function except works on a pipe rather than list
For each condition object in pipe, set up some useful restarts and signal it. If nothing handles it, the default behavior is to ignore. If the use-value restart is invoked, that value will be returned as a pipe datum element.
Exposes elements of pipe forever, ignoring the elements. Similar to pipe-mapc with a no-op procedure. Useful to provoke the pipeline processing of an infinite pipe.
Exposes elements of pipe until test returns t. When that happens, returns the (non-empty) pipe. If the pipe goes empty, returns nil. The test procedure is called with the current element as arg.
Returns a list from the given pipe input argument. Infinite recursion results if the pipe is infinite.
Runs procedure on each element of pipe; replacing each original element
Removes duplicates according to optional predicate func. Only dups in sequence are removed.
Returns a pipe of best rational approximations for every power-of-mult numerator/denominator. If arg is not a number, assumes it is a continued fraction pipe.
Returns the upper limit of an interval
Converts intervals into an exacts. :random picks a random value within the interval instead of the midpoint. :rat picks the first convergent rational fraction (which may not be the midpoint) :upper or :lower selects the upper or lower limit. :alpha modifies whats considered the midpoint of the interval. :discrete requests to only return one of either the lower or upper interval limit. By default, returns the midpoint. If passed in a list/tree, recursively modifies everything that looks like an interval and leaves everything else intact.
Compares either exacts or intervals for possible equality.
Removes and returns object from fifo. If fifo becomes empty, struct is destroyed, i.e. setf nil
Adds obj to fifo, instantiating new fifo struct if necessary. Returns new count of fifo
When the ~ function is encounted within a with-interval-math block, it converts exacts to intervals. Outside of the lexical scope of a with-interval-math block, ~ converts intervals into exacts.
From a rationalized continued-fraction-pipe arg, returns best convergent honoring limits. 2nd value being the next best ignoring limits.
Returns a pipe of continued fraction terms from the input rational arg.
a
.
cf
.
r0
.
r1
.
rat
.
From a convergent struct, make a Stern-Brocot struct by calculating the left and right parents
From a continued-fraction-pipe return a pipe of the resultant convergents.
Returns an infimum/supremum interval; 2nd value is alpha (>.5 when supremum is closer)
Returns an infimum/supremum interval given a tolerance.
The normal continued-fraction-pipes have each term annotated with a lexical closure that returns the remainder to the terminal value. This value is used to qualify visiting iffy semi-convergents in a denominator/numerator limited rational approximation. With irrational numbers there is no end-value so we can give downpipe logic no insight as to whether an iffy semi-convergent is worthy.
From a specific convergent, check semi-convergents for one below num/denom limits
Iffy semi-convergents are the exactly 1/2 CF semi-convergent of even terms.
Semi-convergents are convergents with a truncated (up to 1/2) CF term
Takes 2 continued-fraction-pipes and returns one that stops at the simplest rational inbetween
Represents a (semi-)convergent in the rational approximation of a continued fraction.
Stern-Brocot left/right parent used to address a node in the Stern-Brocot fraction tree.
Jump to: | %
(
~
B C E F H I L M N P R S T U W |
---|
Jump to: | %
(
~
B C E F H I L M N P R S T U W |
---|
Jump to: | A C D L N Q R S T |
---|
Jump to: | A C D L N Q R S T |
---|
Jump to: | C F P R S |
---|
Jump to: | C F P R S |
---|