Skip to content

Commit

Permalink
fix self-test for applyToep.m in tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
ahbarnett committed Jan 31, 2024
1 parent 75495df commit 531c82f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tutorial/applyToep.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
% larger factors (it is often prime) which slow down the FFT dramatically.
%
% Inputs: x : input column vector length N
% vhat : DFT of v after padding to length 2N (eg, by a zero)
% vhat : DFT of v after padding to length 2N (eg, by a single zero)
% Output: Tx : T*x, col vec length N
%
% Without arguments does self-test; see this code for a demo of use

% Barnett 11/7/22. Realized 2N-1 slow for FFT, 12/10/23
% Barnett 11/7/22. Realized 2N-1 slow for FFT (can be prime!) -> 2N. 12/10/23
if nargin==0, test_applyToep; return; end

N = numel(x);
Expand All @@ -29,11 +29,10 @@

%%%%%%%
function test_applyToep
N = 10; % size to compare against direct matvec
N = 10; % size to compare against direct matvec
x = randn(N,1);
x = 0*x; x(1)=1;
t = randn(2*N-1,1); % define nonsymm Toep: back 1st row then down 1st col
T = toeplitz(t(N:end),t(N:-1:1)); % munge single toep vec into (C,R) format
tpad = [t;0]; that = fft(tpad);
tpad = [t;0]; that = fft(tpad); % shows user how to pad
Tx = applyToep(x,that);
fprintf('test_applyToep: Frob norm of diff btw fast and direct: %.3g\n',norm(T*x - Tx,'fro'))

0 comments on commit 531c82f

Please sign in to comment.