ErosOlmi
03-07-2010, 12:04
Next thinBasic beta release will have JOIN$ working also on matrix.
It will be possible to inindicate element and row separators plus format for numeric elements.
Example
Uses "console"
Uses "math"
Dim MaxX As Long = 3
Dim MaxY As Long = 3
PrintL "Defining matrix a and b:", MaxX, "by", MaxY
Dim a(MaxX, MaxY) As Double
Dim b(MaxX, MaxY) As Double
PrintL "Filling matrix a with", Format$(MaxX * MaxY), "numbers"
'---Note row order filling
a() = ( 1, 1, 2,
1, 2, 4,
2, -1, 0 )
PrintL "Inverting matrix a to b"
MAT b() = INV(a())
PrintL
PrintL "A is---------------------"
PrintL Join$(a, $TAB, $CRLF, " 00.0;-00.0; 00.0")
PrintL
PrintL "B is---------------------"
PrintL Join$(b, $TAB, $CRLF, " 00.0;-00.0; 00.0")
WaitKey
Will output:
Defining matrix a and b: 3 by 3
Filling matrix a with 9 numbers
Inverting matrix a to b
A is---------------------
01.0 01.0 02.0
01.0 02.0 04.0
02.0 -01.0 00.0
B is---------------------
02.0 -01.0 00.0
04.0 -02.0 -01.0
-02.5 01.5 00.5
It will be possible to inindicate element and row separators plus format for numeric elements.
Example
Uses "console"
Uses "math"
Dim MaxX As Long = 3
Dim MaxY As Long = 3
PrintL "Defining matrix a and b:", MaxX, "by", MaxY
Dim a(MaxX, MaxY) As Double
Dim b(MaxX, MaxY) As Double
PrintL "Filling matrix a with", Format$(MaxX * MaxY), "numbers"
'---Note row order filling
a() = ( 1, 1, 2,
1, 2, 4,
2, -1, 0 )
PrintL "Inverting matrix a to b"
MAT b() = INV(a())
PrintL
PrintL "A is---------------------"
PrintL Join$(a, $TAB, $CRLF, " 00.0;-00.0; 00.0")
PrintL
PrintL "B is---------------------"
PrintL Join$(b, $TAB, $CRLF, " 00.0;-00.0; 00.0")
WaitKey
Will output:
Defining matrix a and b: 3 by 3
Filling matrix a with 9 numbers
Inverting matrix a to b
A is---------------------
01.0 01.0 02.0
01.0 02.0 04.0
02.0 -01.0 00.0
B is---------------------
02.0 -01.0 00.0
04.0 -02.0 -01.0
-02.5 01.5 00.5