forked from whymirror/potion
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspectral-norm.pn
More file actions
52 lines (45 loc) · 708 Bytes
/
spectral-norm.pn
File metadata and controls
52 lines (45 loc) · 708 Bytes
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
A = (i, j):
ij = i + j
1.0 / (ij * (ij + 1) / 2 + i + 1).
Av = (n, x, y):
i = 0
while (i < n):
a = 0, j = 0
while (j < n):
a += A (i, j) * x (j)
j++.
y (i) = a
i++.
.
Atv = (n, x, y):
i = 0
while (i < n):
a = 0, j = 0
while (j < n):
a += A (j, i) * x (j)
j++.
y (i) = a
i++.
.
AtAv = (n, x, y, t):
Av (n, x, t)
Atv (n, t, y).
n = 100
u = list(n), v = list(n), t = list(n)
i = 0
while (i < n):
u (i) = 1
i++.
i = 0
while (i < 10):
AtAv (n, u, v, t)
AtAv (n, v, u, t)
i++.
vBv = 0, vv = 0, i = 0
while (i < n):
ui = u (i), vi = v (i)
vBv += ui * vi
vv += vi * vi
i++.
a = vBv / vv
a sqrt string slice (0, 11)