Mercurial > octave
changeset 31877:31430ca3644b
movslice.m: Use minimum unsized integer array for slcidx output to save memory (bug #63791).
* movslice.m: Convert internal variable C to uintXX array of the minimum size
necessary to hold indices as large as input parameter N. When slcidx output
is created through broadcasting this can result in an array that is much smaller
than one constructed from doubles (8 bytes).
author | Rik <rik@octave.org> |
---|---|
date | Thu, 02 Mar 2023 13:42:30 -0800 |
parents | ac088212b7dc |
children | fc40c78a8421 |
files | scripts/signal/movslice.m |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/signal/movslice.m Thu Mar 02 16:35:47 2023 -0500 +++ b/scripts/signal/movslice.m Thu Mar 02 13:42:30 2023 -0800 @@ -112,6 +112,18 @@ Cnf = N - wlen(2) + 1; # first center that can't fit the post-window Cpost = Cnf:N; # centers that can't fit centered post-window C = (wlen(1) + 1):(Cnf - 1); + ## Convert C to minimum unsigned integer array large enough to hold indices. + ## This can save significant memory in resulting slcidx array over using a + ## double (8 bytes). + if (N <= 255) + C = uint8 (C); + elseif (N <= 65535) + C = uint16 (C); + elseif (N <= 4294967295) + C = uint32 (C); + else + C = uint64 (C); + endif win = (-wlen(1):wlen(2)).'; slcidx = C + win;