It offers two new variable types: vector and matrix (LA_V and LA_M = linear algebra matrix). In the FB source code they can be used like any variables with operators like '+', '*' or '/' (but mind the linear algebra rules). Here's an example code on how to use it:
Code: Select all
#INCLUDE "libFBla.bas"
#DEFINE english
' used to print out headers and values
#MACRO HEADER(_G_, _E_, _T_)
#IFDEF english
?:?_E_
#ELSE
?:?_G_
#ENDIF
?_T_
#ENDMACRO
HEADER("Loesung eines linearen Gleichungssystemes", _
"Solution of a linear equation system", "")
?" 3x - 3y + z = 0"
?" + 4y - z = 5"
?" 2x - 2y + z = 1"
VAR A = LA_M("3, -3, 1" NL _
"0, 4, -1" NL _
"2, -2, 1")
HEADER("Koeffizientenmatrix A:", _
"Coefficient matrix A:", A)
VAR B = LA_V("0, 5, 1")
HEADER("Loesungsvektor B:", _
"Solution vector B:", B)
VAR r = B / A
HEADER("Ergebnisvektor r = B / A:", _
"Result vector r = B / A:", r)
HEADER("Ergebnisse:", _
"Results:", "")
?"x = ";r.Val_(0)
?"y = ";r.Val_(1)
?"z = ";r.Val_(2)
HEADER("Matrizenrechnung", _
"Matrix algebra", "")
VAR m1 = LA_M( _
".11, .12, .13" NL _
".21, .22, .23")
?"m1:" : ?m1
VAR m2 = LA_M( _
"11, 12" NL _
"21, 22" NL _
"31, 32")
?"m2:" : ?m2
VAR m3 = m1 * m2
?"m3 = m1 * m2:" : ?m3
#IFNDEF __FB_UNIX__
SLEEP
#ENDIF
- The library is based on a user defined real type (ie SINGLE or DOUBLE). By changing this type the library can be adjusted to meet custom needs regarding execution speed and precision (ie: REAL10, QUAD, COMPLEX, ...).
- The new types vector and matrix are variable in size (they can shrink or grow anywhere in the code).
- The new types can be used at modul level as well as inside UDTs (without limits).
- Easy initialisation of vectors and matrices.
- Alot of (all?) operators predefined.
- Variable soft- error handling (report and stop -- only warn -- ignore).
- Easy output with PRINT, custom output format.
Feel free to post your comments and bug reports here.