[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OOC Core Library
>
> Oakwood Guidelines: All I/O modules suffer from the Oberon System
> background. The module "In" is in fact a parser (ever tried to read a
> line with this module?). "Files" has terrible error reporting and
> makes no use of the O2 type-bound procedures. "XYplane" and "Input"
> are nonsense on most systems. This leaves the modules Out, Strings,
> Math, and MathL. These are adequate.
I've been working on a machine-independent implementations of Math &
MathL that don't depend on the host OS. They should work with any
machine that supports the IEEE floating point format. With an optimizing
compiler, these modules should be more efficient than most host-supplied
routines--especially with the REAL numbers, since most host systems, will
be forcing use of LONGREALs (much slower) than a true REAL implementation.
The modules are Oakwood-compliant with some additional routines. Here
is the definition of the Math module.
EXTENDED DEFINITION Math;
CONST
IllegalInvTrig = 7;
IllegalLog = 2;
IllegalLogBase = 5;
IllegalPower = 4;
IllegalRoot = 1;
IllegalTrig = 6;
NoError = 0;
Overflow = 3;
e = 2.71828175E+00;
pi = 3.14159274E+00;
VAR
epsilon-: REAL;
err-: INTEGER;
infinity-: REAL;
zero-: REAL;
PROCEDURE arccos (x: REAL): REAL;
PROCEDURE arccosh (x: REAL): REAL;
PROCEDURE arcsin (x: REAL): REAL;
PROCEDURE arcsinh (x: REAL): REAL;
PROCEDURE arctan (x: REAL): REAL;
PROCEDURE arctan2 (xn, xd: REAL): REAL;
PROCEDURE arctanh (x: REAL): REAL;
PROCEDURE cos (x: REAL): REAL;
PROCEDURE cosh (x: REAL): REAL;
PROCEDURE exp (x: REAL): REAL;
PROCEDURE ipower (x: REAL; base: INTEGER): REAL; (* new *)
PROCEDURE ln (x: REAL): REAL;
PROCEDURE log (x, base: REAL): REAL;
PROCEDURE log2 (x: REAL): REAL; (* new *)
PROCEDURE modf (value: REAL; VAR integerPart: REAL): REAL; (* new *)
PROCEDURE power (x, base: REAL): REAL;
PROCEDURE power2 (x: REAL): REAL; (* new *)
PROCEDURE round (x: REAL): REAL;
PROCEDURE sin (x: REAL): REAL;
PROCEDURE sincos (x: REAL; VAR Sin, Cos: REAL); (* new *)
PROCEDURE sinh (x: REAL): REAL;
PROCEDURE sqrt (x: REAL): REAL;
PROCEDURE tan (x: REAL): REAL;
PROCEDURE tanh (x: REAL): REAL;
END Math.
> -- mva
>
If anyone has any comments, let me know what you think. If a floating
point coprocessor is available with hardware support for some of these
functions, part of the porting effort to generate optimized code will
be to replace those functions which have hardware support with INLINE
code to generate the appropriate coprocessor instructions--although
initial ports should work with no changes to this module.
I'll run some benchmarks later and let you know the results.
Michael Griebling