-
Notifications
You must be signed in to change notification settings - Fork 0
/
nystroem_cauchy_bw.m
73 lines (63 loc) · 2.06 KB
/
nystroem_cauchy_bw.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function dcd = nystroem_cauchy_bw(mbp, ns, g,kappa, eta)
% calculate dcd
r = numel(mbp);
% pre-allocate dcd fields
dcd(r).n = 0;
dcd(r).ts = [];
dcd(r).ws = [];
dcd(r).wls = [];
dcd(r).gammas = [];
dcd(r).normdgammas = [];
dcd(r).dgammas = [];
dcd(r).d2gammas = [];
dcd(r).ngammas = [];
dcd(r).rhoDs = [];
dcd(r).rhoNs = [];
% compute dcd fields
for ll=1:r
n = ns(ll);
llts = circular_quadrature_nodes(n);
dcd(ll).n = n;
dcd(ll).ts = llts;
dcd(ll).ws = circular_quadrature_weights(n);
dcd(ll).wls = circular_quadrature_weights_log(n);
dcd(ll).gammas = mbp(ll).gamma(n);
dcd(ll).dgammas = mbp(ll).dgamma(n);
dcd(ll).normdgammas = vecnorm(dcd(ll).dgammas);
dcd(ll).d2gammas = mbp(ll).d2gamma(n);
dcd(ll).ngammas = mbp(ll).ngamma(n);
dcd(ll).rhoDs = g(dcd(ll).gammas);
end
matlength = sum(ns);
A = zeros(matlength);
plD = zeros(matlength,1);
% plN = zeros(matlength,1);
% b = zeros(matlength,1);
xrange = 1;
for m = 1:r
yrange = 1;
nm = dcd(m).n;
mgammas = dcd(m).gammas;
for l = 1:r
nl = dcd(l).n;
if l ~= m
A(yrange:(yrange + nl)-1,xrange:(xrange +nm-1)) = ...
- calc_Klm(dcd,l,m,kappa) - 1i*eta*calc_Vlm(dcd,l,m, kappa);
else
A(yrange:(yrange + nl)-1,xrange:(xrange +nm-1)) = eye(nm)...
- calc_Klm(dcd,l,m,kappa) - 1i*eta*calc_Vlm(dcd,l,m, kappa);
end
yrange = yrange + nl;
end
plD(xrange:(xrange + nm-1)) = g(mgammas).';
xrange = xrange + nm;
end
plN = A\plD;
xrange = 1;
for i = 1:r
n = dcd(i).n;
dcd(i).rhoDs = plD(xrange:(xrange + n-1)).';
dcd(i).rhoNs = plN(xrange:(xrange + n-1)).';
xrange = xrange + n;
end
end