Relations between DCTVII 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

DCTVII matrix definition

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

N1=9; N=N1;
k=0:N1-1;  l=0:N1-1;
DCT7=cos(pi/(N-1/2)*(k+1/2)'*l)       % display DCTV matrix
DCT7 =
  Columns 1 through 7
    1.0000    0.9830    0.9325    0.8502    0.7390    0.6026    0.4457
    1.0000    0.8502    0.4457   -0.0923   -0.6026   -0.9325   -0.9830
    1.0000    0.6026   -0.2737   -0.9325   -0.8502   -0.0923    0.7390
    1.0000    0.2737   -0.8502   -0.7390    0.4457    0.9830    0.0923
    1.0000   -0.0923   -0.9830    0.2737    0.9325   -0.4457   -0.8502
    1.0000   -0.4457   -0.6026    0.9830   -0.2737   -0.7390    0.9325
    1.0000   -0.7390    0.0923    0.6026   -0.9830    0.8502   -0.2737
    1.0000   -0.9325    0.7390   -0.4457    0.0923    0.2737   -0.6026
    1.0000   -1.0000    1.0000   -1.0000    1.0000   -1.0000    1.0000
  Columns 8 through 9
    0.2737    0.0923
   -0.7390   -0.2737
    0.9830    0.4457
   -0.9325   -0.6026
    0.6026    0.7390
   -0.0923   -0.8502
   -0.4457    0.9325
    0.8502   -0.9830
   -1.0000    1.0000

DCTVII in terms of Tschebyshev polynomials

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

$${\mathbf {DCTVII}} = \left[ {T_l \left( {\alpha _k } \right)} \right]_{k,l} $$

where

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

are roots of polynomial

$${U}_{DCTVII}\mathrm{{=}}\mathrm{\left({{x}{+}{1}}\right)}{V}_{{n}\mathrm{{-}}{1}}$$

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

% compare DCT7 and DCT7t matrices (show that both definitions above are equivalent)
max(max(abs(DCT7-DCT7t)))
DCT7t =
  Columns 1 through 7
    1.0000    0.9830    0.9325    0.8502    0.7390    0.6026    0.4457
    1.0000    0.8502    0.4457   -0.0923   -0.6026   -0.9325   -0.9830
    1.0000    0.6026   -0.2737   -0.9325   -0.8502   -0.0923    0.7390
    1.0000    0.2737   -0.8502   -0.7390    0.4457    0.9830    0.0923
    1.0000   -0.0923   -0.9830    0.2737    0.9325   -0.4457   -0.8502
    1.0000   -0.4457   -0.6026    0.9830   -0.2737   -0.7390    0.9325
    1.0000   -0.7390    0.0923    0.6026   -0.9830    0.8502   -0.2737
    1.0000   -0.9325    0.7390   -0.4457    0.0923    0.2737   -0.6026
    1.0000   -1.0000    1.0000   -1.0000    1.0000   -1.0000    1.0000
  Columns 8 through 9
    0.2737    0.0923
   -0.7390   -0.2737
    0.9830    0.4457
   -0.9325   -0.6026
    0.6026    0.7390
   -0.0923   -0.8502
   -0.4457    0.9325
    0.8502   -0.9830
   -1.0000    1.0000
ans =
   2.5778e-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

$${T}_{l}\mathrm{{=}}\frac{{U}_{l}\mathrm{{+}}{U}_{{l}\mathrm{{-}}{2}}}{2}$$

and

$$\begin{array}{l}
{{\mathrm{\alpha}}_{k}\mathrm{{=}}{\mathrm{\beta}}_{k}{\mathrm{,}}{k}\mathrm{{=}}{0}\mathrm{\ldots}{N}\mathrm{{-}}{1}}\\
{{\mathrm{\alpha}}_{N}\mathrm{{=}}\mathrm{{-}}{1}}
\end{array}$$

we can express DCTVII through DSTVII

$$\begin{array}{l}
{{\mathbf{DCTVII}}\mathrm{{=}}{\left[{{T}_{l}\left({{\mathit{\alpha}}_{k}}\right)}\right]}_{k\mathrm{,}l}\mathrm{{=}}{\left[{\begin{array}{cc}{{U}_{l}\left({{\mathit{\beta}}_{k}}\right)}&{}\\{}&{1}\end{array}}\right]}_{k\mathrm{,}l}\mathit{\cdot}{\mathbf{B}}\mathrm{{=}}\mathrm{\left[{\begin{array}{cc}{{\left({{\mathbf{D}}_{DSTVII}}\right)}^{{-}{1}}\mathit{\cdot}{\mathbf{D}}_{DSTVII}\mathit{\cdot}{\left[{{U}_{l}\left({{\mathrm{\beta}}_{k}}\right)}\right]}_{k,l}}&{}\\{}&{1}\end{array}}\right]}\mathit{\cdot}{\mathbf{B}}\mathrm{{=}}}\\
{\mathrm{{=}}\mathrm{\left[{\begin{array}{cc}{{\left({{\mathbf{D}}_{DSTVII}}\right)}^{{-}{1}}\cdot{\mathbf{DSTVII}}}&{}\\{}&{1}\end{array}}\right]}\mathrm{\cdot}{\mathbf{B}}}
\end{array}$$

where

$${\mathbf{B}}\mathrm{{=}}\mathrm{\frac{1}{2}}\mathrm{\left[{\begin{array}{cccccc}{2}&{0}&{{-}{1}}&{}&{}&{}\\{}&{1}&{}&{\ddots}&{}&{}\\{}&{}&{1}&{\ddots}&{{-}{1}}&{}\\{}&{}&{}&{\ddots}&{}&{{-}{1}}\\{}&{}&{}&{}&{1}&{1}\\{2}&{{-}{2}}&{2}&{\cdots}&{{-}{2}}&{2}\end{array}}\right]}$$

B=toeplitz([0.5 zeros(1,N-1)]',[0.5           0        -0.5 zeros(1,N-length([0.5           0        -0.5]))]);
B(1,1)=1;
B=[B [0; B(1:end-1,end)]];
B(8,9)=0.5;
B=[B; (-1).^(0:size(B,2)-1)];

Check expression of DCTVII through DSTVII

$${\mathbf{DCTVII}}\mathrm{{=}}\left[{\begin{array}{cc}{{\left({{\mathbf{D}}_{DSTVII}}\right)}^{\mathrm{{-}}{1}}\mathrm{\cdot}{\mathbf{DSTVII}}}&{}\\{}&{1}\end{array}}\right]\mathrm{\cdot}{\mathbf{B}}$$

DCT7a=Da7*blkdiag(inv(Db7)*DST7,1)*B
% compare DCT7 and DCT7a matrices (show correctness of representation of DCTVII through DSTVII)
max(max(abs(DCT7-DCT7a)))
DCT7a =
  Columns 1 through 7
    1.0000    0.9830    0.9325    0.8502    0.7390    0.6026    0.4457
    1.0000    0.8502    0.4457   -0.0923   -0.6026   -0.9325   -0.9830
    1.0000    0.6026   -0.2737   -0.9325   -0.8502   -0.0923    0.7390
    1.0000    0.2737   -0.8502   -0.7390    0.4457    0.9830    0.0923
    1.0000   -0.0923   -0.9830    0.2737    0.9325   -0.4457   -0.8502
    1.0000   -0.4457   -0.6026    0.9830   -0.2737   -0.7390    0.9325
    1.0000   -0.7390    0.0923    0.6026   -0.9830    0.8502   -0.2737
    1.0000   -0.9325    0.7390   -0.4457    0.0923    0.2737   -0.6026
    1.0000   -1.0000    1.0000   -1.0000    1.0000   -1.0000    1.0000
  Columns 8 through 9
    0.2737    0.0923
   -0.7390   -0.2737
    0.9830    0.4457
   -0.9325   -0.6026
    0.6026    0.7390
   -0.0923   -0.8502
   -0.4457    0.9325
    0.8502   -0.9830
   -1.0000    1.0000
ans =
   2.3315e-15

Check expression of DSTVII through DCTVII

$$\left[{\begin{array}{cc}{\mathbf{DSTVII}}&{}\\{}&{1}\end{array}}\right]\mathrm{{=}}\left[{\begin{array}{cc}{{\mathbf{D}}_{DSTVII}}&{}\\{}&{1}\end{array}}\right]\mathrm{\cdot}{\mathbf{DCTVII}}\mathrm{\cdot}{\mathbf{B}}^{\mathrm{{-}}{1}}$$

DST7a=blkdiag(Db7,1)*inv(Da7)*DCT7*inv(B);
DST7a=DST7a(1:end-1,1:end-1)
% compare DST7 and DST7a matrices (show correctness of representation of DSTVII through DCTVII)
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.4417e-15

Check computation of DCTVII transform

x=randn(N1,1);
disp('x''=');disp(x');
y=DCT7*x;                      % true result
disp('y''=');disp(y');
y1=Da7*blkdiag(inv(Db7)*DST7,1)*B*x;            % compute DCTVII using DSTVII transform
disp('y1''=');disp(y1');
x'=
  Columns 1 through 7
   -0.8045    0.6966    0.8351   -0.2437    0.2157   -1.1658   -1.1480
  Columns 8 through 9
    0.1049    0.7223
y'=
  Columns 1 through 7
   -0.5078    1.9929   -0.8850   -2.8326    0.5374   -2.7494   -1.6514
  Columns 8 through 9
   -0.9564    0.4287
y1'=
  Columns 1 through 7
   -0.5078    1.9929   -0.8850   -2.8326    0.5374   -2.7494   -1.6514
  Columns 8 through 9
   -0.9564    0.4287

Check computation of DSTVII transform

x=randn(N2,1);
disp('x''=');disp(x');
y=DST7*x;                      % true result
disp('y''=');disp(y');
y1=blkdiag(Db7,1)*inv(Da7)*DCT7*inv(B)*[x;0];            % compute DSTVII using DCTVII transform
disp('y1''=');disp(y1');
% Reference
x'=
  Columns 1 through 7
    2.5855   -0.6669    0.1873   -0.0825   -1.9330   -0.4390   -1.7947
  Column 8
    0.8404
y'=
  Columns 1 through 7
   -2.5477    0.6680    4.1759   -0.0279    2.9861    1.9643    5.0760
  Column 8
   -0.9750
y1'=
  Columns 1 through 7
   -2.5477    0.6680    4.1759   -0.0279    2.9861    1.9643    5.0760
  Columns 8 through 9
   -0.9750   -0.0000