You are looking at historical revision 17926 of this page. It may differ significantly from its current revision.
The mpfi egg contains bindings for the mpfi library for interval arithmetic (a short introduction to interval arithmetic can be found at the mpfi site).
- the mpfi library
- the mpfr library (needed by mpfi)
(use mpfi) (let ((a (make-ia-interval-f64 1 10)) (b (make-ia-interval-f64 -0.5 1))) (when (ia-has-zero? b) (display "b contains zero!") (newline)) (display "a = ") (display (ia->string a)) (newline) (display "b = ") (display (ia->string b)) (newline) (display "a x b = ") (display (ia->string (ia* a b))) (newline)) ==> b contains zero! a = [1.0__10.0] b = [-0.5__1.0] a x b = [-5.0__10.0]
[procedure] (make-ia-interval-f64 LO HI)
The following procedures are available:
(ia+ A B) (ia+f64 A F) (ia- A B) (ia-f64 A F) (f64-ia F A) (ia* A B) (ia*f64 A F) (ia/ A B) (ia/f64 A F) (f64/ia F A)
The procedures ending with +, -, * and / operate on two intervals and give an interval as result. The procedures that have f64 in their name take one flonum argument.
(ia-neg A) (ia-sqr A) (ia-inv A) (ia-sqrt A) (ia-abs A) (ia-log A) (ia-exp A) (ia-exp2 A) (ia-log1p A) (ia-expm1 A) (ia-log2 A) (ia-log10 A)
(ia-cos A) (ia-sin A) (ia-tan A) (ia-acos A) (ia-asin A) (ia-atan A) (ia-cosh A) (ia-sinh A) (ia-tanh A) (ia-acosh A) (ia-asinh A) (ia-atanh A)
(ia-const-log2) (ia-const-pi) (ia-const-e)
These procedures calculate e, pi and the logarithm of two and give back intervals representing them.
(ia< A B) (ia> A B)
Given two intervals A and B, A is considered greater than B is and only if all elements of A are greater than all elements of B.
(ia-overlap? A B)
Returns true if A overlap with or contains B.
(ia-nan? A) (ia-inf? A) (ia-zero? A) (ia-has-zero? A) (ia-positive? A) (ia-negative? A) (ia-strictly-positive? A) (ia-strictly-negative? A) (ia-nonpositive? A) (ia-nonnegative? A) (ia-bounded? A) (ia-empty? A) (ia-inside? A B) (ia-f64-inside? A B)
Procedures returning flonum:
(ia-diameter A) (ia-diameter-absolute A) (ia-diameter-relative A) (ia-magnitude A) (ia-mignitude A) (ia-random A) (ia-middle A)
Other procedures:[procedure] (ia-lo A)
[procedure] (ia-hi A)
Return the low and high endpoints of the interval.[procedure] (ia->string)
Converts interval into a string.
Each nondestructive procedure described above (like ia/ for example) has a destructive counterpart in which there is one extra argument where the result goes:
(ia/ a b) (ia/! result a b)
The destructive operation does not allocate memory; the nondestructive one does.
Bugs and limitations
- the mpfi egg is still not tested enough
- Ther is only support for floating point intervals. Support for integers is planned.
- 0.1 Initial Release
Copyright (c) 2010, Jeronimo C. Pellegrini All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.