2.改進LLL方法-Deep Insertion LLL
原本的LLL只考慮相鄰的兩列向量( \( v_i^*、v_{i-1}^* \) )是否滿足Lovász condition( \( \displaystyle \Vert\; v_i^* \Vert\;^2 \ge (\frac{3}{4}-\mu_{i,i-1}^2)\Vert\; v_{i-1}^* \Vert\;^2 \) ),違反的話則將\( v_{k-1},v_k \)交換。而Deep Insertion則考慮兩個向量( \( \hat v_i^*、v_i^* \) )是否滿足deep exchange condition( \( \displaystyle \Vert\; \hat v_i^* \Vert\;^2 < \frac{3}{4} \Vert\; v_i^* \Vert\;^2 \) ),成立的話則將\( v_k \)向量插入\( v_i \)向量的位置。
先解釋什麼是\( \hat v_i^*、v_i^* \)
設lattice的向量為\( v_1,\ldots,v_{i-1},\color{blue}{v_i},v_{i+1},\ldots,v_{k-1},\color{blue}{v_k},v_{k+1},\ldots,v_n \)
Gram Schmidt正交化後第\( i \)個向量為\( v_i^* \),向量長度的平方為\( \Vert\; v_i^* \Vert\;^2 \)
經deep insertion後將\( v_k \)向量插入\( v_i \)向量的位置\( v_1,\ldots,v_{i-1},\color{blue}{v_k},v_i,v_{i+1},\ldots,v_{k-1},v_{k+1},\ldots,v_n \)
Gram Schmidt正交化第\( i \)個向量為\( \displaystyle \hat v_i^*=v_k-\sum_{j=1}^{i-1} \mu_{k,j} v_j^* \)
移項後得到\( \displaystyle v_k=\hat v_i^*+\sum_{j=1}^{i-1}\mu_{k,j}v_j^* \)
平方求向量長度\( \displaystyle \Vert\; v_k \Vert\;^2=\Vert\; \hat v_i^* \Vert\;^2+\sum_{j=1}^{i-1}\mu_{k,j}^2 \Vert\; v_j^* \Vert\;^2 \)
再移項後得到\( \displaystyle \Vert\; \hat v_i^* \Vert\;^2=\Vert\; v_k \Vert\;^2-\sum_{j=1}^{i-1} \mu_{k,j}^2 \Vert\; v_j^* \Vert\;^2 \)
所以deep exchange condition是在比較插入前和插入後的Gram Schmidt正交化的向量長度,比較條件可以改成\( \displaystyle \Vert\; v_k \Vert\;^2-\sum_{j=1}^{i-1} \mu_{k,j}^2 \Vert\; v_j^* \Vert\;^2 < \frac{3}{4} \Vert\; v_i^* \Vert\;^2 \)。
之前兩個lattice( \( \left[ \matrix{1 & 1 & 1 \cr -1 & 0 & 2 \cr 3 & 5 & 6} \right] \),\( \left[ \matrix{1 & 1 & 7 & 2 \cr 9 & 8 & 4 & 6 \cr 1 & 8 & 5 & 7 \cr 2 & 3 & 1 & 1} \right] \) )執行Deep Insertion LLL後的結果和原來的LLL相同。
於是我採用Lattice Basis Reduction: An Introduction to the LLL Algorithm and Its Applications在91頁的例子
\( \left[ \matrix{9 & 2 & 7 \cr 8 & 6 & 1 \cr 3 & 2 & 6} \right] \)
我將有Deep Insertion的步驟特別寫出來,讓各位可以了解要插入的哪個位置。
第1次Deep Insertion:
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & \cr -\frac{43}{134} & 1 & 0 \cr \frac{73}{134} & -\frac{1015}{5253} & 1} \right] \),\( v^*=\left[ \matrix{\displaystyle 9 & 2 & 7 \cr \frac{253}{134} & \frac{311}{67} & -\frac{503}{134} \cr -\frac{8080}{5253} & \frac{9494}{5253} & \frac{7676}{5253}} \right] \)
\( v_2 \)可不可以插入\( v_1 \)位置?檢查\( \displaystyle \Vert\; v_2 \Vert\;^2 < \frac{3}{4} \Vert\; v_1^* \Vert\;^2 \)是否成立?
\( \displaystyle ((-1)^2+4^2+(-6)^2) < \frac{3}{4}(9^2+2^2+7^2) \),\( 53<100.5 \)成立
\( v=\left[ \matrix{9 & 2 & 7 \cr -1 & 4 & -6 \cr 3 & 2 & 6} \right] \),將\( v_2 \)插入\( v_1 \)位置,\( v=\left[ \matrix{-1 & 4 & -6 \cr 9 & 2 & 7 \cr 3 & 2 & 6} \right] \)
第2次Deep Insertion:
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr -\frac{43}{53} & 1 & 0 \cr \frac{22}{53} & \frac{2536}{5253} & 1} \right] \),\( v^*=\left[ \matrix{\displaystyle -1 & 4 & -6 \cr \frac{434}{53} & \frac{278}{53} & \frac{113}{53} \cr -\frac{8080}{5253} & \frac{9494}{5253} & \frac{7676}{5253}} \right] \)
\( v_3 \)可不可以插入\( v_1 \)位置?檢查\( \displaystyle \Vert\; v_3 \Vert\;^2 < \frac{3}{4} \Vert\; v_1^* \Vert\;^2 \)是否成立?
\( \displaystyle (2^2+6^2+0^2) < \frac{3}{4}((-1)^2+4^2+(-6)^2) \),\( 40<39.75 \)不成立,故\( v_3 \)不能插入\( v_1 \)位置。
\( v_3 \)可不可以插入\( v_2 \)位置?檢查\( \displaystyle \Vert\; v_3 \Vert\;^2-\mu_{3,1}^2 \Vert\; v_1^* \Vert\;^2 < \frac{3}{4} \Vert\; v_2^* \Vert\;^2 \)是否成立?
\( \displaystyle (2^2+6^2+0^2)-\left( \frac{22}{53} \right)^2((-1)^2+4^2+(-6)^2) < \frac{3}{4}\left( \left( \frac{434}{53} \right)^2+\left( \frac{278}{53} \right)^2+\left( \frac{113}{53} \right)^2 \right) \),\( 30.87<74.33 \)成立
\( v=\left[ \matrix{-1 & 4 & -6 \cr 9 & 2 & 7 \cr 2 & 6 & 0} \right] \),將\( v_3 \)插入\( v_2 \)位置,\( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 9 & 2 & 7} \right] \)
第3次Deep Insertion:
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{22}{53} & 1 & 0 \cr \frac{19}{53} & -\frac{184}{409} & 1} \right] \),\( v^*=\left[ \matrix{\displaystyle -1 & 4 & -6 \cr \frac{128}{53} & \frac{230}{53} & \frac{132}{53} \cr \frac{1818}{409} & -\frac{606}{409} & -\frac{707}{409}} \right] \)
\( v_3 \)可不可以插入\( v_1 \)位置?檢查\( \displaystyle \Vert\; v_3 \Vert\;^2 < \frac{3}{4} \Vert\; v_1^* \Vert\;^2
\)是否成立?
\( \displaystyle (3^2+(-2)^2+(-5)^2) < \frac{3}{4}((-1)^2+4^2+(-6)^2) \),\( 38<39.75 \)成立
\( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 3 & -2 & -5} \right] \),將\( v_3 \)插入\( v_1 \)位置,\( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 2 & 6 & 0} \right] \)
第4次Deep Insertion:
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{1}{2} & 1 & 0 \cr \frac{13}{38} & -\frac{37}{87} & 1} \right] \),\( v^*=\left[ \matrix{\displaystyle 3 & -2 & -5 \cr -\frac{5}{2} & 5 & -\frac{7}{2} \cr \frac{6464}{1653} & \frac{4646}{1653} & \frac{2020}{1653}} \right] \)
\( v_3 \)可不可以插入\( v_1 \)位置?檢查\( \displaystyle \Vert\; v_3 \Vert\;^2 < \frac{3}{4} \Vert\; v_1^* \Vert\;^2 \)是否成立?
\( \displaystyle (6^2+0^2+1^2) < \frac{3}{4}(3^2+(-2)^2+(-5)^2) \),\( 37<28.5 \)不成立,故\( v_3 \)不能插入\( v_1 \)位置。
\( v_3 \)可不可以插入\( v_2 \)位置?檢查\( \displaystyle \Vert\; v_3 \Vert\;^2-\mu_{3,1}^2 \Vert\; v_1^* \Vert\;^2 < \frac{3}{4} \Vert\; v_2^* \Vert\;^2 \)是否成立?
\( \displaystyle (6^2+0^2+1^2)-\left( \frac{6464}{1653} \right)^2(3^2+(-2)^2+(-5)^2) < \frac{3}{4}\left( \left( -\frac{5}{2} \right)^2+5^2+\left( -\frac{7}{2} \right)^2 \right) \),\( -544.09<32.63 \)成立
\( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 6 & 0 & 1} \right] \),將\( v_3 \)插入\( v_2 \)位置,\( v=\left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr -1 & 4 & -6} \right] \)
當\( v_k \)向量插入某個\( v_i \)位置之後,Gram-Schmidt正交化的\( \mu \)值和\( v^* \)向量都會受到影響,在Lattice Basis Reduction書中第5.3節有提到如何更新這些值,想了解細節的網友可自行查閱,但在這裡為了方便,我重新計算整個Gram-Schmidt正交化。
maxima程式碼有修改的地方我用紅色標示出來。
(%i1)
DeepInsertionLLL(v):=block
(vstar:copymatrix(v),
m:length(v),
mu:zeromatrix(m,m),
for i:1 thru m do
(for j:1 thru i do
(mu[ i ][j]:v[ i ].vstar[j]/vstar[j].vstar[j],
vstar[ i ]:v[ i ]-sum(mu[ i ][j]*vstar[j],j,1,i-1)
)
),
print("Gram-Schmidt正交化 μ=",mu," v*=",vstar),
k:2,
while k<=m do
(for i:k-1 thru 1 step -1 do
(q:round(mu[k][ i ]),
if q#0 then
(print("round(μ[",k,"][",i,"])=",round(mu[k][ i ]),"違反Size condition"),
print("v=",v," 第",k,"列-",q,"*第",i,"列 v=",rowop(v,k,i,q)),
v:rowop(v,k,i,q),
print("μ=",mu," 第",k,"列-",q,"*第",i,"列 μ=",rowop(mu,k,i,q)),
mu:rowop(mu,k,i,q)
)
),
i:1,
C:v[k].v[k],
startagain:false,
while i<k and startagain=false do
(ci:vstar[ i ].vstar[ i ],
if C>=3/4*ci then
(C:C-mu[k][ i ]^2*ci,
i:i+1
)
else
(tempv:copymatrix(v),
for j:k step -1 thru i+1 do
(v[j]:v[j-1]
),
v[ i ]:tempv[k],
startagain:true,
print("deep exchange condition成立"),
print("目前的μ=",mu," v*=",vstar),
print("v=",tempv," 第",k,"列插入第",i,"列 v=",v),
print("k值",k,"=>",max(i-1,2)),
k:max(i-1,2),
vstar[1]:v[1],
for i:1 thru m do
(for j:1 thru i do
(mu[ i ][j]:v[ i ].vstar[j]/vstar[j].vstar[j],
vstar[ i ]:v[ i ]-sum(mu[ i ][j]*vstar[j],j,1,i-1)
)
),
print("更新μ=",mu," v*=",vstar)
)
),
print("找不到可插入的位置,換下一列 k值",k,"=>",k+1),
k:k+1
),
return(v)
)$
書上第一個例子
(%i2)
DeepInsertionLLL(matrix([9,2,7],
[8,6,1],
[3,2,6]));
Gram-Schmidt正交化 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{91}{134} & 1 & 0 \cr \frac{73}{134} & -\frac{1015}{5253} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle 9 & 2 & 7 \cr \frac{253}{134} & \frac{311}{67} & -\frac{503}{134} \cr -\frac{8080}{5253} & \frac{9494}{5253} & \frac{7676}{5253}} \right] \)
round(μ[2][1])=1違反Size condition
\( v=\left[ \matrix{9 & 2 & 7 \cr 8 & 6 & 1 \cr 3 & 2 & 6} \right] \) 第2列-1*第1列 \( v=\left[ \matrix{9 & 2 & 7 \cr -1 & 4 & -6 \cr 3 & 2 & 6} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{91}{134} & 1 & 0 \cr \frac{73}{134} & -\frac{1015}{5253} & 1} \right] \) 第2列-1*第1列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr -\frac{43}{134} & 1 & 0 \cr \frac{73}{134} & -\frac{1015}{5253} & 1} \right] \)
deep exchange condition成立
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr -\frac{43}{134} & 1 & 0 \cr \frac{73}{134} & -\frac{1015}{5253} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle 9 & 2 & 7 \cr \frac{253}{134} & \frac{311}{67} & -\frac{503}{134} \cr -\frac{8080}{5253} & \frac{9494}{5253} & \frac{7676}{5253}} \right] \)
\( v=\left[ \matrix{9 & 2 & 7 \cr -1 & 4 & -6 \cr 3 & 2 & 6} \right] \) 第2列插入第1列 \( v=\left[ \matrix{-1 & 4 & -6 \cr 9 & 2 & 7 \cr 3 & 2 & 6} \right] \)
k值2 => 2
更新\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr -\frac{43}{53} & 1 & 0 \cr -\frac{31}{53} & \frac{2536}{5253} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle -1 & 4 & -6 \cr \frac{434}{53} & \frac{278}{53} & \frac{113}{53} \cr -\frac{8080}{5253} & \frac{9494}{5253} & \frac{7676}{5253}} \right] \)
找不到可插入的位置,換下一列 k值2 => 3
round(μ[3][1])=-1違反Size condition
\( v=\left[ \matrix{-1 & 4 & -6 \cr 9 & 2 & 7 \cr 3 & 2 & 6} \right] \) 第3列- -1*第1列 \( v=\left[ \matrix{-1 & 4 & -6 \cr 9 & 2 & 7 \cr 2 & 6 & 0} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr -\frac{43}{53} & 1 & 0 \cr -\frac{31}{53} & \frac{2536}{5253} & 1} \right] \) 第3列- -1*第1列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr -\frac{43}{53} & 1 & 0 \cr \frac{22}{53} & \frac{2536}{5253} & 1} \right] \)
deep exchange condition成立
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr -\frac{43}{55} & 1 & 0 \cr \frac{22}{53} & \frac{2536}{5253} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle -1 & 4 & -6 \cr \frac{434}{53} & \frac{278}{53} & \frac{113}{53} \cr -\frac{8080}{5253} & \frac{9494}{5253} & \frac{7676}{5253}} \right] \)
\( v=\left[ \matrix{-1 & 4 & -6 \cr 9 & 2 & 7 \cr 2 & 6 & 0} \right] \) 第3列插入第2列 \( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 9 & 2 & 7} \right] \)
k值3 => 2
更新\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{22}{53} & 1 & 0 \cr -\frac{43}{53} & \frac{634}{409} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle -1 & 4 & -6 \cr \frac{128}{53} & \frac{230}{53} & \frac{132}{53} \cr \frac{1818}{409} & -\frac{606}{409} & -\frac{707}{409}} \right] \)
找不到可插入的位置,換下一列 k值2 => 3
round(μ[3][2])=2違反Size condition
\( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 9 & 2 & 7} \right] \) 第3列-2*第2列 \( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 5 & -10 & 7} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{22}{53} & 1 & 0 \cr -\frac{43}{53} & \frac{634}{409} & 1} \right] \) 第3列-2*第2列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{22}{53} & 1 & 0 \cr -\frac{87}{53} & -\frac{184}{409} & 1} \right] \)
round(μ[3][1])=-2違反Size condition
\( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 5 & -10 & 7} \right] \) 第3列- -2*第1列 \( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 3 & -2 & -5} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{22}{53} & 1 & 0 \cr -\frac{87}{53} & -\frac{184}{409} & 1} \right] \) 第3列- -2*第1列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{22}{53} & 1 & 0 \cr \frac{19}{53} & -\frac{184}{409} & 1} \right] \)
deep exchange condition成立
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{22}{53} & 1 & 0 \cr \frac{19}{53} & -\frac{184}{409} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle -1 & 4 & -6 \cr \frac{128}{53} & \frac{230}{53} & \frac{132}{53} \cr \frac{1818}{409} & -\frac{606}{409} & -\frac{707}{409}} \right] \)
\( v=\left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 3 & -2 & -5} \right] \) 第3列插入第1列 \( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 2 & 6 & 0} \right] \)
k值3 => 2
更新\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{1}{2} & 1 & 0 \cr -\frac{3}{19} & \frac{50}{87} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle 3 & -2 & -5 \cr -\frac{5}{2} & 5 & -\frac{7}{2} \cr \frac{6464}{1653} & \frac{4646}{1653} & \frac{2020}{1653}} \right] \)
找不到可插入的位置,換下一列 k值2 => 3
round(μ[3][2])=1違反Size condition
\( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 2 & 6 & 0} \right] \) 第3列-1*第2列 \( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 3 & 2 & 6} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{1}{2} & 1 & 0 \cr -\frac{3}{19} & \frac{50}{87} & 1} \right] \) 第3列-1*第2列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{1}{2} & 1 & 0 \cr -\frac{25}{38} & -\frac{37}{87} & 1} \right] \)
round(μ[3][1])=-1違反Size condition
\( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 3 & 2 & 6} \right] \) 第3列- -1*第1列 \( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 6 & 0 & 1} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{1}{2} & 1 & 0 \cr -\frac{25}{38} & -\frac{37}{87} & 1} \right] \) 第3列- -1*第1列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{1}{2} & 1 & 0 \cr \frac{13}{38} & -\frac{37}{87} & 1} \right] \)
deep exchange condition成立
目前的\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{1}{2} & 1 & 0 \cr \frac{13}{38} & -\frac{37}{87} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle 3 & -2 & -5 \cr -\frac{5}{2} & 5 & -\frac{7}{2} \cr \frac{6464}{1653} & \frac{4646}{1653} & \frac{2020}{1653}} \right] \)
\( v=\left[ \matrix{3 & -2 & -5 \cr -1 & 4 & -6 \cr 6 & 0 & 1} \right] \) 第3列插入第2列 \( v=\left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr -1 & 4 & -6} \right] \)
k值3 => 2
更新\(\ \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{13}{38} & 1 & 0 \cr \frac{1}{2} & -\frac{703}{1237} & 1} \right] \) \( v^*=\left[ \matrix{\displaystyle 3 & -2 & -5 \cr \frac{189}{38} & \frac{13}{19} & \frac{103}{38} \cr \frac{404}{1237} & \frac{6666}{1237} & -\frac{2424}{1237}} \right] \)
找不到可插入的位置,換下一列 k值2 => 3
round(μ[3][2])=-1違反Size condition
\( v=\left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr -1 & 4 & -6} \right] \) 第3列- -1*第2列 \( v=\left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr 5 & 4 & -5} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{13}{38} & 1 & 0 \cr \frac{1}{2} & -\frac{703}{1237} & 1} \right] \) 第3列- -1*第2列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{13}{38} & 1 & 0 \cr \frac{16}{19} & \frac{534}{1237} & 1} \right] \)
round(μ[3][1])=1違反Size condition
\( v=\left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr 5 & 4 & -5} \right] \) 第3列-1*第1列 \( v=\left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr 2 & 6 & 0} \right] \)
\( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{13}{38} & 1 & 0 \cr \frac{16}{19} & \frac{534}{1237} & 1} \right] \) 第3列-1*第1列 \( \mu=\left[ \matrix{\displaystyle 1 & 0 & 0 \cr \frac{13}{38} & 1 & 0 \cr -\frac{3}{19} & \frac{534}{1237} & 1} \right] \)
找不到可插入的位置,換下一列 k值3 => 4
(%o2) \( \left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr 2 & 6 & 0} \right] \)
書上第二個例子
(%i3)
DeepInsertionLLL(matrix([83,29,21],
[99,45,96],
[2,65,31]));
書上第三個例子
(%i4)
DeepInsertionLLL(matrix([-270,983,-834],
[-725,-979,143],
[929,-612,-27]));
書上第四個例子
(%i5)
DeepInsertionLLL(matrix([84,3,34,17],
[20,48,66,19],
[69,14,63,78],
[28,72,36,57]));
書上第一個例子:\( \left[ \matrix{9 & 2 & 7 \cr 8 & 6 & 1 \cr 3 & 2 & 6} \right] \)
原本的LLL的結果為\( \left[ \matrix{-1 & 4 & -6 \cr 2 & 6 & 0 \cr 3 & -2 & -5} \right] \),向量長度\( \matrix{\sqrt{(-1)^2+4^2+(-6)^2}=\sqrt{53} \cr \sqrt{2^2+6^2+0^2}=\sqrt{40} \cr \sqrt{3^2+(-2)^2+(-5)^2}=\color{blue}{\sqrt{38}}} \)
DeepInsertionLLL的結果為\( \left[ \matrix{3 & -2 & -5 \cr 6 & 0 & 1 \cr 2 & 6 & 0} \right] \),向量長度\( \array{\sqrt{3^2+(-2)^2+(-5)^2}=\sqrt{38} \cr \sqrt{6^2+0^2+1^2}=\color{blue}{\sqrt{37}} \cr \sqrt{2^2+6^2+0^2}=\sqrt{40}} \)
原來長度較短的向量\( [3,-2,-5] \)又找到更短的向量\( [6,0,1] \)。
書上第二個例子:\( \left[ \matrix{83 & 29 & 21 \cr 99 & 45 & 96 \cr 2 & 65 & 31} \right] \)
原本的LLL的結果為\( \left[ \matrix{83 & 29 & 21 \cr 16 & 16 & 75 \cr 2 & 65 & 31} \right] \),向量長度\( \array{\sqrt{83^2+29^2+21^2}=\sqrt{8171} \cr \sqrt{16^2+16^2+75^2}=\sqrt{6137} \cr \sqrt{2^2+65^2+31^2}=\color{blue}{\sqrt{5190}}} \)
DeepInsertionLLL的結果為\( \left[ \matrix{2 & 65 & 31 \cr 14 & -49 & 44 \cr 81 & -36 & -10} \right] \),向量長度\( \matrix{\sqrt{2^2+65^2+31^2}=\sqrt{5190} \cr \sqrt{14^2+(-49)^2+44^2}=\color{blue}{\sqrt{4533}} \cr \sqrt{81^2+(-36)^2+(-10)^2}=\sqrt{7957}} \)
原來長度較短的向量\( [2,65,31] \)又找到更短的向量\( [14,-49,44] \)。
書上第三個例子:\( \left[ \matrix{-270 & 983 & -834 \cr -725 & -979 & 143 \cr 929 & -612 & -27} \right] \)
原本的LLL的結果為\( \left[ \matrix{-270 & 983 & -834 \cr -995 & 4 & -691 \cr 929 & -612 & -27} \right] \),向量長度\( \matrix{\sqrt{(-270)^2+983^2+(-834)^2}=\sqrt{1734745} \cr \sqrt{(-995)^2+4^2+(-691)^2}=\sqrt{1467522} \cr \sqrt{929^2+(-612)^2+(-27)^2}=\color{blue}{\sqrt{1238314}}} \)
DeepInsertionLLL的結果為\( \left[ \matrix{-66 & -608 & -718 \cr 929 & -612 & -27 \cr 659 & 371 & -861} \right] \),向量長度\( \matrix{\sqrt{(-66)^2+(-608)^2+(-718)^2}=\color{blue}{\sqrt{889544}} \cr \sqrt{929^2+(-612)^2+(-27)^2}=\sqrt{1238314} \cr \sqrt{659^2+371^2+(-861)^2}=\sqrt{1313243}} \)
原來長度較短的向量\( [929,-612,-27] \)又找到更短的向量\( [-66,-608,-718] \)。
書上第四個例子:\( \left[ \matrix{84 & 3 & 34 & 17 \cr 20 & 48 & 66 & 19 \cr 69 & 14 & 63 & 78 \cr 28 & 72 & 36 & 57} \right] \)
原本的LLL的結果為\( \left[ \matrix{84 & 3 & 34 & 17 \cr -64 & 45 & 32 & 2 \cr -35 & -37 & -37 & 42 \cr 43 & 61 & 7 & -4} \right] \),向量長度\( \matrix{\sqrt{84^2+3^2+34^2+17^2}=\sqrt{8510} \cr \sqrt{(-64)^2+45^2+32^2+2^2}=\sqrt{7149} \cr \sqrt{(-35)^2+(-37)^2+(-37)^2+42^2}=\sqrt{5727} \cr \sqrt{43^2+61^2+7^2+(-4)^2}=\color{blue}{\sqrt{5635}}} \)
DeepInsertionLLL的結果為\( \left[ \matrix{8 & 24 & -30 & 38 \cr -35 & -37 & -37 & 42 \cr -23 & -13 & 59 & 23 \cr 41 & -58 & 27 & 21} \right] \),向量長度\( \matrix{\sqrt{8^2+24^2+(-30)^2+38^2}=\color{blue}{\sqrt{2984}} \cr \sqrt{(-35)^2+(-37)^2+(-37)^2+42^2}=\sqrt{5727} \cr \sqrt{(-23)^2+(-13)^2+59^2+23^2}=\sqrt{4708} \cr \sqrt{41^2+(-58)^2+27^2+21^2}=\sqrt{6215}} \)
原來長度較短的向量\( [43,61,7,-4] \)又找到更短的向量\( [8,24,-30,38] \)。
參考資料
C. P. Schnorr , M. Euchner, Lattice basis reduction: improved practical algorithms and solving subset sum problems, Mathematical Programming: Series A and B, v.66 n.2, p.181-199, Sept. 7, 1994.
Lattice Basis Reduction: An Introduction to the LLL Algorithm and Its Applications.的第五章
原本的論文關於Deep Insertion只有一小段而已,但在Lattice Basis Reduction一書中則擴展成一章的內容,這篇文章的範例及程式碼就是參考這本書而來的。