Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
cada009
fnft_kdvv_inverse: added skeleton files
Jan 13, 2026
05e4c2d
first working version with early stage of crum transformation feature…
Jan 26, 2026
6679f10
Refactoring, Fix scaling problem due to missing sqrt in mod_mex_fnft_…
Jan 26, 2026
4dd01f3
Refactoring-
Jan 26, 2026
9cf958c
Refactoring add_one_solition.
Feb 2, 2026
9986955
Refactoring of add_one_solition() and fnft_kdvv_inverse() finished so…
Feb 2, 2026
88f579d
Implementing add_two_solitons. Works, but differences to matlab, simi…
Feb 2, 2026
203819d
small refactorings
Feb 2, 2026
8444d87
Remove mod_mex_fnft_kdvv_inverse_example_1.m from project
Feb 2, 2026
8a20f8a
Fixing scaling problem in fnft_kdvv_inverse
Feb 9, 2026
e1ca440
Fixing error at initializing C_E in add_one_solition
Feb 9, 2026
7c682b5
fixing errors in add_two_solitions
Feb 9, 2026
1bf9eab
Refactoring, defining auxiliary functions
Feb 10, 2026
20675bd
Adding first test for inverse kdvv fnft
Feb 16, 2026
b9d2577
Adding conditions in fnft_kdvv_inverse_test_1
Feb 16, 2026
b1e9e22
Change in fnft__misc.c from printf to fnft_errwarn_getprinf() for out…
Feb 17, 2026
0fcc53c
Rename in fnft_kdvv_inverse.c x_grid to t_grid, t1 to temp_t1, t2 to …
Feb 17, 2026
90044ce
Adapt Credentials fnft_kdvv_inverse.c
Feb 17, 2026
47a10a5
Add in find_first_positive_value condition if positive value was found
Feb 17, 2026
25e70c8
Add in fnft_kdvv_inverse_test_1.c function run_test and swap major pr…
Feb 23, 2026
e508b73
Add misc_hausdorff_dist_normed based on misc_hausdorff_dist
Feb 23, 2026
679ee6d
Add test conditions in fnft_kdvv_inverse_test_1 and test for quadrati…
Feb 23, 2026
2ec4c17
Add struct fnft_kdvv_params and implement it into functions in fnft_…
Mar 2, 2026
e1b5e41
Refactoring: Move test prcedure fnft__kdvv_inverse_testcases_get_spec…
Mar 2, 2026
136c7d6
Add fnft_kdvv_inverse_example.c
Mar 2, 2026
a23ea0b
fnft__misc.c: Fix Indexing Error in misc_hausdorff_dist_normed
Mar 2, 2026
67ea8b9
fnft__kdvv_inverse_testcases: Improve Debugging Messages
Mar 2, 2026
8d0892d
fnft_kdvv_inverse_test_1.c: Now allocate for contspec of kdvv_paramet…
Mar 2, 2026
99089a8
Add fnft_kdvv_inverse_test_2.c (Test with 25 Eigenvalues)
Mar 2, 2026
a899844
Change error bounds ind fnft_kdvv_inverse_test_1.c
Mar 16, 2026
2f0db16
Changing number of Eigenvalues in fnft_kdvv_inverse_test_2 and error …
Mar 16, 2026
1656434
Add short test description
Mar 16, 2026
bc0dca0
Rename print_test_results into kdvv_print_spectrum and make it a publ…
Mar 16, 2026
198b7e1
Add fnft_kdvv_inverse_test_3.c for test with assymetric window
Mar 16, 2026
921fafa
Changing error bounds in fnft_kdvv_inverse_test_3.c
Mar 16, 2026
f1e47c1
Changing parameters in fnft_kdvv_inverse_example.c
Mar 16, 2026
a3b50b0
Change Parameters in mex_fnft_kdvv_inverse_example_1.m
Mar 16, 2026
d2d9657
Refactoring fnft_kdvv_inverse_test_3.c
Mar 16, 2026
1d2afec
Changing variable names in fnft_kdvv_inverse_example.c
Mar 27, 2026
1098542
Add an initial version of an analytic test case
Mar 31, 2026
7c72bf6
Minor refactoring in analytic test case
Apr 7, 2026
fbb45e5
Add comments and plots to mex_fnft_kdvv_inverse_example_1.m
Apr 7, 2026
403da4c
Add mex_fnft_kdvv_inverse_example_2.m as illustration for the relatio…
Apr 7, 2026
cfcac85
Add mex_fnft_kdvv_inverse_example_3.m as a fast way to try different …
Apr 7, 2026
e574198
Add mex_fnft_kdvv_inverse_example_4.m as a very simple example
Apr 7, 2026
d737ffc
Minor refactoring in mex_fnft_kdvv_inverse_example_1.m
Apr 7, 2026
3853ca1
Refactoring examples for inverse kdvv because of consistency in the o…
Apr 7, 2026
cb5a2ed
Improving comment in mex_fnft_kdvv_inverse_example_1.m
Apr 7, 2026
bb2d5ab
Add fnft_kdvv_inverse_example_1.c as a simple example for the usage o…
Apr 7, 2026
d4391a3
Change fnft_kdvv_inverse_example.c to fnft_kdvv_inverse_example_2.c. …
Apr 7, 2026
0880a0f
Adapting bound states and windows for correct scaling
Apr 7, 2026
f5013f1
Adding checks for invalid inputs in fnft_kdvv_inverse.c
Apr 7, 2026
b476c5a
Fix crash of matlab after invalid arguments because of wrong dealloca…
Apr 10, 2026
1863e33
Changing in tests and examples fo fnft_kdvv_inversey so that pointers…
Apr 10, 2026
35f85ce
Remove sorting of the handed over bound states and norming constants …
Apr 16, 2026
f4bb220
Improve test description in fnft_kdvv_inverse_analytic_test
Apr 16, 2026
f420513
Define error tolerances as constants and adapt window position in ana…
Apr 17, 2026
4db0a8b
Fix typos in comments
ffischer7 Apr 20, 2026
a8ba21f
Clarification in comments of examples to inverse nft
ffischer7 Apr 20, 2026
40f123c
Improve comments for doxygen in fnft_kdvv_inverse.h
ffischer7 Apr 20, 2026
a56c637
Minor Refactoring in fnft_kdvv_inverse.c
ffischer7 Apr 22, 2026
1ab5da1
Refactoring of fnft_kdvv_inverse_testcases.c due to warning messages
ffischer7 Apr 22, 2026
01e2c26
Adapting fnft__kdvv_inverse_testcases.h due to last commit
ffischer7 Apr 22, 2026
35cf355
Rename normconst_or_residues to norming_constants in context of inver…
ffischer7 Apr 22, 2026
2bd1807
Fix error with fnft_kdvv_print_spectrum
ffischer7 Apr 22, 2026
348acc4
Formatting fnft_kdvv_inverse.c
ffischer7 Apr 22, 2026
a7d191d
Fixing error with free of allocated storage: the pointers of all allo…
ffischer7 Apr 30, 2026
edecdd8
Fixing false order of eigenvalues. in fnft_kdvv_inverse_test_1.c. fnf…
ffischer7 Apr 30, 2026
7ec4205
Change in fnft_kdvv_inverse.c numerical constants from 0 to 0.0
ffischer7 Apr 30, 2026
6936146
Adapt fnft_kdvv_inverse_analytic_test so that output is compared with…
ffischer7 May 4, 2026
80882c2
Add explanation to fnft_kdvv_inverse_analytic_test due to own experie…
ffischer7 May 4, 2026
3dec41b
Merge branch 'fnft_kdvv_inverse' of https://github.com/FastNFT/FNFT i…
ffischer7 May 4, 2026
f0aa486
Adapt doxygen comment for fnft_kdvv_inverse.h
ffischer7 May 4, 2026
9671b04
Adapt matlab help descriptions in mex-file for inverse kdvv
ffischer7 Jun 4, 2026
03a8e05
Clarification in doxygen comment in fnft_kdvv_inverse.h
ffischer7 Jun 4, 2026
b9fb84b
Adding check for valid input (check for duplicity of bound states) in…
ffischer7 Jun 4, 2026
ed2f7e9
Adaption on comment to the observed wrong behavior in fnft_kdvv_inver…
ffischer7 Jun 4, 2026
ed269cf
Changing Value of constant THRESHOLD_EQUALITY_BOUND_STATES
ffischer7 Jun 4, 2026
0065449
Fixing compiler errors due to wrong usage of CABS()
ffischer7 Jun 15, 2026
237cf1c
Refactoring fnft_kdvv_inverse_analytic_test, adapting error bounds du…
ffischer7 Jun 15, 2026
644f6b5
Changing names of arguments
ffischer7 Jun 18, 2026
7f82027
Adding doxygen comments
ffischer7 Jun 18, 2026
3605414
Remove DEBUG constant
ffischer7 Jun 18, 2026
11a17a7
Merge branch 'fnft_kdvv_inverse' of https://github.com/FastNFT/FNFT i…
ffischer7 Jun 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
!/test/fnft__poly/
!/test/fnft_version_test/
!/test/fnft_version_test.c/
!/test/fnft_kdvv_inverse/

# Ignore MacOS hidden files in subdirectories
/**/*.DS_Store
Expand Down
75 changes: 75 additions & 0 deletions examples/fnft_kdvv_inverse_example_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* This file is part of FNFT.
*
* FNFT is free software; you can redistribute it and/or
* modify it under the terms of the version 2 of the GNU General
* Public License as published by the Free Software Foundation.
*
* FNFT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Fabian Fischer (Hiwi KIT) 2026
*/

// This is a simple example for the usage of the inverse kdvv transform in C

#define FNFT_ENABLE_SHORT_NAMES

#include <stdio.h>

#include "fnft_kdvv_inverse.h"
#include "fnft__errwarn.h"
#include "fnft__misc.h"

#define K 5 // number of bound states to add

INT main()
{
INT ret_code = SUCCESS;

COMPLEX * q = NULL;
COMPLEX * contspec = NULL;

// five desired bound states and norming constants
// - bound states have to be positive, purely imaginary numbers
// - bound states have to be in descending order
// - every norming constants belong to the bound state at the same index
// - the signs of the norming constants have to alternate regarding the order
// of bound states. The norming constant of the biggest bound state has to be positive.
COMPLEX bound_states[K] = { I*5.0, I*4.0, I*3.0, I*2.0, I*1.0 };
COMPLEX norming_constants[K] = { 1e5, -1e-2, 1e0, -1e3, 1e1 };

// General parameters
UINT D = 256; // Number of samples of the computed output
REAL T[2] = {-10.0, 10.0}; // area for which the output should be computed

// allocation of memory for the computed output
q = malloc(D * sizeof(COMPLEX));
CHECK_NOMEM(q, ret_code, leave_fun);

// Define continuous spectrum
// continuous spectrum is out of function, but needs to be defined/allocated for using
// the inverse kdvv (state 04/2026)
UINT M = 10;
REAL XI[2] = {-2.0, 2.0};

contspec = malloc(M * sizeof(COMPLEX));
CHECK_NOMEM(contspec, ret_code, leave_fun);

// call of the inverse kdvv
ret_code = fnft_kdvv_inverse(M, contspec, XI, K, bound_states, norming_constants, D, q, T, NULL);
CHECK_RETCODE(ret_code, leave_fun);

// prints the results in the console
misc_print_buf(D, q, "output");

leave_fun:
free(q);
free(contspec);
}
88 changes: 88 additions & 0 deletions examples/fnft_kdvv_inverse_example_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* This file is part of FNFT.
*
* FNFT is free software; you can redistribute it and/or
* modify it under the terms of the version 2 of the GNU General
* Public License as published by the Free Software Foundation.
*
* FNFT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Fabian Fischer (Hiwi KIT) 2026
*/

// This is an example for the usage of the inverse kdvv transform with many
// bound states

#define FNFT_ENABLE_SHORT_NAMES

#include <stdio.h>

#include "fnft_kdvv_inverse.h"
#include "fnft__errwarn.h"
#include "fnft__misc.h"

#define K 19 // Number of bound states to add

INT main()
{
INT ret_code = SUCCESS;

COMPLEX * bound_states = NULL;
COMPLEX * q = NULL;
COMPLEX * contspec = NULL;

COMPLEX desired_solitions_height[K] = { 40.0, 39.0, 38.0, 37.0, 36.0,
30.0, 29.0, 28.0, 27.0, 26.0,
20.0, 19.0, 18.0, 17.0, 16.0,
10.0, 9.0, 8.0, 7.0};

COMPLEX normconsts[K] = { 1e20, -1e-7, 1e5, -1e3, 1e1,
-1e0, 1e2, -1e4, 1e-6, -1e8,
1e2, -1e4, 1e6, -1e8, 1e-10,
-1e7, 1e-6, -1e5, 1e-9};

// resulting bound states out of desired solitions height
bound_states = malloc(K * sizeof(COMPLEX));
CHECK_NOMEM(bound_states, ret_code, leave_fun);

for (UINT i = 0; i<K; i++){
bound_states[i] = I*SQRT(desired_solitions_height[i]/2.0);
}

// General parameters
UINT D = 256;
REAL T[2] = {-18.0, 12.0};

// allocating memory for the output of the inverse kdvv
q = malloc(D * sizeof(COMPLEX));
CHECK_NOMEM(q, ret_code, leave_fun);

// Define Parameters and allocate memory for continuous spectrum
// inverse kdvv cannot deal with a nonzero continuous spectrum (state 04/2026),
// hence it is implicitly assumed to zero.
// Nevertheless the variables needs to be delivered
UINT M = 10;
REAL XI[2] = {-2.0, 2.0};

contspec = malloc(M * sizeof(COMPLEX));
CHECK_NOMEM(contspec, ret_code, leave_fun);

// call inverse kdvv transform
ret_code = fnft_kdvv_inverse(M, contspec, XI, K, bound_states, normconsts, D, q, T, NULL);
CHECK_RETCODE(ret_code, leave_fun);

// print output of inverse kdvv into console
misc_print_buf(D, q, "output");

leave_fun:
free(bound_states);
free(q);
free(contspec);
}
73 changes: 73 additions & 0 deletions examples/mex_fnft_kdvv_inverse_example_1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
% This file is part of FNFT.
%
% FNFT is free software; you can redistribute it and/or
% modify it under the terms of the version 2 of the GNU General
% Public License as published by the Free Software Foundation.
%
% FNFT is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Contributors:
% Sander Wahls (KIT) 2026.
% Fabian Fischer (Hiwi KIT) 2026.

% This example should illustrate how to use the inverse kdvv transform

clear all;
close all;

% desired height of solitions:
desired_solitions = [4, 3, 2, 1];

% resulting bound states out of desired heights of solitions:
% - bound states have to be positive, purely imaginary numbers
% - the bound states have to be in descendent order
bound_states = 1i*sqrt(desired_solitions ./2);

% desired norming constants
% defines how much the solitions are shifted towards each other
% - signs have to alternate regards to the order of the bound states
% - sign of the normconst for the biggest eigenvalue has to be positive
norming_constants = complex([1, -1, 1, -1].*[0.00001, 0.1, 1, 10]);

% Number of samples of the output of the inverse kdvv
D = 1001;

% Area, for which the output has to be computed
% Can be asymmetric
T = [-10 10];

% defining the continuous spectrum:
% out of function, just for seek of completeness (state 04/2026)
contspec = [];
XI = [1e-6 1];

% calls function of c-library FNFT
q = mex_fnft_kdvv_inverse(contspec, XI, bound_states, norming_constants, D, T);
% the result consists of solitions with desired height (if the solitions are far
% away enough to each other)

% --- Plot the results ---
t = linspace(T(1), T(2), D);

% the output of the inverse kdvv is defined as a complex number (state 04/2026),
% however only the imaginary part should be zero and can be neglected
q = double(real(q(:)'));

figure;
plot(t, q);
title('output of inverse kdvv: time-domain');
xlabel('t');
ylabel('q(t)');
legend('q(t)');

figure;
stem(imag(bound_states),real(norming_constants), 'x');
title('Bound states and norming constants');
xlabel('bound states');
ylabel('norming constants');
85 changes: 85 additions & 0 deletions examples/mex_fnft_kdvv_inverse_example_2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
% This file is part of FNFT.
%
% FNFT is free software; you can redistribute it and/or
% modify it under the terms of the version 2 of the GNU General
% Public License as published by the Free Software Foundation.
%
% FNFT is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Contributors:
% Sander Wahls (KIT) 2026.
% Fabian Fischer (Hiwi KIT) 2026.

% This example should illustrate, how to use the inverse kdvv in combination
% with the forward kdvv transform. For basic usage of the inverse kdvv, please
% please have a look at mex_fnft_kdvv_inverse_example_1.m (state 04/2026).

clear all;
close all;

contspec_initial = [];
XI = [1e-6 10];

bound_states_initial = 1i*sqrt([4, 3, 2, 1] ./2);
norming_constants_initial = complex([1, -1, 1, -1].*[10000, 0.1, 1, 0.001]);

D = 1001;
T = [-15 10];

% inverse kdvv transform
q = mex_fnft_kdvv_inverse(contspec_initial, XI, bound_states_initial, norming_constants_initial, D, T);

q = double(real(q(:)'));

% compute the nonlinear Fourier transform of the output of the inverse kdvv
[contspec_computed, bound_states_computed, norming_constants_computed] = mex_fnft_kdvv(q, T, XI);


% --- Plot the results ---
t = linspace(T(1), T(2), D);

figure;
plot(t, q);
title('output of inverse kdvv: time-domain');
xlabel('t');
ylabel('q(t)');
legend('q(t)');

% plotting the initial and the computed discrete spectrum
% the difference between the initial and the computed spectrum should be very small

figure;
stem(imag(bound_states_initial),real(norming_constants_initial), 'x', 'color', 'r');
hold on;
stem(imag(bound_states_computed),real(norming_constants_computed), 'x', 'color', 'g');
hold off;
title('initial and computed bound states and norming constants');
xlabel('bound states');
ylabel('norming constants');
legend('initial', 'computed');

% plotting of continuous spectrum
% values are small because initial continuous spectrum was assumed as zero
% and the computed continuous spectrum is only the result of numerical errors

ep_xi = (XI(2) - XI(1)) / (D - 1);
xi = XI(1):ep_xi:XI(2);

figure;
hmag=subplot(2,1,1);
semilogy(xi, abs(contspec_computed));
title('computed continuous spectrum');
xlabel('\xi');
ylabel('|r(\xi)|');
hang=subplot(2,1,2);
plot(xi, angle(contspec_computed));
xlabel('\xi');
ylabel('\angle r(\xi)');
linkaxes([hmag,hang],'x');

Loading