# Matrix

``` BBS: Inland Empire Archive
Date: 05-02-92 (19:01)             Number: 136
From: PAUL LEONARD                 Refer#: NONE
To: RICHARD VANNOY                Recvd: NO
Subj: Matrix                         Conf: (2) Quik_Bas```
```On or about <May 01 19:40>, Richard Vannoy (1:105/314) scribbled:

RV>     MatrixA           MatrixB          MatrixC

RV>  4  5  6  3  2     6  5  4  3  0     E M P T Y
RV>  3  2  3  4  5     5  4  3  3  3
RV>  2  1  0  6  9     5  2  1  0  4

RV> so, something like...

RV> MAT(C) = MAT(A) * MAT(B)

(nit-picking mode on)

My linear algebra's a bit rusty, but i don't think you can multiply the
matrices in your example.  If A is rA x cA (rA rows by cA
columns), and B is rB x cB, then cA must equal rB in order
to multiply the two matrices.  This is because the
elements of C are formed by multiplying the rows of A by
the columns of B, with C being rA x cB (i learned this by
thinking of the two equal dimensions needing to "canceling
out").  This is why, in general, AB <> BA.  AB is rA x cB
and BA is rB x cA.

(nit-picking mode off)

(For Randy Baer)
I was once put through the matrix multiplication wringer by
a negative student evaluation of his class and vengefully
assigned a nasty stew of matrix manipulation (without MAT
functions), statistical analysis and formatting.  Anyway,
the bare bones of the matrix multiplication are...

DIM mat.a%(rA%,cA%)
DIM mat.b%(rB%,cB%)
DIM mat.c%(rA%,cB%)

FOR i%=1 TO rA%
FOR j%=1 TO cB%
FOR k%=1 TO cA%     '(or rB%)
mat.c%(i%,j%) = mat.c%(i%,j%) + (mat.a%(i%,k%) * mat.b%(k%,j%))
NEXT k%
NEXT j%
NEXT i%

I also found a few more Basic-Plus2 MAT functions while
digging through the on-line help trying to confirm the
above.  They are...

DET  - Returns determinant of a matrix
NUM  - Returns number of rows entered into a matrix with MAT INPUT
NUM2 - Returns number of elements in last row entered
TRN  - Creates the transpose of a matrix

ptl

--- msged 2.07
* Origin: PTL Pointwork (1:105/48.111)
``` Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET