Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using RXXMATH with Regina Interpreter 1

Status
Not open for further replies.

porthome

Programmer
Nov 11, 2010
2
CA
I have a need to include advanced math functions in a REXX program (ie Sine and Cosine). I found and downloaded the so-called "Patrick McPhee's Mathematical Bumper Pack for Regina Rexx." Install instructions are pretty scanty, but I unzipped the package into my Regina folder. However, I can't link to the functions library.

Platform is latest version of Regina under WinXP V3.

Can anyone give me a quick tip on how to correctly install and use this package? Many thanks in advance.

Perry B
 
I don't tried the package by Patrick McPhee, but in ooREXX there is RxMath package included.
Example:
Code:
[COLOR=#0000ff]/* using RxMath package */[/color]
[COLOR=#804040][b]call [/b][/color][COLOR=#008080]RxFuncAdd[/color] [COLOR=#ff00ff]"MathLoadFuncs"[/color][COLOR=#804040][b],[/b][/color][COLOR=#ff00ff]"rxmath"[/color][COLOR=#804040][b],[/b][/color][COLOR=#ff00ff]"MathLoadFuncs"[/color]
[COLOR=#804040][b]call [/b][/color][COLOR=#008080]MathLoadFuncs[/color]

[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin() in Degrees:"[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"-----------------"[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(0)  ="[/color] [COLOR=#008080]RxCalcSin([/color]0[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] D[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(45) ="[/color] [COLOR=#008080]RxCalcSin([/color]45[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] D[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(90) ="[/color] [COLOR=#008080]RxCalcSin([/color]90[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] D[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color]

[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin() in Radians:"[/color] 
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"-----------------"[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(0)    ="[/color] [COLOR=#008080]RxCalcSin([/color]0[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] R[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(Pi/4) ="[/color] [COLOR=#008080]RxCalcSin(RxCalcPi()[/color][COLOR=#804040][b]/[/b][/color]4[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] R[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(Pi/2) ="[/color] [COLOR=#008080]RxCalcSin(RxCalcPi()[/color][COLOR=#804040][b]/[/b][/color]2[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] R[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color]

[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin() in Grades:"[/color] 
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"-----------------"[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(0)   ="[/color] [COLOR=#008080]RxCalcSin([/color]0[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] G[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(50)  ="[/color] [COLOR=#008080]RxCalcSin([/color]50[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] G[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(100) ="[/color] [COLOR=#008080]RxCalcSin([/color]100[COLOR=#804040][b],[/b][/color] [COLOR=#804040][b],[/b][/color] G[COLOR=#008080])[/color]
Output:
Code:
d:\>rexx math.rex
sin() in Degrees:
-----------------
sin(0)  = 0
sin(45) = 0.707106781
sin(90) = 1

sin() in Radians:
-----------------
sin(0)    = 0
sin(Pi/4) = 0.707106781
sin(Pi/2) = 1

sin() in Grades:
-----------------
sin(0)   = 0
sin(50)  = 0.707106781
sin(100) = 1
 
I tried the package you mentoned with Regina.
It seems to contain same functions as the math library included with ooREX, i.e. RxMath library and additional the AMath library (Amiga math library).

Read the included documentation regmath.pdf

Here are the quick installation steps:
1. download the packahe regmath100.zip
2. unzip it and you will get the directory math
3. copy from the \math\win32 subdirectory the two DLLs (rxmath.dll and rexxmath.dll) into a directotry somewhere in your PATH. I copied both DLLs in the Regina home directory: c:\Program Files\Regina

Now the example above works with Regina too:
Code:
c:\>regina math.rex
sin() in Degrees:
-----------------
sin(0)  = 0
sin(45) = 0.7071067811865475
sin(90) = 1

sin() in Radians:
-----------------
sin(0)    = 0
sin(Pi/4) = 0.7071067809055092
sin(Pi/2) = 1

sin() in Grades:
-----------------
sin(0)   = 0
sin(50)  = 0.7071067811865476
sin(100) = 1

With the AMath library the argument of sin should be in Radians only:
Code:
[COLOR=#0000ff]/* using RexxMath package with Regina REXX */[/color]
[COLOR=#804040][b]call [/b][/color][COLOR=#008080]rxfuncadd[/color] [COLOR=#ff00ff]'mathloadfuncs'[/color][COLOR=#804040][b],[/b][/color] [COLOR=#ff00ff]'rexxmath'[/color][COLOR=#804040][b],[/b][/color] [COLOR=#ff00ff]'mathloadfuncs'[/color]
[COLOR=#804040][b]call [/b][/color][COLOR=#008080]mathLoadFuncs[/color]

[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin() in Radians:"[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"-----------------"[/color]
Pi [COLOR=#804040][b]=[/b][/color] 3.1415926535897932384626433832795
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(0)    ="[/color] [COLOR=#008080]Sin([/color]0[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(Pi/4) ="[/color] [COLOR=#008080]Sin([/color]Pi[COLOR=#804040][b]/[/b][/color]4[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"sin(Pi/2) ="[/color] [COLOR=#008080]Sin([/color]Pi[COLOR=#804040][b]/[/b][/color]2[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color]
Output:
Code:
c:\>regina math.rexx
sin() in Radians:
-----------------
sin(0)    = 0
sin(Pi/4) = 0.70710678090550916
sin(Pi/2) = 1
 
Thank you very much! You provided the missing tip I needed

Perry B
 
I think that level of support deserves a star. Nice one mikrom.
 
If youre using the 64 bit version of Regina then the packages won't load, the RXXMATH Math Functions by John Brock, that are bundled with the regmath100 files, work fine and allow for increased precision.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top