gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] complex types


From: Gaius Mulley
Subject: Re: [Gm2] complex types
Date: Mon, 15 Dec 2008 13:35:11 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Andreas Fischlin <address@hidden> writes:

> Arn't C library conversion routines already longreal? MathLib0 definition 
> looks
> similar to this (within RAMSES/RASS):
>
> DEFINITION FOR C MODULE CMath; 
>
>   PROCEDURE sqrt(x : LONGREAL) : LONGREAL;
>   PROCEDURE sin (x : LONGREAL) : LONGREAL;
>   PROCEDURE cos (x : LONGREAL) : LONGREAL;
>   PROCEDURE exp (x : LONGREAL) : LONGREAL;
>   PROCEDURE log (x : LONGREAL) : LONGREAL;
>   PROCEDURE atan(x : LONGREAL) : LONGREAL;
>
> END CMath.
>
> Similarly I expect conversion routines to be also double precision reals, i.e.
> LONGREAL.
>
> Regards,
> Andreas

Hi Andreas,

I've just checked in some changes to MathLib0 - it now has a complete
set of LONGREAL functions and rebuilt the html documentation.

http://www.nongnu.org/gm2/gm2.html#SEC85

The definition module is now:

DEFINITION MODULE MathLib0 ;

(*
    Description: provides access to math functions.
*)

CONST
   pi   = 3.1415926535897932384626433832795028841972;
   exp1 = 2.7182818284590452353602874713526624977572;


PROCEDURE __BUILTIN__ sqrt (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sqrtl (x: LONGREAL) : LONGREAL ;
PROCEDURE __BUILTIN__ sqrts (x: SHORTREAL) : SHORTREAL ;

PROCEDURE exp (x: REAL) : REAL ;
PROCEDURE expl (x: LONGREAL) : LONGREAL ;
PROCEDURE exps (x: SHORTREAL) : SHORTREAL ;

PROCEDURE ln (x: REAL) : REAL ;
PROCEDURE lnl (x: LONGREAL) : LONGREAL ;
PROCEDURE lns (x: SHORTREAL) : SHORTREAL ;

PROCEDURE __BUILTIN__ sin (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sinl (x: LONGREAL) : LONGREAL ;
PROCEDURE __BUILTIN__ sins (x: SHORTREAL) : SHORTREAL ;

PROCEDURE __BUILTIN__ cos (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ cosl (x: LONGREAL) : LONGREAL ;
PROCEDURE __BUILTIN__ coss (x: SHORTREAL) : SHORTREAL ;

PROCEDURE tan (x: REAL) : REAL ;
PROCEDURE tanl (x: LONGREAL) : LONGREAL ;
PROCEDURE tans (x: SHORTREAL) : SHORTREAL ;

PROCEDURE arctan (x: REAL) : REAL ;
PROCEDURE arctanl (x: LONGREAL) : LONGREAL ;
PROCEDURE arctans (x: SHORTREAL) : SHORTREAL ;

PROCEDURE entier (x: REAL) : INTEGER ;
PROCEDURE entierl (x: LONGREAL) : INTEGER ;
PROCEDURE entiers (x: SHORTREAL) : INTEGER ;

END MathLib0.


I've followed PIM2, PIM3, PIM4 (for sqrt, exp, ln, sin, cos, tan,
arctan and entier).  However do you think it better to default to use
the LONGREAL versions and allow users to specify lower precision
variants if desired?

So in the case of tan we might have 

PROCEDURE tan (x: LONGREAL) : LONGREAL ;
PROCEDURE tanr (x: REAL) : REAL ;
PROCEDURE tans (x: SHORTREAL) : SHORTREAL ;

given that LONGREAL, REAL, SHORTREAL are assignment compatible.
However they are not expression compatible so this change will
probably break legacy code..

regards,
Gaius




reply via email to

[Prev in Thread] Current Thread [Next in Thread]