Interval package: Difference between revisions

m
Updated vectorization examples to the current version of the package
(→‎Parameter checking: NaI's may now be non-scalar)
m (Updated vectorization examples to the current version of the package)
Line 25: Line 25:
** No known bugs. The package is quite new and still has a small user base, so there might be hidden bugs. Also some advanced functions will always need more testing.
** No known bugs. The package is quite new and still has a small user base, so there might be hidden bugs. Also some advanced functions will always need more testing.
* Portability
* Portability
** Runs in GNU Octave 3.8.2 and 4.0.0
** Runs in GNU Octave 3.8.2
** Known to run under GNU/Linux, Microsoft Windows, Mac OS X and FreeBSD
** Known to run under GNU/Linux, Microsoft Windows, Mac OS X and FreeBSD
* Possible TODOs
* Possible TODOs
Line 203: Line 203:
==== Use of Octave functions ====
==== Use of Octave functions ====
Octave functions may be used as long as they don't introduce arithmetic errors. For example, the ceil function can be used safely since it is exact on binary64 numbers.
Octave functions may be used as long as they don't introduce arithmetic errors. For example, the ceil function can be used safely since it is exact on binary64 numbers.
  function result = ceil (x)
  function x = ceil (x)
  ... parameter checking ...
  ... parameter checking ...
  result = infsup (ceil (x.inf), ceil (x.sup));
  x.inf = ceil (x.inf);
x.sup = ceil (x.sup);
  endfunction
  endfunction
If Octave functions would introduce arithmetic/rounding errors, there are interfaces to MPFR (<code>mpfr_function_d</code>) and crlibm (<code>crlibm_function</code>), which can produce guaranteed boundaries.


==== Vectorization & Indexing ====
==== Vectorization & Indexing ====
All functions should be implemented using vectorization and indexing. This is very important for performance on large data. For example, consider the plus function. It computes lower and upper boundaries of the result (x.inf, y.inf, x.sup, y.sup may be vectors or matrices) and then uses an indexing expression to adjust values where empty intervals would have produces problematic values.
All functions should be implemented using vectorization and indexing. This is very important for performance on large data. For example, consider the plus function. It computes lower and upper boundaries of the result (x.inf, y.inf, x.sup, y.sup may be vectors or matrices) and then uses an indexing expression to adjust values where empty intervals would have produces problematic values.
  function result = plus (x, y)
  function x = plus (x, y)
  ... parameter checking ...
  ... parameter checking ...
  l = mpfr_function_d ('plus', -inf, x.inf, y.inf);
  l = mpfr_function_d ('plus', -inf, x.inf, y.inf);
Line 218: Line 222:
  l(emptyresult) = inf;
  l(emptyresult) = inf;
  u(emptyresult) = -inf;
  u(emptyresult) = -inf;
  result = infsup (l, u);
 
  endfunction
  endfunction


== VERSOFT ==
== VERSOFT ==
The [http://uivtx.cs.cas.cz/~rohn/matlab/ VERSOFT] software package (by Jiří Rohn) has been released under a free software license (Expat license) and algorithms may be migrated into the interval package.
The [http://uivtx.cs.cas.cz/~rohn/matlab/ VERSOFT] software package (by Jiří Rohn) has been released under a free software license (Expat license) and algorithms may be migrated into the interval package.
The following table is no longer up-to-date, it describes the situation before p-coded files have been disclosed. So, some functions are no longer trapped.


{|
{|
240

edits