# HG changeset patch # User Rik # Date 1677793350 28800 # Node ID 31430ca3644bfb7567583bc7f22fe6a7d288ee09 # Parent ac088212b7dc2ebbd0ec5f8c53cda7571e1cc01d 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). diff -r ac088212b7dc -r 31430ca3644b scripts/signal/movslice.m --- 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;