Elijah 2 Newbie
 Joined: 08/03/2025 Location: United StatesPosts: 10 |
| Posted: 05:09pm 08 Mar 2025 |
|
|
|
Hi all, I'm a new member but have been using MMBasic for a bit. I've found a bug (I think) with the Math M_Mult command. It seems to be using the Bound() of the wrong dimension when computing a product matrix with M_Mult; thus this bug doesn't manifest when multiplying square matrices.
Here is code the demos the bug:
Dim Float A(1, 6), TransA(6, 1), ProdA(6, 6)
Math Set 1, A() A(1, 0) = 0 : A(1, 1) = 2 : A(1, 2) = 3 : A(1, 3) = 4 A(1, 4) = 5 : A(1, 5) = 7 : A(1, 6) = 8
Math M_Transpose A(), TransA() Math M_Mult A(), TransA(), ProdA()
Math M_Print A() : Print Math M_Print TransA() : Print Math M_Print ProdA()
Actual Output:
1.0000, 0.0000 1.0000, 2.0000 1.0000, 3.0000 1.0000, 4.0000 1.0000, 5.0000 1.0000, 7.0000 1.0000, 8.0000
1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000 0.0000, 2.0000, 3.0000, 4.0000, 5.0000, 7.0000, 8.0000
1.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 1.0000, 5.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 1.0000, 7.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 1.0000, 9.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 1.0000, 11.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 1.0000, 15.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000 1.0000, 17.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000
Expected Output for ProdA():
1 1 1 1 1 1 1 1 5 7 9 11 15 17 1 7 10 13 16 22 25 1 9 13 17 21 29 33 1 11 16 21 26 36 41 1 15 22 29 36 50 57 1 17 25 33 41 57 65
You can see that the first two columns of output for ProdA() are correct. If I were to make A() have three columns, the first three would be correct. It's a little confusing because in code you dim A(cols, rows) but in math it's rows x cols. Maybe that's why the bug exists to begin with
If some of the other forum members can confirm this is a bug, I'd appreciate it.
Peter, sorry for emailing you directly about this. I honestly didn't think there was anyway I'd get a working membership on this forum, but it let me register (after a lot of leg work ).
Thanks all! |