DEFINITION MODULE DMMathLib;
(*******************************************************************
Module DMMathLib ('Dialog Machine' DM_V3.0)
Copyright (c) 1991-2006 by Andreas Fischlin and ETH Zurich.
Purpose Basic mathematical routines operating on
type REAL (cf. module DMLongMathLib).
Remarks Macintosh implementation:
------------------------
There are several variants of this module
available: One is using SANE (slower but more
accurate, since all calculations are actually made
with 80 Bit reals [extended IEEE format]) and
another, substantially more efficient version,
which is bypassing SANE, i.e. is using a native 32
Bit floating point arithmetic. The latter is
similar to a third, for utmost portability
implemented variant (BatchDM) available. The
latter variant should yield the most portable
results on any platform. For more details see the
SANE manual, Addison Wesley and module 'DMFloatEnv'.
IBM PC implementation:
---------------------
Portable, not necessary most efficient implementation
provided.
Sun (Unix) implementation:
-------------------------
Portable, not necessary most efficient implementation
provided.
There is also a companion module, named DMMathLF,
available, which directly uses the mathematical
coprocessor and provides optimally efficient
algorithms. However, the price to pay for this
gain in efficiency is portability, since on some
machines this code may not be executable if the
required hardware component is missing. Using the
module 'DMMathLib' is always safe and should not
cause portability problems, but it may not always
be the most efficient solution.
This module belongs to the 'Dialog Machine'.
Programming
o Design
Andreas Fischlin 25/06/1991
o Implementation
Andreas Fischlin 25/06/1991
ETH Zurich
Systems Ecology
CHN E 35.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
URLs:
<mailto:RAMSES@env.ethz.ch>
<http://www.sysecol.ethz.ch>
<http://www.sysecol.ethz.ch/SimSoftware/RAMSES>
Last revision of definition: 05/08/1991 AF
*******************************************************************)
PROCEDURE Sqrt (x: REAL): REAL;
PROCEDURE Exp (x: REAL): REAL;
PROCEDURE Ln (x: REAL): REAL;
PROCEDURE Sin (x: REAL): REAL;
PROCEDURE Cos (x: REAL): REAL;
PROCEDURE ArcTan(x: REAL): REAL;
PROCEDURE Real (x: INTEGER): REAL;
PROCEDURE Entier(x: REAL): INTEGER; (* Entier is similar to TRUNC,
but truncates also negative x
values to the smaller integral
part. Ex.: Entier(-3.3) returns
-4 where TRUNC(-3.3) is -3. *)
(*
Simple random number generators, which return variates in
ranges [0..upperBound] (RandomInt) resp. (0..1] (RandomReal).
Don't use these generators for serious stochastic simulations!
Their properties are not optimal. For better random number
generators see the modules RandGen, RandGen0, RandGen1,
RandNormal etc.
*)
PROCEDURE Randomize;
PROCEDURE RandomInt(upperBound: INTEGER): INTEGER;
PROCEDURE RandomReal(): REAL;
END DMMathLib.