Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
0db7495
Initial commit
PJ-Prins Nov 3, 2020
88167eb
remove initial .gitignore
PJ-Prins Nov 3, 2020
b79f942
Merge branch 'development' of https://github.com/FastNFT/FNFT
PJ-Prins Nov 3, 2020
a090033
Merge remote-tracking branch 'sync/development' into Mimic-NSE-implem…
PJ-Prins Nov 6, 2020
c7b10a7
fnft_nse_discretization_t.h -> fnft_kdv_discretization_t.h
PJ-Prins Nov 6, 2020
e85a8ae
fnft__nse_discretization.h/c -> fnft__kdv_discretization.h/c
PJ-Prins Nov 6, 2020
b2deb81
fnft__nse_fscatter.c/h -> fnft__kdv_fscatter.c/h
PJ-Prins Nov 6, 2020
2b37d4d
fnft__nse_scatter* -> fnft__kdv_scatter*
PJ-Prins Nov 6, 2020
8dc685e
fnft__nse_fscatter.c/h -> fnft__kdv_fscatter.c/h
PJ-Prins Nov 17, 2020
dbc8896
Size generalisation of matrix multiplication function
PJ-Prins Nov 17, 2020
946ed58
Begin nsev.c/h -> kdvv.c/h
PJ-Prins Nov 20, 2020
a73feaf
Fix kdv_discretization_2SPLIT2A
PJ-Prins Nov 20, 2020
9c6b430
Remove an exception for 2split2A: incorrect for KdV
PJ-Prins Nov 20, 2020
03613b3
Continuos spectrum fast methods added
PJ-Prins Nov 21, 2020
223b8ac
implementation 2SPLIT2_MODAL added
PJ-Prins Nov 21, 2020
089fa71
Renaming AKNS discretizations
PJ-Prins Nov 21, 2020
f3420b5
Fix b calculation 2SPLIT2_MODAL_VANILLA
PJ-Prins Nov 21, 2020
0dab25c
Bug fix: comparison between different enum types
PJ-Prins Nov 21, 2020
5fc8689
Flipped AKNS basis added
PJ-Prins Nov 21, 2020
df20626
Fast continuous spectrum flipped AKNS added
PJ-Prins Nov 23, 2020
81781ed
Fixed ES4 and TES4 discretizations
PJ-Prins Nov 24, 2020
3a986f4
Fixed 4SPLIT4A/B
PJ-Prins Nov 25, 2020
a2d6979
Merge remote-tracking branch 'sync/Generalise-preprocessing' into Mim…
PJ-Prins Nov 26, 2020
87d367d
Merge remote-tracking branch 'sync/Generalise-preprocessing' into Mim…
PJ-Prins Nov 26, 2020
8418ddf
Use generalised preprocessing
PJ-Prins Nov 26, 2020
2789c95
Add assertion for realness of potential
PJ-Prins Nov 26, 2020
cf05a12
bound_states != 0 should be bound_states != NULL
PJ-Prins Nov 30, 2020
6817435
Merge remote-tracking branch 'sync/development' into Mimic-NSE-implem…
PJ-Prins Nov 30, 2020
0ec244c
Merge remote-tracking branch 'sync/Generalise-preprocessing' into Mim…
PJ-Prins Nov 30, 2020
deb20ed
Merge remote-tracking branch 'sync/Generalise-preprocessing' into Mim…
PJ-Prins Nov 30, 2020
11a3456
Documentation of an earlier change
PJ-Prins Nov 30, 2020
cbdae63
Remove bound state localisation based on polynomials
PJ-Prins Nov 30, 2020
6ae34af
Remove bound state filtering
PJ-Prins Nov 30, 2020
e0cbc37
Bound state calculation for the slow methods
PJ-Prins Dec 1, 2020
8d2014a
Merge remote-tracking branch 'sync/development' into Mimic-NSE-implem…
PJ-Prins Dec 1, 2020
431a4b8
Bound state calculation for fast methods
PJ-Prins Dec 2, 2020
ae09224
const correctness
PJ-Prins Dec 2, 2020
8bd3dc6
Removed some error bounds
PJ-Prins Dec 2, 2020
d907b1c
Fixed number of gridpoints for initial guesses
PJ-Prins Dec 2, 2020
837bd60
Tests Richardson extrapolation added
PJ-Prins Dec 2, 2020
b69e32c
Fixed use of an uninitialised variable
PJ-Prins Dec 3, 2020
158e932
Code clean-up nse_scatter_bound_states.c
PJ-Prins Dec 4, 2020
8014734
Code clean-up nse_scatter_bound_states.c part 2
PJ-Prins Dec 7, 2020
ca3e590
fnft__nse_scatter_bound_states -> fnft__kdv_scatter_bound_states
PJ-Prins Dec 8, 2020
81a6c69
Added akns_scatter_bound_states
PJ-Prins Dec 8, 2020
8f605d7
nse_scatter_bound_states calls akns_*
PJ-Prins Dec 8, 2020
7686ea9
Added sinc-derivative routine
PJ-Prins Dec 9, 2020
353bdd2
nse/kdv_scatter_matrix/bound_states.c in one file
PJ-Prins Dec 9, 2020
6cf95e9
Fixed undefined behaviour in abolished testcase
PJ-Prins Dec 10, 2020
9fdb403
Fixed a mistake in an overflow check
PJ-Prins Dec 10, 2020
6832022
Default indentation
PJ-Prins Dec 10, 2020
b3de9a9
cleanup akns_scatter_matrix
PJ-Prins Dec 10, 2020
1a69d18
cleanup akns_scatter_matrix part 2
PJ-Prins Dec 11, 2020
a360790
Revert "fnft__nse_fscatter.c/h -> fnft__kdv_fscatter.c/h"
PJ-Prins Dec 11, 2020
9932727
Merge branch 'Mimic-NSE-implementation-for-Kdv'
PJ-Prins Dec 11, 2020
82f6af5
Merge remote-tracking branch 'sync/development' into receive-merge
PJ-Prins Dec 11, 2020
2fbb4bb
Merge branch 'receive-merge'
PJ-Prins Dec 11, 2020
d07c397
Sinc(_derivative) routine static inline
PJ-Prins Dec 11, 2020
3e55929
Merge branch 'Mimic-NSE-implementation-for-Kdv'
PJ-Prins Dec 11, 2020
9c565a0
Merge branch 'master' into Mimic-NSE-implementation-for-Kdv
PJ-Prins Dec 11, 2020
c7f1144
Fixed mistake in residue calculation
PJ-Prins Dec 11, 2020
b0aa42c
Restore AKNS structure CF*_* discretizations
PJ-Prins Dec 11, 2020
b751e01
Romove bounding box passing kdvv.c
PJ-Prins Dec 11, 2020
1f57731
Documentation
PJ-Prins Dec 11, 2020
cfa3187
Restored/fixed bounding box calculation nsev.c
PJ-Prins Dec 12, 2020
168d2ce
Minor simplification
PJ-Prins Dec 12, 2020
cb1b4ef
Fixed another mistake in residue calculation
PJ-Prins Dec 12, 2020
5862a5c
Simplification
PJ-Prins Dec 12, 2020
bf938c2
Renaming
PJ-Prins Dec 12, 2020
32dd762
Completion new testcases kdvv
PJ-Prins Dec 14, 2020
8760426
Removed abolished tests and testcases
PJ-Prins Dec 14, 2020
775801f
Keep 2SPLIT2A/_modal in modified AKNS
PJ-Prins Dec 14, 2020
d67c4f5
Change of basis in akns_scatter_matrix()
PJ-Prins Dec 14, 2020
a4cbf2f
Added some comments to akns_scatter.c
PJ-Prins Dec 14, 2020
4589510
Keep 2SPLIT2A/_modal in modified AKNS part 2
PJ-Prins Dec 15, 2020
ed97b9a
Eigenvalue upperbound
PJ-Prins Dec 17, 2020
f23864a
Merge branch 'Mimic-NSE-implementation-for-Kdv'
PJ-Prins Dec 17, 2020
64a8513
Removed dead code
PJ-Prins Jan 14, 2021
2211763
Increased error bounds for travis
PJ-Prins Jan 15, 2021
3c2520f
Mex file KdV updated, Matlab examples KdV added
PJ-Prins Jan 15, 2021
88cdbf2
Solved doxygen warnings
PJ-Prins Jan 15, 2021
ecbdb4f
Update authors
PJ-Prins Jan 15, 2021
02a0b32
Update C example KdV
PJ-Prins Jan 15, 2021
e763d5b
Added more discritizations to mex nsev and kdvv
PJ-Prins Jan 18, 2021
72ce7a7
Suppress a Matlab warning
PJ-Prins Jan 18, 2021
88aa44d
Check validity initial guesses bound states.
PJ-Prins Jan 18, 2021
80fb3f6
Check option bsloc_NEWTON
PJ-Prins Jan 18, 2021
07bd054
Minor textual changes.
ShrinivasJC Jan 20, 2021
b91a937
Remove one version of L2norm calculation
PJ-Prins Feb 5, 2021
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
194 changes: 133 additions & 61 deletions Doxyfile

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions examples/fnft_kdvv_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
* Contributors:
* Sander Wahls (TU Delft) 2018.
* Peter J. Prins (TU Delft) 2021.
*/

// This example demonstrates the use of the function fnft_kdvv, which
Expand Down Expand Up @@ -59,15 +60,28 @@ int main()
// Buffer for result: Samples of the continuous spectrum
FNFT_COMPLEX contspec[M];

// Maximum number of bound states we expect = size of the two arrays below
FNFT_UINT K = D;

// Buffer for result: Bound states
FNFT_COMPLEX bound_states[K];

// Buffer for result: Norming constants
FNFT_COMPLEX normconsts[K];

// Default options
fnft_kdvv_opts_t opts = fnft_kdvv_default_opts();

// Uncomment the next line to compute residues instead of norming constants
//opts.discspec_type = fnft_kdvv_dstype_RESIDUES;

// See the header file fnft_kdvv.h for the options

/** Step 3: Call fnft_nsev and check for errors **/

int ret_code = fnft_kdvv(D, q, T, M, contspec, XI, NULL, NULL, NULL,
&opts);
int ret_code = fnft_kdvv(D, q, T, M, contspec, XI, &K, bound_states,
normconsts, &opts);

if (ret_code != FNFT_SUCCESS) {
printf("An error occured!\n");
return EXIT_FAILURE;
Expand All @@ -88,5 +102,15 @@ int main()
);
}

printf("Discrete spectrum:\n");
for (FNFT_UINT i=0; i<K; i++) {
printf(" bound state at %g + %gI with norming constant %g + %gI\n",
(double)FNFT_CREAL(bound_states[i]),
(double)FNFT_CIMAG(bound_states[i]),
(double)FNFT_CREAL(normconsts[i]),
(double)FNFT_CIMAG(normconsts[i])
);
}

return EXIT_SUCCESS;
}
38 changes: 26 additions & 12 deletions examples/mex_fnft_kdvv_example.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
%
% Contributors:
% Sander Wahls (TU Delft) 2017-2018.
% Peter J. Prins (TU Delft) 2021.

% This examples demonstrates how the nonlinear Fourier transform with
% respect to the Korteweg-de Vries equation with vanishing boundary
% conditions can be computed using mex_fnft_nsev. The signal is a squared
% conditions can be computed using mex_fnft_kdvv. The signal is a squared
% sech pulse.

clear all;
Expand All @@ -26,35 +27,48 @@
%%% Setup parameters %%%


D = 2^8; % location of the 1st and last sample in the time domain
T = [-10, 10]; % number of samples
XI = [-5, 5]; % location of the 1st and last sample in the xi-domain
D = 2^8; % location of the 1st and last sample in the time domain
T = [-10, 10]; % number of samples
XI = [1e-10, 6]; % location of the 1st and last sample in the xi-domain

%%% Setup the signal %%%

ep_t = (T(2) - T(1)) / (D - 1);
t = T(1):ep_t:T(2);
q = complex(1.2*sech(t).^2);
q = 16*sech(t).^2;

%%% Compute the nonlinear Fourier transform %%%

contspec = mex_fnft_kdvv(q, T, XI);
[contspec, bound_states, norming_constants] = mex_fnft_kdvv(q, T, XI);
% mex_fnft_kdvv has many options => run "help mex_fnft_kdvv" to learn more

%%% Plot the results %%%

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

figure;
plot(t, real(q), t, imag(q));
plot(t, q);
title('Time-domain');
xlabel('t');
ylabel('q(t)');
legend('Real part', 'Imaginary part');
legend('q(t)');

figure;
plot(xi, real(contspec), xi, imag(contspec));
title('Continuous spectrum (numerically)');
hmag=subplot(2,1,1);
semilogy(xi, abs(contspec));
title('Continuous spectrum');
xlabel('\xi');
ylabel('r(\xi)');
legend('Real part', 'Imaginary part');
ylabel('|r(\xi)|');
hang=subplot(2,1,2);
plot(xi, angle(contspec));
xlabel('\xi');
ylabel('\angle r(\xi)');
linkaxes([hmag,hang],'x');

figure;
stem(imag(bound_states),real(norming_constants), 'x');
title('Bound states and norming constants');
xlabel('\lambda_k/j');
ylabel('b(\lambda_k)');
axis([0,4,-2,2]);
120 changes: 120 additions & 0 deletions examples/mex_fnft_kdvv_example_2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
% 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 (TU Delft) 2017-2018, 2020.
% Shinivas Chimmalgi (TU Delft) 2019.
% Peter J. Prins (TU Delft) 2021.

% This example compares the accuracy-execution tradeoff of the various algorithms for
% the Korteweg-de Vries equation with vanishing boundaries.

clear;
close all;
clc;

%%% Setup parameters %%%

T = [0,16]; % location of the 1st and last sample in the time domain
XI = [0.5,23]; % location of the 1st and last sample in the xi-domain

%%% Setup the signal %%%

A = sym(15);
d = sym(0.5);
exp_t0 = sym(3000);
q_fun = @(t) A*sech((t-log(exp_t0))/d).^2;

%%% Analytic expressions for the nonlinear Fourier transform %%%

delta = sqrt(sym(A)*d^2+1/4);
at = @(xi) 1/2 - 1i*xi*d + delta;
bt = @(xi) 1/2 - 1i*xi*d - delta;
ct = @(xi) 1 - 1i*xi*d;
cgam = @(z) gamma(sym(z));

R_fun = @(xi) exp_t0.^(-2i*xi) .* cgam(ct(xi)-at(xi)-bt(xi)) .* cgam(at(xi)) .* cgam(bt(xi)) ./ ...
( cgam(ct(xi)-at(xi)) .* cgam(ct(xi)-bt(xi)) .* cgam(at(xi)+bt(xi)-ct(xi)) );

%%% Prepare variables to store errors and runtimes %%%

error_FCF2_1 = [];
error_FCF4_2 = [];
error_FCF_RE2_1 = [];
error_FCF_RE4_2 = [];
time_FCF2_1 = [];
time_FCF4_2 = [];
time_FCF_RE2_1 = [];
time_FCF_RE4_2 = [];

%%% Iterate of number of samples, gather errors and runtimes for each %%%

for D = 2.^(8:1:12)

fprintf('Running codes with D=%d...',D);
t = linspace(T(1),T(2),D);
q = double(q_fun(t)); % signal samples
R_exact = double(R_fun(linspace(XI(1),XI(2),D)));

% Compute the continuous part of the nonlinear Fourier transform
% numerically with different configurations, save correspoding errors
% and runtimes.

tic
R_comp = mex_fnft_kdvv(q, T, XI, 'discr_2split4B', 'skip_bs');
time_FCF2_1 = [time_FCF2_1,toc];
error_FCF2_1 = [error_FCF2_1, norm(R_exact-R_comp)/norm(R_exact)];

tic
R_comp = mex_fnft_kdvv(q, T, XI, 'discr_4split4B', 'skip_bs');
time_FCF4_2 = [time_FCF4_2,toc];
error_FCF4_2 = [error_FCF4_2, norm(R_exact-R_comp)/norm(R_exact)];

tic
R_comp = mex_fnft_kdvv(q, T, XI, 'discr_2split4B', 'RE', 'skip_bs');
time_FCF_RE2_1 = [time_FCF_RE2_1,toc];
error_FCF_RE2_1 = [error_FCF_RE2_1, norm(R_exact-R_comp)/norm(R_exact)];

tic
R_comp = mex_fnft_kdvv(q, T, XI, 'discr_4split4B', 'RE', 'skip_bs');
time_FCF_RE4_2 = [time_FCF_RE4_2,toc];
error_FCF_RE4_2 = [error_FCF_RE4_2, norm(R_exact-R_comp)/norm(R_exact)];

fprintf('Done.\n');
end

%%% Plot results %%%

lw = 3;
fs = 15;
ms = 6;
alw = 1;
loglog(time_FCF2_1,error_FCF2_1,'-','linewidth',lw,'markersize',ms);
hold on
loglog(time_FCF4_2,error_FCF4_2,'--','linewidth',lw,'markersize',ms);
ax = gca;
ax.ColorOrderIndex = 1;
loglog(time_FCF_RE2_1,error_FCF_RE2_1,':','linewidth',lw,'markersize',ms);
loglog(time_FCF_RE4_2,error_FCF_RE4_2,'-.','linewidth',lw,'markersize',ms);
axis tight

set(gca, 'Units','normalized','FontUnits','points',...
'FontWeight','normal','FontSize',fs,'FontName','Times','LineWidth',alw)

xlabel({'Execution Time (s)'},'Interpreter','latex','FontUnits','points','Fontsize',fs,'FontName','Times');
ylabel({'Relative $L^2$-error in $\rho(\lambda)$'},'Interpreter','latex','FontUnits','points','Fontsize',fs,'FontName','Times')
grid on
grid minor
le = legend("FCF$^{[2]}_1$","FCF$^{[4]}_2$","FCF\_RE$^{[2]}_1$","FCF\_RE$^{[4]}_2$");
set(le,'interpreter','latex','FontUnits','points','Fontsize',fs-2,'FontName','Times','Location','SouthWest');
Loading