[bug #48564] Octave does not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)"
Nicholas Jankowski <[email protected]>
| Newsgroups | gmane.comp.gnu.octave.bugs |
|---|---|
| Message-ID | <[email protected]> |
Please use the bug tracker to post updates to a bug report. The mailing list is intended as a read-only notification stream. Info posted to this mailing list address won't appear in the tracker database where it is most useful.
Follow-up Comment #16, bug #48564 (group octave):
ok, trying again
mrdivide:
x = B/A solves the system of linear equations x*A = B for x. The matrices A
and B must contain the same number of columns. MATLAB® displays a warning
message if A is badly scaled or nearly singular, but performs the calculation
regardless.
If A is a scalar, then B/A is equivalent to B./A.
If A is a square n-by-n matrix and B is a matrix with n columns, then x = B/A
is a solution to the equation x*A = B, if it exists.
If A is a rectangular m-by-n matrix with m ~= n, and B is a matrix with n
columns, then x = B/A returns a least-squares solution of the system of
equations x*A = B.
defined behavior only address behavior for A being 2D. for any 2D A (not just
square), you get an attempt to solve B/A which will run into nonconformant
dimension errors. so needs to apply to any 2D A.
if ndim > 3, it reverts to elementwise division, but this is undocumeted.
and if any of the dims are empty, it seems a bit odd:
I'm guessing it leads with an 'if ismatrix do matrixsolve else elementwise
division' check.
see:
matlab 2025a:
>> 9 / rand(1,3)
Error using /
Matrix dimensions must agree.
>> 9 / rand(3,1)
ans =
0 0 12.0855
>> 9 / rand(2,2)
Error using /
Matrix dimensions must agree.
>> 9 / rand(2,4)
Error using /
Matrix dimensions must agree.
>> 9 / rand(4,2)
Error using /
Matrix dimensions must agree.
>> 9 / rand(3)
Error using /
Matrix dimensions must agree.
>> 9 / rand(3,2,2)
ans(:,:,1) =
19.1114 46.2097
39.0476 39.8368
10.6596 52.7216
ans(:,:,2) =
39.5319 9.7468
20.6565 20.9201
28.9294 48.6970
>> 9 / rand(3,2,1)
Error using /
Matrix dimensions must agree.
>> 9 / rand(3,0,1)
Error using /
Matrix dimensions must agree.
>> 9 / rand(3,0,2)
ans =
3×0×2 empty double array
>> 9 / rand(3,2,0)
ans =
3×2×0 empty double array
>> 9 / rand(3,1,0)
ans =
3×1×0 empty double array
current octave output:
octave:1> 9/rand(1,3)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 1x3)
octave:2> 9/rand(3,1)
ans =
0.8999 3.8746 7.8228
octave:3> 9/rand(2,2)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 2x2)
octave:4> 9/rand(2,4)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 2x4)
octave:5> 9/rand(4,2)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 4x2)
octave:6> 9/rand(3)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x3)
octave:7> 9/rand(3,2,2)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x4)
octave:8> 9/rand(3,2,1)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x2)
octave:9> 9/rand(3,0,1)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x0)
octave:10> 9/rand(3,0,2)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x0)
octave:11> 9/rand(3,2,0)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x0)
octave:12> 9/rand(3,1,0)
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x0)
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?48564>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaZYgmQAKCRCqLAuaBUf3 Th+fAP0cjB32IGcm3LmC1xIlpB5Delm2IQowOroOhbJTasB2/AD/VUCQpQ/8K3nz +obrIcxU9196175uIVvWPoNjqQnwdQ4= =TxgN -----END PGP SIGNATURE-----