PDA

View Full Version : Help file: JOIN$ sample



Petr Schreiber
20-10-2011, 15:10
Second sample code for JOIN$ (titled "Example working on matrix") uses obsolete syntax, it should be the following.

Important note, possible bug?:
Although I use [ ] to force row order assignment, the output of JOIN$ looks like column order (1, 2, 3 is not in first row, but in first column).
This is not problem of row order assignment, but of JOIN$, but maybe I am missing something.



' Usage of the JOIN$ Keyword with matrix
Uses "console", "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"

a(1, 1) = [ 1, 0, 5,
2, 1, 6,
3, 4, 0 ]

PrintL "Inverting matrix a to b"

MAT b() = INV(a())

PrintL
PrintL "A is---------------------"
PrintL Join$(a, $TAB, $CRLF)

PrintL
PrintL "B is---------------------"
PrintL Join$(b, $TAB, $CRLF, " 00.0;-00.0; 00.0")

WaitKey


Petr

ErosOlmi
23-10-2011, 12:54
Example amended.

The problem is that JOIN$ does not anything about how the matrix is filled because row/column assignment is not saved into matrix. And row/column assignment can change at every assignment.

I have to think about how to solve this problem, maybe setting row/column as a characteristic of the matrix.

Opened a feature request: http://www.thinbasic.com/community/project.php?issueid=326

Petr Schreiber
23-10-2011, 15:44
Hi Eros,

maybe it is problem just in my head - in matrix calculus, the first index is row and second column.
But when working with 2D array, I think most people think of the first index as "x" (=column) and second "y" (=row).


Petr