% Wavelet transform in dimension one
%
% Arguments:
% f the signal (a vector of power-of-two length)
% h high-pass filter
% g low-pass filter
% J number of scales
%
% Returns:
% tr the multiscale transform in one vector if same size of f
%
% Samuli Siltanen October 2016
function tr = Wavelet_tr(f,h,g,J)
% Test that f is not a matrix
[row,col] = size(f);
if (row>1) & (col>1)
error('f should be a vector')
end
% Test that the input signal has power-of-two length
f = f(:).';
J0 = log2(length(f));
if (J0-floor(J0))>0
error('f must have power-of-two length')
end
% Test that J is not too big
if J>J0
error('Signal f is too short for J steps of the transform')
end
tr = zeros(1,length(f));
LPcurr = f;
for jjj = 1:J
[LP,HP] = Wavelet_tr_onestep(LPcurr,h,g);
tr(2^(J0-jjj)+[1:2^(J0-jjj)]) = HP(:).';
LPcurr = LP;
end
tr(1:2^(J0-J)) = LPcurr;