probing.py 637 Bytes
Newer Older
Theo Steininger's avatar
Theo Steininger committed
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
# -*- coding: utf-8 -*-

from nifty import Field, RGSpace, DiagonalProberMixin, TraceProberMixin,\
                  Prober, DiagonalOperator


class DiagonalProber(DiagonalProberMixin, Prober):
    pass


class MultiProber(DiagonalProberMixin, TraceProberMixin, Prober):
    pass


x = RGSpace((8, 8))

f = Field.from_random(domain=x, random_type='normal')
diagOp = DiagonalOperator(domain=x, diagonal=f)

diagProber = DiagonalProber(domain=x)
diagProber(diagOp)
print (f - diagProber.diagonal).norm()

multiProber = MultiProber(domain=x)
multiProber(diagOp)
print (f - multiProber.diagonal).norm()
print f.sum() - multiProber.trace