probing.py 678 Bytes
Newer Older
Theo Steininger's avatar
Theo Steininger committed
1
2
# -*- coding: utf-8 -*-

Martin Reinecke's avatar
Martin Reinecke committed
3
from __future__ import print_function
Theo Steininger's avatar
Theo Steininger committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)
Martin Reinecke's avatar
Martin Reinecke committed
23
print((f - diagProber.diagonal).norm())
Theo Steininger's avatar
Theo Steininger committed
24
25
26

multiProber = MultiProber(domain=x)
multiProber(diagOp)
Martin Reinecke's avatar
Martin Reinecke committed
27
28
print((f - multiProber.diagonal).norm())
print(f.sum() - multiProber.trace)
Theo Steininger's avatar
Theo Steininger committed
29
30
31