Relations between DCTVIII and DSTVII

Contents

Definitions

Transform matrix is defined for operating on column-vectors y=T*x, where y, x are column-vectors, T is transform matrix

DCTVIII matrix definition

$${\mathbf{DCTVIII}}\mathrm{{=}}{\left\{{\cos\left({\frac{\mathit{\pi}}{{n}\mathrm{{+}}\frac{1}{2}}\left({{k}\mathrm{{+}}\frac{1}{2}}\right)\left({{l}\mathrm{{+}}\frac{1}{2}}\right)}\right)}\right\}}_{k\mathrm{,}l}$$

N1=8; N=N1;
k=0:N1-1;  l=0:N1-1;
DCT8=cos(pi/(N+1/2)*(k+1/2)'*(l+1/2))       % display DCTV matrix
DCT8 =
  Columns 1 through 7
    0.9957    0.9618    0.8952    0.7980    0.6737    0.5264    0.3612
    0.9618    0.6737    0.1837   -0.3612   -0.7980   -0.9957   -0.8952
    0.8952    0.1837   -0.6737   -0.9957   -0.5264    0.3612    0.9618
    0.7980   -0.3612   -0.9957   -0.1837    0.8952    0.6737   -0.5264
    0.6737   -0.7980   -0.5264    0.8952    0.3612   -0.9618   -0.1837
    0.5264   -0.9957    0.3612    0.6737   -0.9618    0.1837    0.7980
    0.3612   -0.8952    0.9618   -0.5264   -0.1837    0.7980   -0.9957
    0.1837   -0.5264    0.7980   -0.9618    0.9957   -0.8952    0.6737
  Column 8
    0.1837
   -0.5264
    0.7980
   -0.9618
    0.9957
   -0.8952
    0.6737
   -0.3612

DCTVIII in terms of Tschebyshev polynomials

The DCTVIII matrix can be expressed in terms of Tschebyshev polynomials [1]

$${\mathbf{D}}{\mathbf{C}}{\mathbf{TVII}}{\mathbf{I}}\mathrm{{=}}{\mathbf{D}}_{DCTVIII}\mathrm{\cdot}{\left[{{V}_{l}\left({{\mathit{\alpha}}_{k}}\right)}\right]}_{k\mathrm{,}l}$$

where

$${\mathit{\alpha}}_{k}\mathrm{{=}}\cos\mathrm{\left({\frac{\left({{k}{+}\frac{1}{2}}\right)\mathrm{\pi}}{{N}{+}\frac{1}{2}}}\right)}{\mathrm{,}}{k}\mathrm{{=}}{0}\mathrm{\ldots}{N}\mathrm{{-}}{1}$$

are roots of polynomial

$${U}_{DSTVII}\mathrm{{=}}{V}_{n}$$

$${\mathbf{D}}_{DCTVIII}\mathrm{{=}}{diag}{\mathrm{\left\{{\cos\left({\left({{k}{+}\frac{1}{2}}\right)\frac{\mathrm{\pi}}{{2}\left({{N}{+}\frac{1}{2}}\right)}}\right)}\right\}}}_{k}$$

alpha=sort([roots(TschebyshevV(N))],'descend');
DCT8t=zeros(N1);
for l=0:N1-1,
    DCT8t(:,l+1)=polyval(TschebyshevV(l),alpha)';
end
Da8=diag(cos(1/2*pi/(N+1/2)*(k+1/2)));
DCT8t=Da8*DCT8t                    % display DCTV matrix

% compare DCT8 and DCT8t matrices (show that both definitions above are equivalent)
max(max(abs(DCT8-DCT8t)))
DCT8t =
  Columns 1 through 7
    0.9957    0.9618    0.8952    0.7980    0.6737    0.5264    0.3612
    0.9618    0.6737    0.1837   -0.3612   -0.7980   -0.9957   -0.8952
    0.8952    0.1837   -0.6737   -0.9957   -0.5264    0.3612    0.9618
    0.7980   -0.3612   -0.9957   -0.1837    0.8952    0.6737   -0.5264
    0.6737   -0.7980   -0.5264    0.8952    0.3612   -0.9618   -0.1837
    0.5264   -0.9957    0.3612    0.6737   -0.9618    0.1837    0.7980
    0.3612   -0.8952    0.9618   -0.5264   -0.1837    0.7980   -0.9957
    0.1837   -0.5264    0.7980   -0.9618    0.9957   -0.8952    0.6737
  Column 8
    0.1837
   -0.5264
    0.7980
   -0.9618
    0.9957
   -0.8952
    0.6737
   -0.3612
ans =
   2.3428e-13

DSTVII matrix definition

$${\mathbf{DSTVII}}\mathrm{{=}}{\left\{{\sin\left({\frac{\mathit{\pi}}{{n}\mathrm{{+}}\frac{1}{2}}\left({{k}\mathrm{{+}}\frac{1}{2}}\right)\left({{l}\mathrm{{+}}{1}}\right)}\right)}\right\}}_{k\mathrm{,}l}$$

N2=8; N=N2;
k=0:N2-1;  l=0:N2-1;
DST7=sin(pi/(N+1/2)*(k+1/2)'*(l+1))       % display DCTV matrix
DST7 =
  Columns 1 through 7
    0.1837    0.3612    0.5264    0.6737    0.7980    0.8952    0.9618
    0.5264    0.8952    0.9957    0.7980    0.3612   -0.1837   -0.6737
    0.7980    0.9618    0.3612   -0.5264   -0.9957   -0.6737    0.1837
    0.9618    0.5264   -0.6737   -0.8952    0.1837    0.9957    0.3612
    0.9957   -0.1837   -0.9618    0.3612    0.8952   -0.5264   -0.7980
    0.8952   -0.7980   -0.1837    0.9618   -0.6737   -0.3612    0.9957
    0.6737   -0.9957    0.7980   -0.1837   -0.5264    0.9618   -0.8952
    0.3612   -0.6737    0.8952   -0.9957    0.9618   -0.7980    0.5264
  Column 8
    0.9957
   -0.9618
    0.8952
   -0.7980
    0.6737
   -0.5264
    0.3612
   -0.1837

DSTVII in terms of Tschebyshev polynomials

The DSTVII matrix can be expressed in terms of Tschebyshev polynomials [1]

$${\mathbf{DSTVII}}\mathrm{{=}}{\mathbf{D}}_{DSTVII}\mathrm{\cdot}{\left[{{U}_{l}\left({{\mathit{\beta}}_{k}}\right)}\right]}_{k\mathrm{,}l}$$

where

$${\mathit{\beta}}_{k}\mathrm{{=}}\cos\mathrm{\left({\frac{\left({{k}{+}\frac{1}{2}}\right)\mathrm{\pi}}{{N}{+}\frac{1}{2}}}\right)}{\mathrm{,}}{k}\mathrm{{=}}{0}\mathrm{\ldots}{N}\mathrm{{-}}{1}$$

are roots of polynomial

$${U}_{DSTVII}\mathrm{{=}}{V}_{n}$$

$${\mathbf{D}}_{DSTVII}\mathrm{{=}}{diag}{\left\{{\sin\left({\left({{k}\mathrm{{+}}\frac{1}{2}}\right)\frac{\mathit{\pi}}{\left({{N}\mathrm{{+}}\frac{1}{2}}\right)}}\right)}\right\}}_{k}$$

beta=sort([roots(TschebyshevV(N))],'descend');
DST7t=zeros(N);
for l=0:N2-1,
    DST7t(:,l+1)=polyval(TschebyshevU(l),beta)';
end
Db7=diag(sin(pi/(N+1/2)*(k+1/2)));
DST7t=Db7*DST7t                    % display DCTV matrix

% compare DST7 and DST7t matrices (show that both definitions above are equivalent)
max(max(abs(DST7-DST7t)))
DST7t =
  Columns 1 through 7
    0.1837    0.3612    0.5264    0.6737    0.7980    0.8952    0.9618
    0.5264    0.8952    0.9957    0.7980    0.3612   -0.1837   -0.6737
    0.7980    0.9618    0.3612   -0.5264   -0.9957   -0.6737    0.1837
    0.9618    0.5264   -0.6737   -0.8952    0.1837    0.9957    0.3612
    0.9957   -0.1837   -0.9618    0.3612    0.8952   -0.5264   -0.7980
    0.8952   -0.7980   -0.1837    0.9618   -0.6737   -0.3612    0.9957
    0.6737   -0.9957    0.7980   -0.1837   -0.5264    0.9618   -0.8952
    0.3612   -0.6737    0.8952   -0.9957    0.9618   -0.7980    0.5264
  Column 8
    0.9957
   -0.9618
    0.8952
   -0.7980
    0.6737
   -0.5264
    0.3612
   -0.1837
ans =
   1.4100e-13

Finding relations

Because there exist relation

$$ {V}_{l}\mathrm{{=}}{U}_{l}\mathrm{{-}}{U}_{{l}\mathrm{{-}}{1}} $$

and

we can express DCTVIII through DSTVII

where

B=toeplitz([1 zeros(1,N-1)]',[1 -1 zeros(1,N-length([1 -1]))]);

Check expression of DCTVIII through DSTVII

DCT8a=Da8*inv(Db7)*DST7*B
% compare DCT8 and DCT8a matrices (show correctness of representation of DCTVIII through DSTVII)
max(max(abs(DCT8-DCT8a)))
DCT8a =
  Columns 1 through 7
    0.9957    0.9618    0.8952    0.7980    0.6737    0.5264    0.3612
    0.9618    0.6737    0.1837   -0.3612   -0.7980   -0.9957   -0.8952
    0.8952    0.1837   -0.6737   -0.9957   -0.5264    0.3612    0.9618
    0.7980   -0.3612   -0.9957   -0.1837    0.8952    0.6737   -0.5264
    0.6737   -0.7980   -0.5264    0.8952    0.3612   -0.9618   -0.1837
    0.5264   -0.9957    0.3612    0.6737   -0.9618    0.1837    0.7980
    0.3612   -0.8952    0.9618   -0.5264   -0.1837    0.7980   -0.9957
    0.1837   -0.5264    0.7980   -0.9618    0.9957   -0.8952    0.6737
  Column 8
    0.1837
   -0.5264
    0.7980
   -0.9618
    0.9957
   -0.8952
    0.6737
   -0.3612
ans =
   8.8818e-16

Check expression of DSTVII through DCTVIII

DST7a=Db7*inv(Da8)*DCT8*inv(B);
DST7a=DST7a(:,:)
% compare DST7 and DST7a matrices (show correctness of representation of DSTVII through DCTVIII)
max(max(abs(DST7-DST7a)))
DST7a =
  Columns 1 through 7
    0.1837    0.3612    0.5264    0.6737    0.7980    0.8952    0.9618
    0.5264    0.8952    0.9957    0.7980    0.3612   -0.1837   -0.6737
    0.7980    0.9618    0.3612   -0.5264   -0.9957   -0.6737    0.1837
    0.9618    0.5264   -0.6737   -0.8952    0.1837    0.9957    0.3612
    0.9957   -0.1837   -0.9618    0.3612    0.8952   -0.5264   -0.7980
    0.8952   -0.7980   -0.1837    0.9618   -0.6737   -0.3612    0.9957
    0.6737   -0.9957    0.7980   -0.1837   -0.5264    0.9618   -0.8952
    0.3612   -0.6737    0.8952   -0.9957    0.9618   -0.7980    0.5264
  Column 8
    0.9957
   -0.9618
    0.8952
   -0.7980
    0.6737
   -0.5264
    0.3612
   -0.1837
ans =
   3.1086e-15

Check computation of DCTVIII transform

x=randn(N1,1);
disp('x''=');disp(x');
y=DCT8*x;                      % true result
disp('y''=');disp(y');
y1=Da8*inv(Db7)*DST7*B*x;            % compute DCTVIII using DSTVII transform
disp('y1''=');disp(y1');
x'=
  Columns 1 through 7
   -1.9609   -0.1977   -1.2078    2.9080    0.8252    1.3790   -1.0582
  Column 8
   -0.4686
y'=
  Columns 1 through 7
   -0.0897   -4.1294   -5.2016    1.8504    0.7753   -0.2779   -1.5372
  Column 8
   -4.9734
y1'=
  Columns 1 through 7
   -0.0897   -4.1294   -5.2016    1.8504    0.7753   -0.2779   -1.5372
  Column 8
   -4.9734

Check computation of DSTVII transform

x=randn(N2,1);
disp('x''=');disp(x');
y=DST7*x;                      % true result
disp('y''=');disp(y');
y1=Db7*inv(Da8)*DCT8*inv(B)*x;            % compute DSTVII using DCTVIII transform
disp('y1''=');disp(y1');
% Reference
x'=
  Columns 1 through 7
   -0.2725    1.0984   -0.2779    0.7015   -2.0518   -0.3538   -0.8236
  Column 8
   -1.5771
y'=
  Columns 1 through 7
   -3.6435    2.5185    1.0878    0.1070   -2.0081    1.1256   -0.7206
  Column 8
   -3.6206
y1'=
  Columns 1 through 7
   -3.6435    2.5185    1.0878    0.1070   -2.0081    1.1256   -0.7206
  Column 8
   -3.6206