1classdef nfsftTestcaseInitDelegate
2  %NFSFTTESTCASEDELEGATEINIT Summary of this class goes here
3  %   Detailed explanation goes here
4
5  properties
6    name = '';
7    txt = '';
8    flags = 0;
9    kappa = 1000;
10    fpt_flags = 0;
11    nfft_flags = [];
12    nfft_cutoff_m = [];
13  end
14
15  methods
16    function h = nfsftTestcaseInitDelegate(name, flags, fpt_flags, nfft_flags, nfft_cutoff_m)
17      h.name = name;
18      h.txt = h.name;
19      if exist('flags','var') && ~isempty(flags)
20        h.flags = flags;
21        if bitand(flags,NFSFT_USE_DPT) ~= 0
22          h.txt = sprintf('%s DPT', h.name);
23        end
24      end
25      if exist('fpt_flags','var') && ~isempty(fpt_flags)
26        h.fpt_flags = fpt_flags;
27      end
28      if exist('nfft_flags','var') && ~isempty(nfft_flags)
29        h.nfft_flags = nfft_flags;
30      end
31      if exist('nfft_cutoff_m','var') && ~isempty(nfft_cutoff_m)
32        h.nfft_cutoff_m = nfft_cutoff_m;
33      end
34    end
35
36    function nfsft_precompute(h, N)
37      if ~isempty(h.fpt_flags)
38        nfsft_precompute(N,h.kappa,h.flags,h.fpt_flags);
39      elseif ~isempty(h.flags)
40        nfsft_precompute(N,h.kappa,h.flags);
41      elseif ~isempty(h.kappa)
42        nfsft_precompute(N,h.kappa);
43      else
44        nfsft_precompute(N);
45      end
46    end
47
48    function [h, plan] = init(h, N, M)
49      switch h.name
50        case 'init'
51          h.nfsft_precompute(N);
52          plan = nfsft_init(N,M);
53        case 'init_advanced'
54          h.nfsft_precompute(N);
55          plan = nfsft_init_advanced(N,M,h.flags);
56        case 'init_guru'
57          h.nfsft_precompute(N);
58          plan = nfsft_init_guru(N,M,h.flags,h.nfft_flags,h.nfft_cutoff_m);
59        case 'init_class'
60          if isempty(h.flags) && isempty(h.nfft_cutoff_m) && isempty(h.fpt_flags) && isempty(h.nfft_flags)
61            plan = nfsft(N,M);
62          elseif ~isempty(h.flags)
63            plan = nfsft(N,M,h.flags);
64          else
65            plan = nfsft(N,M,h.flags,h.kappa,h.nfft_cutoff_m,h.fpt_flags,h.nfft_flags);
66          end
67        otherwise
68          error('Unknown init name: %s', h.name);
69      end
70    end
71  end
72
73end
74
75