|
48 | 48 | \item An optimization used to avoid repeated allocation of window subsets (explained more deeply in \emph{Implementation} section below) may, in special cases, return rather surprising results: |
49 | 49 | \preformatted{ |
50 | 50 | setDTthreads(1) |
51 | | -frollapply(c(1, 9), n=1L, FUN=identity) ## unexpected |
| 51 | +frollapply(c(1, 9), N=1L, FUN=identity) ## unexpected |
52 | 52 | #[1] 9 9 |
53 | | -frollapply(c(1, 9), n=1L, FUN=list) ## unexpected |
| 53 | +frollapply(c(1, 9), N=1L, FUN=list) ## unexpected |
54 | 54 | # V1 |
55 | 55 | # <num> |
56 | 56 | #1: 9 |
57 | 57 | #2: 9 |
58 | 58 | setDTthreads(2) |
59 | | -frollapply(c(1, 9), n=1L, FUN=identity) ## good only because threads >= input |
| 59 | +frollapply(c(1, 9), N=1L, FUN=identity) ## good only because threads >= input |
60 | 60 | #[1] 1 9 |
61 | | -frollapply(c(1, 5, 9), n=1L, FUN=identity) ## unexpected again |
| 61 | +frollapply(c(1, 5, 9), N=1L, FUN=identity) ## unexpected again |
62 | 62 | #[1] 5 5 9 |
63 | 63 | } |
64 | 64 | Problem occurs, in rather unlikely scenarios for rolling computations, when objects returned from a function can be its input (i.e. \code{identity}), or a reference to it (i.e. \code{list}), then one has to add extra \code{copy} call: |
65 | 65 | \preformatted{ |
66 | 66 | setDTthreads(1) |
67 | | -frollapply(c(1, 9), n=1L, FUN=function(x) copy(identity(x))) ## only 'copy' would be equivalent here |
| 67 | +frollapply(c(1, 9), N=1L, FUN=function(x) copy(identity(x))) ## only 'copy' would be equivalent here |
68 | 68 | #[1] 1 9 |
69 | | -frollapply(c(1, 9), n=1L, FUN=function(x) copy(list(x))) |
| 69 | +frollapply(c(1, 9), N=1L, FUN=function(x) copy(list(x))) |
70 | 70 | # V1 |
71 | 71 | # <num> |
72 | 72 | #1: 1 |
|
0 commit comments