%%====================================
%% This is pst-sigsys documentation.
%% Farshid Delgosha
%% 04/01/2009
%%====================================

\documentclass[10pt]{article}

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[cmex10]{amsmath}
\usepackage{amssymb}
\usepackage{array}
\usepackage[bf,labelsep=period]{caption}
\usepackage[margin=1in,dvips]{geometry}
\usepackage{xspace}
\usepackage{subfig}
\usepackage{enumitem}
\usepackage{url}
\usepackage[table]{xcolor}
\usepackage{multido}
\usepackage{xkeyval}
\usepackage[pstadd]{pst-sigsys}
\usepackage{pst-plot}
\usepackage{pstricks-add}
\usepackage{multicol}
\usepackage{showexpl}
\lstset{explpreset={numbers=left,numberstyle=\tiny,numbersep=.5em},width=7cm,%
basicstyle=\ttfamily\small,rframe=,frame=single,backgroundcolor=\color{orange!30}}
\definecolor{BrickRed}{RGB}{233,49,16}
\usepackage{hyperref}
\hypersetup{colorlinks,backref,pagebackref,breaklinks,linkcolor=BrickRed,dvips,%
bookmarksopen=true,bookmarksopenlevel=2,pdfpagelayout=SinglePage,pdfview=Fit,%
pdftitle={The pst-sigsys Package},pdfauthor={Farshid Delgosha}}



\makeatletter
%=== some settings =================================================
\setlength{\parskip}{.5\baselineskip}
\def\tableofcontents{\@starttoc{toc}}
%=== end some settings =============================================



%=== new macros ====================================================
\def\package{\texttt{pst-sigsys}\xspace}
\def\CMD#1{{\ttfamily\textbackslash #1}}
\def\rmit#1{\textrm{\textit{#1}}}
\def\keys{[\rmit{keys}]}
%
\newsavebox{\syntaxbox}
\newenvironment{syntax}{%
\begin{lrbox}{\syntaxbox}%
\begin{minipage}{\textwidth}%
}
{
\end{minipage}%
\end{lrbox}%
\par\vspace{.5\baselineskip}%
\noindent\fbox{\usebox{\syntaxbox}}%
\vspace{.5\baselineskip}%
\par}
%
\newenvironment{keytable}[1]{
\rowcolors{1}{}{orange!30}
\begin{tabular}{>{\ttfamily}l  >{\itshape}c  c  p{#1}}
\hline
\rmit{Key}  &  \rmit{Value}  &  \rmit{Default}  &  \rmit{Description} \\
\hline
}
{\hline
\end{tabular}
\rowcolors{1}{}{}
}
%
\def\@choice{}
\newif\if@lineA
\newif\if@lineB
%
\define@choicekey*{xdashline}{lines}[\val\@choice]{t,b,tb}{%
  \ifcase\@choice\relax
     \@lineAtrue\@lineBfalse
  \or
     \@lineAfalse\@lineBtrue
  \else
     \@lineAtrue\@lineBtrue
  \fi
}
\def\xdashline{\@ifnextchar[{\xdashline@i}{\xdashline@i[lines=b]}}
\def\xdashline@i[#1](#2,#3,#4)#5#6#7{{%
\setkeys{xdashline}{#1}%
\psset{linecolor=#6}%
\if@lineA%
\rput(#2,#3){\psline[linestyle=dashed,linewidth=.5pt](-#5,0)}%
\fi%
\if@lineB%
\rput(#2,#4){\psline[linestyle=dashed,linewidth=.5pt](-#5,0)}%
\fi%
\rput(#2,#3){\psline[arrows=|<-](0,.5)}%
\rput(#2,#4){\psline[arrows=|<-](0,-.5)}%
\rput(#2,#3){\rput[l]{90}(0,.65){\textcolor{#6}{\texttt{#7}}}}%
}\ignorespaces}
%
%
\define@choicekey*{ydashline}{lines}[\val\@choice]{l,r,lr}{%
  \ifcase\@choice\relax
     \@lineAtrue\@lineBfalse
  \or
     \@lineAfalse\@lineBtrue
  \else
     \@lineAtrue\@lineBtrue
  \fi
}
\def\ydashline{\@ifnextchar[{\ydashline@i}{\ydashline@i[lines=r]}}
\def\ydashline@i[#1](#2,#3,#4)#5#6#7{{%
\setkeys{ydashline}{#1}%
\psset{linecolor=#6}%
\if@lineA%
\rput(#2,#4){\psline[linestyle=dashed,linewidth=.5pt](0,-#5)}%
\fi%
\if@lineB%
\rput(#3,#4){\psline[linestyle=dashed,linewidth=.5pt](0,-#5)}%
\fi%
\rput(#2,#4){\psline[arrows=|<-](-.5,0)}%
\rput(#3,#4){\psline[arrows=|<-](0,0)(.5,0)}%
\rput(#3,#4){\rput[l](.65,0){\textcolor{#6}{\texttt{#7}}}}%
}\ignorespaces}
%
\newcount\example@cnt
\example@cnt=0
\def\Example#1{%
\advance\example@cnt\@ne%
\ifx\empty#1\empty%
\noindent\textbf{Example \the\example@cnt.}\hspace{.5em}
\else%
\noindent\textbf{Example \the\example@cnt.{\normalfont\footnotesize\ttfamily({\normalfont use} #1)}}\hspace{.5em}%
\fi}
%===================================================================
\makeatother



\title{The \package Package \\ {\large (version 1.1)}}
\author{Farshid Delgosha \\ \texttt{fdelgosha@gmail.com}}
\date{April 1, 2009}



\begin{document}

\maketitle



\begin{abstract}
This package is a collection of useful macros for disciplines related to signal processing. It defines macros for plotting a sequence of numbers, drawing the pole-zero diagram of a system, shading the region of convergence, creating an adder or a multiplier node, placing a framed node at a given coordinate, creating an up-sampler or a down-sampler node, and connecting a list of nodes using any node-connecting macro. I welcome all comments for further improvements of this package and suggestions for adding new macros or features.
\end{abstract}


\section*{Contents}
\begin{multicols}{2}
\tableofcontents
\end{multicols}


\section{Introduction}

To use the \package package, add the following command to the preamble of your document.
\begin{verbatim}
   \usepackage{pst-sigsys}
\end{verbatim}
It loads \texttt{pstricks} \cite{pstricks}, \texttt{pst-node} \cite{pst-node}, and \texttt{pst-xkey} \cite{pst-xkey} packages. Moreover, it activates polar coordinates through the \CMD{SpecialCoor} macro defined by the \texttt{pstricks} package. Hence, all macros support polar coordinates.

The \package provides the following options.
\begin{itemize}[label=$\scriptscriptstyle\blacksquare$,topsep=0pt,leftmargin=*]
\item \textbf{notelegant:} When drawing block diagrams, I have found it more elegant to have round corner frames and line breaks. Hence, the \package package sets the following PSTricks keys when loaded.
\begin{verbatim}
   framesep=0.125
   framearc=0.25
   linearc=0.1
\end{verbatim}
To disable them, load the package with the \texttt{notelegant} option.

\item \textbf{pstadd:} The \package defines some PSTricks styles that can be used only with the \texttt{pstricks-add} package \cite{pstricks-add}. Use this option to define those styles that are introduced in Section~\ref{sec:styles}.
\end{itemize}




\section{What's New?}

In version 1.1, four new macros \CMD{pshtick}, \CMD{psvtick}, \CMD{pshTick}, and \CMD{psvTick} are added. The codes of macros \CMD{psusampler} and \CMD{psdsampler} are updated. However, there is no change in their user interface.




\section{Styles Defined by \package}
\label{sec:styles}

The \package package defines a few useful PSTricks styles for drawling arrows and dashed lines as shown in Figure~\ref{fig:styles}. (New styles are in green.) Some of these styles, which are shown in Figure~\ref{subfig:pstricks-add styles}, can be used only with the \texttt{pstricks-add} package. The usage of these styles is shown in Section~\ref{sec:examples} with many examples.
%%=======================================================================
\begin{figure}[ht!]
\centering
\subfloat[\texttt{pstricks} style\label{subfig:pstricks styles}]{%
\begin{pspicture}[showgrid=false](0,-.5)(5,5)
%
\rput[l](0,4.5){Default arrow}
\rput[l](2.5,4.5){\psline{->}(2,0)}
%
\rput[l](0,3.75){{\bfseries\color{green!50!black}Arrow}}
\rput[l](2.5,3.75){\psline[style=Arrow](2,0)}
%
\rput[l](0,3){Default dash}
\rput[l](2.5,3){\psline[linestyle=dashed](2,0)}
%
\rput[l](0,2.25){{\bfseries\color{green!50!black}Dash}}
\rput[l](2.5,2.25){\psline[style=Dash](2,0)}
%
\rput[l](0,1.5){Default line}
\rput[l](2.5,1.5){\psline(2,0)}
%
\rput[l](0,.75){{\bfseries\color{green!50!black}Graph}}
\rput[l](2.5,.75){\psline[style=Graph](2,0)}
%
\rput[l](0,0){{\bfseries\color{green!50!black}Stem}}
\rput[l](2.5,0){\psline[style=Stem]{-*}(2,0)}
%
\end{pspicture}}
%
\hspace{1cm}
%
\subfloat[\texttt{pstricks-add} styles\label{subfig:pstricks-add styles}]{%
\begin{pspicture}[showgrid=false](0,-.5)(5,5)
%
\rput[l](0,.75){{\bfseries\color{green!50!black}ArrowIn}}
\rput[l](2.5,.75){\psline[style=ArrowIn](2,0)}
%
\rput[l](0,0){{\bfseries\color{green!50!black}DashDot}}
\rput[l](2.5,0){\psline[style=DashDot](2,0)}
%
\end{pspicture}}
%
\caption{New styles}
\label{fig:styles}
\end{figure}
%%=======================================================================

In addition, the \package package defines the four styles \texttt{BraceUp}, \texttt{BraceDown}, \texttt{BraceRight}, and \texttt{BraceLeft} in conjunction with the \texttt{psbrace} macro define by the \texttt{pstricks-add} package. In these styles, the distance of the text from the brace is controlled by the \texttt{labelsep} key. Note that the new assignment for the \texttt{labelsep} key must precede the usage of any one of the \texttt{Brace} styles for the distance to take effect. The usage of these styles is shown by the following example.

\begin{LTXexample}
\begin{pspicture}[showgrid=true](5,3)
  \psframe(1,1)(4,2)
  \psset{linecolor=red}
  \psbrace*[labelsep=5mm,style=BraceUp]%
     (4,2)(1,2){Up}
  \psbrace*[style=BraceDown](1,1)(4,1){Down}
  \psbrace*[style=BraceRight](4,1)(4,2){Right}
  \psbrace*[style=BraceLeft](1,2)(1,1){Left}
\end{pspicture}
\end{LTXexample}





\section{Simples Macros}

The \package package defines four macros \CMD{RE}, \CMD{sRE}, \CMD{IM}, and \CMD{sIM} that generate the symbols \RE, \sRE, \IM, and \sIM, respectively. (The small symbols are in script size.) These symbols can be used to refer to the real and imaginary parts of a complex number. All four macros can be used both inside and outside the math mode.

\begin{LTXexample}
The real part of the complex number $c=a+jb$
is $a = \RE(c)$ and its imaginary part
is $b = \IM(c)$.
\end{LTXexample}




\section{Graphical Macros}
\label{sec:graphical macros}

In this section, we introduce all the graphical macros defined by the \package package. Every macro has some keys that can be assigned either directly inside optional brackets right after the macro name or through the \CMD{psset} macro provided by the \texttt{pstricks} package. Unless directly stated, all coordinate inputs specified by \rmit{coor} could be either in cartesian form $(x, y)$ or polar form $(\rho; \theta)$. (Recall that \package activates the polar coordinates on loading. Hence, there is no need to use the \CMD{SpecialCoor} macro.) After the introduction of every macro, some examples are provided to illustrate the usage of that macro.



\subsection{psaxeslabels}

\begin{syntax}
\CMD{psaxeslabels}\keys\{\rmit{arrows}\}($x_0, y_0$)($x_1, y_1$)($x_2, y_2$)\{\rmit{x-label}\}\{\rmit{y-label}\}
\end{syntax}
This macro is a simplified version of the \CMD{psaxes} macro defined by the \texttt{pst-plot} package \cite{pst-plot}. As depicted in Figure~\ref{fig:psaxeslabels}, the \CMD{psaxeslabels} draws two straight lines, one vertical and one horizontal, that intersect at the point ($x_0, y_0$).
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-2,-1)(4,3)
%
\psgrid[griddots=10,subgriddiv=1,gridlabels=0pt](0,0)(-2,-1)(3,2)
\psaxeslabels(0,0)(-2,-1)(3,2){\rmit{x-label}}{\rmit{y-label}}
\psset{linecolor=red}
\dotnode(0,0){org}
\dotnode(-2,-1){xy1}
\dotnode(3,2){xy2}
\nput{45}{org}{\textcolor{red}{$(x_0, y_0)$}}
\nput{45}{xy1}{\textcolor{red}{$(x_1, y_1)$}}
\nput{225}{xy2}{\textcolor{red}{$(x_2, y_2)$}}
\xdashline(3.35,0,-\pslabelsep){1.5}{purple}{labelsep}
\ydashline(0,\pslabelsep,2.35){1.5}{purple}{labelsep}
%
\end{pspicture}
\caption{\CMD{psaxeslabels} macro}
\label{fig:psaxeslabels}
\end{figure}
%%=======================================================================
These lines are enclosed by a virtual rectangular box with the lower left and upper right corners at ($x_1, y_1$) and ($x_2, y_2$), respectively. The two lines are labeled by \rmit{x-label} and \rmit{y-label}, respectively. Similar to \CMD{psaxes} macro, the use of \rmit{arrows} is optional. The keys employed by the \CMD{psaxeslabels} are summarized in Table~\ref{tab:psaxeslabels}.
%%=======================================================================
\begin{table}[ht!]
\centering
\caption{\CMD{psaxeslabels} Keys}
\label{tab:psaxeslabels}
\begin{keytable}{2.8in}
xlpos   &  {\normalfont\ttfamily t | b}  &  \texttt{b}  &  Position of the $x$-label along the horizontal axis  \\
ylpos   &  {\normalfont\ttfamily l | r}  &  \texttt{r}  &  Position of the $y$-label along the vertical axis \\
\end{keytable}
\end{table}
%%=======================================================================


\begin{LTXexample}
\begin{pspicture}[showgrid=true](-2,-1)(2,1)
  \psaxeslabels(0,0)(-2,-1)(2,1){\RE}{\IM}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-2,-1)(2,2)
  \psset{linecolor=blue,xlpos=t,ylpos=l}
  \psaxeslabels{->}(-1,0)(-2,-1)(2,2){$x$}{$y$}
\end{pspicture}
\end{LTXexample}




\subsection{pshtick}

\begin{syntax}
\CMD{pshtick}\keys(\rmit{coor})\{\rmit{ticklength}\}
\end{syntax}

As depicted in Figure~\ref{fig:pshtick}, the \CMD{pshtick} macro draws a horizontal line centered at \rmit{coor} with length $2\rmit{ticklength}$. This could be used for adding a tick line to coordinate axes.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-2,-1)(2,.5)
%
\pnode(0,0){org}
\rput(0,-1){\rnode{coor}{\textcolor{red}{(\rmit{coor})}}}
\ncline[linecolor=red,nodesepA=.15]{->}{coor}{org}
%
\pshtick(0,0){2}
%
\psbrace[style=BraceUp,linecolor=purple,fillstyle=solid,fillcolor=purple]%
(2,0)(0,0){{\ttfamily\footnotesize\color{purple}ticklength}}
%
\psbrace[style=BraceUp,linecolor=purple,fillstyle=solid,fillcolor=purple]%
(0,0)(-2,0){{\ttfamily\footnotesize\color{purple}ticklength}}
%
\end{pspicture}
\caption{\CMD{pshtick} macro}
\label{fig:pshtick}
\end{figure}
%%=======================================================================

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-3,0)(3,2)
   \psaxeslabels(0,0)(-3,0)(3,2){$x$}{$y$}
   \pshtick[linecolor=red](0,.5){.1}
   \pshtick[linecolor=blue](0,1.25){.25}
\end{pspicture}
\end{LTXexample}




\subsection{psvtick}

\begin{syntax}
\CMD{psvtick}\keys(\rmit{coor})\{\rmit{ticklength}\}
\end{syntax}

Similar to the previous macro, the \CMD{psvtick} macro draws a vertical line centered at \rmit{coor} with length $2\rmit{ticklength}$ (Figure~\ref{fig:psvtick}). This could be used for adding a tick line to coordinate axes.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-1.5,-2)(.5,2)
%
\pnode(0,0){org}
\rput(-1.5,0){\rnode{coor}{\textcolor{red}{(\rmit{coor})}}}
\ncline[linecolor=red,nodesepA=.15]{->}{coor}{org}
%
\psvtick(0,0){2}
%
\psbrace[style=BraceRight,linecolor=purple,fillstyle=solid,fillcolor=purple]%
(0,0)(0,2){{\ttfamily\footnotesize\color{purple}ticklength}}
%
\psbrace[style=BraceRight,linecolor=purple,fillstyle=solid,fillcolor=purple]%
(0,-2)(0,0){{\ttfamily\footnotesize\color{purple}ticklength}}
%
\end{pspicture}
\caption{\CMD{psvtick} macro}
\label{fig:psvtick}
\end{figure}
%%=======================================================================

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-3,-1)(3,1)
   \psaxeslabels(0,0)(-3,-1)(3,1){$x$}{$y$}
   \psvtick[linecolor=red](1,0){.1}
   \psvtick[linecolor=blue](2,0){.25}
\end{pspicture}
\end{LTXexample}




\subsection{pshTick}

\begin{syntax}
\CMD{pshTick}\keys(\rmit{coor})
\end{syntax}

Similar to \CMD{pshtick}, the \CMD{pshTick} macro draws a horizontal line centered at \rmit{coor}. The only difference is that the tick length is specified by the \texttt{ticklength} key. This is useful when multiple ticks are drawn all with the same length.

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-2,0)(2,2)
   \psaxeslabels(0,0)(-2,0)(2,2){$x$}{$y$}
   \psset{ticklength=.1,linecolor=red}
   \pshTick(0,.5)
   \pshTick(0,1)
   \pshTick(0,1.5)
\end{pspicture}
\end{LTXexample} 




\subsection{psvTick}

\begin{syntax}
\CMD{psvTick}\keys(\rmit{coor})
\end{syntax}

Similar to \CMD{psvtick}, the \CMD{psvTick} macro draws a vertical line centered at \rmit{coor}. The only difference is that the tick length is specified by the \texttt{ticklength} key. This is useful when multiple ticks are drawn all with the same length.

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-2,-1)(2,1)
   \psaxeslabels(0,0)(-2,-1)(2,1){$x$}{$y$}
   \psset{ticklength=.1,linecolor=red}
   \psvTick(.5,0)
   \psvTick(1,0)
   \psvTick(1.5,0)
\end{pspicture}
\end{LTXexample}




\subsection{psstem}

\begin{syntax}
\CMD{psstem}\keys($x_0, \Delta$)\{\rmit{list}\} \\
\CMD{psstem}\keys\{\rmit{list}\}
\end{syntax}

The \CMD{psstem} macro plots the sequence defined by \rmit{list} that is a comma-separated list of real or integer~numbers. As shown in Figure~\ref{subfig:psstem:sample}, if $\rmit{list} = n_1, n_2, n_3, \dotsc$, then \CMD{psstem} draws vertical lines (stems) at $x_0, x_0 + \Delta, x_0 + 2\Delta, \dotsc$ on the horizontal axis ($y = 0$) with heights $n_1, n_2, n_3, \dotsc$, respectively. \emph{Note that both $x_0$ and $\Delta$ must be integers.} In case their values are not explicitly given, they are assumed $x_0 = 0$ and $\Delta = 1$. The \CMD{psstem} macro is also capable of numerically tagging the stems. As depicted in Figure~\ref{subfig:psstem:tag}, the tag of every stem is place either below or above it depending on whether the corresponding number in the sequence is nonnegative (positive or zero) or negative, respectively. The distance of tags to stems is determined by the \texttt{labelsep} key. The keys employed by the \CMD{psstem} macro are summarized in Table~\ref{tab:psstem}.
%%=======================================================================
\begin{figure}[ht!]
\centering
%-------------------------------------------------------
% Sample
%-------------------------------------------------------
\subfloat[Sample sequence]{\label{subfig:psstem:sample}
\begin{pspicture}[showgrid=false](-1,-1)(4,3)
%
\psgrid[griddots=10,subgriddiv=1,gridlabels=0pt](3,2)
%
\pnode(0,0){a}
\pnode(0,2){b}
\ncline{-*}{a}{b}
\nput{-90}{a}{$x_0$}
\ncline[offset=.35,linecolor=gray]{|*-|*}{a}{b}
\ncput*{$n_1$}
%
\pnode(1.5,0){a}
\pnode(1.5,1){b}
\ncline{-*}{a}{b}
\nput{-90}{a}{$x_0+\Delta$}
\ncline[offset=.35,linecolor=gray]{|*-|*}{a}{b}
\ncput*{$n_2$}
%
\pnode(3,0){a}
\pnode(3,1.5){b}
\ncline{-*}{a}{b}
\nput{-90}{a}{$x_0+2\Delta$}
\ncline[offset=.35,linecolor=gray]{|*-|*}{a}{b}
\ncput*{$n_3$}
%
\end{pspicture}}
%
\hspace{2cm}
%
%-------------------------------------------------------
% Tag
%-------------------------------------------------------
\subfloat[Tagging]{\label{subfig:psstem:tag}
\begin{pspicture}[showgrid=false](-1,-1)(4,3)
%
\psgrid[griddots=10,subgriddiv=1,gridlabels=0pt](3,2)
%
\psset{labelsep=.25}
%
\psline{-*}(0,0)(0,2)
\rput[t](0,-\pslabelsep){$x_i$}
\xdashline[lines=tb](.5,0,-\pslabelsep){1}{purple}{labelsep}
%
\psline{-*}(2.5,0)(2.5,-1)
\rput[b](2.5,\pslabelsep){$x_j$}
\xdashline[lines=tb](3,\pslabelsep,0){1}{purple}{labelsep}
%
\end{pspicture}}
%
\caption{\CMD{psstem} macro}
\label{fig:psstem}
\end{figure}
%%=======================================================================
\begin{table}[ht!]
\centering
\caption{\CMD{psstem} Keys}
\label{tab:psstem}
\begin{keytable}{2.5in}
stemhead       &  style    &  *                  &  Stem head. Possible choices are \texttt{*}, \texttt{o}, \texttt{>}, \texttt{<}, \texttt{>\kern.5pt>}, \texttt{<\kern.5pt<}, \texttt{|}, \texttt{)}, \texttt{(}, \texttt{>|}, and \texttt{<|}. \\
stemtag        &  Boolean  &  \texttt{false}     &  Tagging the stems \\
stemtagformat  &  format   &  \CMD{scriptstyle}  &  Tag format \\
\end{keytable}
\end{table}
%%=======================================================================


\begin{LTXexample}
\begin{pspicture}[showgrid=true](0,-1)(6,2)
  \psstem[style=Stem]{0,.5,1,-1,2}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}
\begin{pspicture}[showgrid=true](0,-1)(6,2)
  \psset{style=Stem,linecolor=red}
  \psstem[stemhead=>,stemtag](1,2){-1,1,2}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}
\begin{pspicture}[showgrid=true](0,-1)(6,2)
   \psset{style=Stem,stemtag}
   \psstem[linecolor=red](0,2){1,-.75,1}
   \psset{stemhead=o}
   \psstem[linecolor=blue](1,2){.5,2,-1}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}
\begin{pspicture}[showgrid=true](5,3)
  \psstem[stemhead=*](0,1){1}
  \psstem[stemhead=o](1,1){1}
  \psstem[stemhead=>](2,1){1}
  \psstem[stemhead=<](3,1){1}
  \psstem[stemhead=>>](4,1){1}
  \psstem[stemhead=<<](5,1){1}

  \rput(0,1.5){%
    \psstem[stemhead=|](0,1){1}
    \psstem[stemhead=)](1,1){1}
    \psstem[stemhead=(](2,1){1}
    \psstem[stemhead=>|](3,1){1}
    \psstem[stemhead=<|](4,1){1}
  }
\end{pspicture}
\end{LTXexample}





\subsection{pszero}

\begin{syntax}
\CMD{pszero}\keys(\rmit{coor})\{\rmit{node}\}
\end{syntax}
This macro is used to generate a circle node centered at \rmit{coor} and labeled \rmit{node} that represents a zero of a system. It could also be used to generate several circles, all centered at \rmit{coor}, representing high order zeros. As shown in Figure~\ref{fig:pszero}, the radius of innermost circle is \texttt{zeroradius} and it is incremented by \texttt{zeroradiusinc} for high order zeros.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-2.5,-2.5)(2.5,2.5)
%
\dotnode[linecolor=red](0,0){org}
\nput[labelsep=.1]{-90}{org}{\textcolor{red}{(\rmit{coor})}}
%
\pscircle(0,0){1.25}
\pscircle(0,0){1.65}
\rput(2,0){\psldots}
\pscircle(0,0){2.35}
%
\pnode(1.25;45){rad}
\ncline[linecolor=purple]{->}{org}{rad}  \naput[nrot=:U]{{\ttfamily\scriptsize\color{purple}zeroradius}}
%
\rput(1.25;-45){\psline[arrows=|<-,linecolor=teal](.5;135)}
\rput(1.65;-45){\psline[arrows=|<-,linecolor=teal](.5;-45)}
\pnode(1.45;-45){inc}
\nput[rot=-45]{45}{inc}{{\ttfamily\scriptsize\color{teal}zeroradiusinc}}
%
\end{pspicture}
\caption{\CMD{pszero} macro}
\label{fig:pszero}
\end{figure}
%%=======================================================================
The line-width of all circles is determined by the \texttt{zerowidth} key. The key \texttt{order} determines the order of the zero. The key \texttt{scale} can be used to scale up or down the radius of innermost circle (\texttt{zeroradius}), the radius increment (\texttt{zeroradiusinc}), and the line-width of all circles (\texttt{zerowidth}). Table~\ref{tab:pszero} summarizes keys corresponding to \CMD{pszero} and their default values.
%%=======================================================================
\begin{table}[ht!]
\centering
\caption{\CMD{pszero} Keys}
\label{tab:pszero}
\begin{keytable}{1.85in}
zerowidth      &  num[dimen]  &  $0.7$pt &  Line-width of all circles \\
zeroradius     &  num[dimen]  &  $0.08$  &  Radius of the innermost circle \\
zeroradiusinc  &  num[dimen]  &  $0.07$  &  Radius increment \\
order          &  int         &  $1$     &  Order of the zero \\
scale          &  num         &  $1$     &  Scale factor \\
\end{keytable}
\end{table}
%%=======================================================================

\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \pszero(0,1){z1}   \nput{-90}{z1}{$z_1$}
  \pszero[linecolor=red](1,1){z2}
  \pszero[zerowidth=2pt](2,1){z3}
  \pszero[zeroradius=.25](3,1){z4}
  \pszero[order=3](4,1){z5}
    \nput{-90}{z5}{$z_5$}
  \pszero[zeroradiusinc=.15,order=2](5,1){z6}
  \pszero[scale=3](6,1){z7}
\end{pspicture}
\end{LTXexample}




\subsection{pspole}

\begin{syntax}
\CMD{pspole}\keys(\rmit{coor})\{\rmit{node}\}
\end{syntax}

This macro is used to generate a cross node, as shown in Figure~\ref{fig:pspole}, centered at \rmit{coor} and labeled \rmit{node} that represents the pole of a system. The key \texttt{scale} can be used to scale up or down the pole line-width (\texttt{polewidth}) and pole length (\texttt{polelength}). The keys corresponding to the \CMD{pspole} macro are summarized in Table~\ref{tab:pspole}.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-2,-1.5)(2,1.5)
%
\pnode(0,0){org}
\rput(0,-1){\rnode{coor}{\textcolor{red}{(\rmit{coor})}}}
\ncline[linecolor=red,nodesepA=.15]{->}{coor}{org}
%
\psline[linestyle=dashed,linecolor=gray](-2,0)(2,0)
\psarc[linecolor=gray](0,0){1}{0}{45}
\rput(1.35;22.5){\textcolor{gray}{$45^\circ$}}
%
\pspole[polelength=2,linewidth=1pt](0,0){p}
%
\psbrace[style=Brace,rot=-90,nodesepA=-.15,nodesepB=-.15,linecolor=purple,fillstyle=solid,fillcolor=purple]%
(2;45)(0,0){{\ttfamily\footnotesize\color{purple}polelength}}
%
\end{pspicture}
\caption{\CMD{pspole} macro}
\label{fig:pspole}
\end{figure}
%%=======================================================================
\begin{table}[ht!]
\centering
\caption{\CMD{pspole} Keys}
\label{tab:pspole}
\begin{keytable}{1in}
polewidth   &  num[dimen]  &  $0.7$pt &  Cross line-width \\
polelength  &  num[dimen]  &  $0.12$  &  Cross length \\
scale       &  num         &  $1$     &  Scale factor \\
\end{keytable}
\end{table}
%%=======================================================================

\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \pspole(1,1){p1}   \nput{-90}{p1}{$p_1$}
  \pspole[linecolor=red](2,1){p2}
  \pspole[polewidth=2pt](3,1){p3}
  \pspole[polelength=.5](4,1){p4}
  \pspole[scale=3](5,1){p5}
    \nput{-90}{p5}{$p_5$}
\end{pspicture}
\end{LTXexample}




\subsection{pscircleop}

\begin{syntax}
\CMD{pscircleop}\keys(\rmit{coor})\{\rmit{node}\}
\end{syntax}

This macro draws a cross inside a circle that are both centered at \rmit{coor} and labeled \rmit{node} as shown in Figure~\ref{fig:pscircleop}. The length of the cross and its line-width are controlled by the \texttt{oplength} and \texttt{opwidth} keys, respectively. Note that the line-width of the enclosing circle is separately controlled by the \texttt{linewidth} key. The distance between the circle and the cross is determined by the key \texttt{opsep}. The type of the operation (whether plus or times) is controlled by the key \texttt{operation}. Another way of determining the operation inside the circle is through the key \texttt{angle} that determines the angle of the cross. The key \texttt{scale} can be used to scale up or down the cross line-width (\texttt{opwidth}), the cross length (\texttt{oplength}), the separation between the cross and the circle (\texttt{opsep}), and the circle line-width (\texttt{linewidth}). The keys corresponding to the \CMD{pscircleop} macro are summarized in Table~\ref{tab:pscircleop}.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-2,-2)(2,2)
%
\pnode(0,0){org}
\rput(1;-105){\rnode{coor}{\textcolor{red}{(\rmit{coor})}}}
\ncline[linecolor=red,nodesepA=.15]{->}{coor}{org}
%
\psline[linestyle=dashed,linecolor=gray](-1.5,0)(1.5,0)
\psarc[linecolor=gray](0,0){1}{0}{30}
\rput[l](1.1;15){{\ttfamily\footnotesize\color{gray}angle}}
%
\pscircleop[oplength=1.5,opsep=.5,angle=30](0,0){op}
%
\psbrace[style=Brace,rot=-90,nodesepA=-.15,nodesepB=-.15,linecolor=purple,fillstyle=solid,fillcolor=purple]%
(1.5;30)(0,0){{\ttfamily\footnotesize\color{purple}oplength}}
%
\pscircle[linestyle=dashed,linecolor=gray]{1.5}
\rput(2;150){\psline[arrows=|<-,linecolor=teal](.5;150)}
\rput(1.5;150){\psline[arrows=|<-,linecolor=teal](.5;-30)}
\pnode(1.75;150){sep}
\nput[rot=-30]{60}{sep}{{\ttfamily\scriptsize\color{teal}opsep}}
\end{pspicture}
\caption{\CMD{pscircleop} macro}
\label{fig:pscircleop}
\end{figure}
%%=======================================================================
\begin{table}[ht!]
\centering
\caption{\CMD{pscircleop} Keys}
\label{tab:pscircleop}
\begin{keytable}{2.75in}
opwidth    &  num[dimen]                         &  $0.7$pt        &  Cross line-width \\
oplength   &  num[dimen]                         &  $0.125$        &  Cross length \\
opsep      &  num[dimen]                         &  $0.1$          &  Separation between the cross and the frame \\
operation  &  {\normalfont\ttfamily plus|times}  &  \texttt{plus}  &  Operation \\
angle      &  angle                              &  $0$            &  Cross angle \\
scale      &  num                                &  $1$            &  Scale factor \\
\end{keytable}
\end{table}
%%=======================================================================


\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \pscircleop(.5,1){op1}
  \pscircleop[opwidth=2pt](1.25,1){op2}
  \pscircleop[oplength=.25](2,1){op3}
  \pscircleop[opsep=0](2.75,1){op4}
  \pscircleop[operation=times](3.5,1){op5}
  \pscircleop[angle=20](4.25,1){op6}
  \pscircleop[scale=2.5](5.5,1){op7}
\end{pspicture}
\end{LTXexample}




\subsection{psframeop}

\begin{syntax}
\CMD{psframeop}\keys(\rmit{coor})\{\rmit{node}\}
\end{syntax}

This macro is very similar to the \CMD{pscircleop} macro. The only difference is that the operation is enclosed inside a square frame rather than a circular one.


\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \psframeop(.5,1){op1}
  \psframeop[opwidth=2pt](1.25,1){op2}
  \psframeop[oplength=.25](2,1){op3}
  \psframeop[opsep=0](2.75,1){op4}
  \psframeop[operation=times](3.5,1){op5}
  \psframeop[angle=20](4.25,1){op6}
  \psframeop[scale=2.5](5.5,1){op7}
\end{pspicture}
\end{LTXexample}




\subsection{psdisk}

\begin{syntax}
\CMD{psdisk}\keys(\rmit{coor})\{\rmit{radius}\}
\end{syntax}

It draws a solid disk centered at \rmit{coor} with radius \rmit{radius} as depicted in Figure~\ref{fig:psdisk}. The fill color is specified by the \texttt{fillcolor} key. This macro is used to shade the region of convergence of a system in the $z$ plane.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-1.5,-1.5)(1.5,1.5)
%
\psdisk[fillcolor=blue!20](0,0){1.5}
%
\dotnode[linecolor=red](0,0){org}
\nput{-90}{org}{\textcolor{red}{\rmit{coor}}}
\pnode(1.5;45){rad}
\ncline{->}{org}{rad}
\naput[nrot=:U]{\rmit{radius}}
%
\end{pspicture}
\caption{\CMD{psdisk} macro}
\label{fig:psdisk}
\end{figure}
%%=======================================================================


\begin{LTXexample}
\begin{pspicture}[showgrid=true](5,2)
  \psdisk[fillcolor=red](1,1){.5}
  \psdisk[fillcolor=blue](3,1){1}
\end{pspicture}
\end{LTXexample}




\subsection{psring}

\begin{syntax}
\CMD{psring}\keys(\rmit{coor})\{\rmit{inner-radius}\}\{\rmit{outer-radius}\}
\end{syntax}

This macro draws a solid ring centered at \rmit{coor} with inner radius \rmit{inner-radius} and outer radius \rmit{outer-radius} as shown in Figure~\ref{fig:psring}. The fill color is specified by the \texttt{fillcolor} key. This macro is used to shade the region of convergence of a system in the $z$ plane.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-2,-2)(2,2)
%
\psring[fillcolor=blue!20](0,0){1}{2}
%
\dotnode[linecolor=red](0,0){org}
\nput{-90}{org}{\textcolor{red}{\rmit{coor}}}
\pnode(1;0){rad1}
\pnode(2;50){rad2}
\ncline{->}{org}{rad1}  \naput[nrot=:U,npos=1.25]{{\footnotesize\rmit{inner-radius}}}
\ncline{->}{org}{rad2}  \naput[nrot=:U]{{\footnotesize\rmit{outer-radius}}}
%
\end{pspicture}
\caption{\CMD{psring} macro}
\label{fig:psring}
\end{figure}
%%=======================================================================




\begin{LTXexample}
\begin{pspicture}[showgrid=true](5,2)
  \psring[fillcolor=red](1,1){.5}{1}
  \psring[fillcolor=green](3,1){.25}{.5}
\end{pspicture}
\end{LTXexample}




\subsection{psdiskc}

\begin{syntax}
\CMD{psdiskc}\keys(\rmit{coor})($x_0, y_0$)\{\rmit{radius}\}
\end{syntax}

As shown in Figure~\ref{fig:psdiskc}, this macro shades the area confined between a circle centered at \rmit{coor} with radius \rmit{radius} and a rectangle centered at \rmit{coor} and side lengths $2x_0$ and $2y_0$. The fill color is specified by the \texttt{fillcolor} key. This macro is used to shade the region of convergence of a system in the $z$ plane.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-4,-2)(3,2.15)
%
\psdiskc[fillcolor=blue!20,framearc=0](0,0)(2,1.5){1}
%
\dotnode[linecolor=red](0,0){org}
\nput{-90}{org}{\textcolor{red}{\rmit{coor}}}
\pnode(1;45){rad}
\ncline{->}{org}{rad}  \naput[nrot=:U]{{\small\rmit{radius}}}
\dotnode(2,1.5){a}    \nput{45}{a}{$(x_0, y_0)$}
\dotnode(-2,-1.5){b}  \nput{225}{b}{$(-x_0, -y_0)$}
%
\rput(0,2){%
\psline{|<->|}(-2,0)(2,0)
\rput*(0,0){$2x_0$}}
%
\rput(-2.5,0){%
\psline{|<->|}(0,-1.5)(0,1.5)
\rput*{90}(0,0){$2y_0$}}
%
\end{pspicture}
\caption{\CMD{psdiskc} macro}
\label{fig:psdiskc}
\end{figure}
%%=======================================================================

\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \psdiskc[fillcolor=red](1.5,1)(1.5,1){.5}
  \psdiskc[fillcolor=blue](4.5,1)(.5,1){.15}
\end{pspicture}
\end{LTXexample}




\subsection{psldots}

\begin{syntax}
\CMD{psldots}\keys
\end{syntax}

As depicted in Figure~\ref{fig:psldots}, this macro draws three dots each with diameter \texttt{ldotssize} on the same straight line. Every two consecutive dots are separated by \texttt{ldotssep}. The angle of the line on which the dots lie with the horizontal axis is controlled by the key \texttt{angle}. The key \texttt{scale} can be used to scale up or down the dot diameter (\texttt{ldotssize}) and the dot separation (\texttt{ldotssep}). The keys corresponding to \CMD{pslodots} are summarized in Table~\ref{tab:psldots}.
%%=======================================================================
\begin{figure}[ht!]
\centering
\begin{pspicture}[showgrid=false](-4,-2.5)(5,1.5)
%
\psset{linecolor=teal}
\psline[linestyle=dashed](-4;15)(4.5;15)
\psline[linestyle=dashed](-4,0)(4.5,0)
\psarc(0,0){4}{0}{15}
\rput{-82.5}(4.25;7.5){{\ttfamily\color{teal}angle}}
\pnode(-3;15){L1}
\rput(L1){\pnode(1.25;-75){L2}}
\pnode(0,0){O1}
\rput(O1){\pnode(1.25;-75){O2}}
\pnode(3;15){R1}
\rput(R1){\pnode(1.25;-75){R2}}
%
\psset{linecolor=purple,linestyle=dashed,style=Dash}
\ncline{L1}{L2}
\ncline{O1}{O2}
\ncline{R1}{R2}
%
\psset{linestyle=solid}
\ncline{|<*->|*}{L2}{O2}   \nbput[nrot=:U]{{\ttfamily\color{purple}ldotssep}}
\ncline{|<*->|*}{O2}{R2}   \nbput[nrot=:U]{{\ttfamily\color{purple}ldotssep}}
%
\psline[linestyle=dashed](-.5,0)(-.5,1)
\psline[linestyle=dashed](.5,0)(.5,1)
\psline{|<*->|*}(-.5,1)(.5,1)
\rput(0,1.25){{\ttfamily\color{purple}ldotssize}}
%
\psset{linecolor=black}
\rput(0,0){\psldots[ldotssize=1,ldotssep=3,angle=15]}
%
\end{pspicture}
\caption{\CMD{psldots} macro}
\label{fig:psldots}
\end{figure}
%%=======================================================================
\begin{table}[ht!]
\centering
\caption{\CMD{psldots} Keys}
\label{tab:psldots}
\begin{keytable}{2.15in}
ldotssize  &  num[dimen]           &  $0.05$         &  Dot diameter \\
ldotssep   &  num[dimen]           &  $0.15$         &  Distance between consecutive dots \\
angle      &  angle                &  $0$            &  Dots angle \\
scale      &  num                  &  $1$            &  Scale factor \\
\end{keytable}
\end{table}
%%=======================================================================


\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \rput(1,1){\psldots}
  \rput(2,1){\psldots[angle=45]}
  \rput(4,1){\psldots[angle=90,ldotssize=.1]}
  \rput(3,1){\psldots[angle=90,ldotssep=.5]}
  \rput(5,1){\psldots[angle=90,scale=3]}
\end{pspicture}
\end{LTXexample}




\subsection{psblock}

\begin{syntax}
\CMD{psblock}\keys(\rmit{coor})\{\rmit{node}\}\{\rmit{stuff}\}
\end{syntax}

This macro places \rmit{stuff} at coordinate \rmit{coor}, encloses it in a rectangular frame, and turns that into a node labeled \rmit{node}. The separation between the \rmit{stuff} and the frame is controlled by the \texttt{framesep} key.


\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \rput(0,1){\rnode{x}{$x[n]$}}
  \psblock(1.5,1){a}{$z^{-1}$}
  \psblock(4,1){b}{$h[n], H(z)$}
  \rput(6,1){\rnode{y}{$y[n]$}}
  %-----------------
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{x}{a}
  \ncline{a}{b}
  \ncline[nodesepB=.15]{b}{y}
\end{pspicture}
\end{LTXexample}




\subsection{psfblock}

\begin{syntax}
\CMD{psfblock}\keys(\rmit{coor})\{\rmit{node}\}\{\rmit{stuff}\}
\end{syntax}

This macro is very similar to the \CMD{psblock} macro except that the size of the frame is controlled by the key \texttt{framesize}. The frame size is specified as \texttt{framesize=\rmit{num1[dimen]} \rmit{num2[dimen]}}. Note that \rmit{num1} and \rmit{num2} are separated by a space, not by comma. If \rmit{num2} is absent, then a square frame is created.


\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \rput(0,1){\rnode{x}{$x[n]$}}
  \psfblock[framesize=.75 .5](2,1){a}{$H_1$}
  \psfblock[framesize=1.5 1](4,1){b}{$H_2$}
  \rput(6,1){\rnode{y}{$y[n]$}}
  %-----------------
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{x}{a}
  \ncline{a}{b}
  \ncline[nodesepB=.15]{b}{y}
\end{pspicture}
\end{LTXexample}



\subsection{psusampler}

\begin{syntax}
\CMD{psusampler}\keys(\rmit{coor})\{\rmit{node}\}\{\rmit{stuff}\}
\end{syntax}

This macro is similar to the \CMD{psfblock} except that \rmit{stuff} is placed next to an up-arrow in math mode representing an up-sampler. \emph{Notice that \rmit{stuff} must be in text mode, not in the math mode, i.e., do not put \$ around \rmit{stuff}.}

\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \rput(0,1){\rnode{x}{$x[n]$}}
  \psusampler[framesize=1 .75](3,1){a}{2}
  \rput(6,1){\rnode{y}{$y[n]$}}
  %-----------------
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{x}{a}
  \ncline[nodesepB=.15]{a}{y}
\end{pspicture}
\end{LTXexample}



\subsection{psdsampler}

\begin{syntax}
\CMD{psdsampler}\keys(\rmit{coor})\{\rmit{node}\}\{\rmit{stuff}\}
\end{syntax}

This macro is similar to the \CMD{psfblock} except that \rmit{stuff} is placed next to a down-arrow in math mode representing a  down-sampler. \emph{Notice that \rmit{stuff} must be in text mode, not in the math mode, i.e., do not put \$ around \rmit{stuff}.}

\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \rput(0,1){\rnode{x}{$x[n]$}}
  \psdsampler[framesize=1 .75](3,1){a}{3}
  \rput(6,1){\rnode{y}{$y[n]$}}
  %-----------------
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{x}{a}
  \ncline[nodesepB=.15]{a}{y}
\end{pspicture}
\end{LTXexample}




\subsection{nclist}

\begin{syntax}
\CMD{nclist}\keys\{\rmit{nc-macro}\}\{\rmit{node-list}\}
\end{syntax}

This macro is very useful when connecting several nodes using a single node-connecting macro. The \rmit{node-list} must be a comma-separated list of nodes. If \rmit{node-list} is $n_1, n_2, n_3, \dotsc$ is a list of nodes, then \CMD{nclist} connects $n_1$ to $n_2$, $n_2$ to $n_3$, and so forth all using the macro \rmit{nc-macro}.

\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \psblock(1,1){a}{A}
  \psblock(2.5,1){b}{B}
  \psblock(4,1){c}{C}
  \psblock(5.5,1){d}{D}
  \nclist[style=Arrow]{ncline}{a,b,c,d}
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}
\begin{pspicture}[showgrid=true](6,2)
  \dotnode(0,1){a}
  \dotnode(1.5,1){b}
  \dotnode(3,1){c}
  \dotnode(4.5,1){d}
  \dotnode(6,1){e}
  \psset{style=ArrowIn,arcangle=35}
  \psset{linecolor=red}
  \nclist{ncarc}{a,b,c,d,e}
\end{pspicture}
\end{LTXexample}



%%=======================================================================
%% Examples
%%=======================================================================

\lstset{pos=t}

\section{Examples}
\label{sec:examples}

In this section, we provide some examples to illustrate the benefits and usage of macros defined in Section~\ref{sec:graphical macros}. Note that some of these examples require the use of additional packages. In that case, additional packages are mentioned next to the example number.



\subsection{Complex Number}

%%------------------------
%%--- example ------------
%%------------------------

\Example{pstricks-add} Show the complex number $c = a + j b = \rho e^{j\theta}$ as a point in the complex plane.

\bigskip

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-1,-1)(3,3)
  %--- Drawing axes ---
  \psaxeslabels[xlpos=t](0,0)(0,0)(3,3){\RE}{\IM}

  %--- Defining some useful nodes ---
  \dotnode[linecolor=blue](2,2){c}
  \pnode(0,0){org}
  \pnode(2,0){a}
  \pnode(0,2){b}

  %--- Connecting nodes ---
  \ncline{org}{c}
  \ncline[linecolor=gray,style=Dash]{c}{a}
  \ncline[linecolor=gray,style=Dash]{c}{b}

  %--- Labeling ---
  \color{purple}
  \psset{linecolor=purple,arrows=|-|,nrot=:U}
  \psbrace*[style=BraceDown](org)(a){$a$}
  \psbrace*[style=BraceLeft](b)(org){$b$}
  \ncline[offset=.25]{org}{c} \ncput*{$\rho$}
  \psarc[linecolor=gray](org){.75}{0}{45}
  \rput(1;22.5){$\theta$}
\end{pspicture}
\end{LTXexample}



\newpage

\subsection{Plotting}

%%------------------------
%%--- example ------------
%%------------------------

\Example{pst-plot} Consider the continuous-time signal
\[
x_c(t) =
\begin{cases}
\sin(t)\enspace,  &  t \geq 0 \\
0\enspace,  &  t < 0\enspace.
\end{cases}
\]
Draw the sampled sequence $x[n] = x_c(\pi n/4)$.

\bigskip

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-3,-2)(9,2)
  %--- Drawing axes ---
  \psaxeslabels(0,0)(-3,-2)(9,2){$n$}{$x[n]$}

  %--- x_c(t) ---
  \psplot[style=Graph,linecolor=gray,linestyle=dashed]{0}{8}{x 45 mul sin}

  %--- x[n] ---
  \psset{style=Stem,linecolor=teal,stemtagformat={\color{blue}\scriptstyle}}
  \psstem(-2,1){0,0,0}
  \psstem[stemtag](1,1){.707107,1,.707107,0,-.707107,-1,-.707107,0}

  %--- Labeling the origin ---
  \uput[-45](0,0){$\color{blue}\scriptstyle 0$}
  
  %--- Horizontal ticks ----
  \pshtick[linecolor=gray](0,1){.1}
  \pshtick[linecolor=gray](0,-1){.1}
  \uput[180](0,1){$\scriptstyle 1$}
  \uput[180](0,-1){$\scriptstyle -1$}
\end{pspicture}
\end{LTXexample}



\newpage

%%------------------------
%%--- example ------------
%%------------------------

\Example{pst-plot} Consider the process of sampling a continuous-time signal $x_c(t)$ with period $T$ as follows: (1) Multiply $x_c(t)$ by the impulse train $s(t) = \sum_{n=-\infty}^\infty \delta(t - nT)$ to obtain $x_s(t) = x_c(t) s(t)$, and (2) Convert every delta in $x_s(t)$ into a sequence to obtain the sampled sequence $x[n]$. Demonstrate this process for the continuous-time signal $x_c(t) = 0.5\sin(\pi t/2) + 0.5$ and $T = 1$.

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-7,-5)(7,1)
  %--- Some settings and definitions ---
  \psset{plotpoints=500,ylpos=l,stemtag}
  \def\plotsin[#1]{\psplot[#1]{-6}{6}{x 90 mul sin .5 mul .5 add}}

  %--- x_c(t) ---
  \psaxeslabels(0,0)(-7,0)(7,0){$t$}{}
  \rput[tl](-7,1){$x_c(t)$}
  \plotsin[style=Graph,linecolor=teal]
  \multips(-6,0)(1,0){13}{\psline[linecolor=gray](0,-.075)(0,.075)}
  \multido{\nn=-6+1}{13}{\rput[t](\nn,-.25){$\scriptstyle\nn$}}

  %--- s(t) ----
  \rput(0,-1.5){%
    \psaxeslabels(0,0)(-7,0)(7,0){$t$}{}
    \rput[tl](-7,1){$s(t)$}
    \psset{style=Stem,style=Arrow,stemhead=>,linecolor=teal}
    \psstem(-6,1){1,1,1,1,1,1,1,1,1,1,1,1,1}}

  %--- x_s(t) ---
  \rput(0,-3){%
    \psaxeslabels(0,0)(-7,0)(7,0){$t$}{}
    \rput[tl](-7,1){$x_s(t)$}
    \plotsin[style=Graph,linecolor=gray,linestyle=dashed]
    \psset{style=Stem,style=Arrow,stemhead=>,linecolor=teal}
    \psstem(-6,1){.5}  \psstem(-4,1){.5,1,.5}
    \psstem{.5,1,.5}   \psstem(4,1){.5,1,.5}}

  %--- x[n] ----
  \rput(0,-4.5){%
    \psaxeslabels(0,0)(-7,0)(7,0){$n$}{}
    \rput[tl](-7,1){$x[n]$}
    \psset{style=Stem,style=Arrow,linecolor=teal}
    \psstem(-6,1){.5,0,.5,1,.5,0,.5,1,.5,0,.5,1,.5}}
\end{pspicture}
\end{LTXexample}



\newpage

\subsection{Pole-Zero Diagram}

%%------------------------
%%--- example ------------
%%------------------------

\Example{} Draw the pole-zero diagram of a system with the following system function.
\[
H(z) = \frac{z^4 - 2z^3 + 2z^2}{z^2 - 4}
\]


\begin{LTXexample}
\begin{pspicture}[showgrid=true](-3,-2)(3,2)
  %--- Drawing axes ---
  \psaxeslabels(0,0)(-3,-2)(3,2){$\sRE$}{$\sIM$}

  %--- Marking zeros ---
  \pszero[order=2](0,0){z1}
  \pszero(1,1){z2}   \nput{90}{z2}{$1 + j$}
  \pszero(1,-1){z3}  \nput{-90}{z3}{$1 - j$}

  %--- Marking poles ---
  \psset{linecolor=red}
  \pspole(2,0){p1}   \nput{-90}{p1}{$2$}
  \pspole(-2,0){p2}  \nput{-90}{p2}{$-2$}
\end{pspicture}
\end{LTXexample}


\newpage

%%------------------------
%%--- example ------------
%%------------------------

\Example{multido} Draw the pole-zero diagram of a fifth-order Butterworth filter.

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-3,-3)(3,3)
  %--- Drawing axes ---
  \psaxeslabels(0,0)(-3,-3)(3,3){$\sRE$}{$\sIM$}
  \pscircle[linecolor=gray](0,0){2}

  %--- Angle between poles ---
  \psset{linecolor=gray}
  \psline[linestyle=dashed](3;108)
  \psline[linestyle=dashed](3;144)
  \psarc[style=Arrow,arrows=<->](0,0){2.5}{108}{144}
  \rput(2.75;126){\textcolor{gray}{$36^\circ$}}

  %--- Placing poles ---
  \psset{linecolor=red,scale=1.25}
  \multido{\np=108+36}{5}{\pspole(2;\np){p}}
\end{pspicture}
\end{LTXexample}



\newpage


\subsection{Region of Convergence}

%%------------------------
%%--- example ------------
%%------------------------

\Example{} Shade the region of convergence (ROC) of a system with the following system function assuming it is: (1) causal, and (2) stable.
\[
H(z) = \frac{1}{z^2 + z - \tfrac{3}{4}}
\]
Since the poles of the system are at $z = \tfrac{1}{2}$ and $z = -\tfrac{3}{2}$, the ROC of the system with the given assumptions is as follows.

\bigskip

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-5,-4)(5,4)
  %--- Shading ROCs ---
  \psring[fillcolor=teal!30](0,0){.75}{2.25}
  \psdiskc[fillcolor=blue!30](0,0)(3.75,3){2.25}

  %--- Drawing axes ---
  \psaxeslabels(0,0)(-4.25,-3.75)(4.75,4){$\sRE$}{$\sIM$}

  %--- Marking poles ---
  \psset{linecolor=purple,labelsep=.05}
  \pscircle(0,0){1.5}
  \rput[b]{45}(1.68;135){{\scriptsize\color{purple}unit circle}}
  \pscircle[linecolor=gray,linestyle=dashed,style=Dash](0,0){.75}
  \pspole(.75,0){p1}    \nput{-45}{p1}{$\tfrac{1}{2}$}
  \pscircle[linecolor=gray,linestyle=dashed,style=Dash](0,0){2.25}
  \pspole(-2.25,0){p2}  \nput{225}{p2}{$\scriptstyle-\tfrac{3}{2}$}

  %--- Labeling the stable and causal ROCs ---
  \rput*(1.5;45){{\scriptsize Stable}}
  \rput*(3.35;45){{\scriptsize Causal}}
\end{pspicture}
\end{LTXexample}



\newpage


\subsection{Block Diagrams}

%%------------------------
%%--- example ------------
%%------------------------

\Example{} Draw the block diagram of two systems $H_1(z)$ and $H_2(z)$ in both parallel and series combinations.

\bigskip

\begin{LTXexample}
%===========================
%   Parallel Combination
%===========================
\begin{pspicture}[showgrid=true](-3,-1)(3,1)
  %--- Defining blocks ---
  \rput(-3,0){\rnode{x}{$x[n]$}}
  \dotnode(-1.5,0){dot}
  \psblock[fillstyle=solid,fillcolor=red!20](0,.75){H1}{$H_1(z)$}
  \psblock[fillstyle=solid,fillcolor=blue!20](0,-.75){H2}{$H_2(z)$}
  \pscircleop(1.5,0){oplus}
  \rput(3,0){\rnode{y}{$y[n]$}}

  %--- Connecting blocks ---
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{-}{x}{dot}
  \ncangle[angleA=90,angleB=180]{dot}{H1}
  \ncangle[angleA=-90,angleB=180]{dot}{H2}
  \ncangle[angleB=90]{H1}{oplus}
  \ncangle[angleB=-90]{H2}{oplus}
  \ncline[nodesepB=.15]{oplus}{y}
\end{pspicture}
%
%========================
%   Series Combination
%========================
\begin{pspicture}[showgrid=true](-3,-1)(3,1)
  %--- Defining blocks ---
  \rput(-3,0){\rnode{x}{$x[n]$}}
  \psblock[fillstyle=solid,fillcolor=red!20](-1.25,0){H1}{$H_1(z)$}
  \psblock[fillstyle=solid,fillcolor=blue!20](1.25,0){H2}{$H_2(z)$}
  \rput(3,0){\rnode{y}{$y[n]$}}

  %--- Connecting blocks ---
  \ncline[nodesepA=.15]{x}{H1}
  \ncline{H1}{H2}
  \ncline[nodesepB=.15]{H2}{y}
\end{pspicture}
\end{LTXexample}


\newpage

%%------------------------
%%--- example ------------
%%------------------------

\Example{} Draw the block diagram of a continuous-to-discrete-time (C/D) converter.

\bigskip

\begin{LTXexample}
\begin{pspicture}[showgrid=true](-2,-2)(5.5,2)
  %--- Defining blocks ---
  \rput(-1.75,0){\rnode{xc}{$x_c(t)$}}
  \pscircleop[operation=times](0,0){otimes}
  \rput(0,1.25){\rnode{s}{$s(t)$}}
  \psblock[fillstyle=solid,fillcolor=purple!20](2.75,0){conv}{\parbox[c]{2\psunit}%
  {\centering Conversion from impulse train to discrete-time sequence}}
  \rput(5.5,0){\rnode{x}{$x[n]$}}

  %--- Connecting blocks ---
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{xc}{otimes}
  \ncline[nodesepA=.15]{s}{otimes}
  \ncline{otimes}{conv}   \naput{$x_s(t)$}
  \ncline[nodesepB=.15]{conv}{x}

  %--- Drawing the dashed frame ---
  \psframe[linecolor=purple,linestyle=dashed,style=Dash](-.75,-1.5)(4.5,1.5)
  \rput(1.875,1.75){C/D Converter}
\end{pspicture}
\end{LTXexample}



\newpage

%%------------------------
%%--- example ------------
%%------------------------

\Example{multido} Draw the direct-form II block diagram of a discrete-time LTI system with the following system function.
\[
H(z) = \frac{1 - z^{-1} + 2z^{-2} + 3z^{-3}}{1 + z^{-1} - 0.5 z^{-2} + 0.75 z^{-3}}
\]


\begin{LTXexample}
\begin{pspicture}[showgrid=true](-5,-6)(5,1)
  %--- Some settings ---
  \psset{style=Arrow}

  %--- Defining blocks ---
  \dotnode(0,0){dot1}
  \multido{\nA=1+1,\nB=2+1,\ryA=-.9+-1.8,\ryB=-1.8+-1.8}{3}{%
    \psblock(0,\ryA){D\nA}{$z^{-1}$}
    \dotnode(0,\ryB){dot\nB}}
  \multido{\nn=1+1,\ry=0+-1.8}{3}{\pscircleop(-2,\ry){oplusL\nn}}
  \multido{\nn=1+1,\ry=0+-1.8}{3}{\pscircleop(2,\ry){oplusR\nn}}
  \rput(-4,0){\rnode{x}{$x[n]$}}
  \rput(4,0){\rnode{y}{$y[n]$}}

  %--- Connecting blocks ---
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{x}{oplusL1}
  \ncline{oplusL1}{oplusR1}
  \ncline[nodesepB=.15]{oplusR1}{y}
  \nclist{ncline}{dot1,D1,D2,D3}
  \ncline{-}{D3}{dot4}
  \nclist{ncline}{oplusL3,oplusL2,oplusL1}
  \nclist{ncline}{oplusR3,oplusR2,oplusR1}
  \ncline{dot2}{oplusL2}   \nbput{$-1$}
  \ncline{dot2}{oplusR2}   \naput{$-1$}
  \ncline{dot3}{oplusL3}   \nbput{$0.5$}
  \ncline{dot3}{oplusR3}   \naput{$2$}
  \ncangle[angleA=180,angleB=-90]{dot4}{oplusL3}   \nbput[npos=.5]{$-0.75$}
  \ncangle[angleB=-90]{dot4}{oplusR3}   \naput[npos=.5]{$3$}
\end{pspicture}
\end{LTXexample}



\newpage

%%------------------------
%%--- example ------------
%%------------------------

\Example{pstricks-add} Draw the block diagram of an $M$-channel maximally decimated filter bank.


\begin{LTXexample}
\begin{pspicture}[showgrid=true](-6,-4)(6,.5)
  \psset{framesize=1.2 .65}
  \rput(-6,0){\rnode{x}{$x[n]$}}
  \rput(6,0){\rnode{y}{$y[n]$}}
  \dotnode(-4.5,0){dot1}
  \dotnode(-4.5,-1){dot2}
  \newcount\cnt

  %--- First and second channels ---
  \cnt=0
  \psforeach{\ry}{0,-1}{%
    \advance\cnt by 1
    \psfblock(-3,\ry){h\the\cnt}{$h_{\the\cnt}[n]$}
    \psdsampler(-1,\ry){ds\the\cnt}{$M$}
    \psusampler(1,\ry){us\the\cnt}{$M$}
    \psfblock(3,\ry){g\the\cnt}{$g_{\the\cnt}[n]$}
    \pscircleop(4.5,\ry){oplus\the\cnt}}

  %--- Placing dots ---
  \cnt=0
  \psforeach{\rx}{-4.5,-3,-1,1,3,4.5}{%
    \advance\cnt by 1
    \rput(\rx,-2){\rnode{dots\the\cnt}{\psldots[angle=90]}}}

  %--- M-th channel ---
  \psfblock(-3,-3){hM}{$h_M[n]$}
  \psdsampler(-1,-3){dsM}{$M$}
  \psusampler(1,-3){usM}{$M$}
  \psfblock(3,-3){gM}{$g_M[n]$}

  %--- Connecting blocks ---
  \psset{style=Arrow}
  \ncline[nodesepA=.15]{x}{h1}
  \nclist{ncline}{h1,ds1,us1,g1,oplus1}
  \ncline[nodesepB=.15]{oplus1}{y}
  \nclist{ncline}{dot2,h2,ds2,us2,g2,oplus2}
  \ncline[nodesepB=.35]{dot1}{dots1}
  \ncangle[nodesepA=.35,angleA=-90,angleB=180]{dots1}{hM}
  \nclist{ncline}{hM,dsM,usM,gM}
  \ncangle[nodesepB=.35,angleB=-90]{gM}{dots6}
  \ncline[nodesepA=.35]{dots6}{oplus2}
  \ncline{oplus2}{oplus1}
\end{pspicture}
\end{LTXexample}




\bibliographystyle{plain}
\bibliography{pstricks}


\end{document} 