Oberon Community Platform Forum
December 14, 2019, 06:08:08 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Math, MathL  (Read 12787 times)
sage
Full Member
***
Posts: 170



WWW
« on: February 10, 2009, 12:34:20 PM »

Math and MathL lacks of many needed math functions  Sad
For example, arccos, arctan2, power, tan...
Actually, arctan2 is very easy to realize.
The only change needed (example for MathL) is to replace existing inline -Arctan with this:
Code:
PROCEDURE -Arctan(x, y: LONGREAL): LONGREAL;
CODE {SYSTEM.i386, SYSTEM.FPU}
FLD QWORD [ESP]
FLD QWORD 8[ESP]
DB 0D9H, 0F3H (* FPATAN ST(1)/ST(0) *)
ADD ESP, 16
END Arctan;
, change existing arctan a little:
Code:
PROCEDURE arctan*(x: LONGREAL): LONGREAL;
BEGIN
RETURN Arctan2(1, x)
END arctan;
, and add arctan2 code:
Code:
PROCEDURE arctan2*(x, y: LONGREAL): LONGREAL;
BEGIN
RETURN Arctan2(x, y)
END arctan2;
Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #1 on: February 10, 2009, 12:39:31 PM »

arccos may be realized in that way:
Code:
PROCEDURE arccos*(x: LONGREAL): LONGREAL;
BEGIN
RETURN Arctan2(Sqrt(ABS(1 - x * x)), x)
END arccos;
Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #2 on: February 10, 2009, 02:32:05 PM »

Existing Math and MathL didn't comply even to "The Oakwood Guidelines for Oberon-2 Compiler Developers" http://www.europrog.ru/paper/bk1995-01e.pdf
Definition of Math according to Guidelines:
Code:
DEFINITION Math;
   CONST
      pi = 3.14159265358979323846;
       e = 2.71828182845904523536;
     PROCEDURE   sqrt (x : REAL) : REAL;
   PROCEDURE  power (x,base : REAL) : REAL;
     PROCEDURE    exp (x : REAL): REAL;
   PROCEDURE     ln (x : REAL) : REAL; 
   PROCEDURE    log (x,base : REAL) : REAL;
   PROCEDURE  round (x : REAL) : REAL;
   PROCEDURE    sin (x : REAL) : REAL;
   PROCEDURE    cos (x : REAL) : REAL
   PROCEDURE    tan (x : REAL) : REAL;
   PROCEDURE arcsin (x : REAL) : REAL;
   PROCEDURE arccos (x : REAL) : REAL;
   PROCEDURE arctan (x : REAL) : REAL;
   PROCEDURE arctan2(x,y : REAL): REAL
     PROCEDURE sinh   (x:REAL):REAL;
   PROCEDURE cosh   (x:REAL):REAL;
   PROCEDURE tanh   (x:REAL):REAL;
   PROCEDURE arcsinh(x:REAL):REAL;
   PROCEDURE arccosh(x:REAL):REAL;
   PROCEDURE arctanh(x:REAL):REAL;
END Math.
Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #3 on: February 11, 2009, 03:19:43 PM »

Finally, I've found that BlackBox Component Builder has well done Math modules.
It seems BlackBox's license is GPL-like.
So, I hope we can use it in A2.
There are fully Oakwood Guidelines compliant replacements of A2's Math and MathL modules in attached archive.

* Math.zip (4.07 KB - downloaded 476 times.)
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #4 on: February 16, 2009, 11:53:51 AM »

Quote
It seems BlackBox's license is GPL-like
Hmm... I'll have a closer look at this license... actually, we don't want the GPL (or GPL-like) to be used in library modules since this implies GPL for modules that import the library.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!