Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into fix-fracdiff-q…
Browse files Browse the repository at this point in the history
…uasi
  • Loading branch information
Hadrien Montanelli committed Feb 9, 2018
2 parents cd9349c + ecb2314 commit 35a6887
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 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
7 changes: 5 additions & 2 deletions minimax.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@
else
varargin(domIndex) = [];
end

fHandle = str2op(vectorize(f));
if ( ischar(f) )
fHandle = str2op(vectorize(f));
else
fHandle = f;
end
f = chebfun(f, dom, 'splitting', 'on');
else % f is a chebfun input
fHandle = @(x) feval(f, x);
Expand Down
9 changes: 7 additions & 2 deletions tests/misc/test_minimax.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,16 @@
pass(18) = (err < 1e38);

% Test poles and zeros of the best approximation
%{

[p,q,~,~,status] = minimax(@(x) sqrt(x), [0,1], 4,4);
zer1 = roots(p,'all'); zer1 = sort(zer1); zer2 = sort(status.zer);
pol1 = roots(q,'all'); pol1 = sort(pol1); pol2 = sort(status.pol);
pass(19) = ( norm(zer1-zer2,Inf)/norm(zer1,Inf) < 1e-5 && ...
norm(pol1-pol2,Inf)/norm(pol1,Inf) < 1e-5 );
%}

% Test for issue #2244
[p1, err1] = minimax(@exp, 5);
[p2, err2] = minimax(@(x) exp(x), 5);
pass(20) = (err1 == err2);

end
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 35a6887

Please sign in to comment.