function WFWTPO, x,L,qmf
;+
; NAME:
; 	WFWTPO
;
; PURPOSE:
;	This function generates a Forward Wavelet Transform 
;	(periodized, orthonormal).
;
; CATEGORY:
;	Wavelets
;
; CALLING SEQUENCE:
;    wc = WFWTPO(x,L,qmf)
;
; INPUTS:
;    x:		1-d signal; length(x) = 2^J
;    L:		Coarsest Level of V_0;  L << J
;    qmf:	quadrature mirror filter (orthonormal) 
;			[qmf defines wavelet shape]
;
; OUTPUTS:
;    wc:	1-d wavelet transform of x.
;			[Gives wavelet coefficients]
;
; NOTES:
;    1. QMF filter may be obtained from WMKOFILT   
;    2. usually, length(qmf) lt 2^(L+1)
;    3. To reconstruct use WIWTPO
;
; EXAMPLE:
;
; SEE ALSO:
;	wiwtpo, wmkofilt
;
; NOTES on j, k:
; The location  k, at level j, runs from 0 to 2^j-1.
; A signal of length n is taken to a set of n wavelet coefficients 
; by the (orthogonal) wavelet transformation. Since the wavelet 
; coefficients are indexed in a dyadic way due to the natural 
; location/scale interpretation inherent with wavelets, you cannot 
; pick a {j,k} combination that doesn't exist for the transformed data.  
; Consequently j ranges as above and k can be at most log_2(n).  
; The wavelet transformation is not over-complete (i.e., it takes a 
; signal of length n to a set of coefficients of length n).
;
; MODIFICATION HISTORY:
; 	Written by:	Amara Graps		October, 1994
;Translated from MatLab Wavelab routine: fwt_po.m
;-

n = WDYADLNG(x,J)
wcoef = FLTARR(n) 
beta = WSHASROW(x)	;take samples at finest scale as beta-coeffts

FOR k=J-1, L,-1 DO BEGIN

	;High-pass downsampling (throw away every 2nd data point)
	alfa = WDNDYDHI(beta,qmf)
	wcoef(WDYAD(k)-1) = alfa

	;Low-pass smoothing filter
	beta = WDNDYDLO(beta,qmf)   
END

wcoef(0 : (2^L)-1) = beta
wcoef = WSHLIKE(wcoef,x)

;
; Algorithm Source:  WaveLab Version 0.600
; WaveLab WWW site: http://playfair.stanford.edu/ 
; WaveLab Questions? e-mail wavelab@playfair.stanford.edu
;   
    

RETURN, wcoef 
END 
;***************************************************