- PowerBASIC MAT
- HP BASIC MAT =/INPUT/PRINT/READ
- Wang BASIC MAT
![Image](http://www.benryves.com/bin/bbcbasic/2009.07.24.01.gif)
Moderator: benryves
Why not just go with one of the implementations you list? Those are very good (especially the Wang) One thing, though. the operation of the determinant function, DET, is slightly different in different compilers. In some, DET takes no parameters. It only retuns the determinant of the most recently inverted matrix. In order to find the determinant of array A, you'd need to do thisbenryves wrote:I'm wondering if people had any requirements or suggestions for the MAT statement. There are some limitations I have to work with; for example, any matrix operation must be prefixed with MAT, and matrices are not efficiently resizeable as BBC BASIC only stores the current size, not the maximum size (matrices could be shrunk, but not expanded, without leaking memory).
Code: Select all
MAT T = INV(A)
PRINT DET
Code: Select all
PRINT DET(A)
Code: Select all
MAT d=DET(a())
But DET is a single number, not a matrix. It's used to determine how "good" an inversion is. The larger DET is, the better the inversion; the less loss of precision. If DET is zero, then either the matrix is singular (has no inverse) or its inverse is useless due to lost precision.benryves wrote:The following could work:however, you would not be able to use DET() as a regular function, eg in a PRINT statement.Code: Select all
MAT d=DET(a())
Code: Select all
MAT d=DET(a())
The standards and conventions are very clear on this. Here's a quote from a BASIC manual:benryves wrote:Point taken.I shall use the parameterless DET method, then.
What is your view on the different dimensions of arrays? For some operations it wouldn't really matter, I suppose (ZER or CON) and with some it would be nonsensical (assigning a one-dimensional array to a two-dimensional array), but what would you expect to happen if, say, you multiplied a one-dimensional array with a two-dimensional one?
I don't know if you're planning on implementing this or not butbenryves wrote:I'm sure there will be bugs in the features I've implemented above, so please let me know when you find them!
Code: Select all
MAT PRINT A;
Code: Select all
MAT PRINT A (or A,)
Code: Select all
MAT A=B
Not in standard BASIC. Maybe you can eliminate the check for parens when MAT is used. That might free up some space.benryves wrote:I have also added the compacted form of MAT PRINT a; - is there any accepted way to suppress the line feed between PRINTed matrices?
Code: Select all
10 DIM A(2,2)
20 MAT A=IDN
30 MAT PRINT A;
It would free some space, but not a considerable amount. I'll see what I can do.toml_12953 wrote:Maybe you can eliminate the check for parens when MAT is used. That might free up some space.
Whoops, sorry. Build 761 fixes that (a rather overzealous optimisation).When I tried this:I getCode: Select all
10 DIM A(2,2) 20 MAT A=IDN 30 MAT PRINT A;
011
111
111
instead of the correct
100
010
001
Maybe you could eliminate Revision 752benryves wrote:I have also modified quite a lot of the code to try and gain a little more space; I'm down to 490 bytes to squeeze the inversion/determinant code in, which is more than a little tight!
Code: Select all
MAT X = A * X