Skip to content

Commit

Permalink
hot fix from Nick Hale for chebpoly
Browse files Browse the repository at this point in the history
  • Loading branch information
trefethen committed Apr 17, 2023
1 parent 2e1cc63 commit b839628
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 3 additions & 2 deletions chebpoly.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@

% Construct the Chebyshev coefficients:
N = max(n) + 1;
c = eye(N);
c = c(:,n+1);
M = numel(n);
c = zeros(N, M);
c(n+1,:) = eye(M);

% 2nd-kind polynomials:
if ( kind == 2 )
Expand Down
21 changes: 19 additions & 2 deletions tests/misc/test_chebpoly.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,22 @@
U2 = sin(acos(x)*(n+1))./sin(acos(x)*(1+0*n));
err = U2 - U1x;
pass(2) = norm(err(:), inf) < tol;

end

% Check a couple of mins and maxes
T = chebpoly(27);
pass(3) = abs(max(T)-1) < tol;

% Check a couple of mins and maxes
T = chebpoly(44);
pass(4) = abs(min(T)+1) < tol;

% And a little quasimatrix
T = chebpoly([7:8]);
v = T*[1;1];
pass(5) = abs(v(-1)) < tol;

% Make sure big degrees work
T = chebpoly(1e5);
pass(6) = abs(T(1)-1) < tol;

end

0 comments on commit b839628

Please sign in to comment.