[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #48564] Octave does not accept "1 / ND array",
From: |
Philip Nienhuis |
Subject: |
[Octave-bug-tracker] [bug #48564] Octave does not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)" |
Date: |
Wed, 20 Jul 2016 10:14:24 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0 |
Update of bug #48564 (project octave):
Summary: Octave does not accept 1 / ND array => Octave does
not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)"
_______________________________________________________
Follow-up Comment #3:
Thanks John.
As the Matlab docs are unclear about right division by an array of arbitrary
dimensions, I experimented a bit more.
It turns out that mrdivide, rdivide and "/", and for that matter, mldivide
too, all perform element-by-element division for anything except square
matrices. Obvious as that's the only useful outcome for arbitrary arrays.
Matlab r2016b prerelease:
+verbatim-
>> format long
>> format compact
>> MX = rand (3, 3, 3)
MX(:,:,1) =
0.327565434075205 0.833500595588975 0.861980478702072
0.671264370451740 0.768854252429615 0.989872153631504
0.438644982586956 0.167253545494722 0.514423456505704
MX(:,:,2) =
0.884281023126955 0.199862822857452 0.825583815786156
0.588026055308498 0.406954837138907 0.789963029944531
0.154752348656045 0.748705718215691 0.318524245398992
MX(:,:,3) =
0.534064127370726 0.136292548938299 0.189710406017580
0.089950678770581 0.678652304800188 0.495005824990221
0.111705744193203 0.495177019089661 0.147608221976689
>> (1 / MX) - mrdivide (1, MX)
ans(:,:,1) =
0 0 0
0 0 0
0 0 0
ans(:,:,2) =
0 0 0
0 0 0
0 0 0
ans(:,:,3) =
0 0 0
0 0 0
0 0 0
>> (1 / MX) - rdivide (1, MX)
ans(:,:,1) =
0 0 0
0 0 0
0 0 0
ans(:,:,2) =
0 0 0
0 0 0
0 0 0
ans(:,:,3) =
0 0 0
0 0 0
0 0 0
>> (1 / MX) - mldivide (MX, 1)
ans(:,:,1) =
0 0 0
0 0 0
0 0 0
ans(:,:,2) =
0 0 0
0 0 0
0 0 0
ans(:,:,3) =
0 0 0
0 0 0
0 0 0
For square matrix:
>> SMX = rand (2, 2)
SMX =
0.054974146906188 0.560559527354885
0.850712674289007 0.929608866756663
>> 1 / SMX
Error using /
Matrix dimensions must agree.
>> 1 ./ SMX
ans =
18.190368678325679 1.783931859509561
1.175485014180330 1.075721236920778
>> rdivide (1, SMX)
ans =
18.190368678325679 1.783931859509561
1.175485014180330 1.075721236920778
>> mrdivide (1, SMX)
Error using /
Matrix dimensions must agree.
>> mldivide (SMX, 1)
Error using \
Matrix dimensions must agree.
Octave-4.1.0+ does:
+verbatim-
>> 1 / MX
error: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x9)
>> mrdivide (1, MX)
error: mrdivide: operator /: nonconformant arguments (op1 is 1x1, op2 is 3x9)
>> rdivide (1, MX)
ans =
ans(:,:,1) =
3.05282516399582 1.19975919068585 1.16011908008143
1.48972602154801 1.30063662500396 1.01023146911583
2.27974795038665 5.97894649731989 1.94392379926188
ans(:,:,2) =
1.13086221896275 5.00343178237420 1.21126405445310
1.70060491533044 2.45727512917771 1.26588202497301
6.46193746773186 1.33563825635417 3.13947843671169
ans(:,:,3) =
1.87243431780963 7.33715825105533 5.27119213432779
11.11720349048724 1.47350858890021 2.02017824743730
8.95209111422619 2.01947982529240 6.77469037028254
>> mldivide (MX, 1)
error: mldivide: operator \: nonconformant arguments (op1 is 3x9, op2 is
1x1)>>
Is "Matlab compatibility" the proper Item Group or should it rather be one of
"Feature request", "WTF, Matlab?!?" or "Incorrect result"?
And do you want a separate bug report for the ND to 2x2 array conversion?
<title adapted>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?48564>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #48564] Octave does not accept 1 / ND array, Philip Nienhuis, 2016/07/19
- [Octave-bug-tracker] [bug #48564] Octave does not accept 1 / ND array, Philip Nienhuis, 2016/07/19
- [Octave-bug-tracker] [bug #48564] Octave does not accept 1 / ND array, John W. Eaton, 2016/07/19
- [Octave-bug-tracker] [bug #48564] Octave does not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)",
Philip Nienhuis <=
- [Octave-bug-tracker] [bug #48564] Octave does not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)", John W. Eaton, 2016/07/20
- [Octave-bug-tracker] [bug #48564] Octave does not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)", John W. Eaton, 2016/07/20
- [Octave-bug-tracker] [bug #48564] Octave does not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)", Philip Nienhuis, 2016/07/20
- [Octave-bug-tracker] [bug #48564] Octave does not accept "1 / ND array", "mrdivide (1, ND array)", "mldivide (ND array, 1)", Philip Nienhuis, 2016/07/20