# 阿达马变换

## 变换矩阵

H.264中使用了4阶和8阶的阿达马变换来计算SATD，其变换矩阵为：

$H_4 = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{bmatrix}$
$H_8 = \begin{bmatrix} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 & 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 & 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 & 1 & -1 & -1 & 1 \\ 1 & 1 & 1 & 1 & -1 & -1 & -1 & -1 \\ 1 & -1 & 1 & -1 & -1 & 1 & -1 & 1 \\ 1 & 1 & -1 & -1 & -1 & -1 & 1 & 1 \\ 1 & -1 & -1 & 1 & -1 & 1 & 1 & -1 \end{bmatrix}$

## SATD计算方法

$\begin{bmatrix} L_4' \end{bmatrix} = \begin{bmatrix} H_4 \end{bmatrix} \times \begin{bmatrix} L_4 \end{bmatrix} \times \begin{bmatrix} H_4 \end{bmatrix}$

$\begin{bmatrix} L_8' \end{bmatrix} = \begin{bmatrix} H_8 \end{bmatrix} \times \begin{bmatrix} L_8 \end{bmatrix} \times \begin{bmatrix} H_8 \end{bmatrix}$

## 建構阿达马变换

• 二點阿达马变换轉換：

$\boldsymbol{W_2} = \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$

• 四點阿达马变换轉換：

$\boldsymbol{W_4} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \\ 1 & -1 & 1 & -1 \end{bmatrix}$

• 產生 $\boldsymbol{2^k}$ 點阿达马变换的步驟：

$\boldsymbol{V_{2^{k+1}}} \longrightarrow \boldsymbol{W_{2^{k+1}}}$

## 範例

$\boldsymbol{V_4} = \begin{bmatrix} \boldsymbol{W_2} & \boldsymbol{W_2} \\ \boldsymbol{W_2} & \boldsymbol{-W_2} \end{bmatrix} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{bmatrix} ,\quad \boldsymbol{W_4} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \\ 1 & -1 & 1 & -1 \end{bmatrix}.$

$\boldsymbol{V_8} = \begin{bmatrix} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & -1 & -1 & 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 & 1 & -1 & -1 & 1 \\ 1 & -1 & 1 & -1 & 1 & -1 & 1 & -1 \\ 1 & 1 & 1 & 1 & -1 & -1 & -1 & -1 \\ 1 & 1 & -1 & -1 & -1 & -1 & 1 & 1 \\ 1 & -1 & -1 & 1 & -1 & 1 & 1 & -1 \\ 1 & -1 & 1 & -1 & -1 & 1 & -1 & 1 \end{bmatrix}, \quad \boldsymbol{W_8} = \begin{bmatrix} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & -1 & -1 & -1 & -1 \\ 1 & 1 & -1 & -1 & -1 & -1 & 1 & 1 \\ 1 & 1 & -1 & -1 & 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 & 1 & -1 & -1 & 1 \\ 1 & -1 & -1 & 1 & -1 & 1 & 1 & -1 \\ 1 & -1 & 1 & -1 & -1 & 1 & -1 & 1 \\ 1 & -1 & 1 & -1 & 1 & -1 & 1 & -1 \end{bmatrix}.$

## 特性

• 正交性

$\sum_{n=0}^{N-1} W\left[ {h, n} \right]W\left[ {m, n} \right] = 0, \quad \mathrm{if} \, h \ne m.$

$f\left[{n}\right] \Rightarrow F\left[{m}\right] \, and \, \, g\left[{n}\right] \Rightarrow G\left[{m}\right],$

$a\,f\left[{n}\right] + b\,g\left[{n}\right] \Rightarrow a\,F\left[{m}\right] + b\,G\left[{m}\right].$

$W\left[{m, n}\right] \cdot W\left[{l, n}\right] = W\left[{m \oplus l, n}\right].$

$0 \oplus 0 = 0, \quad 0 \oplus 1 = 1, \quad 1 \oplus 0 = 1, \quad 1 \oplus 1 = 0,$

$\delta\left[{n}\right] \Rightarrow 1, \quad 1 \Rightarrow N \cdot \delta\left[{n}\right].$

$f\left[{n}\right] \Rightarrow F\left[{m}\right],$

$f\left[{n \oplus k}\right] \Rightarrow W\left[{k, m}\right] F\left[{m}\right].$

$f\left[{n}\right] \Rightarrow F\left[{m}\right],$

$W\left[{k, n}\right] f\left[{n}\right] \Rightarrow F\left[{m \oplus k}\right].$

$f\left[{n}\right] \Rightarrow F\left[{m}\right], \quad \sum_{n=0}^{N-1} \left| f\left[ n \right] \right|^2 = \left( \frac{1}{N} \right) \sum_{n=0}^{N-1} \left| F\left[ m \right] \right|^2.$

$f\left[{n}\right] \Rightarrow F\left[{m}\right] \, and \, \, g\left[{n}\right] \Rightarrow G\left[{m}\right],$

$\sum_{n=0}^{N-1} f\left[ n \right]g\left[ n \right] = \left( \frac{1}{N} \right) \sum_{n=0}^{N-1} F\left[ m \right]G\left[ m \right].$

• 摺積性質 (Convolution Property)

$f\left[{n}\right] \Rightarrow F\left[{m}\right] \, and \, \, g\left[{n}\right] \Rightarrow G\left[{m}\right],$

$h\left[{n}\right] = f\left[{n}\right] \star g\left[{n}\right] \Rightarrow H\left[{m}\right] = F\left[{m}\right] G\left[{m}\right],$

## 優缺點比較

### 優點

• 僅需實數運算 (Real operation) 。
• 不需乘法運算 (No multiplication) ，僅有加減法運算。
• 有部分性質類似於離散傅立葉變換 (Discrete fourier transform) 。
• 順向轉換 (Forward transform) 與反向轉換 (Inverse transform ) 型式為相似式。

$\begin{cases} \begin{matrix} F\left[ m \right] &=& \sum_{n=0}^{N-1} W\left[ {m, n} \right] f\left[ n \right] & & (\mbox{Forward Type}) \\ f\left[ n \right] &=& \left( \frac{1}{N} \right) \sum_{n=0}^{N-1} W\left[ {m, n} \right]F\left[ m \right] & &(\mbox{Inverse Type}) \end{matrix} \end{cases},$

## 應用範圍

• 帶寬降低 (Bandwidth reduction) 。
• CDMA (Code division multiple access)。

## Jacket 轉換

$\boldsymbol{J_4} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 1 & -w & w & -1 \\ 1 & w & -w & 1 \\ 1 & -1 & -1 & 1 \end{bmatrix}, \quad where \ w = \pm 2^k.$

• $\boldsymbol{2^{k+1}}$ 點的 Jacket 轉換：

$\boldsymbol{J_{2^{k+1}}} = \begin{bmatrix} \boldsymbol{J_{2^{k}}} & \boldsymbol{J_{2^{k}}} \\ \boldsymbol{J_{2^{k}}} & -\boldsymbol{J_{2^{k}}} \end{bmatrix}.$

## 參考文獻

• Jian-Jiun Ding, Advanced Digital Signal Processing class note,the Department of Electrical Engineering, National Taiwan University (NTU), Taipei, Taiwan, 2008.
• H. F. Harmuth,“Transmission of information by orthogonal functions,”1970.
• Moon-Hu. Lee,“A new reverse Jacket transform and its fast algorithm,”IEEE Trans. Circuits Syst.-II, vol. 47, pp.39-46, 2000.
• K.G.Beauchamp, "Walsh Functions and Their Applications," Academic Press,1975.
• H. F. Harmuth, "Transmission of Information by Orthogonal Functions," Springer, 1969.