File: nfsoftTestcaseCheckDelegate.m

package info (click to toggle)
nfft 3.5.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,972 kB
  • sloc: ansic: 44,442; lisp: 1,697; makefile: 1,322; sh: 744; sed: 5
file content (62 lines) | stat: -rw-r--r-- 1,432 bytes parent folder | download
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
classdef nfsoftTestcaseCheckDelegate
  %UNTITLED3 Summary of this class goes here
  %   Detailed explanation goes here
  
  properties
    name = '';
  end
  
  methods
    function h = nfsoftTestcaseCheckDelegate(name)
      h.name = name;
    end

    function plan = prepare(h, plan, f, f_hat)
      switch h.name
        case 'trafo'
          if isnumeric(plan)
            nfsoft_set_f_hat(plan, double(f_hat));
          else
            plan.fhat = f_hat;
          end
        case 'adjoint'
          if isnumeric(plan)
            nfsoft_set_f(plan, f);
          else
            plan.f = f;
          end
        otherwise
          error('Unknown check: %s', h.name);
      end
    end

    function result = compare(h, plan, f, f_hat)
      if isnumeric(plan)
        plan_f = nfsoft_get_f(plan);
        plan_f_hat = nfsoft_get_f_hat(plan);
      else
        plan_f = plan.f;
        plan_f_hat = plan.fhat;
      end
      switch h.name
        case 'trafo'
          numerator = max(abs(f - plan_f));
          denominator = sum(sum(abs(double(plan_f_hat))));
        case 'adjoint'
          numerator = max(max(abs(double(f_hat) - double(plan_f_hat))));
          denominator = sum(abs(plan_f));
        otherwise
          error('Unknown check: %s', h.name);
      end
      
      if numerator == 0
        result = 0;
      else
        result = numerator / denominator;
      end
    end
    
  end
  
end