% Wavelet transform in dimension one, just one step
%
% Arguments:
% tr   the transform (a vector of power-of-two length)
% h    high-pass filter
% g    low-pass filter
%
% Returns:
% f   recovered signal
%
% Samuli Siltanen October 2016

function f = Wavelet_tr_inv_onestep(tr,h,g)

% Extract the low-pass part
tmp1 = tr(1:end/2);

% Upsampling for the low-pass part
LP = zeros(1,length(tr));
LP(2:2:end) = tmp1; 

% Convolution for the low-pass part
LP = conv2(LP,fliplr(h(:).'),'same');

% Extract the high-pass part
tmp2 = tr(end/2+1:end);

% Upsampling for the high-pass part
HP = zeros(1,length(tr));
HP(2:2:end) = tmp2;

% Convolution for the high-pass part
HP = conv2(HP,fliplr(g(:).'),'same');

% Reconstruct signal using inverse transform
f = LP+HP;

