function [dh,dg,drh,drg] = DerivFilter(h,g,rh,rg)
% returns the derivatives filters related to h,g,rh,rg,d,rd.
% By convention, the z-transforms of the analysis filters are
% h(z) = z^d sum h[k+1]z^(-k) and g(z) = z^d sum g[k+1]z^(-k)
% and, for reconstruction filters, the z-transform of rh and rg are
% rh(z) = z^rd sum rh[k+1]z^(-k) and rg(z) = z^rd sum rg[k+1]z^(-k).
% Similar conventions are use for the output filters.
% dd = d;
% drd = rd;
dh = conv(h,[1 1])/2;
[dg,r] = deconv(g,[1 -1]);
if abs(r) > 1e-14
error('Hi pass analysis filter does not seem to be dividable');
break
end
dg = 2*dg;
[drh,r]= deconv(rh,[1 1]);
if abs(r) > 1e-14
error('Low pass reconstruction filter does not seem to be dividable');
break
end
drh = 2*drh;
drg = conv(rg,[1 -1])/2;