

                          (Public Domain)

             Signal Processing Packages and Notebooks 2.0
                               for
                  Mathematica Version 1.2 and higher

                                by

              Brian Evans, James McClellan, Kevin West,
                  Wallace McClure, and Lina Karam

               Digital Signal Processing Laboratory
                 School of Electrical Engineering
                 Georgia Institute of Technology
                     Atlanta, GA  30332-0250

                      evans@eedsp.gatech.edu

--> Introduction

	This is an unsupported release  of  Mathematica  code  for symbolic
signal processing copyrighted by The Georgia Tech Research Foundation and
Wolfram  Research  Inc.   Once  installed (see below),  this  collection of
Mathematica packages can be loaded by any user.   Bundled with the packages
are   seven   notebooks  (SignalProcessingExamples,   PiecewiseConvolution,
zTransform,   LaPlaceTest,   AnalogFilters,   SignalProcessingUsage,    and
EducationalTool) that  demonstrate  what  one  can  do with these packages.
See also  "Symbolic Transforms with Applications to Signal Processing" pub-
lished in the Dec. 1990 issue of the Mathematica Journal (vol. 1, issue 2).
A complete set of references is given at the end.

--> Installation

     When you uncompress and untar "SigProc2.0.tar.Z", you will create a
hierarchy of directories under the directory that  you  are currently in.
The signal processing packages will be under the sub-directory Packages,
and the signal processing notebooks will be under the sub-directory
Notebooks. In order to install them in the standard (system) place, move
the contents of Packages/SignalProcessing to

	/NextLibrary/Mathematica/Packages	on a NeXT
	/usr/local/math/Packages		on a Sun
	d:\math\packages			on an IBM PC

--> Macintosh Users

	Please make sure that the start up procedure includes the loading
of the Elliptic functions, symbolic integration, and Series abilities.

--> Getting started

	The  Mathematica  file  "SignalProcessing.m"  loads  in  all  the
necessary files. Load it in by  <<SignalProcessing/SignalProcessing.m  or
alternatively by  Needs["SignalProcessing`SignalProcessing`"].  Note that
one  Support::changes  warning should appear, since we have changed which
supporting packages are loaded.
	The one-dimensional/two-dimensional  signal  analyzing  functions
DSPAnalyze  and  ASPAnalyze  are  good  examples of the code's ability to
switch between  symbolic,  numeric,  and  graphical  representations (the
hooks being provided by Mathematica). The four symbolic transform objects
ZTransform,  InvZTransform,  InvLaPlace,  and  LaPlace  demonstrate their
ability to  handle  multidimensional transforms and the region of conver-
gence.  (The other transform objects are  CTFTransform,  InvCTFTransform,
DFTransform, InvDTFTransform, DTFTransform, and InvDTFTransform.)  All of
the transforms can completely justify  their  answers  by displaying each
step of the transformation process (use the option Dialogue -> True).
	Besides the examples in the ICASSP '90 paper, [1] try

  1. ASPAnalyze[ t Exp [ - 4 t / 5 ] Cos [ 3 Pi t / 4 ] CStep[t], t ]
  2. DSPAnalyze[ n (4/5)^n Step[n], n ]
  3. DSPAnalyze[ (4/5)^n1 Impulse[n1 - n2] Step[n1,n2], {n1,n2} ]
  4. ASPAnalyze[ Exp[- 4 t1 / 50] Delta[t1 - t2] CStep[t1,t2], {t1,t2} ]
  5. DSPAnalyze[ (1/2)^n1 (2/5)^n2 Multinomial[n1,n2] Step[n1,n2], {n1,n2} ]

Note that the  analog analyzer (ASPAnalyze) only displays the interesting
section of magnitude and phase plots (part encompassing the breakpoints).
Also, note that two-dimensional  pole-zero  plots are actually root maps,
unless the  two-dimensional  transform  is  separable (then two pole-zero
plots will be displayed).  Note that

  a.  Delta is the Dirac delta function,
  b.  Impulse is the unit Kronecker delta function, and
  c.  Mathematica's Laplace transform is Laplace whereas mine is LaPlace.

The paper  entitled  "Symbolic  Transforms  with  Applications  to Signal
Processing" [2] gives Mathematica's output for four of the examples above.

---> Transform Capabilities

     Fourier, Laplace and z-transforms are useful for analyzing linear
systems and signal processing operations.  We have implemented packages
for all the transforms commonly used in signal processing:

     (discrete signals)    z-transform
                           discrete-time Fourier transform
                           discrete Fourier transform

     (continuous signals)  Laplace transform
                           Fourier transform

This implementation of the transforms is very general in that multi-
dimensional versions.  The packages also track properties of the trans-
forms, so it is also possible to deduce the stability or instability of
a linear system.  Using the transforms, the packages can solve
linear constant-coefficient difference and differential equations
for right-sided (defined for t > t0) and left-sided (defined for t < t0)
functions.

---> Knowledge Representation for Signals and Systems

     We have added many functions (signal primitives) and operators
(system primitives) that are common in signal processing and linear
systems theory but missing in Mathematica:

     (basic signals)    Kronecker impulse, Dirac delta, sinc,
                        continuous and discrete step functions,
                        continuous and discrete pulse functions,
                        aliased sinc, filter representations

     (basic operators)  aliasing, convolution, DFT, DTFT, backward
                        difference, downsampling, Fourier transform,
                        interleave samples, Laplace transform,
                        periodic, reverse, scale axis, shift,
			summation, upsampling

The transform packages support all of these new objects.

---> Other Abilities of These Packages

     (continuous signals)  analog 1-D filter design
			   1-D piecewise convolution
			   plots of 1-D and 2-D signals

     (discrete signals)    1-D convolution (in version 2.1)
                           plots of 1-D and 2-D sequences

     (general plotting)    pole-zero diagrams
			   root loci
			   frequency responses

---> Signal Processing Notebooks

     In order to extend the use of these extensions in the educational
environment, we have written several notebooks on subjects that are
studied in transform theory and signal processing courses:

     (tutorial notebooks)   z-transform
                            piecewise convolution
                            analog filter design

     (directed help/guide)  signal processing examples
			    Mathematica as an educational tool
                            Laplace transform

     (reference guide)      signal processing usage information

In the tutorial notebooks, we give numerous examples such as might be
found in a standard textbook and solve problems that are at the level
of elementary homework problems.  We use the notebook's animation
ability whenever possible.  In the analog filter design notebook, for
example, we illustrate the dependence of the filter's magnitude
response on the filter order (and elsewhere on the ripple
control parameter) as an animation sequence.


--> Hierarchical Relationship Between Files

	The Mathematica  packages  are grouped		   OORBP
into  four  categories:   supporting routines,		 /	\
digital  signal  processing packages (DSPRBP),	   DSPRBP        ASPRBP
analog  signal  processing  packages (ASPRBP),		 \	/
and object-oriented extensions (OORBP).			  SUPPORT
	The supporting routines are maintained
in six files (as shown  on  the right).  These
are kept in the Mathematica  package directory                TransSupport.m  S
SignalProcessing/Support.  "SupCode.m" defines Convolution.m       |          U
general  purpose  Mathematica   routines  like     |          -----+-----     P
Second,  SeriesQ,  ToList,  GenerateCode,  and	   |	     |	         |    P
PrintIt (which sends  Mathematica  output to a	   |	     |	       ROC.m  O
a PostScript printer).    The file "SigProc.m"	   |	     |	         |    R
establish the representation  of common signal     |   FilterSupport.m   |    T
processing operators  (like  Upsample,  Shift,	   |	    /	         |
and Convolve),  as  well as common signal pro-	   SigProc.m	         |
cessing functions  (like Step, CStep, Impulse,          |	         | 
Delta, and Sinc). "ROC.m" defins routines that	  	 -----+----------
extract  and  combine  regions  of convergence	    	      |
(ROC's),  where an ROC is one open interval of	 	   SupCode.m
points.   The file  "FilterSupport.m"  defines
filter objects like IIR, FIR, and IIRFunction,
as well as filter types like Butterworth and Elliptic.  The remaining file
is "TransSupport.m" which provides a general set of routines to aid in the
writing of transformation rule bases, extends Mathematica's graphics capa-
bilities  (to include magnitude/phase responses, pole-zero diagrams, root-
loci),  and  defines  tools  for stability analysis LSI systems.  The file
"Convolution.m" defines one-dimensional  piecewise discrete and continuous
convolution.
	The digital signal  processing  routines  are  maintained  in  the
hierarchy shown on the next page. These files are maintained in the Mathe-
matica package  directory  under  SignalProcessing/Digital.  Most files in
the DSPRBP rely  on  the  forward  and inverse z-transform capabilities in
"ZTransform.m" and "InvZTransform.m", respectively, which  in  turn depend
on the file "ZSupport.m".   "ZSupport.m" defines  the  z-transform  object,
supporting routines for  rule  writing, and  checking for valid transforms.
The files "DTFT.m" and "DFT.m" contain  the  rules  for  the discrete-time
Fourier transform and  the  discrete Fourier transform, respectively.  The
file  "DSPAnalyzer.m"  provides  a  powerful  analyzer  of  one-  and two-
dimensional signals generated  by  linear,  shift-invariant systems.  This
routine graphs a signal  in  the  time-domain, prints out its z-transform,
indicates conditions for the sequence to be stable, displays its pole-zero
diagram, gives its DTFT, and plots its magnitude and phase responses.  The
package "ZSolve.m" provides  the  ability  to solve linear, constant coef-
ficient difference equations.

					   |
			 ----------+-------+---------
			|	   |		     |
	DSPAnalyze.m   DFT.m	   |		     |			 D
	    |		|	   |	             |			 I
	     -----------+	   |		     |			 G
			|	   |		     |			 I
		      DTFT.m    ZSolve.m        Correlation.m		 T
			|	   |		     |	    		 A
	     -----------+	 --+-----------------+------		 L
	    |		|	|			    |
	    |	      ZTransform.m		     InvZTransform.m
	    |			|			    |
	    |		         ---------------------------
	    |				       |
	DSupport.m			   ZSupport.m
	    |				       |
	     ----------------------------------
			      |

	The analog signal processing  packages  are  arranged in a similar
manner, as shown below. "LaPlace.m" and "InvLaPlace.m" provide the forward
and inverse Laplace transforms, which  are  able  to transform expressions
involving signal processing operators and functions. Note that the Laplace
transform extensions released by Wolfram Research only do one-dimensional,
one-sided transforms and  are  biased  toward  higher  order  mathematical
functions (which are common in physics).   Ours work for multidimensional,


		     ASPAnalyze.m
		    |	         |	
		    |	     Fourier.m	    LSolve.m			 A
		    |	         |	       |			 N
		    |        ----+-------------+----			 A
		    |	    |			    |			 L
		    LaPlace.m			InvLaPlace.m		 O
			|			    |			 G
			 --------+------------------
				 |
	FilterDesign.m	      LSupport.m
	      |			 |

multi-sided  funnctions  and,  therefore, track the region of convergence.
ASPAnalyze provides the same capabilities as does the DSPAnalyze.
	The top layer  is  not  yet  included  with  the signal processing
packages.   It  implements  properties  of  signals and systems, including
routines that reason about them.  Because this code implements some of the
work of Gary Kopec, Cory Myers, and Michele Covell,  we  originally called
it  the  object-oriented  signal  processing packages, which is a misnomer
because Mathematica is object-oriented.   Anyway, the files "Signal.m" and
"System.m" provide  signal  and  system  definitions, respectively.  Since
Mathematica is formula-based,  it can compute signal values in a point-by-
point fashion. These new packages add array-based, stream-based, and state
machine-based signals.  This will  eventually  allow  simulation of a wide
variety of signals and systems.

--> Alteration of Standard Mathematica Routines

1.  the absolute value of a positive number is that number,
2.  the absolute value of a negative number is that number negated,
3.  the first argument to ClearAttributes and SetAttributes is held,
4.  the determinant Det of a number is that number, and
5.  the dot product (Dot) of two numbers is their product.

--> Summary of C utilities

When one runs Mathematica, one keeps multiple windows open.
I keep one window open for Mathematica  (the Untitled window)
and one or more windows to other machines.  On the Next machine,
two files will be created when you save an entire window -- a
``.mb'' and a ``.ma'' file.  On a Sun workstation, one must use
Mathematica commands like Save or Display to write information to
a file.  In either case, an output file can contain a mixture
of symbolic, numeric, and graphics information.

These Unix utilities will allow you to extract desired
information from an output file:

Command		 	Argument(s)		 	Function	 
		 				 			 
   getplot 	plot-number file 	extracts plot-number from the file  
   rmecho 	file		 	removes all of the echoed expressions  
   rmgraphics   file		 	strips all graphics from the file  
   psfix 	file		 	standardizes Mathematica postscript  
   plotinfo 	file		 	number of and titles of plots  
   charcount 	string file1 file2     	counts occurrences of characters
					in string  which occur in each file
   makedoc 	 			extracts usage information from all  
		 			Mathematica files & puts in LaTeX form  
   makenotebook   		 	As makedoc but summarizes usage
					information in notebook form  
		 				 
For example, in order to print plot 1 from ``file.ma'' in Unix, use

   getplot 1 file.math | psfix | lpr -Pnec496b  

You can save one graphics object from within    Mathematica  using

   Display["filename", graphics].
   
You can then send the plot to a printer of your choice from Unix with

   psfix filename | lpr printer  

In an Unix environment, THE EASIEST WAY to print a graphics object
from within Mathematica is 

   PrintIt[graphics].
   
The plot will be sent to default printer on your machine, or

   PrintIt[graphics, printer]
   
where printer is a string.  Note that PrintIt is defined in the file
``SupCode.m''.  To check for balance parenthesis, brackets, and braces
in one or more files, use

   charcount -b file1 file2   

--> Disclaimer and Future Releases

	This software is the property of Wolfram Research, Inc.,  and the
Georgia Tech Research Corporation.  I can  send  the  software  licensing
agreement to you.   I would, however, like to know if you find bugs in it.
I have stopped sending new releases since I  have  posted updated code in
an anonymous ftp location and since Wolfram Research Inc. is distributing
the code (at the cost of the distribution medium plus shipping/handling).

Brian L. Evans and James McClellan
Georgia Tech, School of Electrical Engineering, Atlanta, GA  30332-0250
USENET:   ...!{allegra,hplabs,ulysses}!gatech!eedsp!evans
INTERNET: evans@eedsp.gatech.edu

--> Suggestion

	Please, please, use lower  case  one-letter  symbols as variables
and do not  assign values to them.  This includes variables like n, t, x,
and y, as well as t1, t2, etc.   Use  one-letter  upper case variables to
represent constants (A, G,...), although Mathematica reserves I and N and
we reserve L and Z.

--> Documentation

     Most of the documentation is in notebook format.  Since most users
do not have access to the notebook interface, I have also include two
LaTeX files:  "usage.tex" (reference quide) and "usersguide.tex".  Another
option is to find a Macintosh computer and acquire MathReader (from the
anonymous ftp sub-directory) which is a public domain notebook reader.
MathReader will at least allow you to peruse notebooks but you will not
be able to evalute any code fragments.

--> References on the Signal Processing Packages

1.  Evans, Brian, James McClellan, and Wallace McClure. "Symbolic Trans-
    forms Using DSP Knowledge Bases", Proc. of the 1990 IEEE Inter. Conf.
    on Acoustics, Speech, and Signal Processing. pp. 1775-1778.

2.  Evans, Brian, James McClellan, and Wallace McClure.  "Symbolic Trans-
    forms with Applications to Signal Processing".   Mathematica Journal.
    vol. 1, issue #2.  Dec., 1990.  pp 70-80.

3.  Evans, Brian, and James McClellan. "Transforms for Signal Processing".
    1991 Mathematica Conference. Jan., 1991.

--> References on the Signal Processing Packages and Notebooks

4.  Evans, Brian,  James McClellan,  and  Kevin West.  "Mathematica as an
    Educational  Tool  for  Signal  Processing".  Proc. IEEE Southeastern
    Conference (Southeastcon).  April, 1991.  pp. 1162-1166.

5.  Evans, Brian, and James McClellan.  "Symbolic Analysis of Signals and
    Systems", ch. 3 of Symbolic and Knowledge-Based Signal Processing ed.
    by Alan Oppenheim and Hamid Nawab.   Prentice  Hall, Englewood Cliffs
    (NJ), May, 1992.

--> References on Transforms

6.  Clements, Mark, and Jerrold Pease. 1989.  "On Causal Linear Phase IIR
    Digital Filters,"  IEEE Transactions on Acoustics, Speech, and Signal
    Processing, vol. ASSP-37, issue #4, pp. 479-484.

7.  Churchill, Ruel. 1958. Operational Mathematics. McGraw-Hill, New York.

8.  Dudgeon, Dan, and Russel Mersereau.  1984.  Multidimensional  Digital
    Signal Processing. Prentice Hall, Englewood Cliffs (NJ).

9.  Muth, Eginhard.  1978.  Transform  Methods.  Prentice Hall, Englewood
    Cliffs (NJ).

10. Oberhettinger, Fritz, and Larry Badii. 1973. Tables of Laplace Trans-
    forms. Springer-Verlag, New York.

11. Oppenheim, Alan and Alan Willsky. 1983. Signals and Systems. Prentice
    Hall, Englewood Cliffs (NJ).

12. Oppenheim, Alan, and Ronald Schafer. 1989.  Discrete-Time Signal Pro-
    cessing. Prentice Hall, Englewood Cliffs (NJ).

--> References on Symbolic Signal Processing

13. Covell, Michele. 1989. An Algorithm Design Environment for Signal Pro-
    cessing.  Ph.D. Thesis and RLE Tech. Rep. #549.  MIT, Cambridge (MA).

14. Kopec, Gary. 1980. "The Representation  of  Discrete-Time Signals and
    Systems in Programs."  Ph.D. Thesis. MIT, Cambridge (MA).

15. Kopec, Gary. 1985. "The  Signal  Representation  Language  SRL." IEEE
    Trans. on Acoustics, Speech, and Signal Processing, vol. ASSP-33,
    issue #4, pp. 921-932.

16. Myers, Cory S.  1986.  "Signal Representation for Symbolic and Numeric
    Processing"  Ph.D. Thesis and RLE Tech. Rep. #521. MIT, Cambridge, MA.

