Relations between DCTVI and DSTV

Contents

Definitions

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

DCTVI matrix definition

$${\bf DCTVI}=\cos{\left({{{{\rm \pi}}\over{n-{{1}\over{2}}}}k\left({l+{{1}\over{2}}}\right)}\right)}_{k,l}$$

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

DCTVI in terms of Tschebyshev polynomials

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

$${\bf DCTVI}={\bf D}_{DCTVI}\cdot{\left[{V_{l}\left({{\rm \alpha}_{k}}\right)}\right]}_{k,l}$$

where

$${\rm \alpha}_{k}=\cos\left({{{\left({k+1}\right){\rm \pi}}\over{N-{{1}\over{2}}}}}\right),k=-1\ldots N-2$$

are roots of polynomial

$$ U_{DCTVI}  = 2\left( {x - 1} \right)W_{n - 1} $$

$${\bf D}_{DCTVI}=diag{\left\{{\cos\left({k{{\pi}\over{2\left({N-{{1}\over{2}}}\right)}}}\right)}\right\}}_{k}$$

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

% compare DCT6 and DCT6t matrices (show that both definitions above are equivalent)
max(max(abs(DCT6-DCT6t)))
DCT6t =
  Columns 1 through 7
    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000
    0.9830    0.8502    0.6026    0.2737   -0.0923   -0.4457   -0.7390
    0.9325    0.4457   -0.2737   -0.8502   -0.9830   -0.6026    0.0923
    0.8502   -0.0923   -0.9325   -0.7390    0.2737    0.9830    0.6026
    0.7390   -0.6026   -0.8502    0.4457    0.9325   -0.2737   -0.9830
    0.6026   -0.9325   -0.0923    0.9830   -0.4457   -0.7390    0.8502
    0.4457   -0.9830    0.7390    0.0923   -0.8502    0.9325   -0.2737
    0.2737   -0.7390    0.9830   -0.9325    0.6026   -0.0923   -0.4457
    0.0923   -0.2737    0.4457   -0.6026    0.7390   -0.8502    0.9325
  Columns 8 through 9
    1.0000    1.0000
   -0.9325   -1.0000
    0.7390    1.0000
   -0.4457   -1.0000
    0.0923    1.0000
    0.2737   -1.0000
   -0.6026    1.0000
    0.8502   -1.0000
   -0.9830    1.0000
ans =
   1.6165e-13

DSTV matrix definition

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

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

DSTV in terms of Tschebyshev polynomials

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

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

where

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

are roots of polynomial

$${U}_{DCTVI}\mathrm{{=}}{W}_{n}$$

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

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

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

Finding relations

Because there exist relation

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

and

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

we can express DCTVI through DSTV

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

where

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

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

Check expression of DCTVI through DSTV

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

DCT6a=Da6*blkdiag(1,inv(Db5)*DST5)*B
% compare DCT6 and DCT6a matrices (show correctness of representation of DCTVI through DSTV)
max(max(abs(DCT6-DCT6a)))
DCT6a =
  Columns 1 through 7
    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000
    0.9830    0.8502    0.6026    0.2737   -0.0923   -0.4457   -0.7390
    0.9325    0.4457   -0.2737   -0.8502   -0.9830   -0.6026    0.0923
    0.8502   -0.0923   -0.9325   -0.7390    0.2737    0.9830    0.6026
    0.7390   -0.6026   -0.8502    0.4457    0.9325   -0.2737   -0.9830
    0.6026   -0.9325   -0.0923    0.9830   -0.4457   -0.7390    0.8502
    0.4457   -0.9830    0.7390    0.0923   -0.8502    0.9325   -0.2737
    0.2737   -0.7390    0.9830   -0.9325    0.6026   -0.0923   -0.4457
    0.0923   -0.2737    0.4457   -0.6026    0.7390   -0.8502    0.9325
  Columns 8 through 9
    1.0000    1.0000
   -0.9325   -1.0000
    0.7390    1.0000
   -0.4457   -1.0000
    0.0923    1.0000
    0.2737   -1.0000
   -0.6026    1.0000
    0.8502   -1.0000
   -0.9830    1.0000
ans =
   1.7208e-15

Check expression of DSTV through DCTVI

$$\mathrm{\left[{\begin{array}{cc}{1}&{}\\{}&{\mathbf{DSTV}}\end{array}}\right]}\mathrm{{=}}\mathrm{\left[{\begin{array}{cc}{1}&{}\\{}&{{\mathbf{D}}_{DSTV}}\end{array}}\right]}\mathrm{\cdot}{\mathbf{D}}_{DCTVI}{}^{\mathrm{{-}}{1}}\mathit{\cdot}{\mathbf{DSTV}}{\mathbf{I}}\mathrm{\cdot}{\mathbf{B}}^{\mathrm{{-}}{1}}$$

DST5a=blkdiag(1,Db5)*inv(Da6)*DCT6*inv(B);
DST5a=DST5a(2:end,2:end)
% compare DST5 and DST5a matrices (show correctness of representation of DSTV through DCTVI)
max(max(abs(DST5-DST5a)))
DST5a =
  Columns 1 through 7
    0.3612    0.6737    0.8952    0.9957    0.9618    0.7980    0.5264
    0.6737    0.9957    0.7980    0.1837   -0.5264   -0.9618   -0.8952
    0.8952    0.7980   -0.1837   -0.9618   -0.6737    0.3612    0.9957
    0.9957    0.1837   -0.9618   -0.3612    0.8952    0.5264   -0.7980
    0.9618   -0.5264   -0.6737    0.8952    0.1837   -0.9957    0.3612
    0.7980   -0.9618    0.3612    0.5264   -0.9957    0.6737    0.1837
    0.5264   -0.8952    0.9957   -0.7980    0.3612    0.1837   -0.6737
    0.1837   -0.3612    0.5264   -0.6737    0.7980   -0.8952    0.9618
  Column 8
    0.1837
   -0.3612
    0.5264
   -0.6737
    0.7980
   -0.8952
    0.9618
   -0.9957
ans =
   1.9984e-15

Check computation of DCTVI transform

x=randn(N1,1);
disp('x''=');disp(x');
y=DCT6*x;                      % true result
disp('y''=');disp(y');
y1=Da6*blkdiag(1,inv(Db5)*DST5)*B*x;            % compute DCTVI using DSTV transform
disp('y1''=');disp(y1');
x'=
  Columns 1 through 7
   -0.8637    0.0774   -1.2141   -1.1135   -0.0068    1.5326   -0.7697
  Columns 8 through 9
    0.3714   -0.2256
y'=
  Columns 1 through 7
   -2.2120   -2.0540   -0.4309    2.3145   -0.0095   -3.0319   -0.2648
  Columns 8 through 9
    0.2902   -2.5875
y1'=
  Columns 1 through 7
   -2.2120   -2.0540   -0.4309    2.3145   -0.0095   -3.0319   -0.2648
  Columns 8 through 9
    0.2902   -2.5875

Check computation of DSTV transform

x=randn(N2,1);
disp('x''=');disp(x');
y=DST5*x;                      % true result
disp('y''=');disp(y');
y1=blkdiag(1,Db5)*inv(Da6)*DCT6*inv(B)*[0;x];            % compute DSTV using DCTVI transform
disp('y1''=');disp(y1');
% Reference
x'=
  Columns 1 through 7
    1.1174   -1.0891    0.0326    0.5525    1.1006    1.5442    0.0859
  Column 8
   -1.4916
y'=
  Columns 1 through 7
    2.3113   -1.8069   -1.2896    3.4160   -0.3740    3.5372    0.3434
  Column 8
    1.3075
y1'=
  Columns 1 through 7
    0.0000    2.3113   -1.8069   -1.2896    3.4160   -0.3740    3.5372
  Columns 8 through 9
    0.3434    1.3075