Next: Precision Handling and Surrounding Modes, Previous: Function Classes, Up: MPRIA Basics [Index]
MPRIA functions expect output arguments before input arguments. This general rule, which is inherited from the GNU MP library, is based on an analogy with the assignment operator.
As a matter of fact,
the analogy has been pushed further by allowing
to use the same variable for both input and output in the same expression;
this extension of the general rule is also inherited from the GNU MP library.
For example,
the square function, mpri_sqr
, can be used as follows:
mpri_sqr (x, x);
what computes the set of squares of every rational number belonging to x
and puts the results back in x
.
As for MP variables, MPRIA variables must be initialised once before any assignment and may be cleared out after use. A (MP or) MPRIA variable should be initialised only once, or at least be cleared out between each initialisation. After such a variable has been initialised, it can be assigned numerous times; it will have the same allocated space during all its lifetime.
For efficiency reasons, avoid excessive initialising and clearing out: as a rule of thumb, initialise near the beginning of an application and clear out near its ending; better still, implement workspaces or garbage collections to pass and reuse these variables all along the computing process.