Skip to content

Commit

Permalink
Merge branch 'fix-nufft-highlyperturbed' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Hale committed Feb 5, 2018
2 parents cc6d73a + 5933bc6 commit 475af62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions @chebfun/nufft.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@
[u, v] = constructAK(omega/N, (0:N-1)', K);

function pc = p(c)
I = speye(numel(c));
cK = repmat(c,1,K);
tmp1 = conj(cK.*u);
tmp1 = tmp1(t,:);
tmp2 = conj( ifft( tmp1, [], 1) );
tmp1 = full(I(:,t)*tmp1);
tmp2 = conj(ifft( tmp1, [], 1));
pc = N*sum(v.*tmp2, 2);
end

Expand Down
18 changes: 18 additions & 0 deletions tests/misc/test_nufft.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
count = count + 1;
end

% Test on random inputs:
N = 50;
omega = N*randn(1,N);
c = rand(N,1) + 1i*rand(N,1);
F = exp(-2*pi*1i*((0:N-1)/N).'*omega);
f = chebfun.nufft(c, omega.', 1);
pass(count) = ( norm( f - F*c ) < 300*N*tol*norm(c,1) );
count = count + 1;

% Test NUFFT-II:
for N = 10.^(0:4)
x = linspace(0,1,N+1)'; x(end) = [];
Expand All @@ -31,6 +40,15 @@
count = count + 1;
end

% Test on random inputs:
N = 50;
x = 100*rand(N,1);
c = rand(N,1) + 1i*rand(N,1);
F = exp(-2*pi*1i*x*(0:N-1));
f = chebfun.nufft(c, x);
pass(count) = ( norm( f - F*c ) < 300*N*tol*norm(c,1) );
count = count + 1;

% Test NUFFT-III
for N = 10.^(0:4)
omega = (0:N-1)';
Expand Down

0 comments on commit 475af62

Please sign in to comment.