🐥
不連続面と連続面のある関数の圧縮
前回では、不連続面のある関数を扱ってきたが、ここでは、不連続面と連続な二変数関数の圧縮をしてみたい。
不連続面のある方向については、QTT、連続な方向については、TTという感じで使い分けたい。
using Plots
using LinearAlgebra
using LaTeXStrings
using ITensors
using ITensorMPS
ITensors.disable_warn_order()
R = 10
Nx = 32
Ny = 2^R
function g(x)
if x < -1
return x^2
elseif x < 0
return -1.0
elseif x < 2
return sin(x)
elseif x < 3
return 1.0
else
return x
end
end
f(x, y) = sin(x) * g(y)
;
X = range(-2, 2, length = Nx)
Y = range(-2, 2, length = Ny)
fdata = [f(x, y) for x in X, y in Y]
fdata_plot = [f(x, y) for x in X[1:10:end], y in Y[1:10:end]]
;
heatmap(X[1:10:end], Y[1:10:end], fdata_plot,
#title = L"\dfrac{\gamma}{(x-y)^2 + \gamma^2}, ~~(\gamma = 0.1)",
xlabel = L"x",
ylabel = L"y",
top_margin = 3Plots.mm)
#savefig("function_plots.pdf")
QTT/TTで圧縮
sitesx = [Index(Nx, "Qubit,x")]
sitesy = [Index(2, "Qubit,y=$i") for i in 1:R]
Tensor = ITensor(fdata, vcat(reverse(sitesx), reverse(sitesy)))
#スケール分解せずにMPSを構成
cutoff = 1e-12
M = MPS(Tensor, vcat(sitesx, sitesy))
M1 = MPS(Tensor, vcat(sitesx, sitesy); cutoff=cutoff)
;
#ボンド次元をプロットする
BondDim = plot(yscale = :log,
title = L"\mathrm{Bond~Dimension},~~ (R = 12, ~~\mathrm{cutoff}={cutoff})",
xlabel = L"\mathrm{auxiliary~index}",
ylabel = L"\mathrm{Bond~Dimension}")
plot!(BondDim, linkdims(M),
linestyle = :dash,
label = L"\mathrm{No~Compression}")
plot!(BondDim, linkdims(M1),
markershape = :circle,
label = L"\mathrm{QTT}")
M2_reconst = Array(reduce(*, M1), vcat(reverse(sitesx), reverse(sitesy)));
M2_reconst = reshape(M2_reconst, Nx, 2^R);
abs.(fdata .- M2_reconst) |> maximum |> println
しかし、TTで表現した変数については、グリッドの間の点を評価することはできない。そこで、
次の記事で、TTで表現した変数を多項式補間する方法を紹介する。
Discussion