Qbasicnews.com
January 26, 2021, 03:06:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 3 [4]
  Print  
Author Topic: Math library for Free Basic  (Read 48101 times)
keeling
Forum Regular
**
Posts: 149



WWW
« Reply #45 on: March 15, 2005, 07:56:57 PM »

GREAT

I'll be interested in seeing what happens.
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #46 on: March 15, 2005, 09:51:00 PM »

Bad news.. gsl has many functions that return structs, not ptr to structs, what FB doesn't support atm.

To support that, the GCC ABI must be followed, or nothing will work..
Logged

jdebord
Member
*
Posts: 60


WWW
« Reply #47 on: March 16, 2005, 12:44:22 PM »

Quote from: "diakin"
Math functions, Math-Expression Evaluators etc
Rapid-Q
http://groups.yahoo.com/group/Rapid-Q/files/math.zip


Thanks for pointing to this archive. Here are some comments on the programs contained in it and their compatibility with FB and FBMath:

* calc.zip : Calculator - portable to FB?

* CubicEquation.zip : FBMath allows complex roots and higher degrees.

* LinearSolver.zip : Gauss-Jordan method is already in FBMath. Polynomial regression is planned (I have already working codes in QB and VB, but I have to improve the graphics).

* rq_math.zip : most functions for real variables are already in FBMath. Complex functions will be added soon.

* simplex.zip : simplex method for linear programming. This one should be interesting to port to FB (FBMath has already the simplex method for NONlinear optimization, because I use it in my work ;-))

* TrigSolver.zip : may be interesting to port to FB, too.

The other programs are parsers. Since several parsers have already been implemented in FB, it seems wiser to use them.
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
diakin
Member
*
Posts: 72



WWW
« Reply #48 on: March 17, 2005, 10:48:41 AM »

I don't use this progs,  just collect its and zip.

Edit

Also possible useful

http://www.wildgardenseed.com/RQDP/custom/func_array.htm
ARRAverageSubtract
ARRAverage
ARRMax
ARRMin
ArrExtr (Max and Min)
ArrRaznost
ArrRaznostR
ArrSum
ArrSumR
kTArray
kTArrayR
Nakopl-Calculate average of function by moving window  
LoadArray
SaveArray
ARRAddConst
ArrReSample 'Resample with interpolation
OgibF-build envelope - up and down


Also
SUB io2RndInter1 (io$, rndf$, LostP)
'convert text file with the two-fields per string "point,data" format
' to binary format file with interpolation of missed points
' and with averaging-out of extra points
' points sequence can be to increase or to decrease
' outputs two binary files - argue (point number) and function (point value)

http://www.wildgardenseed.com/RQDP/FreeBasic/rqSub.zip
Logged

ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
keeling
Forum Regular
**
Posts: 149



WWW
« Reply #49 on: March 21, 2005, 08:42:32 PM »

Jean,

Are you going to impliment more elementary functions in the library?

For example the floor, ceiling, and round? What follows are limited versions that aren't well tested but should give an idea.

Code:

Function Round (x as double, Digit_Count as integer = 0) as double
   dim MaxRoundPlaces as integer
   MaxRoundPlaces = 16
   dim ReturnAnswer as double
   ReturnAnswer = 0
   
   If (Digit_Count >= 0) and (Digit_Count < MaxRoundPlaces) then
      Dim Dec_Place as double
      Dec_Place = 10 ^ Digit_Count
      ReturnAnswer = int((abs (x) * Dec_Place) + 0.5)
      ReturnAnswer = Sgn(x) * ReturnAnswer / Dec_Place
   else
      'raise an error
   end if
   Round = ReturnAnswer
End Function

Function Ceil (x as double) as integer
   Dim ReturnAnswer as integer
   ReturnAnswer = int(x)
   if ReturnAnswer < x then ReturnAnswer = ReturnAnswer + 1
   Ceil = ReturnAnswer
End Function

Function Floor (x as Double) as integer
   Dim ReturnAnswer as integer
   ReturnAnswer = int(x)
   if ReturnAnswer > x then ReturnAnswer = ReturnAnswer - 1
   Floor = ReturnAnswer
End Function


Also, would you be open to expanding the constants list?
Logged
jdebord
Member
*
Posts: 60


WWW
« Reply #50 on: March 22, 2005, 06:48:57 AM »

Of course,  all contributions are welcome  Tongue

I will check your rounding routines and add them to the library.

Feel free to add constants, too. If possible, use the following format:

#DEFINE Pi 3.14159...
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
jdebord
Member
*
Posts: 60


WWW
« Reply #51 on: March 28, 2005, 06:42:29 AM »

I have set up a Yahoo group for this library. It is located at:

http://groups.yahoo.com/group/fbmathlib/

In addition, the group will serve as a repository for the code snippets which are posted here from time to time and may be of interest for the library users. I have already placed 4 of these snippets in the "Files" section of the group (math parsers, color constants, date functions).
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
diakin
Member
*
Posts: 72



WWW
« Reply #52 on: March 29, 2005, 06:15:23 AM »

Quote from: "jdebord"
I have set up a Yahoo group for this library. It is located at:

http://groups.yahoo.com/group/fbmathlib/
[...]


I think Yahoo group better than forum in any case  :wink:
I can receive all message via e-mail and  store and find  on local disk.
Logged

ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
jdebord
Member
*
Posts: 60


WWW
« Reply #53 on: April 03, 2005, 04:48:09 AM »

Quote from: "keeling"

For example the floor, ceiling, and round? What follows are limited versions that aren't well tested but should give an idea.


Here is a slightly modified version, with a short demo program:

Code:

' Function Round (x as double, Digit_Count as integer = 0) as double
   const MaxRoundPlaces = 16
   dim ReturnAnswer as double
   ReturnAnswer = 0
   
   If (Digit_Count >= 0) and (Digit_Count < MaxRoundPlaces) then
      Dim Dec_Place as double
      Dec_Place = 10 ^ Digit_Count
      ReturnAnswer = int((abs (x) * Dec_Place) + 0.5)
      ReturnAnswer = Sgn(x) * ReturnAnswer / Dec_Place
   end if
   Round = ReturnAnswer
End Function

Function Ceil (x as double) as integer
   Dim ReturnAnswer as integer
   ReturnAnswer = int(x)
   if ReturnAnswer < x then ReturnAnswer = ReturnAnswer + 1
   Ceil = ReturnAnswer
End Function

Function Floor (x as Double) as integer
   Dim ReturnAnswer as integer
   ReturnAnswer = int(x)
   if ReturnAnswer > x then ReturnAnswer = ReturnAnswer - 1
   Floor = ReturnAnswer
End Function
 
' *************************************************************

option explicit

dim as double  x, h
dim as integer i

' The h value was chosen because it does not have an exact
' binary expansion, so that it generates some rounding errors
h = 0.1

for i = 0 to 10
  x = i * h
  ? x, tab(25), Round(x, 6), Ceil(x), Floor(x)
next i

sleep



I will add these functions to the library.

Thanks for this useful contribution.
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
jdebord
Member
*
Posts: 60


WWW
« Reply #54 on: April 07, 2005, 05:21:43 AM »

The library has been updated:

* Added rounding functions (contributed by R. Keeling)
* Added Lambert function
* New demo program: function plotter
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
jdebord
Member
*
Posts: 60


WWW
« Reply #55 on: April 30, 2005, 01:48:54 PM »

The library has been updated. I have added probability functions, some statistical functions, and random number generators.

This version is for FB 0.13b Windows. Some programs may not work with the DOS and Linux versions.
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #56 on: May 04, 2005, 01:44:48 AM »

add a #inclib "math" to the include .bi file and people won't have to bother with the -l math. :wink:
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
jdebord
Member
*
Posts: 60


WWW
« Reply #57 on: May 04, 2005, 03:15:21 PM »

Quote from: "dumbledore"
add a #inclib "math" to the include .bi file and people won't have to bother with the -l math. :wink:


OK. It will be in the next update.
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
Pages: 1 2 3 [4]
  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!