Weird behavior for pagemrdivide matlab 2022b vs 2022a
Mostrar comentarios más antiguos
I am noticing some strange behaviour when using pagemrdivide. When I run the code below, the Dpage variable contains a lot of NaN, while the Dfor variable computes just fine. I expect these two to be equal, but they are not. Has anyone else encountered this behaviour before?
When I run the same code in matlab 2022a, I don't get this behaviour, it seems to be introduced in 2022b.
F = 300;
D = randn(2,2,F) + 1i*randn(2,2,F);
P = [0 0 1 0
1 0 0 0
0 0 0 1
0 -1 0 0];
P11 = P(1:2,1:2);
P12 = P(1:2,3:4);
P21 = P(3:4,1:2);
P22 = P(3:4,3:4);
Dpage = pagemrdivide(pagemtimes(P11,D) + P12, pagemtimes(P21,D)+P22);
Dfor = zeros(size(D));
for ff = 1 : F
Dfor(:,:,ff) = mrdivide(P11*D(:,:,ff)+P12,P21*D(:,:,ff)+P22);
end
nnz(isnan(Dpage))
nnz(isnan(Dfor))
13 comentarios
You are right, it is pretty bad, giving all nan and inf results if asked to process more than one page
format long g
D = cat(3, [1 2; 3 4], [2 -1; 3 5]) + 1i*cat(3, [20 19; 18 17], [-1 5; 7 9])
P = [0 0 1 0
1 0 0 0
0 0 0 1
0 -1 0 0];
P11 = P(1:2,1:2);
P12 = P(1:2,3:4);
P21 = P(3:4,1:2);
P22 = P(3:4,3:4);
arg1 = pagemtimes(P11,D) + P12
arg2 = pagemtimes(P21,D) + P22
Dpage = pagemrdivide(arg1, arg2)
Dpage2 = cat(3, pagemrdivide(arg1(:,:,1), arg2(:,:,1)), pagemrdivide(arg1(:,:,2), arg2(:,:,2)))
nnz(isnan(arg1))
nnz(isnan(arg2))
nnz(isnan(Dpage))
nnz(isnan(Dpage2))
The debugging confirms that it is not the fault of pagemtimes, and confirms that if you only do one page at a time that the problem does not occur.
the cyclist
el 22 de Dic. de 2022
Seems to be pretty clear-cut bug, introduced in R2022b. (The function itself was only introduced in R2022a!)
Also, pagemldivide doesn't work for @Walter Roberson's example. Pehaps even worse, pagemldivide on multiple pages doesn't yield a result that's obviously incorrect, i.e., with nan or inf entries. Just returns realistic looking, but incorrect, numbers for a few entries.
format long g
D = cat(3, [1 2; 3 4], [2 -1; 3 5]) + 1i*cat(3, [20 19; 18 17], [-1 5; 7 9]);
P = [0 0 1 0
1 0 0 0
0 0 0 1
0 -1 0 0];
P11 = P(1:2,1:2);
P12 = P(1:2,3:4);
P21 = P(3:4,1:2);
P22 = P(3:4,3:4);
arg1 = pagemtimes(P11,D) + P12;
arg2 = pagemtimes(P21,D) + P22;
Both pages at once
Dpage = pagemldivide(arg1, arg2)
Use plain vanilla mldivide
Dpage1 = cat(3,arg1(:,:,1)\arg2(:,:,1),arg1(:,:,2)\arg2(:,:,2))
pagemldivide one page at a time.
Dpage2 = cat(3, pagemldivide(arg1(:,:,1), arg2(:,:,1)), pagemldivide(arg1(:,:,2), arg2(:,:,2)))
nnz(isnan(arg1))
nnz(isnan(arg2))
nnz(isnan(Dpage))
nnz(isnan(Dpage2))
Dpage - Dpage1
Dpage - Dpage2
Dpage1 - Dpage2
Any thoughts on checking the other page* functions?
Walter Roberson
el 22 de Dic. de 2022
Good point, Paul.
Adam
el 22 de Dic. de 2022
Adam
el 22 de Dic. de 2022
Paul
el 22 de Dic. de 2022
Thanks! I always find it interesting when they find something worthy of an "internal bug report," but don't list it on the the external Bugs page. The criteria for what's shown on that page has always been a mystery to me.
Adam
el 23 de Dic. de 2022
Heiko Weichelt
el 23 de Dic. de 2022
Thanks for reporting this. The external bug report is under review and will be published shortly (modulo holiday break).
We identified and fixed the issue and working on getting the fix out as soon as possible.
When introduced in R2022a, pagemldivide/pagemridivide only distingished between rectangular -> using QR and square -> using LU. In R2022b, we unified pagemldivide/pagemrdivide and mldivide/mrdivide using the same algorithms underneath (a few exceptions apply; compare https://www.mathworks.com/help/matlab/ref/pagemldivide.html#mw_b5069599-8b9b-4941-934f-c94c53d4dd56 with https://www.mathworks.com/help/matlab/ref/mldivide.html#bt4jslc-6).
The algorithm detecting the structure introduced the faulty behavior for complex inputs of a certain structure.
Paul
el 16 de En. de 2023
@Adam or anyone else ....
Any new information on this issue? I still don't see the external bug report on the bug reports page.
Adam
el 17 de En. de 2023
Heiko Weichelt
el 19 de En. de 2023
EBR is online:
As mentioned before, R2022b Update 4, which will be released in a few days, will contain the fix.
Respuestas (1)
Be on the lookout for the next update (update 4) to MATLAB R2022b.
3 Ways to check for MATLAB Updates
- From MATLAB Desktop, go to the home tab and select the dropdown menu under Help, then select "Check for Updates".
- Look for a red bell in the upper right corner of the desktop (it's gray when there are no available updates). Click it.
- Check the manual download page https://www.mathworks.com/downloads/, Select "Get Updates" from the "I WANT TO" dropdown menu.

10 comentarios
Paul
el 18 de En. de 2023
Are you willing and able to comment on why this bug isn't listed on the bug reports page?
More generally, are you willing and able to explain the criteria TMW uses to determine which bugs to share or not share with their customers on the bug reports page?
Adam Danz
el 18 de En. de 2023
I'm not a spokesman for MW, I just like to help folks out in between tasks or when I'm on a break :)
Paul
el 18 de En. de 2023
Thanks for the link, never saw that before.
And thanks for helping folks out when you're on break! You should take more breaks.
I realize you can't comment on this, but:
"Published bug reports are for bugs that have been reported in this system that may be of interest to customers, based on general use of our products."
Seems like this bug would qualify, considering that many of othe bug reports are much, much more esoteric IMO as compared to core functionality like matrix division.
Bruno Luong
el 18 de En. de 2023
The reason might be that TMW has internal bug ticket before it has been officialy reported from us (Adam). One bug one ticket.
The bug is beeing fixed and will be released in Update 4, the next one, probably in few days or weeks. What else do you want to know?
Paul
el 18 de En. de 2023
I want to know why this bug is not considered worthy of being on the external bugs page. And I want to know how TMW determines, in general, which bugs "may be of interest to customers." My concern is about the process, not the status of this bug.
Bruno Luong
el 19 de En. de 2023
Editada: Bruno Luong
el 19 de En. de 2023
You imply that *this* bug is not logged externally because they think is not of interested to costumers, which perhaps not correct. Here is the reason
"They closed my ticket because of the existing internal ticket"
Secondly you need to talk to the specific person who has decided the bug is not logged externally and speak in the public place.
If you have experience in the large corporate as TMW you will know that is not going to happen.
Steven Lord
el 19 de En. de 2023
We are working on writing, reviewing, and publishing the bug report for this bug. It's taking longer than expected due to the holidays (as Heiko indicated) and other factors unrelated to whether or not this is "of interest to customers." I will make sure that when it is published either Heiko or I post a comment linking to it.
Heiko Weichelt
el 19 de En. de 2023
EBR is online:
As mentioned before, R2022b Update 4, which will be released in a few days, will contain the fix.
Bruno Luong
el 19 de En. de 2023
Editada: Bruno Luong
el 19 de En. de 2023
@Heiko Weichelt thanks.
It looks pretty similar to this one. If you need me to fire a bug report I'll happy to do it.
Heiko Weichelt
el 19 de En. de 2023
I was not aware of this but GPU code is separate and not my expertise. I'll poke some of my colleagues about it. Thanks.
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!