
function test_dctall
% Here we test the dctall.m function which generates
% the transformation matices of all types of DCT
% Use the debbuger if you wanna check the values

% ------- test_dctall.m ------------------------------------
% Marios Athineos, marios@ee.columbia.edu
% http://www.ee.columbia.edu/~marios/
% Copyright (c) 2005 by Columbia University.
% All rights reserved.
% ----------------------------------------------------------

% In order to get the kernel we use eye().  This is faster
% than usind dctallmtx() cause we cache the kernel in dctall().
% Change the size at will
x = eye(6);

% Test that the kernel is the same as MATLAB's dct (Type II)
r = dct(x) - dctall(x,2);

% Types I and IV are involutary
r = dctall(x,1)^2;
r = dctall(x,4)^2;

% All of them are unitary
r = dctall(x,1) * dctall(x,1)';
r = dctall(x,2) * dctall(x,2)';
r = dctall(x,3) * dctall(x,3)';
r = dctall(x,4) * dctall(x,4)';

% Type III is the inverse of type II and vice versa
r = dctall(x,2) * dctall(x,3);
r = dctall(x,3) * dctall(x,2);

% And now some speed tests compared to the internal dct()
x = randn(2^9,2^12);

fprintf('Four runs of dct()\n');
tic;dct(x);toc
tic;dct(x);toc
tic;dct(x);toc
tic;dct(x);toc
fprintf('\n');
fprintf('Four runs of dctall()\n');
fprintf('(The first is slower cause we build the matrix)\n');
tic;dctall(x);toc
tic;dctall(x);toc
tic;dctall(x);toc
tic;dctall(x);toc