Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 05:14 29 Mar 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : READ Matrix Command

Author Message
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 323
Posted: 11:34am 31 Jul 2021
Copy link to clipboard 
Print this post

Since some features are still in beta, would it be possible to bring CMM2 in line with other BASICs that have a MAT READ and vary the column faster than the row? I don't think that many programs have been written yet that this change would break while there have been thousands of programs that need rewriting as it is now.

In other BASICs:

DIM A(2,2)
MAT READ A
DATA 1,2,3,4
MAT PRINT A

1     2
3     4


In CMM2 BASIC

DIM A(2,2)
READ A()
DATA 1,2,3,4
MATH M_PRINT A()

1    3
2    4

Edited 2021-07-31 21:37 by toml_12953
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8516
Posted: 11:57am 31 Jul 2021
Copy link to clipboard 
Print this post

  Quote  In CMM2 BASIC


?


 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 323
Posted: 02:28pm 31 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  
  Quote  In CMM2 BASIC


Something is different:

option base 1
dim a(3,3)
read a() ' MAT READ A in Standard BASIC
data 1,2,3,4,5,6,7,8,9
for r=1 to 3
for c=1 to 3
print a(r,c),
next c
print
next r

Output in MMC2
1     4     7
2     5     8
3     6     9

Output in Standard
1     2     3
4     5     6
7     8     9
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8516
Posted: 02:44pm 31 Jul 2021
Copy link to clipboard 
Print this post

As I've explained in all matrix operations in MMBasic the fastest moving dimension is the first.  Everything is self consistent. For your program just reverse the indices in your for loops. This isn't going to change.

From the manual
  Quote  Note:
2 dimensional maths matrices are always specified DIM matrix(n_columns,
n_rows) and of course the dimensions respect OPTION BASE.

Edited 2021-08-01 01:38 by matherp
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024