Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Math library for Free Basic
#11
Hello,

I have just added a solver for linear equations (Gauss-Jordan method):
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip

Solvers for non-linear equations (Newton-Raphson) will follow.

Question: is it necessary to add $DYNAMIC in a procedure which uses local dynamic arrays, to ensure that these arrays are correctly deallocated at the end of the procedure? I have never used this directive in my QB programs, nor in this solver.

Thanks in advance,

Jean Debord
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#12
If you have dynamic arrays, and you allocate them at the beginning of a SUB procedure, you have to deallocate them at the end with ERASE.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#13
Deallocation is done automatically with local dynamic arrays.

But they don't need to be dynamic, keep using static arrays (DIM'ed), access is much faster, as they are allocated on stack - that is by default 1MB, what can be changed using the command-line option "-t 4096" for a 4MB stack, for example.
Reply
#14
Oh, that's cool. QB ran out of memory if you didn't take care of deallocating Dynamic stuff... Not really sure about it, but when I added those ERASEs my games worked Tongue
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#15
Quote:Deallocation is done automatically with local dynamic arrays

Thanks. So, I was right by not using $DYNAMIC Smile

Quote: keep using static arrays (DIM'ed), access is much faster

OK. But it is difficult in scientific applications. In most cases the array size is known only at run time.
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#16
Hello,

I have added some non-linear optimization routines:

* golden search
* minimization along a line
* Newton-Raphson

More routines will be added soon.

Best regards,

Jean Debord
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#17
I am experiencing difficulties with FB 0.11. The compilations go well, but the PRINT USING statement does not work anymore, so that the output of my programs are very ugly !

There was no problem with FB 0.10

Thanks in advance for correcting this bug.

Jean Debord
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#18
AFAIK PRINT USING has never worked. Is in the unsupported keywords list.
V0.11 is using more digits to print DOUBLES than V0.10...
Antoni
Reply
#19
The following program works in QB but not in FB 0.11

Code:
DIM X AS DOUBLE

X = 1.23456789

PRINT USING "##.########"; X  ' Should print 1.23456789
PRINT USING "##.####"; X      ' Should print 1.2346
PRINT USING "##.###"; X       ' Should print 1.235

DO: LOOP UNTIL INKEY$ <> ""

With FB 0.11, the program prints the whole number of digits, regardless of the format string.

It seems that FB does not round the number before printing it.
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#20
Maybe I have not written QB program for ages, now I find it is difficult to remember and use Basic's 'print using' than C's 'printf format string'. Perhaps it is not easy to achieve printf-like in fbc since it is written in fbc itself, but who knows :wink:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)