April 27, 2024, 03:05:13 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


New Features Request

Started by Steve Rusich, December 04, 2006, 07:50:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Parker

December 31, 2006, 05:32:12 PM #25 Last Edit: January 01, 2007, 07:00:02 PM by Parker
LBound and UBound are traditionally used in BASIC languages to find the upper boundary and lower boundary of an array (traditional BASIC allows you to specify an other-than-zero lower bound). Those names would confuse people. You can misspell your names as long as you don't forget: I used sward once when sword was taken with the variable type. Or use a prefix like _floor and _ceiling. There are lots of creative options.

PS: I noticed this forum now has spell checking. No chance of it coloring code though, hmm ;)?
Edit - nevermind, that's just firefox 2...

J B Wood (Zumwalt)

Hm, I never knew Floor and Ceiling were common math objects.
I wonder why I never ran across that before when compiling my RPG's.
funky.

Learn something new every day.
I ended up using sFloor and sCeiling in my code, better off that way anyway.

paravantis

I too think LBOUND and UBOUND are not appropriate names for the FLOOR and CEILING functions.

Apart from their occasional (i.e. in some BASIC dialects) usage in arrays, "LBOUND" and "UBOUND" would rather refer to optimization problems (as in upper and lower bounds of an objective function, constraints etc).

BTW happy new year eBasic lot!

Dennisc

Since John is in this thread, I would love to see a business Math and/or Stat pack added to EBasic with functions such as NPV, Std Deviations, Averages, etc. being added.

Ke to Xrono John! (Greek New Year wish) and to all on this forum

Dennis
Failure is only the opportunity to begin again more intelligently
www.denniscomninos.com

paravantis

Dennis,

If any other users wish to join forces, on my part I would gladly convert and enhance my random number generation package written in another Basic dialect.

As an interim solution to users wishing to employ math and stat function, the fbmath library of FreeBasic is available as a freeware and its source easy to translate to eBasic:

http://sourceforge.net/projects/fbmath/

John

J B Wood (Zumwalt)

I don't recall, does sourceforge allow binaries also or only code?

Dennisc

Thanks John - will look at the library suggested and see if I can find the time to convert and make available.

QuoteI don't recall, does sourceforge allow binaries also or only code?

To the best of my knowledge Jonathan, the concept of open source supported by SourceForge requires that source must be made available.

Dennis
Failure is only the opportunity to begin again more intelligently
www.denniscomninos.com

paravantis

Folks,

The FBmath download

fbmat043.zip

includes ALL source code nicely organized in folders (curfit, equation, fmath, fourier, integral, largeint, matrices, optim, plot, polynom, proba, random, stat & strings). The code is very clean, well structured and nicely commented as in sample below

DECLARE FUNCTION RanGen3 AS DOUBLE
' Returns a random number in (0,1)

' ------------------------------------------------------------------
' Global variables
' ------------------------------------------------------------------

DIM SHARED GaussSave AS DOUBLE  ' Saves a Gaussian number
DIM SHARED GaussNew AS INTEGER  ' Flags a new calculation

' ******************************************************************

OPTION EXPLICIT

FUNCTION RanGaussStd AS DOUBLE
' ------------------------------------------------------------------
' Computes 2 random numbers from the standard normal distribution,
' returns one and saves the other for the next call
' ------------------------------------------------------------------

  DIM AS DOUBLE R, Theta

  IF GaussNew = 0 THEN
    R = SQR(-2 * LOG(RanGen3))
    Theta = TwoPi * RanGen3
    RanGaussStd = R * COS(Theta)  ' Return 1st number
    GaussSave = R * SIN(Theta)    ' Save 2nd number
  ELSE
    RanGaussStd = GaussSave       ' Return saved number
  END IF
  GaussNew = NOT GaussNew
END FUNCTION

FUNCTION RanGauss(Mu AS DOUBLE, Sigma AS DOUBLE) AS DOUBLE
' ------------------------------------------------------------------
' Returns a random number from a Gaussian distribution
' with mean Mu and standard deviation Sigma
' ------------------------------------------------------------------

  RanGauss = Mu + Sigma * RanGaussStd
END FUNCTION


This should give you a good idea.

Barney

Yes. It does look interesting. I've downloaded it and already translated a few functions into EBasic. Now, if only I can find some time...  ::)

Barney

J B Wood (Zumwalt)

Unfortunately, EBasic doesn't support inline comments with the single quote at the moment.
So you have to go through the code and move those commends to either above or below but on there own lines.
Very nice to have item though for converting :)
Now, if search/replace would be able to take a " '" and add a chr(13) or chr(10) to the begining (carraige return), it would simplify things :)

Barney

January 02, 2007, 10:57:31 AM #35 Last Edit: January 02, 2007, 11:04:00 AM by Barney
Hmmm.. it seems you are wrong on that one, Jonathan. This compiles and runs properly:

' ******************************************************************
'                         Mathematical constants
' ******************************************************************

CONST Pi         = 3.141592653589793   ' Pi
CONST Ln2        = 0.6931471805599453  ' Ln(2)
CONST Ln10       = 2.302585092994046   ' Ln(10)
CONST LnPi       = 1.1447298858494     ' Ln(Pi)
CONST InvLn2     = 1.442695040888963   ' 1/Ln(2)
CONST InvLn10    = 0.4342944819032518  ' 1/Ln(10)
CONST TwoPi      = 6.283185307179586   ' 2*Pi
CONST PiDiv2     = 1.570796326794897   ' Pi/2
CONST SqrtPi     = 1.772453850905516   ' Sqrt(Pi)
CONST Sqrt2Pi    = 2.506628274631001   ' Sqrt(2*Pi)
CONST InvSqrt2Pi = 0.3989422804014327  ' 1/Sqrt(2*Pi)
CONST LnSqrt2Pi  = 0.9189385332046728  ' Ln(Sqrt(2*Pi))
CONST Ln2PiDiv2  = 0.9189385332046728  ' Ln(2*Pi)/2
CONST Sqrt2      = 1.414213562373095   ' Sqrt(2)
CONST Sqrt2Div2  = 0.7071067811865476  ' Sqrt(2)/2
CONST Gold       = 1.618033988749895   ' Golden Mean (1 + Sqrt(5))/2
CONST CGold      = 0.3819660112501052  ' 2 - Gold

' ******************************************************************
'                         Mathematical constants
' ******************************************************************

PRINT "Pi         = ",Pi
PRINT "Ln2        = ",Ln2
PRINT "Ln10       = ",Ln10
PRINT "LnPi       = ",LnPi
PRINT "InvLn2     = ",InvLn2
PRINT "InvLn10    = ",InvLn10
PRINT "TwoPi      = ",TwoPi
PRINT "PiDiv2     = ",PiDiv2
PRINT "SqrtPi     = ",SqrtPi
PRINT "Sqrt2Pi    = ",Sqrt2Pi
PRINT "InvSqrt2Pi = ",InvSqrt2Pi
PRINT "LnSqrt2Pi  = ",LnSqrt2Pi
PRINT "Ln2PiDiv2  = ",Ln2PiDiv2
PRINT "Sqrt2      = ",Sqrt2
PRINT "Sqrt2Div2  = ",Sqrt2Div2
PRINT "Gold       = ",Gold
PRINT "CGold      = ",CGold

DO:UNTIL INKEY$ <> ""
END


Actually I am already well on the way with changing the math.bi file. There are some small issues, which FreeBasic handles differently than EBasic but nothing that could not be solved relatively easily and quickly. Also, some of the functions are already implemented in EBasic.

Barney

J B Wood (Zumwalt)

Odd, ok, will re-install ebasic from scratch them, I probably have mixed dll's or something.
I can't get inline comments to compile without errors on my version. *shrugs* typically something stupid on my pc.

paravantis

Barney,

Make sure you post a message, possibly on a new thread, when you are done with conversion to eBasic of any of the modules of fbmath.

I was thinking, if we get a group of people to collaborate on translating fbmath to eBasic (not that the translation is a difficult task, mostly because I imagine that many of us may not have much free time), we could let Paul include it as part of the standard eBasic package (it would always have to be a freeware component though)!

Judging from the appeal of fbmath, this might make eBasic a more attractive product to quite a few people.

Dennisc

Hey - well done guys. I like John's suggestion to have a MathPac as a freeware download add-on to EBasic.

Dennis
Failure is only the opportunity to begin again more intelligently
www.denniscomninos.com

paravantis

Maybe Paul himself would like to take on part of the task of translating fbmath to eBasic.

That should keep him off the night life for a while  ;D

John S

Quote from: paravantis on January 02, 2007, 11:38:53 AM
Barney,
Make sure you post a message, possibly on a new thread, when you are done with conversion to eBasic of any of the modules of fbmath...

I was thinking, if we get a group of people to collaborate on translating fbmath to eBasic (not that the translation is a difficult task, mostly because I imagine that many of us may not have much free time), we could let Paul include it as part of the standard eBasic package (it would always have to be a freeware component though)!

Judging from the appeal of fbmath, this might make eBasic a more attractive product to quite a few people.

I've requested that Vikki & GWS (Graham) create either a sticky topic or new heading in "The Roundtable" area.

You are right - if a bunch of us start working on individual files, we can convert the whole thing in no time.
John Siino, Advanced Engineering Services and Software

Jerry Muelver

I'm a text guy, and don't know a cosine from an asymptote, so if you guys run into a snag and need some help, you'll probably have to look up this guy for some pointers:
http://www.theonion.com/content/node/38718

John S

Quote from: Jerry Muelver on January 02, 2007, 06:59:04 PM
...you'll probably have to look up this guy for some pointers:  http://www.theonion.com/content/node/38718

He's busy right now, but perhaps in two years, he'll have more time.   ;D
John Siino, Advanced Engineering Services and Software

paravantis

Quotehttp://www.theonion.com/content/node/38718

It was SOOO good, I could not resist forwarding the link to a couple of old friends in the US...