% test sigAC with sigDC
%
% opt = optFP;
% x0 = -1e-11;
% nx = 3;
% [ds, sa, s0, s1] = test(nx, x0, dx)

function [ds, sa0, sd0, sd1] = test(opt, nx, x0)
  
  dx = 1e-16;
  pos = zeros(opt.Noptic, 1);
  dpos = zeros(opt.Noptic, 1);
  pos(nx) = x0;
  dpos(nx) = dx;
  
  % compute signals
  [sd0, sa0, tm0] = compute(opt, pos - dpos, 1e-6);
  [sd1, sa1, tm1] = compute(opt, pos + dpos, 1e-6);

  % make sensing matrix from DC signals
  ds = (sd1 - sd0) / (2 * dx)
  sa0 = sa0(:, nx, 1);
  sa1 = sa1(:, nx, 1);

  % do they match?
  mag_phi0 = [log(abs(sa0 ./ ds)), angle(sa0 ./ ds)]
  mag_phi1 = [log(abs(sa1 ./ ds)), angle(sa1 ./ ds)]
  tm0
