@@ -95,14 +95,15 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap
9595
9696 return out ;
9797 }
98- // Compute the first forward difference:
99- base ( N , x , strideX , offsetX , N1 , prepend , strideP , offsetP , N2 , append , strideA , offsetA , workspace , strideW , offsetW ) ;
100-
101- // If `k` is one, we're finished...
98+ // If `k` is equal to one, we can compute the forward difference while writing directly to the output array...
10299 if ( k === 1 ) {
100+ base ( N , x , strideX , offsetX , N1 , prepend , strideP , offsetP , N2 , append , strideA , offsetA , out , strideOut , offsetOut ) ;
103101 return out ;
104102 }
105- // Otherwise, recursively compute forward differences...
103+ // Compute the first forward difference:
104+ base ( N , x , strideX , offsetX , N1 , prepend , strideP , offsetP , N2 , append , strideA , offsetA , workspace , strideW , offsetW ) ;
105+
106+ // Recursively compute the next forward differences...
106107 n = total - 1 ;
107108 for ( i = 1 ; i < k - 1 ; i ++ ) {
108109 base ( n , workspace , strideW , offsetW , 0 , prepend , strideP , offsetP , 0 , append , strideA , offsetA , workspace , strideW , offsetW ) ;
0 commit comments