function [W,lambda,alpha,AmDQ,ApDQ] = rp_ac_1d(ql,qr,A)
  [R,lambda] = eig(A);

  alpha = R\(qr-ql);
  
  for n=1:size(ql,2)
    W(:,:,n) = R*diag(alpha(:,n));
    AmDQ(:,n) = W(:,:,n)*min(diag(lambda),0.);
    ApDQ(:,n) = W(:,:,n)*max(diag(lambda),0.);
  end
end