function q = getPar(q, w_bb)
%% construct helper params 

%% check 2nd argument
if nargin == 2
    q.w_bb = w_bb;
end

%% main
% --- the time domain ----
t     = (1:q.N ) / q.N;
% --- entire frequency domain, c.f. Shannon (Hz) ---
ww    = (-q.N/2 : 1/q.pad : q.N/2-1);
% --- truncate frequency to baseband of interest ---
w1    = find(ww >=  q.w_bb, 1, 'first');
w0    = find(ww <= -q.w_bb, 1,  'last');
% --- truncated frequency domain ---
w     = ww(w0:w1);
len_w = length(w);
W     = zeros(length(w), q.N);
% --- DFT basis (over truncated frequency domain)
for n = 0:q.N-1
    W(:, n+1) = exp(-2*pi*i* w*n / q.N) ./ q.N;
end
% --- want to force aolution to be 0 or 1; hence introduce flips into DFT ...
% ... matrix                                                              --- 
pos_flip = [ ones(len_w, q.N/4), ...
            -ones(len_w, q.N/2), ...
             ones(len_w, q.N/4) ];
% --- this is matrix used in optimiser ---
Wp    = pos_flip .* W;

% === build exact solution ===
% --- imaginary part of target basis (a sin wave!) ---
et    = imag(exp(i*2*pi*t'));
% --- take (circular) difference ---
dfe   = diff(et);
dfe   = [dfe; et(1)-et(end)];
dfep  = dfe.*[ones(1,q.N/4), -ones(1,q.N/2), ones(1,q.N/4)]';
exact = q.N / pi * Wp * dfep;

%%
q.t = t;
q.w = w;
q.len_w = len_w;
q.exact = exact;
q.Wp = Wp;

%%





