[bug #68300] blkdiag with arguments of type single returns result of type double
Rik <[email protected]> Sun, 3 May 2026 14:46:02 -0400 (EDT)
| 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.
Update of bug #68300 (group octave):
Status: None => Patch Reviewed
_______________________________________________________
Follow-up Comment #5:
@Fernando: Thanks for noticing this.
@Dmitri: Interesting strategy to use Octave's own type-promotion logic with
addition operator to determine final type. I asked for some tests to be run
to see how Matlab handles some of the edge cases. See
https://octave.discourse.group/t/help-with-matlab-compatibility-of-blkdag/7520.
It seems that *blkdiag*, which is just assembling arrays, is more like the
function *cat* than it is like the addition operator *+*. Test case:
A = ones (2,2, 'uint8');
B = ones (2,2, 'int32');
A + B
error: binary operator '+' not implemented for 'uint8 matrix' by 'int32
matrix' operations
BUT, you can concatenate these types and the output is the first integer type
seen.
C = cat (1, A, B);
class (C)
ans = uint8
D = cat (1, B, A);
class (D)
ans = int32
The results from testing in Matlab show that *blkdiag* seems to be doing the
same thing and choosing the first integer format found.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68300>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCafeX6gAKCRCqLAuaBUf3 TushAQC4FB34hw2TgK8TcT3ATjCFQ9el5Za1LIq80DuOkboSSgD+NoPe2j101qlE xmm7rBH49SciOJJyoiYM+mN9/LX9pg8= =vXOp -----END PGP SIGNATURE-----