%% 
%% This is a LaTeX document generated by automatic conversion of a
%% Mathematica notebook using Mathematica 4.0.
%% 
%% This document uses special macros that are defined in a LaTeX 
%% package file with a name of the form notebook*.sty.  Appropriate 
%% commands for loading the package have been included in this file.
%% The LaTeX package files can be found in the Mathematica 
%% installation under 
%% 
%% Tigger:Applications:Mathematica 4.0:SystemFiles:IncludeFiles:TeX:
%% 
%% The LaTeX package used in in this document may require that your 
%% LaTeX implementation support fonts other than the standard Computer 
%% Modern fonts that are used by LaTeX.  See the Additional Information 
%% section under the TeXSave entry in the Mathematica reference guide 
%% for more information.
%% 

\documentclass{article}
\usepackage{notebook2e, latexsym}

\begin{document}

\Title{Automation of the lifting  factorisation of wavelet transforms}

\Subtitle{M. Maslen, P. Abbott\inlineTFinmath{{{}^{a}}}}

\noindent \inlineTFinmath{{{}^a}} Department of Physics, University of
Western Australia, Nedlands WA  6907, Australia \\

E-mail: {\tt  paul@physics.uwa.edu.au} \\

URL: {\verb$http://physics.uwa.edu.au/~paul$} \\

\Section*{Abstract}
Wavelets are sets of basis functions used in the analysis of signals and images. 
In contrast to Fourier analysis, wavelets have both spatial and frequency
localisation, making them useful for the analysis of sharply-varying or
non-periodic signals.  The {\itshape lifting scheme} for finding the discrete
wavelet transform was demonstrated by Daubechies and Sweldens (1996).  In
particular, they showed that this method depends on the factorisation of
{\itshape polyphase matrices}, whose entries are Laurent polynomials, using the
Euclidean algorithm extended to Laurent polynomials.  Such factorisation is not
unique and hence there are multiple factorisations of the polyphase matrix.  In
this paper we  outline a {\itshape Mathematica} program that finds all
factorisations of such matrices by automating the Euclidean algorithm for Laurent
polynomials.  Polynomial reduction using Gr\ODoubleDot{}bner bases was also
incorporated into the program so as to reduce the number of wavelet filter
coefficients appearing in a given expression through use of the relations they
satisfy, thus permitting exact symbolic factorisations for any polyphase matrix.\\

\noindent PACS: 02.70,  07.05.K.\\

\noindent Keywords: Wavelets; Lifting; Euclidean algorithm; Laurent polynomials, \\
Gr\ODoubleDot{}bner bases, Polynomial reduction \\

\Subtitle{PROGRAM SUMMARY} 

\noindent Title of program: {\verb$LiftingFactorisation.nb$}

\noindent Version number: 1.0

\noindent Catalogue identifier: 

\noindent Program obtainable from: {\tt ftp://ftp.physics.uwa.edu.au/-\\
pub/Wavelets/LiftingFactorisation.nb}

\noindent Programming language used: {\itshape Mathematica} 3.0

\noindent Platform: Any platform supporting {\itshape Mathematica} 3.0

\noindent Number of bytes in distributed program, including test data, etc.: 36,764

\noindent Distribution format: ASCII

\noindent Keywords: wavelets, lifting, Euclidean algorithm, Laurent polynomials, Gr\ODoubleDot{}bner bases, 
polynomial reduction

\noindent Nature of physical problem \\
Spectral analysis and compression of signals or images.

\noindent Method of solution \\
Symbolic computer algebra is used to automate the Euclidean algorithm for Laurent
polynomials [1] so as to factorise wavelet transforms yielding a sequence of
simple arithmetic operations suitable for parallel, in-place, implementation [2].

\noindent Limitations \\
The program requires that the Laurent polynomial quotients used in the algorithm
have Laurent degree at most 1.  The polyphase matrix must have unit determinant
(though any polyphase matrix may be adjusted to satisfy this criterion [2]).

\noindent Unusual features \\
The program can find symbolic greatest common divisors (gcds) of two Laurent
polynomials.  Using Gr\ODoubleDot{}bner bases and polynomial reduction on the
filter coefficients reduces the number of unknown coefficients appearing in
expressions.  There is also capability to convert the lifting steps from
mathematical notation to computer pseudo-code, suitable for implementation in C
or Fortran. \\

\noindent {\itshape References}

\noindent [1] M.J. Maslen, Factoring Wavelet Transforms into Lifting Steps, (University of
Western Australia, 1997). URL: \\
{\verb$http://www.physics.uwa.edu.au/~paul/publications.html$}

\noindent [2] I. Daubechies, W. Sweldens, J. Fourier Anal. Appl. 4 (1998) 247. URL: \\
{\tt http://cm.bell-labs.com/who/wim/papers/papers.html\#{}factor} \\


\Subtitle{LONG WRITE-UP}

\Section*{1. Introduction}
Scientists and engineers are familiar with Fourier analysis, which is an ideal
tool for describing information such as waves, optical signals, and vibrations. 
It is the periodic nature of the Fourier basis which makes it so useful for these
applications, for which the information is frequently oscillatory in nature. 
However, for highly non-periodic signals, the Fourier expansion requires many
terms to achieve acceptable representation.  In such cases an alternative is to
use {\itshape wavelets}.

There are a variety of wavelet bases, each having particular characteristics such
as symmetry, smoothness or orthogonality.  As such they are far more versatile
than Fourier analysis, and can be tailored to specific situations.  Wavelets
bases of {\itshape compact support} have excellent spatial localisation (in
contrast with the Fourier basis).  Wavelets have been applied to areas such as
geophysical survey analysis, image compression (FBI fingerprint database) [3],
denoising, and encryption.  Further details can be found in, for example,
[1,4,5,6,7,8]. For a survey of applications of the wavelet transform to a wide
range of physical fields --- including astrophysics, turbulence, meteorology,
plasma physics, atomic and solid state physics, and mathematical physics --- see
[9].

Wavelet research has proliferated over the last decade.  Much of the relevant
background theory has been developed, and the recent focus has been on
applications and implementation techniques.  One particularly powerful
implementation method is that of lifting.  This has been shown to be equivalent
to the more traditional methods such as Mallat's algorithm and Fourier methods
[10,11,12,13].  Lifting has several advantages over other methods.  It is a very
general technique, applicable to {\itshape n}-dimensional transforms and wavelets
on manifolds.  In some cases the method can yield integer-to-integer transforms
[14] allowing for lossless compression.  Computationally it allows a parallel,
in-place implementation, which is faster by a factor of 2 for large datasets [2].
 It reduces the implementation to a sequence of simple steps involving elementary
algebraic operations, making it trivial to find the inverse transform.

A major recent development is the {\itshape factorisation} of the lifting scheme
[2].  This provides a simple method for deriving the sequence of lifting steps. 
Importantly, the factorisation is fundamentally non-unique, so there exist
several possible sequences of lifting steps for a given wavelet transform.  This
is an important feature as it allows a choice of which set of steps to use --
some sets may be better suited to hardware implementation, numerical computation,
or  symmetric implementation, for example.

Two questions that arise from this factorisation are (i) how many factorisations
exist, and (ii) how does one find all factorisations.  This paper addresses both
of these issues, in the form of a {\itshape Mathematica} program that finds all
gcds of two Laurent polynomials.


\Section*{2. Mathematical preliminaries}
We outline some of the background mathematical ideas relating to wavelets and the lifting scheme.

\Subsection*{2.1. Laurent polynomials, finite filters, and {\itshape z}--transforms}

A{\itshape  Laurent polynomial} is an expression of the form

\inlineTFinmath {p(z)  =  \sum _{k=a}^{b}{c_k}{z^{-k}}.}

\noindent We define the {\itshape degree} of a nonzero Laurent polynomial as
\inlineTFinmath{\LeftBracketingBar p(z)\RightBracketingBar   = 
b-a}, and the degree of the zero polynomial is defined to be
-\inlineTFinmath{\infty }.

A {\itshape finite filter} may be described as a set of coefficients
\inlineTFinmath{h=\{{h_k}  :  k  \in  
\DoubleStruckCapitalZ \}}, which are zero outside the finite range 
\inlineTFinmath{{k_b}  \leq   k  \leq   {k_e}}.  The
\inlineTFinmath{z}{\itshape -transform} of a finite filter is the Laurent
polynomial whose coefficients are the filter coefficients, namely

\dispTFNumberedEquationmath{h(z)  =  \sum _{k={k_b}}^{{k_e}}{h_k}{z^{-k}}.}

\noindent The limiting points \inlineTFinmath{{k_e}} and \inlineTFinmath{{k_b}} are
arbitrary subject to the restriction that \inlineTFinmath{{k_e}-{k_b}} is the
length of the filter.  Equivalently, the {\itshape z}-transform is defined only
up to a monomial factor.

\Subsection*{2.2. The Euclidean algorithm}
The {\itshape Euclidean algorithm} is a method for finding the greatest common
divisor (gcd) of two integers. The {\itshape division algorithm} states that for
any integers {\itshape a} and {\itshape b}, where
\inlineTFinmath{\LeftBracketingBar a\RightBracketingBar >\LeftBracketingBar
b\RightBracketingBar } (here \(\LeftBracketingBar \)\(\cdot
\)\(\RightBracketingBar \) denotes absolute value) and \inlineTFinmath{b\neq 0},
there exist integers \inlineTFinmath{{q_1}}and\inlineTFinmath{  {r_1}} (the
reason for the subscripts will become clear) such that \inlineTFinmath{a  =   
{q_1}b  +  {r_1}} with \inlineTFinmath{0  \leq   {r_1}  <  b}.

The Euclidean algorithm can be used to find the gcd as follows.  Firstly note
that if \inlineTFinmath{{r_1}=0}, then \inlineTFinmath{\gcd(a,b)=b}.  If 
\inlineTFinmath{{r_1}\neq 0}, we see that any common divisor of {\itshape b} and
\inlineTFinmath{{r_1}} is a divisor of {\itshape a}, and thus is a common divisor
of {\itshape a} and {\itshape b}.  Rewriting the above expression as
\inlineTFinmath{{r_1}  =  a  -  {q_1}b}, shows that any common factor of
{\itshape a} and {\itshape b} is a factor of \inlineTFinmath{{r_1}}, and is thus
a common factor of \inlineTFinmath{{r_1}} and {\itshape b}.  We have shown that
the common divisors of {\itshape a} and {\itshape b} are the same as those of
\inlineTFinmath{{r_1}} and {\itshape b}, and hence \inlineTFinmath{\gcd(a,b)  = 
\gcd({r_1},b)}.  The problem has thus been reduced to finding the gcd of the
smaller pair of numbers \inlineTFinmath{({r_1},b)}.

We may now apply the division algorithm to \inlineTFinmath{{r_1}} and {\itshape
b} to get \inlineTFinmath{b  =  {q_2}{r_1}  +  {r_2}} with \inlineTFinmath{0 
\leq   {r_2}  <  {r_1}}, and repeating the argument above, we see that
\inlineTFinmath{\gcd({r_1},b)  =  \gcd({r_1},  {r_2})}.  We iterate this process,
each time obtaining a smaller remainder until eventually \inlineTFinmath{{r_i}=0}
for some {\itshape i}. We then have \inlineTFinmath{{r_{i-2  }}=  {q_i}{r_{i-1}}}
and thus we have \inlineTFinmath{\gcd(a,b)=\gcd({r_{i-2}},{r_{i-1}})={r_{i-1}}}.
The algorithm has a simple computational implementation, in recursive form:

\dispTFNumberedEquationmath{\MathBegin{MathArray}{l}
{a_i}\leftarrow {b_{i-1}},  \\
\noalign{\vspace{0.5ex}}{b_i}\leftarrow {a_{i-1}}-{a_i}  {q_i}.\\
\MathEnd{MathArray}}

The Euclidean algorithm can be generalised to the Laurent polynomials.  The
procedure is similar to that shown above, with the generalisation being that we
require that \inlineTFinmath{\LeftBracketingBar r\RightBracketingBar
<\LeftBracketingBar b\RightBracketingBar }, where
\inlineTFinmath{\LeftBracketingBar \cdot \RightBracketingBar } is the Laurent
degree.

\Subsection*{2.3. An example}

An important point is that the quotients are {\itshape not} necessarily unique in
the Euclidean algorithm.  That is, although the gcd is unique up to an invertible
(monomial) factor, the {\itshape quotients} can be chosen in several nontrivially
distinct ways.  To illustrate this we give an example of the Euclidean algorithm
for Laurent polynomials. Let \inlineTFinmath{a=\frac{1}{z}+3-2  z}, and
\inlineTFinmath{b=\frac{-6}{{z^2}}+\frac{3}{z}}. We wish to find
\inlineTFinmath{\gcd(a,b)}. Note that \inlineTFinmath{\LeftBracketingBar
a\RightBracketingBar =1-(-1)=2}, while \inlineTFinmath{\LeftBracketingBar
b\RightBracketingBar =-1-(-2)=1}.  We set up the first step of the Euclidean
algorithm:

\inlineTFinmath {\frac{1}{z}+3-2  z={q_1}  \big(\frac{-6}{{z^2}}+\frac{3}{z}\big)+{r_1}\cdot }

\noindent Since the remainder must have degree less than that of {\itshape b}, it must be
monomial.  Rearranging this equation for \inlineTFinmath{{r_1}}, we get

\inlineTFinmath {{r_1}=\big(\frac{1}{z}+3-2  z\big)-{q_1}  \big(\frac{-6}{{z^2}}+\frac{3}{z}\big).}

\noindent We must choose \inlineTFinmath{{q_1}} so that \inlineTFinmath{{r_1}} will be
monomial.  One way to do this is to choose \inlineTFinmath{{q_1}} so that the
highest monomials in each term in this expression are equal, and will thus
cancel.  This means that \inlineTFinmath{{q_1}} will need to be of the form
\inlineTFinmath{{z^2}  \big(c+\frac{d}{z}\big)} in order for the terms to have
the same highest exponents.  The parameters {\itshape c} and {\itshape d} are
then found by the method of undetermined coefficients.  Substituting, we find
that the first remainder has the form

\inlineTFinmath {z  (-3  c-2)+6  c-3  d+\frac{6  d+1}{z}+3,}

\noindent and, setting the coefficients of the {\itshape z} and constant terms to zero, we
get \inlineTFinmath{c=-\frac{2}{3},      d=-\frac{1}{3}}, so our first quotient
is \inlineTFinmath{-\frac{2  {z^2}}{3}-\frac{z}{3}}, and the first remainder is
\inlineTFinmath{-\frac{1}{z}}. We now apply the Euclidean algorithm to this
remainder and \inlineTFinmath{b} to get

\inlineTFinmath {b={q_2}  {r_1}+{r_2}  \hspace{1em}\Rightarrow \hspace{1em}    {r_2}=b-{q_2}  {r_1}.}

\noindent Once again, the remainder \inlineTFinmath{{r_2}} must have degree less than that
of \inlineTFinmath{{r_1}}.  Since \inlineTFinmath{{r_1}} has degree zero, it
follows that \inlineTFinmath{{r_2}} must be zero (recall that the degree of the
zero polynomial is defined as -\(\infty \)).  As before, we choose a quotient
form so that both powers are matched, and find that the second remainder has the
form

\inlineTFinmath {\frac{c+3}{z}+\frac{d-6}{{z^2}}\cdot }

\noindent We can set both terms, and thus the remainder, to zero to get
\inlineTFinmath{c=\Mvariable{--3},    d=6}, so the second quotient is
\inlineTFinmath{\frac{6}{z}-3}. Alternatively, we could have decided to eliminate
the lowest two powers from the original expression, or even the lowest and the
highest power.  This gives three possible factorisations, each with different
quotients.  The gcd here is defined only up to a power of {\itshape z }:  the gcd
is 'greatest' in the sense that it has greatest possible Laurent degree.  In this
case, we found that the gcd was \inlineTFinmath{\frac{-1}{z}} (the last nonzero
remainder).  The other factorisation branches lead to a monomial gcd also.  In
this case the original Laurent polynomial {\itshape a} can be retrieved via
\inlineTFinmath{a={q_1}b+\kappa }, where \(\kappa \) is the gcd, and the reader
can easily verify that the three factorisations below are all valid:

\inlineTFinmath {a=\bigg(-\frac{2  {z^2}}{3}-\frac{z}{3}\bigg)b-\frac{1}{z},}
\inlineTFinmath {a=\bigg(-\frac{2  {z^2}}{3}-\frac{z}{6}\bigg)b-\frac{1}{2},}
\inlineTFinmath {a=\bigg(-\frac{7  {z^2}}{12}-\frac{z}{6}\bigg)b-\frac{z}{4}\cdot }

The gcd is the same for each factorisation up to a monomial factor, but the first
quotients differ nontrivially.  The last quotients differ only by monomial
factors, because at this stage we have no freedom over which powers to eliminate.

Note that multiplying \inlineTFinmath{a} by \inlineTFinmath{z} and
\inlineTFinmath{b} by \inlineTFinmath{{z^2}} converts these Laurent polynomials
into (ordinary) polynomials in \inlineTFinmath{z}. Polynomial division then gives

\inlineTFinmath {(a  z)=-2  {z^2}+3  z+1=\big(-\frac{2  z}{3}-\frac{1}{3}\big)(b  {z^2})-1,}

\noindent which is equivalent to the first factorisation above, providing a simple
computational check.  Similarly, the last factorisation can be obtained by
dividing \inlineTFinmath{a/z} by \inlineTFinmath{b  z} (since these are ordinary
polynomials in \inlineTFinmath{1/z}), {\itshape i.e.},

\inlineTFinmath {\frac{a}{z}=-2+\frac{3}{z}+\frac{1}{{z^2}}=\big(-\frac{7}{12}-\frac{1}{6  z}\big)(b  z)-\frac{1}{4}\cdot }

\noindent Furthermore, there are fast algorithms for polynomial division and these can be
used for these computations.  However, the second factorisation cannot be
obtained in this way.

Later, we will factorise certain \inlineTFinmath{2\times 2} matrices whose
entries are Laurent polynomials (specifically {\itshape z}-transforms as defined
above) by executing the Euclidean algorithm on two of the entries.  The factors
are matrices whose entries are determined by the quotients resulting from the
algorithm.  Thus, using the different sets of quotients, we can obtain several
different matrix factorisations.

\Subsection*{2.4. Gr\ODoubleDot{}bner bases and polynomial reduction}

The Euclidean algorithm can yield complicated algebraic expressions when carried
out on {\itshape z}-transforms with symbolic filter coefficients.  It is
desirable to reduce such expressions as much as possible, using any relations
that exist between the filter coefficients. A useful way of carrying out such
simplifications is to use {\itshape Gr\ODoubleDot{}bner bases} and {\itshape
polynomial reduction}.  {\itshape Mathematica} has built-in functions to generate
Gr\ODoubleDot{}bner bases and to carry out polynomial reduction.

The formal definition of a Gr\ODoubleDot{}bner basis is somewhat involved, making
use of several concepts in the theory of rings and multivariate polynomials (the
interested reader is referred to [1]).  The essential point is that
Gr\ODoubleDot{}bner bases encode the information contained in the constraints on
the filter coefficients, which can then be exploited to simplify factorisations
by the technique of polynomial reduction. The utility of Gr\ODoubleDot{}bner
bases may be demonstrated by considering an example.  In the general case of
D{\itshape N} orthogonal wavelets ({\itshape D} denotes Daubechies and {\itshape
N} here denotes the number of non-zero filter coefficients), the following
relations are satisfied by the filter coefficients \inlineTFinmath{{h_k}} [5]:
\inlineTFinmath {{{\sum }_k}{h_k}  =  {\sqrt{2}}},
\inlineTFinmath {{{\sum }_k}{h_k}{h_{k-2m}}  =  2  {{\delta }_{0,m}}} for
\inlineTFinmath {m=0,1,2,...,  \frac{N}{2}-1},
\inlineTFinmath {{{\sum }_k}{{(-1)}^k}{k^{p-1}}{h_k}=0} where
\inlineTFinmath {p=1,2,...,\frac{N}{2}}.

These conditions arise from applying certain approximation and orthonormality
constraints.  The equations may be solved for the coefficients of a given
D{\itshape N} basis.  In general the above conditions give \inlineTFinmath{N+1}
equations in \inlineTFinmath{N} unknowns, however the system of equations is
consistent; square normalisation can be derived from the other conditions.  They
can be solved exactly when \inlineTFinmath{N\leq 6}, but for \inlineTFinmath{N>6}
they must be solved numerically.    Solving for \inlineTFinmath{N=6} gives

\inlineTFinmath {\MathBegin{MathArray}[c]{ll}
	{h_0}=\frac{{\sqrt{2}}}{32}  \big(1+{\sqrt{10}}+{\sqrt{5+2  {\sqrt{10}}}}\big),&{h_1}=\frac{{\sqrt{2}}}{32}  \big(5+{\sqrt{10}}+3  {\sqrt{5+2  {\sqrt{10}}}}\big), \\
	{h_2}=\frac{{\sqrt{2}}}{32}  \big(10-2  {\sqrt{10}}+2  {\sqrt{5+2  {\sqrt{10}}}}\big),&{h_3}=\frac{{\sqrt{2}}}{32}  \big(10-2  {\sqrt{10}}-2  {\sqrt{5+2  {\sqrt{10}}}}\big), \\
	{h_4}=\frac{{\sqrt{2}}}{32}  \big(5+{\sqrt{10}}-3  {\sqrt{5+2  {\sqrt{10}}}}\big),&{h_5}=\frac{{\sqrt{2}}}{32}  \big(1+{\sqrt{10}}-{\sqrt{5+2  {\sqrt{10}}}}\big). 
  \MathEnd{MathArray}}

A Gr\ODoubleDot{}bner basis is a set of polynomial expressions which are
constructed using the zero conditions satisfied by the coefficients. An important
feature is that the resulting Gr\ODoubleDot{}bner basis always has exactly the
same collection of common roots as the original set of polynomials and is a
canonical form from which many properties can conveniently be deduced.  {\itshape
Mathematica} has a built-in command for computing a Gr\ODoubleDot{}bner basis:

\dispTFinmath{\MathBegin{MathArray}{l}
g=\Mfunction{GroebnerBasis}\big[\big\{\sum _{i=0}^{5}{h_i}-{\sqrt{2}},\sum _{i=0}^{5}{{(-1)}^i}  {h_i},\sum _{i=0}^{5}i  {{(-1)}^i}  {h_i},  \\
\noalign{\vspace{1.59375ex}}
\hspace{3.em} \sum _{i=0}^{5}{i^2}  {{(-1)}^i}  {h_i},\sum _{i=0}^{3}{h_i}  {h_{i+2}},\sum _{i=0}^{1}{h_i}  {h_{i+4}}\big\},\Mfunction{Table}[{h_i},\{i,0,5\}]\big]\\
\MathEnd{MathArray}}
\dispTFoutmath{\MathBegin{MathArray}{l}
\big\{65536  h_{5}^{4}-8192  {\sqrt{2}}  h_{5}^{3}-3072  h_{5}^{2}-96  {\sqrt{2}}  {h_5}+9,  \\
\noalign{\vspace{0.625ex}}
\hspace{1.em} -256  h_{5}^{3}+32  {\sqrt{2}}  h_{5}^{2}+6  {h_5}+3  {h_4},   \\
\noalign{\vspace{0.625ex}}
\hspace{1.em} -4096  h_{5}^{3}+512  {\sqrt{2}}  h_{5}^{2}+192  {h_5}+24  {h_3}-3  {\sqrt{2}},   \\
\noalign{\vspace{0.625ex}}
\hspace{1.em} 8  {h_2}+16  {h_5}-3  {\sqrt{2}},4096  h_{5}^{3}-512  {\sqrt{2}}  h_{5}^{2}-168  {h_5}+24  {h_1}-9  {\sqrt{2}},   \\
\noalign{\vspace{0.625ex}}
\hspace{1.em} 2048  h_{5}^{3}-256  {\sqrt{2}}  h_{5}^{2}-96  {h_5}+24  {h_0}-3  {\sqrt{2}}\big\}\\
\MathEnd{MathArray}}

\noindent This basis will eliminate \inlineTFinmath{{h_0},{h_1},{h_2},{h_3}}, and
\inlineTFinmath{{h_4}} from any expression, replacing it with terms in
\inlineTFinmath{{h_5}}.  Now consider the following expression:

\dispTFinmath{\Mvariable{expr}={h_1}  {h_5}+{h_0}  {h_3}+{h_4}  {h_2};}

This can be reduced to an expression involving only a single coefficient, here
\inlineTFinmath{{h_5}}, using polynomial reduction with the above
Gr\ODoubleDot{}bner basis:

\dispTFinmath{\Mvariable{reduced}=\Mfunction{PolynomialReduce}[\Mvariable{expr},g,\Mfunction{Table}[{h_i},\{i,0,5\}]]//\Mfunction{Last}}
\dispTFoutmath{\frac{64}{3}  {\sqrt{2}}  h_{5}^{3}-\frac{25  h_{5}^{2}}{3}-\frac{5  {h_5}}{4  {\sqrt{2}}}-\frac{1}{64}}

Observe that the form of these filter coefficients makes it difficult to give
this reduced form of \inlineTFinmath{\Mvariable{expr}} using elementary algebra. 
Note also that we do not need to know the exact values of all of the
coefficients, only their defining relationships.  For example, it can be shown
that finding the exact form of the D8 coefficients is equivalent to solving an
irreducible sixth degree polynomial.  However, polynomial reduction can still be
carried out on the D8 coefficients, giving rise to {\itshape exact} expressions
containing only {\itshape one} coefficient.  This may be more satisfactory for
numerical implementations, as we only need to substitute one numerical value into
exact expressions.

\Subsection*{2.5. Mallat's algorithm}

We briefly describe here an established algorithm for computing the discrete
wavelet transform. For a sampled signal, considered for simplicity to be of
length \inlineTFinmath{l={2^n}} (this is easily generalized), we can use the
relations satisfied by the wavelets to compute the wavelet expansion
coefficients.  We define matrices called {\itshape quadrature mirror filters}
(QMF) in terms of the filter coefficients, and multiply by our data vector to
produce a step of the wavelet transform.  After each matrix multiplication, half
of the vector is 'left alone' -- it is one component of the wavelet transform. 
Before the next step, a new QMF matrix of half the original dimensions is
constructed.  Eventually we reach a point where we are operating on a two
component vector (only if \inlineTFinmath{l={2^n}}), and the result of this step
is the last component of the discrete wavelet transform.  This is called
{\itshape Mallat's algorithm }[5].

More precisely, we denote our sampled signal by the vector 
\inlineTFinmath{{s^{[n]}}}; these sampled values correspond to the highest
resolution level.  With the coefficients \inlineTFinmath{{h_k}}
(\inlineTFinmath{{g_k}}) forming a low(high)-pass filter, we define the QMF
matrices as

\dispTFNumberedEquationmath{{{(H)}_{k,l}}={h_{l-2  k}}, {{(G)}_{k,l}}={g_{l-2  k}}.}

\noindent Then we have the relations;

\dispTFNumberedEquationmath{{s^{[j]}}=H {s^{[j+1]}}, {d^{[j]}}=G {s^{[j+1]}},} 

\noindent where the vectors \inlineTFinmath{{s^{[j]}}} and
\inlineTFinmath{{d^{[j]}}} are the 'signal' and 'difference' terms at resolution
{\itshape j}.  In other words, the components of these vectors are the
coefficients in the expansion of a signal into the wavelet basis.  This defines a
step of the discrete wavelet transform in terms of multiplication by {\itshape H}
and {\itshape G}, the QMF matrices.  The (in the \inlineTFinmath{l={2^n}} case)
one-component vector \inlineTFinmath{{s^{[0]}}} is the average or 'DC' term of
our signal. After the first step the QMF matrices are redefined at half the
dimensions, and we carry out the step (4) on the signal term found at the
previous level.  Thus we are able to find the expansion coefficients at {\itshape
all} levels beginning with our sampled values \inlineTFinmath{{s^{[n]}}}.

As a simple example of this, consider an explicit matrix implementation of the D4
wavelet transform. It is, of course, highly inefficient to implement Mallat's
algorithm using matrix multiplication: this implementation is presented here only
to introduce some notation and indicate the algorithm's inherent
parallelisability. For an initial data vector
\inlineTFinmath{{s^{[3]}}=\{{s_0},{d_0},{s_1},{d_1},{s_2},{d_2},{s_3},{d_3}\}}
(the reason for the artificial structure of this vector will become clear later),
the first step,

\inlineTFinmath {\Big(\MathBegin{MathArray}[c]{c}
	{s^{[2]}} \\
	{d^{[2]}} 
  \MathEnd{MathArray}\Big)=\Bigg(\MathBegin{MathArray}[c]{cccccccc}
	{h_0}&{h_1}&{h_2}&{h_3}&0&0&0&0 \\
	0&0&{h_0}&{h_1}&{h_2}&{h_3}&0&0 \\
	0&0&0&0&{h_0}&{h_1}&{h_2}&{h_3} \\
	{h_2}&{h_3}&0&0&0&0&{h_0}&{h_1} \\
	{g_2}&{g_3}&0&0&0&0&{g_0}&{g_1} \\
	{g_0}&{g_1}&{g_2}&{g_3}&0&0&0&0 \\
	0&0&{g_0}&{g_1}&{g_2}&{g_3}&0&0 \\
	0&0&0&0&{g_0}&{g_1}&{g_2}&{g_3} 
  \MathEnd{MathArray}\Bigg).\Bigg(\MathBegin{MathArray}[c]{c}
	{s_0} \\
	{d_0} \\
	{s_1} \\
	{d_1} \\
	{s_2} \\
	{d_2} \\
	{s_3} \\
	{d_3} 
  \MathEnd{MathArray}\Bigg),}

\noindent can be split into the parallel operations involving only {\itshape h};

\dispTFNumberedEquationmath{\MathBegin{MathArray}{l}
{s^{[2]}}\leftarrow \Bigg(\MathBegin{MathArray}[c]{cccc}
	{h_0}&{h_2}&0&0 \\
	0&{h_0}&{h_2}&0 \\
	0&0&{h_0}&{h_2} \\
	{h_2}&0&0&{h_0} 
  \MathEnd{MathArray}\Bigg).\Bigg(\MathBegin{MathArray}[c]{c}
	{s_0} \\
	{s_1} \\
	{s_2} \\
	{s_3} 
  \MathEnd{MathArray}\Bigg)+  \\
\noalign{\vspace{3.16667ex}}
\hspace{2.em} \Bigg(\MathBegin{MathArray}[c]{cccc}
	{h_1}&{h_3}&0&0 \\
	0&{h_1}&{h_3}&0 \\
	0&0&{h_1}&{h_3} \\
	{h_3}&0&0&{h_1} 
  \MathEnd{MathArray}\Bigg).\Bigg(\MathBegin{MathArray}[c]{c}
	{d_0} \\
	{d_1} \\
	{d_2} \\
	{d_3} 
  \MathEnd{MathArray}\Bigg)\\
\MathEnd{MathArray},}

\noindent and {\itshape g}:

\dispTFNumberedEquationmath{\MathBegin{MathArray}{l}
{d^{[2]}}\leftarrow \Bigg(\MathBegin{MathArray}[c]{cccc}
	{g_2}&0&0&{g_0} \\
	{g_0}&{g_2}&0&0 \\
	0&{g_0}&{g_2}&0 \\
	0&0&{g_0}&{g_2} 
  \MathEnd{MathArray}\Bigg).\Bigg(\MathBegin{MathArray}[c]{c}
	{s_0} \\
	{s_1} \\
	{s_2} \\
	{s_3} 
  \MathEnd{MathArray}\Bigg)+  \\
\noalign{\vspace{3.16667ex}}
\hspace{2.em} \Bigg(\MathBegin{MathArray}[c]{cccc}
	{g_3}&0&0&{g_1} \\
	{g_1}&{g_3}&0&0 \\
	0&{g_1}&{g_3}&0 \\
	0&0&{g_1}&{g_3} 
  \MathEnd{MathArray}\Bigg).\Bigg(\MathBegin{MathArray}[c]{c}
	{d_0} \\
	{d_1} \\
	{d_2} \\
	{d_3} 
  \MathEnd{MathArray}\Bigg)\\
\MathEnd{MathArray}.}

The {\itshape lifting scheme} described in \S{}3 presents an alternative, highly
efficient, method for computing the wavelet transform --- only involving simple
multiplication and addition operations --- which is faster than Mallat's
algorithm by a factor of 2 for large datasets [2].  Moreover, lifting is more
general, applicable to {\itshape n}-dimensional transforms and wavelets on
manifolds.

\Section*{3. Lifting}

In this section we outline the general theory of the {\itshape lifting scheme}.
Further details can be found in{\itshape  }[2], and broader information in
[10,11,12,13].  The lifting scheme has been shown to be equivalent to the
traditional method of implementing the wavelet transform via the QMF matrices
[2].  It has several advantages over Mallat's algorithm, as will be shown below. 
It turns out that the procedure is equivalent to the factorisation of a matrix
whose components are related to the {\itshape z}-transform of the filter.  This
matrix factorisation is non-unique, and we can find all factorisations through
automation of the Euclidean algorithm for Laurent polynomials.

\Subsection*{3.1. Polyphase representations}

We define the {\itshape polyphase representation} of a filter;

\dispTFNumberedEquationmath{h(z)={h_e}({z^2})+{z^{-1}}{h_o}({z^2}),}

\noindent where {\itshape h} is the {\itshape z}-transform of the filter as defined in
equation (1).  Here  \inlineTFinmath{{h_e}} (\inlineTFinmath{{h_o}}) is the
{\itshape even (odd) polyphase component of h}, defined by

\dispTFNumberedEquationmath{{h_e}({z^2})=\frac{h(z)+h(-z)}{2},    {h_o}({z^2})=\frac{h(z)-h(-z)}{2  {z^{-1}}}\cdot }

\noindent We see that \inlineTFinmath{{h_e}} and \inlineTFinmath{{h_o}} contain the filter
coefficients at even and odd locations respectively.  We now define the {\itshape
polyphase matrix}:

\dispTFNumberedEquationmath{P(z)=\big(\MathBegin{MathArray}[c]{cc}
	{h_e}(z)&{g_e}(z) \\
	{h_o}(z)&{g_o}(z) 
  \MathEnd{MathArray}\big),}

\noindent where \inlineTFinmath{{g_e}} and \inlineTFinmath{{g_o}} are defined in terms of
the high pass filter {\itshape g} in analogously to (7).  Note that the
determinant of this matrix is always monomial [2].  The program requires it to be
unity, but any polyphase matrix can be suitably adjusted to satisfy this
requirement [2]. Here {\itshape z} is not a value to be substituted, but a
symbolic entity representing a data shift.  In general for a filter {\itshape f},
we have the rule:

\dispTFNumberedEquationmath{{z^m} {f_l}\rightarrow {f_{l-m}},}

\noindent where the direction of the shift is a choice of convention.

The polyphase matrix provides an alternative method of executing the lifting
scheme.  For a data vector \inlineTFinmath{{s^{[j+1]}}}, we begin by performing
the {\itshape lazy wavelet transform}, which simply involves subsampling the data
at even and odd locations.  That is;

\dispTFNumberedEquationmath{\MathBegin{MathArray}{l}
{{{s^{[j]}}}_l}\leftarrow {{{s^{[j+1]}}}_{2  l}},  \\
\noalign{\vspace{0.604167ex}}{{{d^{[j]}}}_l}\leftarrow {{{s^{[j+1]}}}_{2  l+1}}.\\
\MathEnd{MathArray}}

In analogy with Mallat's algorithm, The vector
\inlineTFinmath{({s^{[j]}},{d^{[j]}})} then premultiplies the polyphase matrix to
give one stage of the discrete wavelet transform, bearing in mind that the
components \inlineTFinmath{{s^{[j]}}}{\itshape  }and \inlineTFinmath{{d^{[j]}}}
are {\itshape themselves} vectors, and the polyphase matrix elements are Laurent
polynomials containing the {\itshape z}-operator (shift).  That is, a general
step may be written as

\dispTFNumberedEquationmath{({s^{[j]}},{d^{[j]}})\leftarrow ({s^{[j+1]}},{d^{[j+1]}}).\big(\MathBegin{MathArray}[c]{cc}
	{h_e}(z)&{g_e}(z) \\
	{h_o}(z)&{g_o}(z) 
  \MathEnd{MathArray}\big).}

\noindent The result of the multiplication is the signal and detail at the next level, and
the next step is to repeat the lazy wavelet transform (11) on
\inlineTFinmath{{s^{[j]}}} and proceed as in (12).  The length of
\inlineTFinmath{{s^{[j]}}} and \inlineTFinmath{{d^{[j]}}} is reduced by a factor
of 2 at each step, and thus the algorithm must always terminate after {\itshape
n} steps.

\Subsection*{3.2. The factorisation of the polyphase matrix}

The factorisation of the polyphase matrix is obtained by using Theorem 7 of [2]. 
We first apply the Euclidean algorithm to divide \inlineTFinmath{{h_e}(z)} by
\inlineTFinmath{{h_o}(z)}.  That is, we start by setting
\inlineTFinmath{{a_0}={h_e}(z)}, \inlineTFinmath{{b_0}={h_o}(z)}, and then
iterate the scheme as in (2),

\inlineTFinmath {\MathBegin{MathArray}{l}
{a_i}={b_{i-1}},  \\
\noalign{\vspace{0.5ex}}{b_i}={a_{i-1}}-{a_i}  {q_i},\\
\MathEnd{MathArray}}

\noindent choosing quotients \inlineTFinmath{{q_i}} such that the degrees of the remainders
\inlineTFinmath{{b_i}} are reduced at each step.  The factorisation of the
polyphase matrix is given in terms of these quotients by

\dispTFNumberedEquationmath{P(z)=\bigg(\prod _{i=1}^{n/2-1}\big(\MathBegin{MathArray}[c]{cc}
	1&{q_{2i-1}}(z) \\
	0&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	{q_{2i}}(z)&1 
  \MathEnd{MathArray}\big)\bigg).\big(\MathBegin{MathArray}[c]{cc}
	1&{{\kappa }^2}s(z) \\
	0&1 
  \MathEnd{MathArray}\big).\bigg(\MathBegin{MathArray}[c]{cc}
	\kappa &0 \\
	0&\frac{1}{\kappa } 
  \MathEnd{MathArray}\bigg),}

\noindent where \(\kappa \) is a constant {\itshape scaling factor} which is simply the
gcd, and \inlineTFinmath{s(z)  }is a {\itshape lifting term}, found by comparison
of the factorised and unfactorised forms of the polyphase matrix.  We refer to
the matrices in the initial product as {\itshape quotient matrices}, and to the
last two matrices as the {\itshape lifting matrix} and the {\itshape scaling
matrix} respectively.

The alternating upper and lower triangular structure of this factorisation is
what allows an 'in-place' implementation of the wavelet transform.  Consider the
effect of premultiplication of \inlineTFinmath{P(z)} in {\itshape factorised}
form by a two-element row vector \inlineTFinmath{({s^{[j]}},{d^{[j]}})} as in
(12).  The first factor here,\inlineTFinmath{\big(\MathBegin{MathArray}[c]{cc}
	1&{q_1}(z) \\
	0&1 
\MathEnd{MathArray}\big)}, is upper triangular with diagonal entries equal to 1. 
The {\itshape lifting step} corresponding to this matrix factor is thus

\dispTFNumberedEquationmath{({s^{[j]}},{d^{[j]}}).\big(\MathBegin{MathArray}[c]{cc}
	1&{q_1}(z) \\
	0&1 
  \MathEnd{MathArray}\big)  \equiv   \big(\MathBegin{MathArray}[c]{c}
	{s^{[j]}}\leftarrow {s^{[j]}} \\
	{d^{[j]}}\leftarrow {d^{[j]}}+{q_1}(z){s^{[j]}}   
  \MathEnd{MathArray}\big) \cdot}

Similar steps result from subsequent matrices in the factorisation.  This
illustrates the fact that the lifting method is in-place and trivially invertible
because \inlineTFinmath{{{\big(\MathBegin{MathArray}[c]{cc}
	1&x \\
	0&1 
  \MathEnd{MathArray}\big)}^{-1}}=\big(\MathBegin{MathArray}[c]{cc}
	1&-x \\
	0&1 
  \MathEnd{MathArray}\big)} and \inlineTFinmath{{{\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	x&1 
  \MathEnd{MathArray}\big)}^{-1}}=\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	-x&1 
\MathEnd{MathArray}\big)}.  Note that in general the quotients contain powers of
{\itshape z}, which will give rise to shifting of the lists.  The lifting scheme
can thus be written as a sequence of steps of the form (14) with alternating
{\bfseries {\itshape s}} and {\bfseries {\itshape d}} symbols, followed by the
scaling step.  The initial values of \inlineTFinmath{s} and \inlineTFinmath{d}
are the results of the lazy wavelet transform as in (11).

When we reach the end of the factorisation, that is, when the scaling steps have
been executed, we record the final values of \inlineTFinmath{{s^{[j]}}} and
\inlineTFinmath{{d^{[j]}}}.  As before, \inlineTFinmath{{d^{[j]}}} represents the
high frequency component at scale {\itshape j}; this is one component of the
wavelet transform.  We conduct the lazy wavelet transform on the result of
scaling \inlineTFinmath{{s^{[j]}}}, and follow the same lifting steps as before.
These ideas are illustrated by the examples in \S{}5.

The scaling matrix, \inlineTFinmath{\bigg(\MathBegin{MathArray}[c]{cc}
	\kappa &0 \\
	0&\frac{1}{\kappa } 
\MathEnd{MathArray}\bigg)}, is implemented as \inlineTFinmath{{s^{[j]}}\leftarrow
\kappa     {s^{[j]}}} and \inlineTFinmath{{d^{[j]}}\leftarrow \frac{1}{\kappa } 
{d^{[j]}}}.  For implementation purposes it is preferable to have a factorisation
with {\itshape constant} gcd.  The gcd is always monomial [2], and, for a general
gcd, we can factorise the scaling matrix into lifting steps followed by a
constant scaling matrix.  To see this, note that

\dispTFNumberedEquationmath{\MathBegin{MathArray}{l}
\big(\MathBegin{MathArray}[c]{cc}
	x&0 \\
	0&1/x 
  \MathEnd{MathArray}\big)=\big(\MathBegin{MathArray}[c]{cc}
	1&x-{x^2} \\
	0&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	-1/x&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&x-1 \\
	0&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	1&1 
  \MathEnd{MathArray}\big)\equiv   \\
\noalign{\vspace{1.16667ex}}
\hspace{2.em} \big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	-1&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&1-1/x \\
	0&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	x&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&1/{x^2}-1/x \\
	0&1 
  \MathEnd{MathArray}\big),\\
\MathEnd{MathArray}}

\noindent where {\itshape x} represents \inlineTFinmath{{z^{\pm 1}}}-- only in this case do
the matrices in these factorisations have degree 1 entries.  So for an arbitrary
gcd, \inlineTFinmath{\alpha   {x^m},  m>0}, we could factorise the scaling matrix
as

\inlineTFinmath {\MathBegin{MathArray}{l}
\big(\MathBegin{MathArray}[c]{cc}
	\alpha   {x^m}&0 \\
	0&1/(\alpha   {x^m}) 
  \MathEnd{MathArray}\big)={{\big(\MathBegin{MathArray}[c]{cc}
	x&0 \\
	0&1/x 
  \MathEnd{MathArray}\big)}^m}.\big(\MathBegin{MathArray}[c]{cc}
	\alpha &0 \\
	0&1/\alpha  
  \MathEnd{MathArray}\big)=  \\
\noalign{\vspace{1.25ex}}
\hspace{2.em} {{\big(\big(\MathBegin{MathArray}[c]{cc}
	1&x-{x^2} \\
	0&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	-1/x&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&x-1 \\
	0&1 
  \MathEnd{MathArray}\big).\big(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	1&1 
  \MathEnd{MathArray}\big)\big)}^m}\big(\MathBegin{MathArray}[c]{cc}
	\alpha &0 \\
	0&1/\alpha  
  \MathEnd{MathArray}\big),\\
\MathEnd{MathArray}}

\noindent and still have alternating upper and lower triangular matrices with degree 1
entries followed by a constant scaling matrix.  Similarly we could factorise the
matrix using the second elementary factorisation in (15), or indeed a combination
of the two.  Hence there are \inlineTFinmath{{2^m}} ways of factorising the
scaling matrix using these elementary factorisations, quite apart from the fact
that we can choose the quotients in different ways.

\Subsection*{3.3. The number of factorisations}

It is important to consider the number of possible factorisations of a given
wavelet transform.  This is equivalent to the question of how many factorisations
exist for two Laurent polynomials.  In the following analysis, we only consider
quotients of degree at most 1.

Suppose \inlineTFinmath{{a_0}} and \inlineTFinmath{{b_0}} are our starting
polynomials.  We first consider the case where \inlineTFinmath{\LeftBracketingBar
{a_0}\RightBracketingBar =\LeftBracketingBar {b_0}\RightBracketingBar +1}. 
Consider the first step of the Euclidean algorithm as in (2),

\dispTFNumberedEquationmath{\MathBegin{MathArray}{l}
{a_1}={b_0},  \\
\noalign{\vspace{0.5ex}}{b_1}={a_0}-{a_1}  {q_1}.\\
\MathEnd{MathArray}}

The aim is to choose \inlineTFinmath{{q_1}} so that the degree of {\itshape b} is
reduced ({\itshape i.e.}, so \inlineTFinmath{\LeftBracketingBar
{b_1}\RightBracketingBar <\LeftBracketingBar {b_0}\RightBracketingBar }).  Since
we are using degree 1 quotients, we have that \inlineTFinmath{\LeftBracketingBar
{b_0}{q_1}\RightBracketingBar =\LeftBracketingBar {b_0}\RightBracketingBar
+\LeftBracketingBar {q_1}\RightBracketingBar =\LeftBracketingBar
{a_0}\RightBracketingBar }, that is, \inlineTFinmath{{a_0}} and
\inlineTFinmath{{b_0}{q_1}} have the {\itshape same }number of terms.  We must
choose the quotient so that the highest (or equivalently the lowest) powers of
\inlineTFinmath{{a_0}} and \inlineTFinmath{{b_0}{q_1}} are the same.  If this
were not so, there would be extra powers introduced by the subtraction, and we
could not reduce the degree.  Since a generic degree 1 quotient has the form
\inlineTFinmath{{z^n}\big(c+\frac{d}{z}\big)}, this is simply a matter of
choosing {\itshape n} appropriately.

In order to reduce the degree, we may choose to eliminate the two highest or two
lowest powers, or each extreme power, by choice of the quotient coefficients
{\itshape c} and {\itshape d}.  Clearly there is no point eliminating
intermediate terms, since this will have no effect on the degree.  Thus we have
three possibilities at this step.  After this step, we set
\inlineTFinmath{{a_1}={b_0}} and proceed similarly to (16) to find
\inlineTFinmath{{b_2}}.  The degrees of {\itshape a} and {\itshape b} have each
been reduced by one, so we proceed as in the first step.  Thus we have three
possibilities at each step {\itshape except} the last one.  This is because at
the last step, {\itshape a} has degree 1, and all options are {\itshape
equivalent} -- there are only two terms that can be eliminated.  Since we reduce
the degree of {\itshape b} by 1 at each step, the number of steps in the
Euclidean algorithm is \inlineTFinmath{\LeftBracketingBar b\RightBracketingBar
+1}, and hence the number of factorisations in this case is
\inlineTFinmath{{3^{\LeftBracketingBar b\RightBracketingBar }}}.

Now let us consider the case where \inlineTFinmath{\LeftBracketingBar
a\RightBracketingBar =\LeftBracketingBar b\RightBracketingBar }.  Considering
again (16), we see that the degree can be reduced if \inlineTFinmath{{q_1}} has
degree 0 ({\itshape i.e.}, is monomial) under certain circumstances.  We can
cover all cases by defining a generic quotient as before.  This time, however,
\inlineTFinmath{{b_0}{q_1}} has one more term than \inlineTFinmath{{a_0}}.  We
can still eliminate each extreme power, but this time we must choose whether we
want to match the highest {\itshape or} lowest powers in \inlineTFinmath{{a_0}}
and \inlineTFinmath{{b_0}{q_1}} -- these choices are no longer equivalent.  We
eliminate the highest two powers or lowest two powers as before.  The degree 0
quotients are arise when we set c or d to zero when eliminating terms.  Hence
there are now {\itshape four} possible elimination options at the first step. 
After the first step, we set \inlineTFinmath{{a_1}={b_0}} as above.  This time,
however, the degree of {\itshape b} has been reduced by 1, but the degree of
{\itshape a} has {\itshape not} changed.  Thus we are in the situation where
\inlineTFinmath{\LeftBracketingBar a\RightBracketingBar =\LeftBracketingBar
b\RightBracketingBar +1}, and we can proceed as above.  The number of
factorisations in this case is thus \inlineTFinmath{4\times
{3^{\LeftBracketingBar b\RightBracketingBar -1}}}.

If {\itshape a} and {\itshape b} have degrees differing by more than 1, we
{\itshape cannot} execute the Euclidean algorithm using only quotients of degree
at most 1.  To see this, consider again the first step (16),  and suppose that
\inlineTFinmath{\LeftBracketingBar {a_0}\RightBracketingBar >\LeftBracketingBar
{b_0}\RightBracketingBar +1}.  For degree 1 quotients, we can cancel two terms
from \inlineTFinmath{{a_0}}, so \inlineTFinmath{\LeftBracketingBar
{b_1}\RightBracketingBar =\LeftBracketingBar {a_0}\RightBracketingBar
-2>\LeftBracketingBar {b_0}\RightBracketingBar -1}, that is
\inlineTFinmath{\LeftBracketingBar {b_1}\RightBracketingBar \geq
\LeftBracketingBar {b_0}\RightBracketingBar } (since we are dealing with positive
integers) so we have {\itshape not} reduced the degree of {\itshape b}.  This is
not a great limitation, since we are not dealing with {\itshape arbitrary}
Laurent polynomials, but {\itshape even and odd components of polyphase filters}.
 Usually the degrees of the even and odd components will have degrees differing
by 0 or 1.  The only exception would be if one of the filter coefficients in the
range \inlineTFinmath{{k_b}<k<{k_e}} was zero.

Note that we do not count any extra factorisations introduced by the non-unique
factorisation of the scaling matrix when the gcd is a non-constant monomial;
these are not fundamentally important or enlightening.

\Section*{4. Description of the program}

We turn now from the general theory of lifting to the automation of polyphase
factorisations and lifting using {\itshape Mathematica}.

\Subsection*{4.1. Overview}

The program, consisting of two broad parts, automates the factorisation of the
polyphase matrix, and can find all factorisations.  The first part is an
implementation of the Euclidean algorithm for Laurent polynomials, and the second
part is concerned with transforming the results into a sequence of lifting steps.
The Euclidean algorithm part takes two Laurent polynomials, and runs the
Euclidean algorithm, thus finding the quotients necessary to construct the matrix
factorisation (13).  All the factorisations are found this way, although the
program restricts the form of the quotients to have degree one.  As indicated in
\S{}3.3, this is not a great loss of generality.  It is noted in [2] that
quotients of degree 1 are more favourable for hardware implementations than
higher degree quotients.

The task of transforming the result of the Euclidean algorithm into a sequence of
lifting steps is divided into smaller parts again.  The first part converts to
the matrix factorisation (13), which involves arranging the quotients and gcd
into matrix factors, and also finding the lifting term \inlineTFinmath{s(z)}.
This factorisation in itself is not the final aim, although it is helpful to be
able to see what the factorisation looks like.  The next part converts the matrix
factorisation into the sequence of lifting steps suitable for hardware or
software implementation.  This is done by simply carrying out the matrix
multiplication of the symbolic vectors \inlineTFinmath{(s,d)} by each matrix
factor.  The inverse of a given transform is also easily found. The final part
converts these steps into {\itshape Mathematica} input.  Implementing the
factorisation results permits comparison between the package and the results of
different factorisations of the same transform.

The following subsections outline the main components of the program, and \S{}5
gives several examples of its use.

\Subsection*{4.2. SingleIteration module}

This module simply takes as arguments the initial {\itshape a} and {\itshape b}
on which to execute a step of the Euclidean algorithm, along with an elimination
option.  Its output is the quotient, the remainder, and the second Laurent
polynomial (to be used in the next step).  This module may be called repeatedly
by a while loop whose stopping condition is that the remainder is identically
zero.  A generic quotient of degree one is defined as
\inlineTFinmath{{z^n}\big(c+\frac{d}{z}\big)}, where {\itshape n} is determined
by matching extreme powers.  This is substituted to give the form of the
remainder, and c and d are found by the method of undetermined coefficients. 
Effectively these parameters are determined by the elimination option. Based on
the analysis of \S{}3.3, the four possible elimination options are:

\inlineTFinmath{\Mvariable{EliminateEndsMatchHigh}} :  This option means that the
highest and lowest powers of the expression are to be eliminated, but the highest
powers are to be matched by suitable choice of {\itshape n}.

\inlineTFinmath{\Mvariable{EliminateEndsMatchLow}} :  Again the extreme power
terms will be eliminated, but this time the lowest two powers will be matched.

\inlineTFinmath{\Mvariable{EliminateLow}} :  In this case the lowest two power
terms will be matched and eliminated.

\inlineTFinmath{\Mvariable{EliminateHigh}} :  similarly, the highest two power
terms will be matched and eliminated.

As indicated in \S{}3.3, the first two options are frequently equivalent. 
However, since these options cover all cases, we do not need to test when the
distinction is actually necessary.

\Subsection*{4.3. FindAll module}

This module generates every possible elimination branch, and runs
\inlineTFinmath{\Mvariable{SingleIteration}} on each of them until a zero
remainder is found.  It takes as input the two Laurent polynomials to be
factorised and an optional simplification or transformation rule (see below). 
Note that at the last stage of the algorithm, one is dealing with a remainder
which is monomial, and so all elimination options are equivalent.  This is
accounted for in the module, and saves three \inlineTFinmath{\Mvariable{Solve}}
operations occurring at each of a large number of factor branch nodes.

The structure of the module is such that it generates all possible choices that
could be made at the first stage, solves for each choice, and stores the result. 
This is repeated at the next level, and so on, keeping the results at every
stage.  In this way, a 'tree' of factor branches is found.  It is important to be
aware of which quotients from different levels may be combined to form a branch
of quotients.  That is, since we are simply generating the lists of quotients at
each level, these need to be arranged into a set of branch structures.

In summary, the process occurs in such a way that every possible equation is
solved {\itshape once} and stored, and then recombined appropriately.  The output
is a list, each element of which corresponds to one factorisation.  The elements
themselves have a substructure -- their first element is the list of quotients,
and their second (and last) element is the gcd.

Neither of the above modules need be directly called by the user.  The user calls
the \inlineTFinmath{\Mvariable{EuclideanFactorisation}} module, which checks
which elimination option has been specified, and delegates the task to one of the
above modules as appropriate.  The module takes as input the starting Laurent
polynomials (in a 2-element list), along with an elimination rule.  The
elimination rule is of the form
\inlineTFinmath{\Mvariable{EliminationBranch}\rightarrow
\{\Mvariable{opt1},\Mvariable{opt2},\ldots \}} where
\inlineTFinmath{\{\Mvariable{opt1},\Mvariable{opt2},\ldots \}} is a list of
elimination options if the user wishes to find a specific factorisation, or
simply \inlineTFinmath{\Mvariable{EliminationBranch}\rightarrow \Mvariable{All}}
if the user wants to find every factorisation. Note that the user can specify an
optional third argument to simplify or transform the results in some way.  For
example, this is how the Gr\ODoubleDot{}bner reduction is done, and if the user
wants numeric factorisations, then \inlineTFinmath{\Mvariable{Chop}} (which sets
to zero any quantity less than \inlineTFinmath{{{10}^{-10}}}) is a suitable
argument.  If no third argument is given then it defaults to
\inlineTFinmath{\Mvariable{Simplify}}.

\Subsection*{4.4. PolynomialReduction and DaubechiesZeros modules}

\inlineTFinmath{\Mvariable{PolynomialReduction}} takes as arguments the
expression to be reduced and the filter coefficients along with the zero
conditions they satisfy.  It generates a Gr\ODoubleDot{}bner basis by calling the
built-in \inlineTFinmath{\Mvariable{GroebnerBasis}} command, and this is
dynamically stored to avoid recomputation.  It then simply uses the built-in
\inlineTFinmath{\Mvariable{PolynomialReduce}} command with the
Gr\ODoubleDot{}bner basis.  The Gr\ODoubleDot{}bner bases for D{\itshape N} can
be computed using the \inlineTFinmath{\Mvariable{DaubechiesZeros}} command, which
automatically generates the zero conditions satisfied by Daubechies coefficients.


\Subsection*{4.5. PolyphaseFactorisation module}

This module gives the factorisation of a polyphase matrix, taking as arguments
the polyphase matrix, a factorisation as found by the
\inlineTFinmath{\Mvariable{EuclideanFactorisation}} module, and an optional
simplification function.  It returns the matrix factorisation as in (13).  The
given polyphase matrix must have determinant 1, though any matrix can be suitably
modified in order to satisfy this criterion [2].

Note that optional simplification rules can be entered for this module as well as
in the \inlineTFinmath{\Mvariable{EuclideanFactorisation}} module.  If one wishes
to have a matrix factorisation simplified by polynomial reduction, for example,
the rule {\itshape must} be re-entered when calling this module.  Although the
quotients were simplified during the Euclidean algorithm, when finding the
{\itshape matrix} factorisation we need the lifting term \inlineTFinmath{s(z)}. 
This depends on the {\itshape unfactorised} polyphase matrix, which has not
undergone any simplification.

The module first checks to see if the number of steps required is odd, and if so,
it prepends a zero to the quotient list found in the Euclidean algorithm.  This
will effectively produce an identity matrix as the first factor, and so the only
effect this step has is to cause the following matrix factors to be transposed. 
This produces results consistent with those from [2], and is a valid
factorisation of the polyphase matrix.  In fact it is equivalent to changing the
order of the initial Laurent polynomials and setting the first quotient to zero. 
The lifting term \inlineTFinmath{s(z)}{\itshape  }is found by equating the
factorised and unfactorised forms of the polyphase matrix and solving
appropriately.  Note also that the module uses \inlineTFinmath{s} to describe
\inlineTFinmath{{{\kappa }^2}  s(z)}.

The factorisation is then given by constructing the appropriate matrices with the
quotients, the lifting term, and the scaling matrix which is determined by the
gcd.  Any identity matrices in the factorisation are discarded, and the
placeholder command \inlineTFinmath{\Mvariable{CenterDot}} is applied to those
remaining to prevent them being multiplied during output.

If the factorisation has a non-constant gcd, the user can apply the function
\inlineTFinmath{\Mvariable{ScalingTransform}} to \(\kappa \) to replace the
scaling matrix.  The user can also specify a list according to the sequence of
elementary factorisations (15) they wish to use.  For example, if the gcd was
\inlineTFinmath{{z^2}}, and the user wished only to use the second of the
factorisations  (15), they would provide the list \{2,2\}.  If they wished to use
the second followed by the first they would specify \{2,1\} and so on.  If no
list is provided, the default is \{1,1,\(\ldots \),1\}, corresponding to the use
of the first factorisation only.

\Subsection*{4.6. ToLifting module}

This converts the polyphase factorisation into the sequence of lifting steps.
Recall that the polyphase factorisation is a sequence of alternating upper and
lower triangular matrices, followed by a diagonal scaling matrix.  The diagonal
entries of the triangular matrices are all equal to unity. In general, the first
matrix can be upper or lower triangular, and the module works in each case. 
After converting the factorisation into a list of factors, it tests to see
whether the first matrix is upper triangular.  If so, the first element to be
changed is {\itshape s}, and the symbol to be changed alternates until we reach
the scaling steps (the diagonal matrix).  We simulate this by defining the list
\inlineTFinmath{\Mvariable{components}=\{s,d\}}.  A generic step similar to (14)
is defined with {\itshape x} being the first or last component of
\inlineTFinmath{\Mvariable{components}}.  The variable
\inlineTFinmath{\Mvariable{offset}} is defined to offset arguments of
\inlineTFinmath{\Mvariable{Part}} as applied to
\inlineTFinmath{\Mvariable{components}}, according to whether {\itshape s} or
{\itshape d} is the variable to be changed. When all the intermediate steps have
been found, the lazy steps are prepended, and the scaling steps are found using
the final diagonal matrix.  If one wishes to implement the lifting steps in
another language, the output of \inlineTFinmath{\Mvariable{ToLifting}} can serve
as pseudocode.

A {\itshape Mathematica} replacement rule is defined to simulate the {\itshape
z}-operator as defined in (10).  This rule is applied to all the steps of the
transform, after some algebraic simplification to ensure the replacement rule
will function properly.

A slightly different notation from that used in [2] was developed, in order to be
more conducive to programming, since superscripts are difficult for computer
algebra systems to distinguish from exponents.  The notation '{\itshape s}' and
'{\itshape d}' is still used to denote 'signal' and 'difference' terms
respectively.  Also in [2] subscripts were used to denote intermediate steps.  As
we have seen, these are unnecessary, because we can overwrite the old values at
every step.

The \inlineTFinmath{\Mvariable{InverseLifting}} module finds the steps of the
inverse wavelet transform given the forward steps.  We do not solve any
equations, but instead use {\itshape pattern matching} and {\itshape replacement}
[16].  The module first reverses the order of the steps and converts them to
equations, dropping the lazy steps.  This is done because it is syntactically
more difficult to carry out replacements on rules.  It works by recognising
typical intermediate steps and typical scaling steps, and replacing them with
their inverse.  The final operation is to replace steps of the form
\inlineTFinmath{{s_{l +1}}\rightarrow {s_{l }}} with the equivalent step
\inlineTFinmath{{s_{l }}\rightarrow {s_{l -1}}}, for the sake of form and
programming.  Note that the replacement is applied to all the steps, although it
will only be needed for the last two (the inverse scaling steps).  This is not a
serious problem, since even for the longest practical filters the number of
lifting steps is relatively small.

\Subsection*{4.7. ToMathematica module}

Once the lifting steps have been found, it is helpful to be able to test them by
carrying out wavelet transforms as required.  It is a relatively straightforward
matter to convert to them into {\itshape Mathematica} form.  The first is simply
a replacement of the symbols used in the general notation to that used by
{\itshape Mathematica}.  In particular, there is no need to refer explicitly to
list positions, since we can carry out operation on all list elements in
parallel, and shifts are indicated by the \inlineTFinmath{\Mvariable{RotateLeft}}
and \inlineTFinmath{\Mvariable{RotateRight}} commands.  The user can then copy
the output from this command and create a new module from it to carry out one
stage of the algorithm.  The wavelet transform can be carried out on a list by
using \inlineTFinmath{\Mvariable{NestList}} combined with the resulting module.

When the replacements have been made, we only need to add in the trivial steps
that occur in the forward or inverse transform.  Specifically, if we are carrying
out the forward transform, we add the preliminary lazy steps, and if we are
carrying out the inverse transform, we must include a final joining step.

The syntax to convert the inverse to {\itshape Mathematica} form is
\inlineTFinmath{\Muserfunction{ToMathematica}[\Mvariable{expr},\Mvariable{Inverse}\rightarrow
\Mvariable{True}]}, and where there is no second argument, the default conversion
setting is to find the forward transform.


\Section*{5. Examples}

In this section the use of the program is demonstrated with examples.

\Subsection*{5.1. D4}

Consider the factorisation of D4, the basis given in the example of \S{}2.5.  We
create the list of four nonzero coefficients, needed for polynomial reduction
procedures, as:

\dispTFinmath{H :=\Mfunction{Table}[{h_i},\{i,0,3\}]}

\noindent The filters are

\dispTFinmath{h[\Mvariable{z\_}]={h_0}+\frac{{h_1}}{z}+\frac{{h_2}}{{z^2}}+\frac{{h_3}}{{z^3}};}

\dispTFinmath{g[\Mvariable{z\_}]=\Mfunction{Collect}[{z^{-1}}  h[-{z^{-1}}],z]}
\dispTFoutmath{-{h_3}  {z^2}+{h_2}  z-{h_1}+\frac{{h_0}}{z}}

\noindent and so the polyphase matrix is

\dispTFinmath{P[\Mvariable{z\_}]=\Muserfunction{Polyphase}[z]}
\dispTFoutmath{\Bigg(\MathBegin{MathArray}[c]{cc}
	{h_0}+\frac{{h_2}}{z}&-{h_1}-z  {h_3} \\
	{h_1}+\frac{{h_3}}{z}&{h_0}+z  {h_2} 
  \MathEnd{MathArray}\Bigg)}

\noindent which can be compared with equations (5) and (6).  We run the Euclidean algorithm
on the low-pass polyphase components -- the entries of the first column of
\inlineTFinmath{P[z]}.  Finding all factorisations gives;

\dispTFinmath{\MathBegin{MathArray}{l}
(\Mvariable{AllFacts}=\Mvariable{EuclideanFactorisation}[  \\
\noalign{\vspace{0.5ex}}
\hspace{5.em} \{P[z]\LeftDoubleBracket 1,1\RightDoubleBracket ,P[z]\LeftDoubleBracket 2,1\RightDoubleBracket \},\Mvariable{EliminationBranch}\rightarrow \Mvariable{All},   \\
\noalign{\vspace{0.5ex}}
\hspace{5.em} \Muserfunction{PolynomialReduction}[\#,\Muserfunction{DaubechiesZeros}[H ],H ]\&])//   \\
\noalign{\vspace{0.5ex}}
\hspace{2.em} \Mvariable{ColumnForm}//\Mfunction{Simplify}\\
\MathEnd{MathArray}}
\dispTFoutmath{\MathBegin{MathArray}[c]{l}
	\big\{\big\{1+\frac{1}{2  {\sqrt{2}}  {h_3}},\frac{z-4  {\sqrt{2}}  (z+1)  {h_3}-1}{4  z}\big\},-\frac{1}{4  {h_3}}\big\} \\
	\big\{\big\{\frac{{\sqrt{2}}-4  {h_3}}{2  {\sqrt{2}}-4  {h_3}},\frac{1}{4}  (9  z-1)+{\sqrt{2}}  (1-3  z)  {h_3}\big\},\frac{1}{2  {\sqrt{2}}  z-4  z  {h_3}}\big\} \\
	\big\{\big\{\frac{-8  {\sqrt{2}}  {h_3}  z+5  z+4}{9  z-12  {\sqrt{2}}  z  {h_3}},\frac{3  z  \Big({\sqrt{2}}  (1-7  z)+4  (5  z-1)  {h_3}\Big)}{16  {h_3}}\big\},\frac{4  {h_3}}{3  {z^2}  \Big(4  {\sqrt{2}}  {h_3}-3\Big)}\big\} \\
	\big\{\big\{\frac{-4  z+8  {\sqrt{2}}  {h_3}+1}{4  {\sqrt{2}}  {h_3}+1},\frac{{\sqrt{2}}  (z+1)+4  (z+3)  {h_3}}{8  {z^2}  \Big({\sqrt{2}}-2  {h_3}\Big)}\big\},\frac{2  z  \Big({\sqrt{2}}-2  {h_3}\Big)}{4  {\sqrt{2}}  {h_3}+1}\big\} 
  \MathEnd{MathArray}}

\noindent where the first elements are the lists of quotients and the last elements are the
gcds.  Note that although these expressions are fairly complicated, only one of
the filter coefficients (\inlineTFinmath{{h_3}}) appears.  The number of
factorisations is in agreement with the argument in \S{}3.3, viz
\inlineTFinmath{4\times {3^{\LeftBracketingBar b\RightBracketingBar -1}}=4}. 
Note that although the gcds appear quite different in each case, they are all
monomials in {\itshape z}, and so are all the same up to an invertible factor. 
Each of the four factorisations above would give rise to a different
set of lifting steps, but all are implementations of the same transform.

Let us now construct the lifting implementation of the first factorisation.  We
find the polyphase matrix factorisation:

\dispTFinmath{\MathBegin{MathArray}{l}
\Muserfunction{PolyphaseFactorisation}[P[z],\Mvariable{AllFacts}\LeftDoubleBracket 1\RightDoubleBracket ,  \\
\noalign{\vspace{0.5ex}}
\hspace{1.em} \Muserfunction{PolynomialReduction}[\#,\Muserfunction{DaubechiesZeros}[H ],H ]\&]\\
\MathEnd{MathArray}}
\dispTFoutmath{\MathBegin{MathArray}{l}
\Bigg(\MathBegin{MathArray}[c]{cc}
	1&1+\frac{1}{2  {\sqrt{2}}  {h_3}} \\
	0&1 
  \MathEnd{MathArray}\Bigg)\cdot \Bigg(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	-{\sqrt{2}}  {h_3}+\frac{-{\sqrt{2}}  {h_3}-\frac{1}{4}}{z}+\frac{1}{4}&1 
  \MathEnd{MathArray}\Bigg)\cdot   \\
\noalign{\vspace{2.ex}}
\hspace{1.em} \Bigg(\MathBegin{MathArray}[c]{cc}
	1&z  \bigg(\frac{1}{2  {\sqrt{2}}  {h_3}}+\frac{1}{16  h_{3}^{2}}\bigg) \\
	0&1 
  \MathEnd{MathArray}\Bigg)\cdot \bigg(\MathBegin{MathArray}[c]{cc}
	-\frac{1}{4  {h_3}}&0 \\
	0&-4  {h_3} 
  \MathEnd{MathArray}\bigg)\\
\MathEnd{MathArray}}

To simplify the factorisation we substitute the exact value of \inlineTFinmath{{h_3}} [5]:

\dispTFinmath{\MathBegin{MathArray}{l}
\Mvariable{MatrixFactorisation}=  \\
\noalign{\vspace{1.03125ex}}
\hspace{1.em} \%/.{h_3}\rightarrow \frac{1-{\sqrt{3}}}{4  {\sqrt{2}}}//\Mfunction{Simplify}//\Mfunction{RootReduce}//\Mfunction{ToRadicals}\\
\MathEnd{MathArray}}
\dispTFoutmath{\Big(\MathBegin{MathArray}[c]{cc}
	1&-{\sqrt{3}} \\
	0&1 
  \MathEnd{MathArray}\Big)\cdot \Bigg(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	\frac{{\sqrt{3}}  z+{\sqrt{3}}-2}{4  z}&1 
  \MathEnd{MathArray}\Bigg)\cdot \big(\MathBegin{MathArray}[c]{cc}
	1&z \\
	0&1 
  \MathEnd{MathArray}\big)\cdot \Bigg(\MathBegin{MathArray}[c]{cc}
	{\sqrt{2+{\sqrt{3}}}}&0 \\
	0&{\sqrt{2-{\sqrt{3}}}} 
  \MathEnd{MathArray}\Bigg)}

\noindent and from this we get the lifting implementation:


\dispTFinmath{(\Mvariable{LiftingSteps}=\Muserfunction{MatrixFactorisation}//\Muserfunction{ToLifting})//\Mfunction{ColumnForm}}
\dispTFoutmath{\MathBegin{MathArray}[c]{l}
	{s_{l }}\leftarrow {x_{2  l }} \\
	{d_{l }}\leftarrow {x_{2  l +1}} \\
	{d_{l }}\leftarrow {d_{l }}-{\sqrt{3}}  {s_{l }} \\
	{s_{l }}\leftarrow \frac{{\sqrt{3}}  {d_{l }}}{4}+\bigg(-\frac{1}{2}+\frac{{\sqrt{3}}}{4}\bigg)  {d_{l +1}}+{s_{l }} \\
	{d_{l }}\leftarrow {d_{l }}+{s_{l -1}} \\
	{s_{l }}\leftarrow {\sqrt{2+{\sqrt{3}}}}  {s_{l }} \\
	{d_{l }}\leftarrow {\sqrt{2-{\sqrt{3}}}}  {d_{l }} 
  \MathEnd{MathArray}}

\Subsection*{5.2. Inverse D4 transform}

We find the inverse of the above lifting implementation of the D4 wavelet transform:

\dispTFinmath{\Muserfunction{LiftingSteps}//\Muserfunction{InverseLifting}//\Mfunction{ColumnForm}}
\dispTFoutmath{\MathBegin{MathArray}[c]{l}
	{d_{l }}\leftarrow \frac{{d_{l }}}{{\sqrt{2-{\sqrt{3}}}}} \\
	{s_{l }}\leftarrow \frac{{s_{l }}}{{\sqrt{2+{\sqrt{3}}}}} \\
	{d_{l }}\leftarrow {d_{l }}-{s_{l -1}} \\
	{s_{l }}\leftarrow -\frac{1}{4}  {\sqrt{3}}  {d_{l }}-\bigg(-\frac{1}{2}+\frac{{\sqrt{3}}}{4}\bigg)  {d_{l +1}}+{s_{l }} \\
	{d_{l }}\leftarrow {d_{l }}+{\sqrt{3}}  {s_{l }} \\
	{x_{2  l +1}}\leftarrow {d_{l }} \\
	{x_{2  l }}\leftarrow {s_{l }} 
  \MathEnd{MathArray}}

\noindent Observe that the inverse is just as simple as the forward transform.

\Subsection*{5.3. D10}

Computing the factorisation of D10 numerically clearly shows the benefit of using
this program.  With the D10 coefficients as

\dispTFinmath{\Mvariable{D10Coefficients}}
\dispTFoutmath{\MathBegin{MathArray}{l}
\{0.160102,0.603829,0.724309,0.138428,-0.242295,  \\
\noalign{\vspace{0.5ex}}
\hspace{1.em} -0.0322449,0.0775715,-0.00624149,-0.0125808,0.00333573\}\\
\MathEnd{MathArray}}

\noindent we again construct the polyphase filters and matrix:

\dispTFinmath{h[\Mvariable{z\_}]=\Mvariable{D10Coefficients}.\Mfunction{Table}[  {z^{-i}},\{i,0,9\}];}
\dispTFinmath{g[\Mvariable{z\_}]=\Mfunction{Collect}[{z^{-1}}  h[-{z^{-1}}],z];}
\dispTFinmath{P[\Mvariable{z\_}]=\Muserfunction{Polyphase}[z];}

\noindent Note that there are a large number of factorisations;

\dispTFinmath{\MathBegin{MathArray}{l}
(\Mvariable{AllFacts}=\Muserfunction{EuclideanFactorisation}[\{P[z]\LeftDoubleBracket 1,1\RightDoubleBracket ,P[z]\LeftDoubleBracket 2,1\RightDoubleBracket \},  \\
\noalign{\vspace{0.5ex}}
\hspace{4.em} \Mvariable{EliminationBranch}\rightarrow \Mvariable{All},\Mvariable{Chop}])//\Mfunction{Length}\\
\MathEnd{MathArray}}
\dispTFoutmath{108}

\noindent again in agreement with \S{}3.3 viz \inlineTFinmath{{{4.3}^{4-1}}}.  We examine
two of these, each with constant gcd.  The following factorisation would be
numerically unstable;

\dispTFinmath{\Mvariable{AllFacts}\LeftDoubleBracket 2\RightDoubleBracket }
\dispTFoutmath{\MathBegin{MathArray}{l}
\big\{\big\{-0.265145,-0.499843-\frac{0.878163}{z},  \\
\noalign{\vspace{1.1875ex}}
\hspace{2.em} -212910.-\frac{45.7871}{z},4.69682\times {{10}^{-6}}-\frac{1.00854\times {{10}^{-9}}}{z},   \\
\noalign{\vspace{1.35417ex}}
\hspace{2.em} -4.16681\times {{10}^{10}}-\frac{1.25669\times {{10}^{11}}}{z}\big\},-2.4687\times {{10}^{-6}}\big\}\\
\MathEnd{MathArray}}

\noindent whereas the following factorisation should be stable:


\dispTFinmath{\Mvariable{AllFacts}\LeftDoubleBracket 54\RightDoubleBracket }
\dispTFoutmath{\MathBegin{MathArray}{l}
\big\{\big\{3.77152,0.0698843  z-0.247729,\frac{3.03369}{{z^2}}-\frac{7.59758}{z},  \\
\noalign{\vspace{1.14583ex}}
\hspace{2.em} 0.0157993  {z^3}-0.0503964  {z^2},\frac{0.172573}{{z^4}}-\frac{1.10315}{{z^3}}\big\},0.347389\big\}\\
\MathEnd{MathArray}}

In general, it is preferable to have as many coefficients as possible close to
unity.  It is clear that in this case there are several factorisations that do
not satisfy this criterion; this shows the advantage of non-unique factorisation.

\Subsection*{5.4. Cohen-Daubechies-Feauveau {\upshape (4,2)} filter}

We now demonstrate that the program works for non-orthogonal filters.  The
Cohen-Daubechies-Feauveau (4,2) (CDF4,2) filters are given by

\dispTFinmath{h[\Mvariable{z\_}]=\frac{{\sqrt{2}}}{32}(40+5(z+{z^{-1}})-12({z^2}+{z^{-2}})+3({z^3}+{z^{-3}}));}
\dispTFinmath{g[\Mvariable{z\_}]=\frac{{\sqrt{2}}}{16}({z^{-3}}-4{z^{-2}}+6{z^{-1}}-4+z);}

The polyphase matrix is guaranteed to have monomial determinant, in fact we
require it to be unity [2].  This is achieved by dividing the entries of the
second column by the determinant.  Substitution of the appropriate coefficients
will verify that the D4 and D10 polyphase matrices had determinant 1.  For the
CDF (4,2) filter, the determinant is --1, so we reconstruct the polyphase matrix
as

\dispTFinmath{P[\Mvariable{z\_}]=\Muserfunction{Polyphase}[z]}
\dispTFoutmath{\Bigg(\MathBegin{MathArray}[c]{cc}
	-\frac{3  z}{4  {\sqrt{2}}}+\frac{5}{2  {\sqrt{2}}}-\frac{3}{4  {\sqrt{2}}  z}&-\frac{1}{2  {\sqrt{2}}}-\frac{1}{2  {\sqrt{2}}  z} \\
	\frac{3  {z^2}}{16  {\sqrt{2}}}+\frac{5  z}{16  {\sqrt{2}}}+\frac{5}{16  {\sqrt{2}}}+\frac{3}{16  {\sqrt{2}}  z}&\frac{z}{8  {\sqrt{2}}}+\frac{3}{4  {\sqrt{2}}}+\frac{1}{8  {\sqrt{2}}  z} 
  \MathEnd{MathArray}\Bigg)}

We note that in this case \inlineTFinmath{{h_o}} has degree greater than that of
\inlineTFinmath{{h_e}}.  In this case the first quotient is zero, [2]; this is
allowed for in the program.

\dispTFinmath{\MathBegin{MathArray}{l}
\Muserfunction{EuclideanFactorisation}[\{P[z]\LeftDoubleBracket 1,1\RightDoubleBracket ,P[z]\LeftDoubleBracket 2,1\RightDoubleBracket \},  \\
\noalign{\vspace{0.5ex}}
\hspace{1.em} \Mvariable{EliminationBranch}\rightarrow \{\Mvariable{EliminateHigh},\Mvariable{EliminateEndsMatchLow},   \\
\noalign{\vspace{0.5ex}}
\hspace{3.em} \Mvariable{EliminateEndsMatchHigh},\Mvariable{EliminateHigh}\}]\\
\MathEnd{MathArray}}
\dispTFoutmath{\big\{\big\{0,-\frac{z}{4}-\frac{1}{4},-1-\frac{1}{z},\frac{3  z}{16}+\frac{3}{16}\big\},2  {\sqrt{2}}\big\}}

\noindent This gives rise to the polyphase matrix factorisation:

\dispTFinmath{\Muserfunction{PolyphaseFactorisation}[P[z],\%]}
\dispTFoutmath{\bigg(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	-\frac{z}{4}-\frac{1}{4}&1 
  \MathEnd{MathArray}\bigg)\cdot \bigg(\MathBegin{MathArray}[c]{cc}
	1&-1-\frac{1}{z} \\
	0&1 
  \MathEnd{MathArray}\bigg)\cdot \bigg(\MathBegin{MathArray}[c]{cc}
	1&0 \\
	\frac{3  z}{16}+\frac{3}{16}&1 
  \MathEnd{MathArray}\bigg)\cdot \Bigg(\MathBegin{MathArray}[c]{cc}
	2  {\sqrt{2}}&0 \\
	0&\frac{1}{2  {\sqrt{2}}} 
  \MathEnd{MathArray}\Bigg)}

We find the total number of factorisations:

\dispTFinmath{\MathBegin{MathArray}{l}
\Muserfunction{EuclideanFactorisation}[\{P[z]\LeftDoubleBracket 1,1\RightDoubleBracket ,P[z]\LeftDoubleBracket 2,1\RightDoubleBracket \}//\Mfunction{N},  \\
\noalign{\vspace{0.5ex}}
\hspace{2.em} \Mvariable{EliminationBranch}\rightarrow \Mvariable{All},\Mvariable{Chop}]//\Mfunction{Length}\\
\MathEnd{MathArray}}
\dispTFoutmath{9}

\noindent Given that we have effectively reversed the order of the starting Laurent
polynomials, this agrees with the analysis of \S{}3.3, viz
\inlineTFinmath{{3^2}=9}.

\Section*{6. Conclusion}

The program finds all factorisations of two Laurent polynomials using the
Euclidean algorithm with degree 1 quotients, and can display the matrix
factorisation of a polyphase matrix.  Conversion of this factorisation into a
sequence of lifting steps was automated, as was conversion of the lifting steps
into {\itshape Mathematica} input form.  The inverse of a given wavelet transform
can be found either in general form or in {\itshape Mathematica} form.

The ability to provide exact factorisations for bases such as D{\itshape N} was
enabled through the use of polynomial reduction with Gr\ODoubleDot{}bner bases. 
This uses the relations between the filter coefficients, and, as a result, we can
obtain an exact factorisation for a basis such as D8 in terms of only one of the
filter coefficients, even though the coefficients themselves cannot be calculated
exactly.

Future research efforts in this area could investigate the use of quotients whose
degree is greater than one.  This would preclude in-place implementation, but may
lead to factorisations which are favourable in other ways.  As noted previously,
higher degree quotients would be necessary to factorise two Laurent polynomials
whose degrees differed by more than 1.  Integer to integer transforms could also
be incorporated into this new implementation of lifting [14].

Choosing the optimum factorisation for a given purpose was not investigated in
detail, and the question of what makes a 'good' factorisation is very much an
open one.  For example, it is preferable to have as many coefficients as possible
of the order of unity, but there are no well-defined criteria for deciding
whether the given coefficients are too big or too small.  This issue may best be
investigated by those applying this method to a particular task.

\Section*{References}

 [1] M.J. Maslen, Factoring Wavelet Transforms into Lifting Steps,
 (University of Western Australia, 1997). URL: \\
 {\verb$http://www.physics.uwa.edu.au/~paul/publications.html$}
 
\noindent [2] I. Daubechies, W. Sweldens, J. Fourier Anal. Appl. 4 (1998) 247. URL: \\
 {\tt  http://cm.bell-labs.com/who/wim/papers/papers.html\#{}factor}
 
\noindent [3] J.N. Bradley, C.M. Brislawn, T. Hopper, Visual Info. Process. II, SPIE 1961 (1993).
 
\noindent [4] P.C. Abbott, Introduction to Wavelets, (University of Western Australia, 1998). URL:\\
 {\tt  http://www.physics.uwa.edu.au/Physics/Courses/Honours/-\\
 Modules/wavelets.html}
 
\noindent [5] I. Daubechies Ten Lectures on Wavelets (SIAM, 1992).
 
\noindent [6] T.H. Koornwinder, Wavelets: An Elementary Treatment of Theory and Applications  (World Scientific, 1993).
 
\noindent [7] D.E. Newland Introduction to Random Vibrations, Spectral and Wavelet Analysis, (Longman, 1993).
 
\noindent [8] G. Strang, SIAM Review 31 (1989) 614.
 
\noindent [9] J.C. van den Berg, Wavelets in Physics (Cambridge University Press, 1998).
 
\noindent [10] W. Sweldens, Wavelets and the Lifting Scheme: A 5 Minute Tour. URL:\\
 {\tt  http://cm.bell-labs.com/who/wim/papers/papers.html\#{}iciam95}
 
\noindent [11] W. Sweldens, The Lifting Scheme: A Custom-Design Construction of Biorthogonal Wavelets (1995). URL:\\
 {\tt  http://cm.bell-labs.com/who/wim/papers/papers.html\#{}lift1}
 
\noindent [12] W. Sweldens, The Lifting Scheme: A New Philosophy in Biorthogonal Wavelet Construction. URL:\\
 {\tt  http://cm.bell-labs.com/who/wim/papers/papers.html\#{}spie95}
 
\noindent [13] W. Sweldens, P. Schr\ODoubleDot{}der, Building Your Own Wavelets at Home. URL:\\
 {\tt  http://cm.bell-labs.com/who/wim/papers/papers.html\#{}athome}
 
\noindent [14] A.R. Calderbank, I. Daubechies, W. Sweldens, B-L. Yeo, Appl. Comp. Harm. Anal., in press. URL:\\
 {\tt  http://cm.bell-labs.com/who/wim/papers/index.html\#{}integer}
 
\noindent [15] I. Daubechies, Comm. Pure Appl. Math. 41 (1988) 909
 
\noindent [16] S. Wolfram, The {\itshape Mathematica} Book, 3rd ed. (Wolfram Media/Cambridge University Press, 1996).

\end{document}
