バックナンバーはこちら。
https://www.simulationroom999.com/blog/stock-predict-matlabpython-backnumber/
はじめに
前回は回転因子を行列表現し、
回転因子であるが故の各種最適化を実施。
これだけでも便利な概念ではある。
今回は、これをバタフライ演算に繋げるべくさらに最適化していく。
登場人物
博識フクロウのフクさん

イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん

イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
異なる回転因子を混ぜる

前回は回転因子が円状にあることを利用して最適化をしたが、
ここに対して異なるNの回転因子を混ぜることが可能だ。

異なるNの回転因子?

前回は\(N=4\)をベースにした回転因子だったが、
この中の\(n=0,2\)って
\(N=2\)に於ける\(n=0,1,\)と同じ値になるんだよね。

あ、そっか。
言われてみれば回転因子としては同じ位置になるね。

よって、以下に表現し直せる。
\(f_n\)の並びが変わっているところに注意だ。
\(
\begin{bmatrix}
F_0 \\
F_1 \\
F_2 \\
F_3 \\
\end{bmatrix}
=
\begin{bmatrix}
W_2^0 & W_2^0 & W_4^0W_2^0 & W_4^0W_2^0 \\
W_2^0 & W_2^1 & W_4^1W_2^0 & W_4^1W_2^1 \\
W_2^0 & W_2^1 & W_4^2W_2^0 & W_4^2W_2^0 \\
W_2^0 & W_2^1 & W_4^3W_2^0 & W_4^3W_2^1 \\
\end{bmatrix}
\begin{bmatrix}
f_0 \\
f_2 \\
f_1 \\
f_3 \\
\end{bmatrix}
\)

なんか余計ややこしくなったようにも見えるが・・・。
良く見ると、なんかルールはありそうにも見える・・・。

左上の2×2の行列だけを抜き出してみよう。
\begin{bmatrix}
W_2^0 & W_2^0 \\
W_2^0 & W_2^1 \\
\end{bmatrix}

あ!他の右上、左下、右下にも同じ並びがあるね。

これをいい感じに整理したのがこれだ
\(
\begin{bmatrix}
F_0 \\
F_1 \\
F_2 \\
F_3 \\
\end{bmatrix}
=
\begin{bmatrix}
1 & 0 & W_4^0 & 0 \\
0 & 1 & 0 & W_4^1 \\
1 & 0 & W_4^2 & 0 \\
0 & 1 & 0 & W_4^3 \\
\end{bmatrix}
\begin{bmatrix}
W_2^0 & W_2^0 & 0 & 0 \\
W_2^0 & W_2^1 & 0 & 0 \\
0 & 0 & W_2^0 & W_2^0 \\
0 & 0 & W_2^0 & W_2^1 \\
\end{bmatrix}
\begin{bmatrix}
f_0 \\
f_2 \\
f_1 \\
f_3 \\
\end{bmatrix}
\)
中間変数を置いてみる。

キレイに整理されていくように見える反面、
行列が分離した魔境臭もしてきたぞ・・・。

行列が分離するということは演算もキレイに分離できるってことだ。
つまり、中間変数\(G_n\)を挟んで2段階に分けて計算すると以下になる。
\(
\begin{bmatrix}
G_0 \\
G_1 \\
\end{bmatrix}
=
\begin{bmatrix}
W_2^0 & W_2^0 \\
W_2^0 & W_2^1 \\
\end{bmatrix}
\begin{bmatrix}
f_0 \\
f_2 \\
\end{bmatrix}
\)
\(
\begin{bmatrix}
G_2 \\
G_3 \\
\end{bmatrix}
=
\begin{bmatrix}
W_2^0 & W_2^0 \\
W_2^0 & W_2^1 \\
\end{bmatrix}
\begin{bmatrix}
f_1 \\
f_3 \\
\end{bmatrix}
\)
\(
\begin{bmatrix}
F_0 \\
F_1 \\
F_2 \\
F_3 \\
\end{bmatrix}
=
\begin{bmatrix}
1 & 0 & W_4^0 & 0 \\
0 & 1 & 0 & W_4^1 \\
1 & 0 & W_4^2 & 0 \\
0 & 1 & 0 & W_4^3 \\
\end{bmatrix}
\begin{bmatrix}
G_0 \\
G_1 \\
G_2 \\
G_3 \\
\end{bmatrix}
\)

そして、\(W_4^2=-W_4^2\)、\(W_4^3=-W_4^1\)なので、
\(
\begin{bmatrix}
F_0 \\
F_1 \\
F_2 \\
F_3 \\
\end{bmatrix}
=
\begin{bmatrix}
1 & 0 & W_4^0 & 0 \\
0 & 1 & 0 & W_4^1 \\
1 & 0 & -W_4^0 & 0 \\
0 & 1 & 0 & -W_4^1 \\
\end{bmatrix}
\begin{bmatrix}
G_0 \\
G_1 \\
G_2 \\
G_3 \\
\end{bmatrix}
\)

なんか\(0,1,W_4^0,W_4^1\)だけになっちゃったね。

これでバタフライ演算の準備が整った状態だ。
まとめ

まとめだよ。
- Nの回転因子にN/2の回転因子を含めることが可能
- 複数段の行列に分解可能。
- つまり、演算を分解できる。
- 最終的に残る値はかなり限られる。
- これを利用してバタフライ演算を行うことになる。
バックナンバーはこちら。
コメント