Skip to content

Commit 25a825e

Browse files
authored
fix segmentation fault bug in fft.ifft (#557)
1 parent 155dad9 commit 25a825e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

code/numpy/fft/fft_tools.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ mp_obj_t fft_fft_ifft_spectrogram(mp_obj_t data_in, uint8_t type) {
118118

119119
if(in->dtype == NDARRAY_COMPLEX) {
120120
uint8_t sz = 2 * sizeof(mp_float_t);
121-
uint8_t *data_ = (uint8_t *)out->array;
122121
for(size_t i = 0; i < len; i++) {
123-
memcpy(data_, array, sz);
122+
memcpy(data, array, sz);
123+
data += 2;
124124
array += in->strides[ULAB_MAX_DIMS - 1];
125125
}
126126
} else {
@@ -149,7 +149,7 @@ mp_obj_t fft_fft_ifft_spectrogram(mp_obj_t data_in, uint8_t type) {
149149
} else { // inverse transform
150150
fft_kernel_complex(data, len, -1);
151151
// TODO: numpy accepts the norm keyword argument
152-
for(size_t i = 0; i < len; i++) {
152+
for(size_t i = 0; i < 2 * len; i++) {
153153
*data++ /= len;
154154
}
155155
}

code/ulab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "user/user.h"
3434
#include "utils/utils.h"
3535

36-
#define ULAB_VERSION 6.0.0
36+
#define ULAB_VERSION 6.0.1
3737
#define xstr(s) str(s)
3838
#define str(s) #s
3939

docs/ulab-change-log.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat, 5 Nov 2022
2+
3+
version 6.0.1
4+
5+
fix fft.ifft
6+
17
Wed, 21 Sep 2022
28

39
version 6.0.0

0 commit comments

Comments
 (0)