Next: Function Classes, Previous: Headers and Libraries, Up: MPRIA Basics [Index]
A rational interval is a closed connected set of rational numbers,
it is represented in MPRIA by its endpoints which are GMP rational numbers.
The C data type for these objects is mpri_t
.
MPRIA functions operate on valid rational intervals, while their behaviour remains undefined with non-valid rational intervals; a valid rational interval is defined as follows1:
MPRIA functions may return intervals that are not valid as input value; their semantic is defined as follows2:
Some functions on rational intervals return a rational number.
Among such functions, there are mpri_get_left
and mpri_get_right
that respectively return the left and right endpoints of a rational interval,
and there is mpri_diam_abs
that computes the width of a rational interval.
Rational numbers (or rationals for short) and rational arithmetic functions
are brought as is from the GMP library.
The C data type for rationals is mpq_t
,
while their related functions start with the prefix mpq_
(see Rational Number Functions in The GNU MP Manual).
For rational intervals,
because their endpoints are numbers exactly representable
that are meant to enclose a result not exactly representable,
the notion of precision is essentially related to their width
which is meant to be arbitrarily small.
The precision of a rational interval designs
the integer binary logarithm of the reciprocal of its width;
as such, it expresses in bits.
The corresponding C data type is mpri_prec_t
.
When a MPRIA function implements some sort of convergent algorithm to return rational intervals,
besides passing a precision parameter in bits to terminate the computation,
a surrounding mode parameter specifies whether to place the best convert
either at the left endpoint, at the right endpoint or arbitrarily.
The C data type for these modes is mpri_srnd_t
.
Typically it concerns implementations based on the Euclidean algorithm (which are omnipresent).
Some MPRIA functions that involve heavy computations admit as last parameter
an assignment mode which specifies whether to assign
either only the left endpoint, only the right endpoint, or the two endpoints.
The C data type for these modes is mpri_asgmt_t
.
Those functions are considered as low-level and are both
appended with the capitalised suffix _ASGMT
and wrapped by a macro that assigns the two endpoints.
The definition of a valid rational interval might be refined in future releases of MPRIA.
The meaning of an invalid operation, the representation of the empty interval and their handling may evolve in future releases of MPRIA, according to the standardisation of interval arithmetic in IEEE-1788 (see References).
Next: Function Classes, Previous: Headers and Libraries, Up: MPRIA Basics [Index]