240

edits

Jump to navigation
Jump to search

→Developer Information

== Developer Information ==

=== Source Code Repository ===

https://sourceforge.net/p/octave/interval/ci/default/tree/

=== Build ===

The repository contains a Makefile which controls the build process. Some common targets are:

* <code>make release</code> Create a release tarball and the HTML documentation for [[Octave Forge]] (takes a while).

* <code>make check</code> Run the full test-suite to verify that code changes didn't break anything (takes a while).

* <code>make run</code> Quickly start Octave with minimal recompilation and functions loaded from the workspace (for interactive testing of code changes).

'''Build dependencies'''

* Octave

** Version 3.8.0 or greater

** No need to compile from source, but you need development files e.g. package <code>liboctave-dev</code> in Debian.

* Mercurial

* Texinfo

* MPFR

** Version 3.1.0 or greater

** No need to compile from source, but you need development files e.g. package <code>libmpfr-dev</code> in Debian.

* Octave package: doctest

** Purpose: Verification of the examples in the manual and in the function documentation

** Installation: Use <code>pkg install -forge doctest</code> inside Octave

* Octave package: generate_html

** Purpose: Generate HTML documenation for publication on Octave Forge (only needed for release)

** Installation: Use <code>pkg install -forge generate_html</code> inside Octave

* ITF1788

** Purpose: Compilation of unit-test

** Installation:

**# Clone the git repository from https://github.com/oheim/ITF1788

**# Install python 3 and the dependencies described by ITF1788's <code>requirements.txt</code> file

**# Set up an environment variable ITF1788_HOME to point to your local git workspace, for example put the line <code>export IFT1788_HOME=/home/user/ITF1788</code> into your <code>.bashrc</code>.

* LilyPond, Inkscape, Poppler

** Purpose: Generate / convert images for the manual

** Installation: Use your distribution's package manager (look for packages called <code>lilypond</code> <code>inkscape</code> <code>poppler-utils</code>)

=== Architecture ===

In a nutshell the package provides two new data types to users: bare intervals and decorated intervals. The data types are implemented as:

* class <code>infsup</code> (bare interval) with attributes <code>inf</code> (lower interval boundary) and <code>sup</code> (upper interval boundary)

* class <code>infsupdec</code> (decorated interval) which extends the former and adds attribute <code>dec</code> (interval decoration).

Almost all functions in the package are implemented as methods of these classes, e. g. <code>@infsup/sin</code> implements the sine function for bare intervals. Most code is kept in m-files. Arithmetic operations that require correctly-rounded results are implemented in oct-files (C++ code), these are used internally by the m-files of the package. The source code is organized as follows:

+- doc/ – package manual

+- inst/

| +- @infsup/

| | +- infsup.m – class constructor for bare intervals

| | +- sin.m – sine function for bare intervals (uses mpfr_function_d internally)

| | `- ... – further functions on bare intervals

| +- @infsupdec/

| | +- infsupdec.m – class constructor for decorated intervals

| | +- sin.m – sine function for decorated intervals (uses @infsup/sin internally)

| | `- ... – further functions on decorated intervals

| `- ... – a few global functions that don't operate on intervals

+- src/

| | +- mpfr_function_d.cc – computes various arithmetic functions correctly rounded (using MPFR)

| | `- ... – other oct-file sources

`- test/ – interval arithmetic unit tests

=== Best practices ===

==== Parameter checking ====

* All methods must check <code>nargin</code> and call <code>print_usage</code> if the number of parameters is wrong. This prevents simple errors by the user.

* Methods with more than 1 parameter must convert non-interval parameters to intervals using the class constructor. This allows the user to mix non-interval parameters with interval parameters and the function treats any inputs as intervals. Invalid values will be handled by the class constructors.

if (not (isa (x, "infsup")))

x = infsup (x);

endif

if (not (isa (y, "infsup")))

y = infsup (y);

endif

if (not (isa (x, "infsupdec")))

x = infsupdec (x);

endif

if (not (isa (y, "infsupdec")))

y = infsupdec (y);

endif

* Methods of class <code>infsupdec</code> as well as methods of class <code>infsup</code> that are not overridden by <code>infsupdec</code> must check parameters using the <code>isnai</code> function and return the NAI value if it is present. This will propagate NAI values through any function evaluations.

if (isnai (x))

result = x;

return

endif

==== 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.

function result = ceil (x)

... parameter checking ...

result = infsup (ceil (x.inf), ceil (x.sup));

endfunction

==== 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.

function result = plus (x, y)

... parameter checking ...

l = mpfr_function_d ('plus', -inf, x.inf, y.inf);

u = mpfr_function_d ('plus', +inf, x.sup, y.sup);

emptyresult = isempty (x) | isempty (y);

l(emptyresult) = inf;

u(emptyresult) = -inf;

result = infsup (l, u);

endfunction

[[Category:Octave-Forge]]

240

edits

Retrieved from "https://wiki.octave.org/Special:MobileDiff/8234"

- Not logged in
- Talk
- Contributions
- Create account
- Log in