Skip to content

Commit 0fc4df7

Browse files
authored
Merge pull request #11 from FastNFT/release-0.1
Release 0.1.1
2 parents f6036bb + b188d3b commit 0fc4df7

10 files changed

Lines changed: 36 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Changelog
2+
3+
4+
5+
## [0.1.1] -- 2018-05-14
6+
7+
### Added
8+
9+
- Mex files now compile also with Matlab R2018a
10+
11+
### Changed
12+
13+
- Fixed: Several potential memory violations in fnft_nsev, poly_chirpz and nsev_testcases
14+
- Fixed: Some return codes in fnft_nsep had not been checked
15+
- Fixed: misc_merge did not work correctly for empty input vectors
16+
- Fixed: The continuous spectrum in mex_fnft_nsev_example.m was plotted over t, not xi
17+
- Fixed: A superfluous parameter kappa was given in the documentation of mex_fnft_kdvv

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project(fnft C)
33

44
set(FNFT_VERSION_MAJOR 0)
55
set(FNFT_VERSION_MINOR 1)
6-
set(FNFT_VERSION_PATCH 0)
6+
set(FNFT_VERSION_PATCH 1)
77

88
include(CheckIncludeFiles)
99
include(CheckFunctionExists)
@@ -151,7 +151,9 @@ if (WITH_MATLAB)
151151
foreach (srcfile ${MEX_SOURCES})
152152
get_filename_component(mexfile ${srcfile} NAME_WE)
153153
matlab_add_mex(NAME ${mexfile} SRC ${srcfile} LINK_TO fnft ${LIBM})
154-
set_target_properties(${mexfile} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/matlab")
154+
set_target_properties(${mexfile} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/matlab")
155+
target_compile_options(${mexfile} PRIVATE -DMEX_DOUBLE_HANDLE)
156+
# -DMEX_DOUBLE_HANDLE avoids the new complex interleaved API
155157
endforeach()
156158
endif()
157159
endif()

examples/mex_fnft_nsev_example.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
legend('Real part', 'Imaginary part');
5555

5656
figure;
57-
plot(t, real(contspec), t, imag(contspec));
57+
plot(xi, real(contspec), xi, imag(contspec));
5858
title('Continuous spectrum');
5959
xlabel('\xi');
6060
ylabel('r(\xi)');

matlab/mex_fnft_kdvv.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% MEX_FNFT_KDVV Fast nonlinear Fourier transform for the Korteweg-de Vries
22
% equation with vanishing boundaries.
33
%
4-
% contspec = MEX_FNFT_KDVV(q, T, XI, kappa)
4+
% contspec = MEX_FNFT_KDVV(q, T, XI)
55
%
66
% DESCRIPTION
77
% Provides an interface to the C routine fnft_kdvv.

matlab/mex_fnft_nsep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
7575
fnft_errwarn_setprintf(mexPrintf);
7676

7777
/* Check remaining inputs, if any */
78-
for (k=3; k<nrhs; i++) {
78+
for (k=3; k<nrhs; k++) {
7979

8080
/* Check if current input is a string as desired and convert it */
8181
if ( !mxIsChar(prhs[k]) ) {

src/fnft_nsep.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ static inline INT gridsearch(const UINT D,
337337
M = oversampling_factor*deg;
338338
ret_code = poly_roots_fftgridsearch(deg, transfer_matrix+(deg+1), &M,
339339
PHI, roots);
340+
CHECK_RETCODE(ret_code, release_mem);
340341

341342
// Coordinate transform (from discrete-time to continuous-time domain)
342343
for (i=0; i<M; i++)
@@ -476,6 +477,7 @@ static inline INT subsample_and_refine(const UINT D,
476477
// Refine the remaining roots
477478
ret_code = refine_mainspec(D, q, eps_t, K, roots,
478479
opts_ptr->max_evals, +2.0, kappa);
480+
CHECK_RETCODE(ret_code, release_mem);
479481

480482
// Filter the refined roots
481483
if (opts_ptr->filtering != fnft_nsep_filt_NONE) {
@@ -574,7 +576,8 @@ static inline INT subsample_and_refine(const UINT D,
574576
// Refine the roots
575577
ret_code = refine_auxspec(D, q, eps_t, M, roots,
576578
opts_ptr->max_evals, kappa);
577-
579+
CHECK_RETCODE(ret_code, release_mem);
580+
578581
// Filter the refined roots
579582
if (opts_ptr->filtering != fnft_nsep_filt_NONE) {
580583
ret_code = misc_filter(&M, roots, NULL, opts_ptr->bounding_box);

src/fnft_nsev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ static inline INT tf2contspec(
267267

268268
// We reuse an unused part of the transfer matrix as buffer
269269
a_vals = transfer_matrix + (deg+1);
270+
if (M > deg+1)
271+
return E_NOT_YET_IMPLEMENTED(M >> D, "Any M<=2*D should work. It is planned to remove this restriction in the next release.");
270272

271273
// Set step sizes
272274
eps_t = (T[1] - T[0])/(D - 1);
@@ -423,7 +425,7 @@ static inline INT tf2boundstates(
423425
case nsev_bsloc_FAST_EIGENVALUE:
424426

425427
K = deg;
426-
if (*K_ptr <= K) {
428+
if (*K_ptr >= K) {
427429
buffer = bound_states;
428430
} else {
429431
// Store intermediate results in unused part of transfer matrix.

src/private/fnft__misc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ INT misc_merge(UINT *N_ptr, COMPLEX * const vals, REAL tol)
227227
UINT i, j, N, N_filtered;
228228

229229
if (N_ptr == NULL)
230-
return E_INVALID_ARGUMENT(N_ptr)
230+
return E_INVALID_ARGUMENT(N_ptr);
231+
if (*N_ptr == 0)
232+
return SUCCESS;
231233
if (vals == NULL)
232234
return E_INVALID_ARGUMENT(vals);
233235
if (tol < 0.0)

src/private/fnft__nsev_testcases.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ INT nsev_testcases(nsev_testcases_t tc, const UINT D,
381381
release_mem_4:
382382
free(*bound_states_ptr);
383383
release_mem_3:
384-
free(ab_ptr);
384+
free(*ab_ptr);
385385
release_mem_2:
386386
free(*contspec_ptr);
387387
release_mem_1:

src/private/fnft__poly_chirpz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ INT poly_chirpz(const UINT deg, COMPLEX const * const p, \
5656
Y = malloc(L * sizeof(kiss_fft_cpx));
5757
V = malloc(L * sizeof(kiss_fft_cpx));
5858
buf = malloc(L * sizeof(kiss_fft_cpx));
59-
if (cfg == NULL && Y == NULL && V == NULL && buf == NULL) {
59+
if (cfg == NULL || Y == NULL || V == NULL || buf == NULL) {
6060
ret_code = E_NOMEM;
6161
goto release_mem;
6262
}

0 commit comments

Comments
 (0)