
% corrections added 3-18-98
%     3-24-98

\documentstyle[e-e-ijmpa,twoside]{article}
\input psfig    \input epsfig


\renewcommand{\thefootnote}{\fnsymbol{footnote}}        %USE SYMBOLIC FOOTNOTE

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\def\beq{\begin{equation}}
\def\eq{\end{equation}}
\def\eeq{\end{equation}}
\def\bea{\begin{eqnarray}}
\def\ea{\end{eqnarray}}



\newcommand{\newc}{\newcommand}

\newc{\gsim}{\lower.7ex\hbox{$\;\stackrel{\textstyle>}{\sim}\;$}}
\newc{\lsim}{\lower.7ex\hbox{$\;\stackrel{\textstyle<}{\sim}\;$}}


\normalsize\textlineskip
%\pagestyle{empty}
%\setcounter{page}{1}

\title{\hfill  \\
\hfill {\normalsize SU-ITP 98-17} \\
%\hfill {\normalsize  \\
\hfill {\normalsize  \\
\vspace{.3in}
CP-ODD PHASES IN SLEPTON PAIR PRODUCTION\footnote{To appear
in the proceedings of the the Second International Workshop on Electron-Electron
Interactions at TeV Energies.}}

%\title{CP-ODD PHASES IN SLEPTON PAIR PRODUCTION\footnote{To appear
%in the proceedings of the the Second International Workshop on Electron-Electron
%Interactions at TeV Energies.}}
%%ffects of CP-odd phases on CP-even observables in slepton
%% pair production


\author{SCOTT THOMAS%
%\footnote{Work supported by the Department of Energy,
%Contract DE-AC00 76SF00000}
}

\address{Physics Department \\
Stanford University \\ Stanford, CA 94305}

%\author{SECOND AUTHOR}

%\address{Lawrence Berkeley National Lab       \\
%1 Cyclotron Road, Berkeley, CA  94720, USA}


\maketitle\abstracts{
The effects of CP-odd supersymmetric phases on slepton pair production
are considered.
It is shown that CP-even observables
in $e^+ e^-$ and $e^- e^-$ collisions, such as the total selectron cross section,
can depend on CP-odd supersymmetric phases through interference
between different tree level amplitudes.
Left handed selectron pair production in $e^- e^-$ collisions
is particularly sensitive to the
relative phase between the bino and wino masses.
This sensitivity is not limited to any kinematic regime and extends
over all of neutralino parameter space.
The relative phase between the bino and wino masses
is a renormalization group invariant at one-loop,
and as such provides a clean probe for operators which
violate gaugino universality at the messenger scale.
}

\setcounter{footnote}{0}
\renewcommand{\thefootnote}{\alph{footnote}}

\vspace*{1pt}\textlineskip

% ---------------------------------------------------------



\section{Introduction}

If nature is supersymmetric at the weak scale, a plethora
of superpartners are waiting to be discovered at future
colliders.
The spectrum and couplings of the superpartners
provide an indirect window to the messenger scale
for supersymmetry breaking.
Precision measurements of the superpartners
could therefore provide indirect information
about physics at scales well beyond those directly
accessible to colliders.
In this paper the possibility of measuring CP-odd
supersymmetric phases
in selectron pair production is considered.

%At the Next Linear Collider (NLC),

%This is true even of CP-even observables such as the
%differential cross section.


The CP-violating phases of the minimal supersymmetric standard
model (MSSM) are reviewed in the context of slepton pair production
in the next section.
The two basis independent combinations of phases
in the neutralino mass matrix are identified.
The possibility and advantages of measuring CP-odd phases with
 CP-even observables
through interference between different tree level amplitudes
is discussed in section 3.
It is shown that selectron pair production in $e^+ e^-$
or $e^- e^-$ collisions can depend on the CP-odd phases in the
neutralino mass matrix.
These processes are interesting in that effects of CP-odd
phases arise from interference between amplitudes in the
same kinematic channel, and so are not limited to any particular
region of phase space.
The relative sensitivity in different helicity modes to these phases
in the gaugino or Higgsino limit
is explained in section 3.1 in terms of the chiral properties of the
tree level amplitudes.
In section 3.2
the production of left handed sleptons in $e^- e^-$ collisions
is shown to be particularly sensitive to
the relative phase between the bino and wino masses.
This process is unique in that the phase sensitivity extends over all
of supersymmetry parameter space.
Other modes are suppressed outside the mixed gaugino-neutralino
region of parameter space.

The relative phase between the bino and wino masses is a renormalization
group invariant at one-loop, and therefore provides a clean
probe for violations of gaugino universality at the messenger scale.
%It is also not bounded by electric dipole measurements.
Precision measurements of left handed slepton production in the
$e^- e^-$ mode of the Next Linear Collider (NLC)
provide an interesting window to the messenger scale through
this phase.
This mode also provides probably the best opportunity to measure
any supersymmetric CP-odd phase at the NLC, and is complimentary
to low energy electric dipole measurements which are
are not directly sensitive to
the relative phase between the bino and wino masses.


\section{CP-Violating Phases in the MSSM}

\label{cpsec}

The CP-violating phases which arise in the MSSM beyond those
of the standard model appear in Lagrangian mass parameters.
The first appears in the superpotential
Dirac mass parameter $\mu$,
\beq
W = \mu H_u H_d
\label{muterm}
\eeq
Assuming squark and slepton
universality, the remaining phases appear in the
soft SUSY breaking mass parameters
$m_i$, $A$, and $m_{ud}^2$,
\beq
{\cal L} =
- {1 \over 2} m_{i} \lambda_i \lambda_i
- A \left(  h_u Q H_u \bar{u}
     - h_d Q H_d \bar{d}
     - h_e L H_d \bar{e} \right)
- m_{ud}^2 H_u H_d
~+~ h.c.
\label{softterms}
\eeq
where $\lambda_i$, $i=1,2,3$ are the gauginos, and $h_i$ are the Yukawa
coupling matrices.
%and the $A$ parameters in general carry
%arbitrary flavor structure.
%Only two of the four phases are physical CP violating phases
%\cite{dgh}.
Only a subset of all the phases in the Lagrangian parameters
(\ref{muterm}) and (\ref{softterms}) represent basis
independent combinations of physical CP-violating phases.
The simplest way to determine these basis independent combinations
is to notice that for
$\left\{ \mu, m_i, A, m_{ud}^2 \right\} \to 0$
the MSSM possesses additional $U(1)_{PQ}$ and $U(1)_R$ global
symmetries.\cite{charges}
The mass parameters can therefore be treated as background
spurions which spontaneously break the global symmetries.
A particular assignment of background charges to the mass parameters and fields
is listed in Table 1.
%\begin{table*}[htbp]
\begin{table}
\tcaption{ Background charges of spurions and fields.
%The ratio of Higgs expectation values is defined as
%$\tan \beta = \langle H_u / H_d^* \rangle$.
}
\leavevmode
\begin{center}
\label{chargetable}
\begin{tabular}{crr}
%
\hline
\hline
           & \multicolumn{1}{c}{$U(1)_{PQ}$}
           & \multicolumn{1}{c}{$U(1)_R$}   \\
\hline
$m_i        $ &  0   & $-$2  \\
$A$           &  0   & $-$2  \\
$m_{ud}^2$    & $-$2 &  0  \\
$\mu$         & $-$2 &  2  \\
$H_u$         &    1 &  0  \\
$H_d$         &    1 &  0  \\
%$\tan \beta$  &    2 &  0  \\
%$\sin 2\beta$ & XXX  & XXXX \\
%$\cos 2\beta$ & XXX  & XXXX \\
$Q \bar{u}$   & $-$1 &  2  \\
$Q \bar{d}$   & $-$1 &  2  \\
$L \bar{e}$   & $-$1 &  2  \\
\hline
\hline
%
\end{tabular}
\end{center}
%\end{table*}
\end{table}
%---------------------------------------------------------------------
%
Physical amplitudes must be invariant under the background symmetries.
The invariant combinations of mass parameters which can
have a non-trivial phase and appear
in physical amplitudes are
%$$
%\begin{array}{cc}
% (A_a h_a)^* m_i  &  A_a h_a \mu (m_{ud}^2)^* \\
%
%m_i \mu ( m_{ud}^2 )^*  & m_i^* m_j  \\
%\end{array}
%$$
\beq
A^* m_i  ~~~~ A \mu (m_{ud}^2)^*
\label{Aparameters}
\eq
\beq
m_i \mu ( m_{ud}^2 )^*  ~~~~ m_i^* m_j
\label{mparameters}
\eq
For selectron production %(relevant to $e^- e^-$ collisions)
the gluino
mass does not appear through two loops, and
effects suppressed by the electron Yukawa coupling are irrelevant.
Observable effects of non-zero phases can therefore only appear in
the parameters (\ref{mparameters}) with $i=1,2$.
Among these there are two linear combinations of phases which may
be taken to be
\beq
{\rm Arg}\left(m_1 \mu (m_{ud}^2)^* \right)
 ~~~~~
{\rm Arg} \left( m_1^* m_2 \right )
\label{phases}
\eq
At tree level these phases can affect selectron production only through
the neutralino mass matrix.


In the basis
$( -i \tilde{B}, -i \tilde{W}, \tilde{H}_d, \tilde{H}_u)$
the neutralino mass matrix is
$$
{\cal L} = -{ 1 \over 2} \lambda M \lambda ~+~h.c.
$$
\beq
M = \left(
\begin{array}{cccc}
m_{1}  & 0 & - (g^{\prime} / \sqrt{2} ) H_d^{0*} &
    ( g^{\prime} / \sqrt{2} ) H_u^{0*} \\
0 & m_2 &   (g / \sqrt{2} ) H_d^{0*} &
    - (g / \sqrt{2} ) H_u^{0*} \\
 - (g^{\prime} / \sqrt{2} ) H_d^{0*} &  ({g / \sqrt{2} }) H_d^{0*} &
 0 & -\mu \\
 ({g^{\prime} / \sqrt{2} }) H_u^{0*} &  - ({g / \sqrt{2} }) H_u^{0*} &
 -\mu & 0 \\
\end{array}   \right)
\label{Nmass}
\eq
$$ $$
where $H_u^0$ and $H_d^0$ are understood to be expectation values.
In a general basis all terms in the mass matrix are complex.
The off diagonal gauge interaction
terms which mix the gauginos and Higgsinos clearly
depend on the phase of the Higgs condensates.
The relative phase of the two Higgs condensates is not arbitrary
but determined dynamically by the Higgs potential.
The only tree level potential term which depends
on the relative phase is
\begin{eqnarray}
V &\supset&  - m_{ud}^2 H_u^0 H_d^0 ~+~ h.c.  \nonumber \\
  & & \nonumber \\
  &=& -|m_{ud}^2 H_u^0 H_d^0|  \cos \left[
     {\rm Arg}(m_{ud}^2) + {\rm Arg}(H_u H_d) \right]
\end{eqnarray}
%where $v_u = |H_u|$ and $v_d = |H_d|$.
In the ground state, with broken electroweak symmetry,
the phases of the Higgs condensates
dynamically adjust to
${\rm Arg}(m_{ud}^2) = -  {\rm Arg}(H_u H_d)$.
This corresponds to vanishing expectation value for the
pseudo-scalar Higgs boson $A^0$, and is generally not
modified by quantum corrections.
With this alignment, the complex phases which appear in the mass matrix
are those of $m_1, m_2, \mu$, and $m_{ud}^2$.
From the discussion of the basis independent combinations of phases
given above it is clear that a diagonalization of (\ref{Nmass})
can only depend on the two phases (\ref{phases}).
It is these two phases which can have an effect on slepton
pair production as discussed in the next section.
The rotation between mass and interaction eigenstates,
$\lambda = V \chi$, is in general complex for non-zero phases
(\ref{phases}).
It is always possible to work in a basis
in which the mass eigenvalues are real, although it is
sometimes convenient to leave the eigenvalues complex, as
is done in the next section.
It is however not possible in general to absorb all the
phase dependence in (\ref{Nmass}) onto the eigenvalues.

The phase ${\rm Arg}\left(m_1 \mu (m_{ud}^2)^* \right)$
only appears implicitly in the neutralino mass matrix in the
off diagonal mixing terms through the phase
of the Higgs condensates relative to the other parameters.
Its effects are therefore unsuppressed only in the mixed
region of parameter space,
$ \left| |\mu|^2 - |m_1|^2 \right| \lsim m_Z^2$,
in which gaugino-Higgsino mixings are important.
In contrast, the effects of the phase ${\rm Arg} \left( m_1^* m_2 \right )$
do not require mixing and are unsuppressed over all of the
neutralino parameter space.

The phases ${\rm Arg}(A^* m_1)$ and
${\rm Arg}\left(m_1 \mu (m_{ud}^2)^* \right)$ are bounded
by electric dipole moment measurements.
Over most of the SUSY parameter space these phases are typically bounded
to be less than $10^{-(1-3)}$.
Electric dipole measurements are however
not directly sensitive to
${\rm Arg} \left( m_1^* m_2 \right )$.
Mixing effects in the neutralino mass matrix do allow for
non-vanishing contributions to electric dipole moments,
but these are suppressed in the gaugino or Higgsino
limit.
This is in contrast to left handed slepton pair production in
$e^-e^-$ collisions discussed in section 3.2, which has an
unsuppressed sensitivity to ${\rm Arg} \left( m_1^* m_2 \right )$
in these regions of parameter space.
Measurements in this mode of slepton pair production are
therefore complimentary to electric dipole moment measurements.


The expectations for the magnitude of these CP-violating
phases of course depends on the model for the messenger and
supersymmetry breaking sectors.
Under the assumption of gaugino universality, such as would
occur in dilaton dominated supersymmetry breaking,
${\rm Arg} \left( m_1^* m_2 \right )$ would be expected to vanish.
However, even in this class of theories
violations of universality can in general induce
non-zero ${\rm Arg} \left( m_1^* m_2 \right )$.
For example, in the dilaton dominated ansatz, Planck scale slop
can induce a small relative phase between the bino and wino
masses.\cite{nima}
Since the gaugino mass renormalization group equations are
homogeneous at one-loop, the relative phases are preserved
at this order under renormalization group evolution.
Two loop renormalization group
modifications of ${\rm Arg} \left( m_1^* m_2 \right )$
from mixing with ${\rm Arg}(A^* m_i)$ and
${\rm Arg}(m_i^* m_3)$
%${\rm Arg}\left(m_1 \mu (m_{ud}^2)^* \right)$
typically amount to only a fraction of a percent
even for high scale supersymmetry breaking.
The sensitivity of slepton pair production to
${\rm Arg} \left( m_1^* m_2 \right )$ discussed below therefore provides
a clean probe for operators which violate gaugino universality
at the messenger scale.

In the CP-conserving case the phases (\ref{phases}) reduce to two
sign ambiguities in the neutralino mass matrix
\beq
{\rm sgn}( m_1 \mu m_{ud}^2 ) = \pm
 ~~~~~
{\rm sgn}( m_1 m_2) = \pm
\label{signs}
\eq
The first of these is often referred to in the literature
as ${\rm sgn}(\mu)$ with
some particular choice of basis.
The second sign ambiguity is often ignored, and $m_1$ and $m_2$
are tacitly assumed to have the same sign.
Even in the CP-conserving case, the signs
(\ref{signs}) can have very large effects on selectron pair production
as discussed below.


%$$
%M = \left(
%\begin{array}{cccc}
%m_{\tilde{B}}  & 0 & - m_Z \cos \beta \sin \theta_W  &
%     m_Z \sin \beta \sin \theta_W  \\
%0 & m_{\tilde{W}} &  m_Z \cos \beta \cos \theta_W &
%    - m_Z \sin \beta \cos \theta_W \\
% - m_Z \cos \beta \sin \theta_W  &  m_Z \cos \beta \cos \theta_W &
% m_Z \sin \beta \sin \theta_W  &  - m_Z \sin \beta \cos \theta_W &
% -\mu & 0 \\
%\end{array}   \right)
%$$


%Assuming for simplicity $m_{\tilde{e}_L} = m_{\tilde{e}_R}$
%\beq
%d_e \simeq - e { \alpha \over 24 \pi \cos^2 \theta_W}
%  { {\rm Im}\left[ m_e m_1 ( A_e^* + \mu \tan \beta) \right]
%  ~ f(m_1^2 / m_{\tilde{e}^2})
%\eq
%where $f(x)$ is a loop function.


%\beq
%\mu {d \over d \mu} m_i \supset { 2g_i^2 \over (16 \pi^2)^2}
% ~ C_i \lambda_t^* \lambda_t A_t
%\eq
%where $C_1 = 6$ and $C_2=4$.

%\beq
%\mu {d \over d \mu} {\rm Arg}(m_1^* m_2) \simeq
%  {8 g_u^2 \over 5 (16 \pi^2)^2} ~ \lambda_t^* \lambda_t
%  {\rm Arg} (A_t / m_{1/2})
%\eq


%$\delta {\rm Arg}(m_1^* m_2) \lsim 5 \times 10^{-3}
%  {\rm Arg}(A_t / m_{1/2})$.





\section{Slepton Pair Production}


Any physical process in general receives contributions from
multiple quantum amplitudes.
The probabilities then depend on both the magnitudes and
relative phases of the amplitudes.
Physical observables can depend on CP-odd phases
directly through the interference of
relative phases of the amplitudes.
This is true {\it even} for CP-even observables.
In this case, since a CP-odd phase
changes sign under CP or T, $\varphi \to - \varphi$,
the observable must depend on the CP or T even quantity
$\cos \varphi$.
Because of this, a CP-even measurements can only determine
a CP-odd phase up to a $Z_2$
ambiguity.\fnm{$\dagger$}\fnt{$\dagger$}{This $Z_2$ sign ambiguity
differs from the sign ambiguities of the
neutralino mass matrix in the CP-conserving case.
The latter sign ambiguities can be determined by CP-even
measurements as discussed below.}
If near destructive interference occurs between two
amplitudes for some values of CP-odd phases, then certain CP-even
observables can in fact be quite sensitive to these phase.
This is in fact the case for left handed selectron production
in $e^- e^-$ collisions as discussed in section %(\ref{eesec}).
3.2.


The general
scheme for determining CP-odd phases %from CP-even measurements
outlined here differs significantly from the standard treatment.
Almost all discussions of the effects of CP-violating phases
in the literature
rely on the fact that amplitudes which depend on CP-odd phases
are conjugated under CP or T.
However, CP-conserving final state rescaterings give an imaginary
contribution to the amplitude which does not change sign under CP or T.
A CP-odd observable then receives a contribution from interference
between the CP-violating and final state amplitudes, proportional
to $\sin \varphi$.
While such CP-odd observables provide a direct probe for CP-violation,
in the absence finite width enhancements for nearly degenerate states,
they are generally unobservably small for supersymmetric phenomena
at colliders since final state rescatterings only occur at one-loop.
In contrast, the CP-even observables described below are
sensitive to CP-odd phases at tree level.

Specializing to the case of charged slepton pair production, it is interesting
to determine which channels are sensitive to supersymmetric CP-violating
phases through interference between different amplitudes.
As discussed in the previous section, since Yukawa coupling
effects are generally irrelevant to production, the only
possible phase dependence arises in the neutralino mass matrix.
Slepton production at hadron colliders proceeds through
s-channel $\gamma^*$ and $Z^{*}$ exchange, and so is not
sensitive to neutralino phases.
The same applies to %$\tilde{\mu}+ \tilde{\mu}^-$ and
%$\tilde{\tau}+ \tilde{\tau}^-$.
smuon and stau final states at $e^+ e^-$ colliders.
Selectron final states at $e^+ e^-$ and $e^- e^-$ colliders
do in general, however, have contributions from
$t$- and $u$-channel neutralino amplitudes.

\newpage

\subsection{The Neutralino Functions}

In order to discuss selectron production at $e^+ e^-$ and
$e^- e^-$ colliders it is useful to work in the helicity
or equivalently chiral basis.
In this basis the right chiral initial states couple only
to neutralinos through the bino component,
while left chiral initial states couple through both
bino and wino components.
%Initial states with(without) a net chirality must scatter through
%$t$- and in some cases $u$- channel chirally violating(conserving)
%neutralino propagators.
The $t$- and $u$- channel neutralino propagators with these
chiral couplings can be written
in compact form in terms of the neutralino functions introduced
by Peskin.\cite{functions,peskin}
The couplings of the $i$-th neutralino mass eigenstate, $\chi_i$,
to left and right handed chiral states are
\bea
\sqrt{2} e V_{Ri} &=& \sqrt{2} e \left(
    {1 \over \cos \theta_w} V_{1i}  \right) \label{Rcoup}
       \\ & & \nonumber \\
\sqrt{2} e V_{Li} &=& \sqrt{2} e \left(
      { 1 \over 2 \cos \theta_w } V_{1i}
        + { 1 \over 2 \sin \theta_w} V_{2i}  \right)
                \label{Lcoup} \\ \nonumber
\ea
where $\lambda = V \chi$,
and the diagonal mass matrix is $V^t M V$.
The neutralino functions are then defined to be proportional
to the sum over mass eigenstates of the
%chirally conserving and chirally violating
neutralino propagators
weighted by the chiral couplings (\ref{Rcoup}) and (\ref{Lcoup})
\beq
{\cal N}_{ab}(t) = \sum_i V_{ai}^* {1 \over |m_i|^2 -t} V_{bi}
\eq
\beq
{\cal M}_{ab}(t) = \sum_i V_{ai}^* {m_i \over |m_i|^2 -t} V_{bi}^*
\eq
for $a,b=L,R$.
The functions ${\cal N}_{ab}(t)$ arise from chirally conserving
neutralino propagators, while ${\cal M}_{ab}(t)$ are from the
chirally violating propagators.
The contributions of the four mass eigenstates to the neutralino
functions in general have some non-trivial interference.
Peskin's dimensionless neutralino functions,
$N_{ab}(t)$ and $M_{ab}(t)$,
are
related to these by
$N_{ab}(t) = |m_1|^2 {\cal N}_{ab}(t)$ and
$M_{ab}(t) = |m_1| {\cal M}_{ab}(t)$.
%Note that
%

\begin{table}
\tcaption{Selectron production modes which are sensitive to neutralino
phases through interference. Summary of the chiral structure of the
neutralino propagator,
overall magnitude of the cross section, and sensitivity
of the cross section to neutralino phases
in the gaugino or Higgsino limit.
}
\leavevmode
\begin{center}
\label{summary}
\begin{tabular}{cccc}
%
\hline
\hline
        Mode & Neutralino Propagator &
               \multicolumn{2}{c}{Gaugino/Higgsino Limit} \\
                        &     &    Magnitude  & Phase Sensitivity \\
\hline
$e_R^+ e_R^- \to \tilde{e}_L^+ \tilde{e}_R^-$  &
     Chirally Violating & Suppressed  & Unsuppressed \\
$e_L^+ e_L^- \to \tilde{e}_R^+ \tilde{e}_L^-$  &
     Chirally Violating & Suppressed  & Unsuppressed \\
$e_R^- e_R^- \to \tilde{e}_R^- \tilde{e}_R^-$  &
     Chirally Violating & Unsuppressed  & Suppressed \\
$e_L^- e_R^- \to \tilde{e}_L^- \tilde{e}_R^-$  &
     Chirally Conserving & Suppressed  & Unsuppressed \\
$e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$  &
     Chirally Violating & Unsuppressed  & Unsuppressed \\
\hline
\hline
%
\end{tabular}
\end{center}
%\end{table*}
\end{table}
%---------------------------------------------------------------------
%


For non-zero phases (\ref{phases}) in the neutralino mass matrix,
the chirally violating propagator functions ${\cal M}_{ab}(t)$ are
complex in general.
The differential cross section for selectron production with
$e^+ e^-$ and $e^- e^-$
initial states with a net chirality therefore in general depends on the
neutralino phases via interference between the neutralino mass eigenstates.
The chirally conserving propagator function ${\cal N}_{LR}(t)$
also has non-trivial interference in general.
However Im${\cal N}_{aa}(t)=0$ as a result of hermiticity of
the chirally conserving bino-bino and wino-wino propagators.
This has the consequence that for $e^+ e^-$ collisions, modes with pairs of
right handed selectrons or pairs of left handed selectrons in the
final state do not depend on the phases
(\ref{phases}) through interference between different amplitudes.
The remaining modes which are sensitive to neutralino phases through
interference are listed in Table 2.
The differential cross sections for these modes are
\bea
{ d \sigma \over dt}
  (e^+_R e^-_R \rightarrow \tilde{e}^+_L \tilde{e}^-_R) &=&
  3 R ~ \left| {\cal M}_{LR}(t) \right|^2 \\  & &  \nonumber \\
{ d \sigma \over dt}
  (e^+_L e^-_L \rightarrow \tilde{e}^+_R \tilde{e}^-_L) &=&
  3 R ~ \left| {\cal M}_{LR}(t) \right|^2  \\ & & \nonumber \\
{ d \sigma \over dt}
  (e^-_R e^-_R \rightarrow \tilde{e}^-_R \tilde{e}^-_R) &=&
{3 \over 2} R ~ \left| {\cal M}_{RR}(t) +  {\cal M}_{RR}(u)
  \right|^2 \\ & & \nonumber \\
{ d \sigma \over dt}
  (e^-_L e^-_L \rightarrow \tilde{e}^-_L \tilde{e}^-_L) &=&
{3 \over 2} R ~ \left| {\cal M}_{LL}(t) +  {\cal M}_{LL}(u)
  \right|^2  \\ & & \nonumber \\
{ d \sigma \over dt}
  (e^-_L e^-_R \rightarrow \tilde{e}^-_L \tilde{e}^-_R) &=&
3 R \left[ { (t-m_{\tilde{e}_L}^2) (m_{\tilde{e}_R}^2 -t) \over s}
         -t   \right]
~ \left| {\cal N}_{LR}(t)
  \right|^2 \\ %& & \nonumber \\
  \nonumber
\ea
where $R = \sigma(e^+ e^- \rightarrow \mu^+ \mu^-)
= 4 \pi \alpha^2 / 3s$, and the angular
integrations are over $-1 \leq \cos \theta \leq 1$.
The first four of these are s-wave near threshold, while
the last one is p-wave.



An important feature of the
modes listed above is that the phase dependent interference
takes place between different neutralino mass eigenstates
in the {\it same} channel.
Because the interference is between amplitudes in the same
kinematic channel, the effects are not limited to a particular
kinematic region of phase space, and are not suppressed
for production well above threshold.
This is in contrast to analogous chargino and neutralino
processes mentioned in the conclusions.


The magnitudes and phases of the neutralino eigenstate
contributions to the neutralino functions are determined
by diagonalization of the neutralino mass matrix (\ref{Nmass}).
In order to understand the physical content of this
diagonalization it is instructive to consider the mostly gaugino
or mostly Higgsino limit.
In this limit the physical mass eigenstates are mostly
the gaugino and Higgsino eigenstates with small admixtures
of the other states induced by the off diagonal mixing terms
in (\ref{Nmass}).
This limit is reached if the level splitting between the
gauginos and Higgsinos is large compared with the off diagonal
mixing terms,
$ \left| |\mu|^2 - |m_1|^2 \right| \gsim m_Z^2$.
This limit holds regardless of whether the lightest neutralino
is gaugino or Higgsino like, subject to the small mixing
criterion above.

In the gaugino or Higgsino limit the %chirally conserving and violating
bino-wino propagators only arise through mixing
with intermediate Higgsino states.
The bino-wino propagators projected onto the physical mass
eigenstates are therefore
suppressed by ${\cal O}( m_Z^2 / ( \mu^2 - m_i^2) )$
as compared with the bino-bino or wino-wino propagators.
This has the effect that all
the $LR$ neutralino functions are suppressed in magnitude
by a similar amount compared with the $RR$ or $LL$ functions.
These functions, although reduced in magnitude,
are sensitive to the phases in the neutralino mass matrix.
%mixing term phase
%${\rm Arg}\left(m_1 \mu (m_{ud}^2)^* \right)$.

The chirally violating neutralino function
${\cal M}_{LL}(t)$ receives contributions
from both bino-bino and wino-wino
propagators.
In the gaugino or Higgsino limit these propagators projected
onto the physical mass eigenstates are dominated by the mostly
bino and mostly wino states.
Interference between these two amplitudes is therefore
sensitive in this limit to the relative phase between the bino
and wino masses,
${\rm Arg}(m_1^* m_2)$.
However, the chirally violating neutralino function
${\cal N}_{RR}(t)$
is dominated only the mostly bino state
and can not have a large interference with the other states
in this limit.
So while the magnitude of this function is
not suppressed in this limit, its sensitivity to phases is
suppressed.

The (non)suppressions of the overall rate and phase sensitivity in the
gaugino or Higgsino limit for the
$e^+e^-$ and $e^-e^-$ modes discussed above are summarized in Table 2.
The relative suppression of some of the phase sensitive
modes is best illustrated
by considering the pure gaugino or Higgsino limit, in which
case the relevant neutralino functions reduce to
\bea
{\cal M}_{RR}(t) &=&  {1 \over \cos^2 \theta_w}
  {m_1 \over |m_1|^2 -t} \\ & & \nonumber \\
{\cal M}_{LL}(t) &=& {1 \over 4 \sin^2 \theta_w}
 \left( { m_1 \tan^2 \theta_w \over |m_1|^2 -t} +
 { m_2 \over |m_2|^2 -t} \right ) \\ & & \nonumber \\
{\cal M}_{LR}(t)&=&0 \\ & & \nonumber \\
{\cal N}_{LR}(t)&=&0 \\ \nonumber
\ea
Since there is no bino-wino mixing in this limit,
the $LR$ functions vanish.
The chirally violating function ${\cal M}_{LL}(t)$ is given
by pure bino and wino exchange in this limit, and as such the interference
term in $|{\cal M}_{LL}(t)|^2$ depends on
${\rm Arg}(m_1^* m_2)$.
The chirally violating function ${\cal M}_{LL}(t)$ is given by
pure bino exchange in this limit, and
$|{\cal M}_{RR}(t)|^2$ therefore does not depend on either phase in the
neutralino mass matrix.

In the mixed region of neutralino parameter space the differential
cross sections for all the modes
listed in Table 2 depend in a non-trivial way
on the phases (\ref{phases}).
However, it is important to note that even in the gaugino
or Higgsino limit the suppressed modes still have non-trivial
dependence on the phases.
It is in fact these suppressed modes which would help to
determine the $\mu$ parameter in the gaugino limit if the
heavier neutralino states are kinematically inaccessible.
This makes clear that any precision fit of neutralino parameters
to data must include the phases (\ref{phases}).
Even if CP-conservation is assumed the sign ambiguities (\ref{signs})
must be included a fit.


\subsection{Phase Dependence in $e^-e^-$ Collisions}

\label{eesec}

The only mode of selectron pair production in
which both the rate and phase sensitivities are unsuppressed
in the gaugino or Higgsino limit
is $e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$.
It is therefore worthwhile to consider this process in the
pure gaugino or Higgsino limit.
The magnitude squared of the neutralino function for this
case is
$$
\left| {\cal M}_{LL}(t) \right|^2=
  {1 \over 16 \sin^4 \theta_w} \left(
{ |m_1|^2 \tan^4 \theta_w \over (|m_1|^2-t)^2 } +
{ 2 |m_1||m_2| \tan^2 \theta_w \cos \left( {\rm Arg}(m_1^*m_2) \right)
     \over (|m_1|^2-t) (|m_2|^2-t) }   \right.
$$
\beq
 \left.
 + { |m_2|^2 \over (|m_2|^2-t)^2 }
 \right)  ~~~~~~~~~\\ \nonumber
\eq
The bino-wino interference term depends on
$\cos \left( {\rm Arg}(m_1^*m_2) \right)$.
Note that maximal constructive(destructive) interference
is obtained for ${\rm Arg}(m_1^* m_2)=0,\pi$
or in the CP-conserving case
${\rm sgn}(m_1 m_2) = +(-)$.
%
\begin{figure}[htbp]
%\vspace*{13pt}
%\centerline{\vbox{\hrule width 5cm height0.001pt}}
\centerline{
\epsfig{figure=eephasea.ps,height=6.9cm,width=10.0cm,angle=0}}
%\vspace*{1.4truein}             %ORIGINAL SIZE=1.6TRUEIN x 100% - 0.2TRUEIN
%\centerline{\vbox{\hrule width 5cm height0.001pt}}
%\vspace*{13pt}
\fcaption{Total cross sections for
$e_R^- e_R^- \to \tilde{e}_R^- \tilde{e}_R^-$  and
$e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$ in the
pure gaugino or Higgsino limit as a function of ${\rm Arg}(m_1^* m_2)$.
The parameters are
$\sqrt{s} = 500$ GeV, $|m_1| = 100$ GeV, $|m_2|= 200$ GeV,
$m_{\tilde{e}_R} = 130$ GeV, and
$m_{\tilde{e}_L} = 180$ GeV.
For reference $R \simeq 400$ fb at this center of mass energy.
}
\label{totalsig}
\end{figure}
%
The total cross sections
$\sigma(e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-)$ and
$\sigma(e_R^- e_R^- \to \tilde{e}_R^- \tilde{e}_R^-)$
are shown in Fig. \ref{totalsig}~as a function of ${\rm Arg}(m_1^* m_2)$
with a typical set of parameters at the NLC.
The differential cross sections for the same set of parameters
are shown in Fig. \ref{difsiga}.
\begin{figure}[htbp]
%\vspace*{13pt}
%\centerline{\vbox{\hrule width 5cm height0.001pt}}
\centerline{
\epsfig{figure=eeanga.ps,height=6.9cm,width=10.4cm,angle=0}}
%\vspace*{1.4truein}             %ORIGINAL SIZE=1.6TRUEIN x 100% - 0.2TRUEIN
%\centerline{\vbox{\hrule width 5cm height0.001pt}}
%\vspace*{13pt}
\fcaption{Differential cross sections for
$e_R^- e_R^- \to \tilde{e}_R^- \tilde{e}_R^-$  and
$e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$ in the
pure gaugino or Higgsino limit for ${\rm Arg}(m_1^* m_2)=0,\pi$.
The parameters are the same those in fig. \ref{totalsig}.
}
\label{difsiga}
\end{figure}
For constructive interference between bino and wino exchange
in $e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$
the differential cross section is a monotonic
function of $\cos \theta$ in the forward hemisphere.
Any non-monotonic deviation implies
${\rm Arg}(m_1^*m_2) \neq 0$.
The sensitivity to ${\rm Arg}(m_1^*m_2)$
is very pronounced in the forward direction.

The large forward peak in both
$e_R^- e_R^- \to \tilde{e}_R^- \tilde{e}_R^-$  and
$e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$ is less
pronounced for scattering near threshold, and with
heavier neutralinos.
The differential cross sections for slightly more massive
states are shown in Fig. \ref{difsigb}.
For this set of parameters the
$e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$ distribution
happens to be nearly flat in $\cos \theta$ for destructive interference.
%
\begin{figure}[htbp]
%\vspace*{13pt}
%\centerline{\vbox{\hrule width 5cm height0.001pt}}
\centerline{
\epsfig{figure=eeangb.ps,height=6.9cm,width=10.4cm,angle=0}}
%\vspace*{1.4truein}             %ORIGINAL SIZE=1.6TRUEIN x 100% - 0.2TRUEIN
%\centerline{\vbox{\hrule width 5cm height0.001pt}}
%\vspace*{13pt}
\fcaption{Differential cross sections for
$e_R^- e_R^- \to \tilde{e}_R^- \tilde{e}_R^-$  and
$e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$ in the
pure gaugino or Higgsino limit for ${\rm Arg}(m_1^* m_2)=0,\pi$.
The parameters are
$\sqrt{s} = 500$ GeV, $|m_1| = 150$ GeV, $|m_2|= 300$ GeV,
$m_{\tilde{e}_R} = 170$ GeV, and
$m_{\tilde{e}_L} = 210$ GeV.}
\label{difsigb}
\end{figure}


The process $e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$
is apparently quite sensitive to the phase
${\rm Arg}(m_1^*m_2)$.
This fortuitous sensitivity is the result of a numerical coincidence which
allows near complete
constructive or destructive interference over much of the kinematic
phase space.
Well above threshold the total cross section is dominated
by small $t$ corresponding to scattering
in the nearly forward direction.
For $t=0$
\beq
\left| {{\cal M}}_{LL}(0) \right|^2=
  {1 \over 16 \sin^4 \theta_w} \left(
 \tan^4 \theta_w +
 {2 |m_1| \over |m_2|} \tan^2 \theta_w
       \cos\left( {\rm Arg}(m_1^*m_2) \right)  +
{ |m_1|^2 \over |m_2|^2 }
\right)
\eq
The interference between bino and wino exchange can
be nearly completely destructive
for ${\rm Arg}(m_1^*m_2) = \pi$
if $\tan^2 \theta_w \sim |m_1 / m_2|$.
This is in fact the case for the gaugino unification value
of $|m_1 / m_2| \simeq {1 \over 2}$.
In the pure gaugino limit, assuming gaugino unification,
$|{\cal M}_{LL}(0)|^2 \simeq$ 0.82(0.04)
for ${\rm Arg}(m_1^*m_2) = 0(\pi)$.


Away from the pure gaugino or pure Higgsino limit
these results are modified slightly, but the qualitative
features are not changed at lowest order.
The overall rates for $e_R^- e_R^- \to \tilde{e}_R^- \tilde{e}_R^-$  and
$e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$ are modified
at ${\cal O}(m_Z^2 / (\mu^2 - m_i^2))$ by mixing with the
Higgsino states.
The phase ${\rm Arg}(m_1^*m_2)$, interpreted as the relative
phase of the masses of the mostly bino and mostly wino
states, is also renormalized at ${\cal O}(m_Z^2 / (\mu^2 - m_i^2))$
by ${\rm Arg}\left(m_1 \mu (m_{ud}^2)^* \right)$ through mixing
with the Higgsino states.
An upper limit on this modification can however be
obtained from the electron electric dipole moment experimental bound.
Finally, the rate for $e_L^- e_R^- \to \tilde{e}_L^- \tilde{e}_R^-$
is down by ${\cal O}(m_Z^4 / (\mu^2 - m_i^2)^2)$
compared with the unsuppressed modes.

A precision measurement of ${\rm Arg}(m_1^*m_2)$ at the NLC
in the $e^- e^-$ mode must contend with uncertainties
in the kinematic masses, beam polarization,
supersymmetry parameters responsible for
mixing with the Higgsino states, and detector monte carlo uncertainties
in both signal and background efficiencies with cuts.
For typical parameters at the NLC it is estimated that
even from a total cross section measurement,
${\rm Arg}(m_1^*m_2)$ could be determined to a precision of
a few percent in a year of running.\cite{big}
A slightly better measurement could be obtained
from observables which are optimized to take account of angular
dependences.
As discussed in section 2 this phase is
a clean probe of gaugino universality violations at
the messenger scale.
So the mode $e_L^- e_L^- \to \tilde{e}_L^- \tilde{e}_L^-$
at the NLC provides an interesting window to the messenger scale
for supersymmetry breaking.


%\subsection{Experimental Sensitivity}
%to in $e^- e^-$
%Collisions}



\section{Conclusions}

CP-odd phases in the neutralino mass matrix have an effect
on CP-even observables associated with
selectron production in $e^+ e^-$ and $e^- e^-$ collisions
through interference between different tree level amplitudes
in the same kinematic channel.
In the gaugino or Higgsino limit, left handed slepton
production in $e^- e^-$ collisions is very sensitive to the
relative phase between the bino and wino masses.
Since this phase is not modified at a significant
level by renormalization group evolution, this process
provides a clean probe for gaugino non-universality
at the messenger scale.
This is in contrast to small violations of gaugino
universality in the magnitudes of the gaugino masses 
which can receive significant modifications from two-loop
renormalization group evolution. 


In addition to the differential cross section for longitudinally
polarized beams, it is possible to form other
CP-even observables which are sensitive to interference between
different amplitudes
with transversely polarized beams.
These are however suppressed outside the mixed
gaugino-Higgsino regions of parameter space, and
require interference between different kinematic
channels.\cite{transverse}
Other possibilities for observing CP-odd phases
in CP-even observables from interference effects are for
$\chi_i^0 \chi_j^0$, $i \neq j$ and
$\chi_1^{\pm} \chi_2^{\mp}$ final states.
These however are suppressed outside the mixed gaugino-Higgsino
regions of parameter space and require a mass insertion in the final
state so are additionally suppressed well above
threshold.\cite{transverse}
Left handed selectron production in $e^- e^-$
collisions therefore provides probably
the best opportunity to measure a CP-odd phase at the NLC,
and is complimentary to low energy electric dipole measurements.


\nonumsection{Acknowledgements}
\noindent
Estimates of the experimental sensitivity to CP-odd phases at the NLC
were done in collaboration with J. Feng.
I would also like to thank H. Haber and S. Martin for useful discussions,
and C. Heusch and N. Rogers for organizing the
Second International Workshop on Electron-Electron
Interactions at TeV Energies.
This work was partially supported by Stanford University through
a Fredrick E. Terman Fellowship.


\nonumsection{References}
%\noindent
%References are to be listed in the order cited in the text. Use
%the style shown in the following examples. For journal names,
%use the standard abbreviations. Typeset references in 9 pt Times
%Roman.

\begin{thebibliography}{000}

\bibitem{charges} S. Dimopoulos and S. Thomas,
 {\bibit Nucl. Phys. B} {\bf 465}
(1996) 23.

%\bibitem{twoloop} S. Martin and M. Vaughn, 
%{\bibit Phys. Lett. B} {\bf 318} (1993) 331.

\bibitem{nima} N. Arkani-Hamed, {\bibit private communication}.

\bibitem{functions} M. Peskin, in {\bibit Proceedings of the Third
Workshop on Physics and Experiments with Linear Colliders}, ed.
A. Miyamoto, {\bibit et al.} (World
Scientific, Singapore, 1996) p. 248.

\bibitem{peskin} M. Peskin,  {\bibit these proceedings}.

\bibitem{big} J. Feng and S. Thomas {\bibit to appear}.


\bibitem{transverse} S. Thomas, {\bibit unpublished}.


%\bibitem{1}
%H. Haber, C. Kane and T. Sterling, {\bibit Nucl. Phys.} (1979)
%493.

%\bibitem{2}
%J. D. Bjorken, in {\bibit Lecture Notes on Current-Induced
%Reactions}, ed. J. Komer {\bibit et al.} (Springer, Heidelberg,
%1975).

%\bibitem{3}
%A. Bohr and B. R. Mottelson, {\bibit Nuclear Structure}
%(Benjamin, New York, 1969), Vol. 1, pp. 100--102.

%\bibitem{4}
%R. C. Webb, PhD thesis, Princeton University, 1972.

%\bibitem{5}
%T. Toimela, Helsinki Research Institute for Theoretical Physics,
%Report No. HU-TFT-82-37, 1982 (unpublished).
%\end{thebibliography}

\end{thebibliography}






\end{document}



\appendix


$$
{\cal L} = i \lambda^*  \left( 1 +  \delta Z \right)
\bar{\sigma}^{\mu} \partial_{\mu} \lambda
 - {1 \over 2} \left[ \lambda
  \left( m + \delta m  \right)
   \lambda  + h.c.
    \right]
$$
where $\lambda = \lambda_i$,
$m = {\rm diag}(m_1, m_2)$,
and $\delta Z_{ij}$ and $\delta m_{ij}$ are arbitrary $2 \times 2$
matrices induced by mixing.


$$
{\rm Det}(1 + \delta Z) \simeq 1 + \delta Z_{11} + \delta Z_{22}
  + {\cal O}( \delta Z_{ij}^2)
$$

Give expressions for m's and Z's




wave function renormalization
$$
\chi_i = \lambda_i (1 + \delta Z_{ii})^{1/2}
  \simeq 1 + {1 \over 2} \delta Z_{ii}
$$


$$
{\cal L} = i \chi_i^{*} \bar{\sigma}^{\mu} \partial_{\mu} \chi_i
  - {1 \over 2} \left( m_{\chi_i} \chi_i \chi_i + h.c. \right)
$$
with
$$
m_{\chi_1} = m_1 - { m_{Z^0}^2 \sin^2 \theta_W (m_1 + \mu \sin 2 \beta)
  \over |\mu|^2 - |m_1|^2 }
$$
$$
m_{\chi_2} = m_2 - { m_{W^{\pm}}^2 (m_2 + \mu \sin 2 \beta)
  \over |\mu|^2 - |m_2|^2 }
$$

couplings are modified ..

$$
g_{\chi_1} =  g_1 \left( 1 + ...\right)
$$
$$
g_{\chi_2} = g_2 \left( 1 + ...\right)
$$


%
\vspace*{-0.5cm}
\nn
\begin{figure}[htbp]
\centerline{
\epsfig{figure=fig4.eps,height=15.5cm,width=14cm,angle=0}}
\vspace*{-4.5cm}
\fcaption{ Total cross sections for leptoquark pair-production at
  fixed center-of-mass energies as a function of the leptoquark mass
  $M$ assuming vanishing Yukawa couplings and including corrections
  due to beamstrahlung and ISR from the analysis of RSS. Here S or V
  refer to the LQ spin, the upper(lower) index is the corresponding
  electric charge(weak isospin).}
\label{figsigtot}
\end{figure}
\vspace*{0.4mm}
%



\begin{figure}[htbp]
\vspace*{13pt}
\centerline{\vbox{\hrule width 5cm height0.001pt}}
\vspace*{1.4truein}             %ORIGINAL SIZE=1.6TRUEIN x 100% - 0.2TRUEIN
\centerline{\vbox{\hrule width 5cm height0.001pt}}
\vspace*{13pt}
\fcaption{Labeled tree {\footnotesize\it T}.}
\end{figure}





%
\begin{table*}[htbp]
\tcaption{ Cross sections for the three scalar
leptoquark pair decay channels in fb at
a 500 GeV NLC assuming complete leptoquark multiplets with a common mass of
200 GeV. The polarization asymmetry in the $\ell \ell jj$ channel is also
given. In all cases $\tilde \lambda \ll 1$ is assumed.}
\leavevmode
\begin{center}
\label{lqnlc}
\begin{tabular}{lcccc}
%
\hline
\hline
Leptoquark&$\ell \ell jj$&$\ell\nu jj$&$\nu\nu jj$&$A^{LR}_{\ell \ell jj}$ \\
\hline

$S_{1L}$        & 1.88 & 3.77 & 1.88 & -0.618 \\
$S_{1R}$        & 7.53 & 0.0  & 0.0  & -0.618 \\
$\widetilde S_{1R}$ &120.4 & 0.0  & 0.0  & -0.618 \\
$S_{3L}$        &192.2 & 3.77 & 1.88 &  0.931 \\
$R_{2L}$        &181.0 & 0.0  & 80.4 &  0.196 \\
$R_{2R}$        &261.4 & 0.0  & 0.0  & -0.141 \\
$\widetilde R_{2L}$ & 47.6 & 0.0  & 33.2 &  0.946 \\
\hline
\hline
%
\end{tabular}
\end{center}
\end{table*}
%




The terms which contribute to the neutralino mass matrix
are
$$
{\cal L}  = - {g^{\prime} \over \sqrt{2} } \left(
  H_u^{0*} \tilde{B} \tilde{H}_u - H_d^{0*} \tilde{B} \tilde{H}_d
     \right)
 - {g \over \sqrt{2} } \left(
  - H_u^{0*} \tilde{W} \tilde{H}_u + H_d^{0*} \tilde{W} \tilde{H}_d
     \right)
$$
$$
- {1 \over 2} m_{\tilde{B}} \tilde{B} \tilde{B}
- {1 \over 2} m_{\tilde{W}} \tilde{W} \tilde{W}
+ \mu \tilde{H}_u^0 \tilde{H}_d^0 ~+~h.c.
$$

%Scott, here is epsfig.sty.  --Nora

%----------------------------------------------
\def\fileversion{v1.20}%
\def\filedate{26.1.94}%
%%%
%%% from a suggestion by eijkhout@csrd.uiuc.edu to allow
%%% loading as a style file:
\edef\epsfigRestoreAt{\catcode`@=\number\catcode`@\relax}%
\catcode`\@=11\relax
\ifx\undefined\@makeother                % -pks-
\def\@makeother#1{\catcode`#1=12\relax}  % -pks-
\fi                                      % -pks-
\immediate\write16{Document style option `epsfig', \fileversion\space
<\filedate> (edited by SPQR)}%
%%%--------------------------------------------------------------------
%%% psfig merged with EPSF = epsfig Release 1
%%% 1.0 November 91
%%% 1.1 Dec 91  fixed some bugs
%%% 1.2 Jan 92  fixed bug that it never stopped reading PS file until
%%%             it reached the end! merged in changes from psfig1.8
%%%             (plain TeX definition of \fbox, new code for rotation)
%%% 1.3 Jan 92  separated out \special code so that dvitops can be
%%%             supported. use \psfigdriver{dvitops}%
%%% 1.4 Jan 92  fixed dvitops. need to input psfig at different point
%%%      in dvips from dvitops. define \psfig@start and \psfig@end to cope
%%%      with this
%%% 1.5 Jan 92  force use of psfig method if using dvitops
%%% 1.6 May 92 fixed bugs
%%% 1.7 Sep 92 added support for emtex, sort of. reads a .bb file
%%%            and imports .pcx file. Boolean flag \epsfigdos used
%%%             to indicate that we cannot have more than one . in the
%%%             suffix (ie we will look at file.bb not file.eps.bb)
%%%
%%% 1.8 Sep 92 added support for OzTeX; fixed bugs in dvips support
%%% (including clipping to bounding box); removed use of dimen100.
%%%
%%% 1.9 Dec 92 cleaned up documentation again
%%% 1.10 Mar 93 cleaned up for plain TeX
%%% 1.11 Mar 93 merged in changes by Peter Galko (supplied by CERN) for
%%%             use with Textures
%%% 1.12 Apr 93 actually *tested* the Textures additions, and so rewrote
%%%            from scratch (borrowed an idea from psbox)
%%% 1.13 May 93 allow for file names with _ or $ in them in \psdraft, and
%%%             fix problem that occurred with missing BoundingBox
%%% 1.14 May 93 allow for .z suffix
%%% 1.15 July 93 allow for .gz suffix
%%%              use \leavevmode as appropriate
%%%              fix plain \TeX mode 
%%%             (fixes from Peter-Klaus Schilling <R02SCH@DSYIBM.DESY.DE>)
%%% 1.16 August 93 [peta@mcrcim.mcgill.edu (Peter Whaite)]
%%%        -- Implement Perl scripts to do compressed file inclusion and bb
%%%           generation. 
%%%        -- Add \pscompress.
%%%        -- Tidy up comments.
%%% 1.17 September 93 SPQR
%%%     better code for literal name printing
%%%     allowed for spaces around , and =
%%% 1.18 17.9.93
%%%   updates to epsbb and epsfig from Peter W
%%% 1.19 14.11.93
%%%   mistaken placement of calculation of EPS@Height resulted in errors
%%% 1.20 defaults to no compression
%--------------------------------------------------------
%%%
%%% code rearranged by Sebastian Rahtz (spqr@uk.ac.york.minster)
%%% from work by
%%% Trevor Darrell; Tom Rokicki; Daniel Smith; H. Payne, Robert Russell
%%%
%%% This is a version of Darrell's `psfig' macros which are designed
%%% to be used with dvips or dvitops, and the `epsf' macros (these are
%%% automaticaly included by the style file). I did this because the
%%% \special commands used by `epsf' appear to be more robust and
%%% portable than the raw \specials used by `psfig', but I preferred
%%% the psfig interface. This system preserves the psfig interface,
%%% but mainly uses epsf macros to carry out the job. The user
%%% interface is identical to \psfig, but you just use \epsfig
%%% instead. Rotation uses the original psfig macros: I could not work
%%% out how to do rotation with the epsf macros.
%%%
%%% The same applies to `rheight' and `rwidth'
%%%
%%% If you *really* want old psfig behaviour regardless, use \psfig. It is
%%% still there. Some of the features have gone, however. \figurepath
%%% seemed redundant, since it could be controlled by the TEXINPUTS
%%% variable anyway.
%%%
%%% As an added feature, if FILE cannot be found, a file called FILE.bb
%%% is searched for. This should simply contain a %%BoundingBox line. A perl
%%% script "epsbb" is provided to generate these automatically.  It is
%%% assumed that if this exists, then the actual postscript is in UNIX
%%% compress format in FILE.Z or in GNU gzip format in FILE.gz or FILE.z.
%%%
%%% The macros then read the BB from FILE.bb, but insert "`epsfig FILE`" in
%%% the  output for dvips to interpret (don't worry, it knows about this).
%%% "Epsfig" is another perl script which  searches the TEXINPUTS path for
%%% FILE or FILE.{gz,z,Z}.
%%%
%%% As an added bonus if you say \pscompress the -c switch will be passed to
%%% epsfig, causing automatic FILE.bb generation and compression the first
%%% time dvips is run.  Files in the system directories will NOT be
%%% compressed.
%%% If you are *not* on a Unix system and use this, deliberately or by
%%% mischance, you will have problems!
%%%
%%% This file can be included in a dumped format, or used as a LaTeX
%%% style file, or used in plain TeX. It does not load itself twice (I hope)
%%%
%--------------------------------------------------------------------
%--------------------------------------------------------------------
%%% previous notes. this copy of psfig.tex inherited from versions 1.8
%--------------------------------------------------------------------
%%% All psfig/tex software, documentation, and related files
%%% in this distribution of psfig/tex are
%%% Copyright 1987, 1988, 1991 Trevor J. Darrell
%
%%% Permission is granted for use and non-profit distribution of psfig/tex
%%% providing that this notice be clearly maintained. The right to
%%% distribute any portion of psfig/tex for profit or as part of any commercial
%%% product is specifically reserved for the author(s) of that portion.
%%%
%%% Thanks to Greg Hager (GDH) and Ned Batchelder for their contributions
%%% to this project.
%%%--------------------------------------------------------------------------
%%% GDH 7/26/87 -- changed so that it first looks in the local directory,
%%% then in a specified global directory for the ps file.
%%% SPQR 12/91 removed that last change. it follows TEXINPUTS anyway
%%% RPR 6/25/91 -- changed so that it defaults to user-supplied name if
%%% boundingbox info is specified, assuming graphic will be created by
%%% print time.
%%% SPQR 12/91 removed that last change. use LaTeX error message instead
%%% SPQR 12/91 -- `no file found' produces LaTeX error message.
%%%                If you recover from that the file name is set in draft
%%%                mode in place of the file.
%%%
%%% Modified by J. Daniel Smith on 9 October 1990 to accept the
%%% %%BoundingBox: comment with or without a space after the colon.  Stole
%%% file reading code from Tom Rokicki's EPSF.TEX file (see below).
%%% --- SPQR 12.91 removed most of this to use epsf directly
%%%
%%% More modifications by J. Daniel Smith on 29 March 1991 to allow the
%%% the included PostScript figure to be rotated.  The amount of
%%% rotation is specified by the "angle=" parameter of the \epsfig command.
%%%
%%% Modified by Robert Russell on June 25, 1991 to allow users to specify
%%% .ps filenames which don't yet exist, provided they explicitly provide
%%% boundingbox information via the \epsfig command. Note: This will only work
%%% if the "file=" parameter follows all four "bb???=" parameters in the
%%% command. This is due to the order in which psfig interprets these params.
%%% ---- SPQR 12.91 removed all this
%%%
%%% 3 Jul 1991  JDS     check if file already read in once
%%%
%-----------------------------USAGE---------------------------------------
% From: gvr@cs.brown.edu (George V. Reilly)
%
% \psdraft      draws an outline box, but doesn't include the figure
%               in the DVI file.  Useful for previewing.
%
% \psfull       includes the figure in the DVI file (default).
%
% \psscalefirst width= or height= specifies the size of the figure
%               before rotation.
% \psrotatefirst (default) width= or height= specifies the size of the
%                figure after rotation.  Asymetric figures will
%                appear to shrink.
%
% usage: \epsfig{file=, figure=, height=, width=,
%                       bbllx=, bblly=, bburx=, bbury=,
%                       rheight=, rwidth=, clip=, angle=, silent=}%
%
%       "file" is the filename.  If no path name is specified and the
%               file is not found in the current directory,
%               it will be looked for in directory \psfigurepath.
%       "figure" is a synonym for "file".
%       By default, the width and height of the figure are taken from
%               the BoundingBox of the figure.
%       If "width" is specified, the figure is scaled so that it has
%               the specified width.  Its height changes proportionately.
%       If "height" is specified, the figure is scaled so that it has
%               the specified height.  Its width changes proportionately.
%       If both "width" and "height" are specified, the figure is scaled
%               anamorphically.
%       "bbllx", "bblly", "bburx", and "bbury" control the PostScript
%               BoundingBox.
%       "rheight" and "rwidth" are the reserved height and width
%               of the figure, i.e., how big TeX actually thinks
%               the figure is.  They default to "width" and "height".
%       The "clip" option ensures that no portion of the figure will
%               appear outside its BoundingBox.  "clip=" is a switch and
%               takes no value, but the `=' must be present.
%       The "angle" option specifies the angle of rotation (degrees, ccw).
%       The "silent" option makes \psfig work silently.
%
%--------------------------------------------------------------------------
\newcount\EPS@Height \newcount\EPS@Width \newcount\EPS@xscale
\newcount\EPS@yscale
\def\psfigdriver#1{%
  \bgroup\edef\next{\def\noexpand\tempa{#1}}%
    \uppercase\expandafter{\next}%
    \def\LN{DVITOLN03}%
    \def\DVItoPS{DVITOPS}%
    \def\DVIPS{DVIPS}%
    \def\emTeX{EMTEX}%
    \def\OzTeX{OZTEX}%
    \def\Textures{TEXTURES}%
    \global\chardef\fig@driver=0
    \ifx\tempa\LN
        \global\chardef\fig@driver=0\fi
    \ifx\tempa\DVItoPS
        \global\chardef\fig@driver=1\fi
    \ifx\tempa\DVIPS
        \global\chardef\fig@driver=2\fi
    \ifx\tempa\emTeX
        \global\chardef\fig@driver=3\fi
    \ifx\tempa\OzTeX
        \global\chardef\fig@driver=4\fi
    \ifx\tempa\Textures
        \global\chardef\fig@driver=5\fi
  \egroup
\def\psfig@start{}%
\def\psfig@end{}%
\def\epsfig@gofer{}%
\ifcase\fig@driver
% case 0 ln03
\typeout{WARNING! ****
 no specials for LN03 psfig}%
%
\or % case 1: dvitops
\def\psfig@start{}%
\def\psfig@end{\special{dvitops: import \@p@sfilefinal \space
\@p@swidth sp \space \@p@sheight sp \space fill}%
\if@clip \typeout{Clipping not supported}\fi
\if@angle \typeout{Rotating not supported}\fi
}%
\let\epsfig@gofer\psfig@end
%
\or %case2 dvips
\def\psfig@start{\special{ps::[begin]  \@p@swidth \space \@p@sheight \space%
        \@p@sbbllx \space \@p@sbblly \space%
        \@p@sbburx \space \@p@sbbury \space%
        startTexFig \space }%
        \if@angle
                \special {ps:: \@p@sangle \space rotate \space}
        \fi
        \if@clip
                \if@verbose
                        \typeout{(clipped to BB) }%
                \fi
                \special{ps:: doclip \space }%
        \fi
        \special{ps: plotfile \@p@sfilefinal \space }%
        \special{ps::[end] endTexFig \space }%
}%
\def\psfig@end{}%
\def\epsfig@gofer{\if@clip
                        \if@verbose
                           \typeout{(clipped to BB)}%
                        \fi
                        \epsfclipon
                  \fi
                  \epsfsetgraph{\@p@sfilefinal}%
}%
%
\or % case 3, emTeX
\typeout{WARNING. You must have a .bb info file with the Bounding Box
  of the pcx file}%
\def\psfig@start{}%
% when emtex imports a pcx file, it is *below* where we are now.
% so raise the box
\def\psfig@end{\typeout{pcx import of \@p@sfilefinal}%
\if@clip \typeout{Clipping not supported}\fi
\if@angle \typeout{Rotating not supported}\fi
\raisebox{\@p@srheight sp}{\special{em: graph \@p@sfilefinal}}}%
\def\epsfig@gofer{}%
%
\or % case 4, OzTeX
\def\psfig@start{}%
\def\psfig@end{%
\EPS@Width\@p@swidth
\EPS@Height\@p@sheight
\divide\EPS@Width by 65781  % convert sp to bp
\divide\EPS@Height by 65781
\special{epsf=\@p@sfilefinal
\space
width=\the\EPS@Width
\space
height=\the\EPS@Height
}%
\if@clip \typeout{Clipping not supported}\fi
\if@angle \typeout{Rotating not supported}\fi
}%
\let\epsfig@gofer\psfig@end
\or % case 5, Textures
\def\psfig@end{
% what is scaling of picture
         \EPS@Width=\@bbw  
         \divide\EPS@Width by 1000
         \EPS@xscale=\@p@swidth \divide \EPS@xscale by \EPS@Width
         \EPS@Height=\@bbh  
         \divide\EPS@Height by 1000
         \EPS@yscale=\@p@sheight \divide \EPS@yscale by\EPS@Height
% take largest calculated scale
  \ifnum\EPS@xscale>\EPS@yscale\EPS@xscale=\EPS@yscale\fi
\if@clip
   \if@verbose
      \typeout{(clipped to BB)}%
   \fi
   \epsfclipon
\fi
\special{illustration \@p@sfilefinal\space scaled \the\EPS@xscale}%
}%
\def\psfig@start{}%
\let\epsfig\psfig
\else
\typeout{WARNING. *** unknown  driver - no psfig}%
\fi
}%
% copies of bits of LaTeX we need....
\newdimen\ps@dimcent
%
% \fbox is defined in latex.tex; so if \fbox is undefined, assume that
% we are not in LaTeX.
% Perhaps this could be done better???
\ifx\undefined\fbox
% \fbox code from modified slightly from LaTeX
\newdimen\fboxrule
\newdimen\fboxsep
\newdimen\ps@tempdima
\newbox\ps@tempboxa
\fboxsep = 0pt
\fboxrule = .4pt
\long\def\fbox#1{\leavevmode\setbox\ps@tempboxa\hbox{#1}\ps@tempdima\fboxrule
    \advance\ps@tempdima \fboxsep \advance\ps@tempdima \dp\ps@tempboxa
   \hbox{\lower \ps@tempdima\hbox
  {\vbox{\hrule height \fboxrule
          \hbox{\vrule width \fboxrule \hskip\fboxsep
          \vbox{\vskip\fboxsep \box\ps@tempboxa\vskip\fboxsep}\hskip
                 \fboxsep\vrule width \fboxrule}%
                 \hrule height \fboxrule}}}}%
\fi
\ifx\@ifundefined\undefined
\long\def\@ifundefined#1#2#3{\expandafter\ifx\csname
  #1\endcsname\relax#2\else#3\fi}%
\fi
%
\@ifundefined{typeout}%
{\gdef\typeout#1{\immediate\write\sixt@@n{#1}}}%
{\relax}%
%
%%% check to see if macros already loaded in (maybe some other file says
%%% "\input epsfig") ...
\@ifundefined{epsfig}{}{\typeout{EPSFIG --- already loaded}\endinput}%
%
%%%
%%% we need Rokicki's EPSF macros anyway, unless they are already loaded
%
\@ifundefined{epsfbox}{\input epsf}{}%
%
%% SPQR 12.91 handling of errors using standard LaTeX error
%% mechanism. In case we are plain TeX we first define the
%% error routines...
\ifx\undefined\@latexerr
        \newlinechar`\^^J
        \def\@spaces{\space\space\space\space}%
        \def\@latexerr#1#2{%
        \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
        \typeout{Error. \space see a manual for explanation.^^J
         \space\@spaces\@spaces\@spaces Type \space H <return> \space for
         immediate help.}\errmessage{#1}}%
\fi
%------------------------
%% a couple of LaTeX error messages
\def\@whattodo{You tried to include a PostScript figure which
cannot be found^^JIf you press return to carry on anyway,^^J
The failed name will be printed in place of the figure.^^J
or type X to quit}%
\def\@whattodobb{You tried to include a PostScript figure which
has no^^Jbounding box, and you supplied none.^^J
If you press return to carry on anyway,^^J
The failed name will be printed in place of the figure.^^J
or type X to quit}%
%------------------------
%
%------------------------------------------------------------------------
%------------------------------------------------------------------------
%%% @psdo control structure -- similar to Latex @for.
%%% I redefined these with different names so that psfig can
%%% be used with TeX as well as LaTeX, and so that it will not
%%% be vunerable to future changes in LaTeX's internal
%%% control structure,
%
\def\@nnil{\@nil}%
\def\@empty{}%
\def\@psdonoop#1\@@#2#3{}%
\def\@psdo#1:=#2\do#3{\edef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
    \expandafter\@psdoloop#2,\@nil,\@nil\@@#1{#3}\fi}%
\def\@psdoloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
       #5\def#4{#2}\ifx #4\@nnil \else#5\@ipsdoloop #3\@@#4{#5}\fi\fi}%
\def\@ipsdoloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
       \let\@nextwhile=\@psdonoop \else
      #4\relax\let\@nextwhile=\@ipsdoloop\fi\@nextwhile#2\@@#3{#4}}%
\def\@tpsdo#1:=#2\do#3{\xdef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
    \@tpsdoloop#2\@nil\@nil\@@#1{#3}\fi}%
\def\@tpsdoloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
       \let\@nextwhile=\@psdonoop \else
      #4\relax\let\@nextwhile=\@tpsdoloop\fi\@nextwhile#2\@@#3{#4}}%
%%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% file reading stuff from epsf.tex
%%%   EPSF.TEX macro file:
%%%   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
%%%   Revised by Don Knuth, 3 Jan 1990.
%%%   Revised by Tomas Rokicki to accept bounding boxes with no
%%%      space after the colon, 18 Jul 1990.
%%%   Portions modified/removed for use in PSFIG package by
%%%      J. Daniel Smith, 9 October 1990.
%%%   Just the bit which knows about (atend) as a BoundingBox
%
%%%    hacked back a bit by SPQR 12/91
%
\long\def\epsfaux#1#2:#3\\{\ifx#1\epsfpercent
   \def\testit{#2}\ifx\testit\epsfbblit
        \@atendfalse
        \epsf@atend #3 . \\%
        \if@atend
           \if@verbose
                \typeout{epsfig: found `(atend)'; continuing search}%
           \fi
        \else
                \epsfgrab #3 . . . \\%
                \epsffileokfalse\global\no@bbfalse
                \global\epsfbbfoundtrue
        \fi
   \fi\fi}%
%
%%% Determine if the stuff following the %%BoundingBox is `(atend)'
%%% J. Daniel Smith.  Copied from \epsf@grab above.
%
\def\epsf@atendlit{(atend)}
%
\def\epsf@atend #1 #2 #3\\{%
   \def\epsf@tmp{#1}\ifx\epsf@tmp\empty
      \epsf@atend #2 #3 .\\\else
   \ifx\epsf@tmp\epsf@atendlit\@atendtrue\fi\fi}%
 
 
%%% End of file reading stuff from epsf.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% trigonometry stuff from "trig.tex"
\chardef\trig@letter = 11
\chardef\other = 12
 
\newif\ifdebug %%% turn me on to see TeX hard at work ...
\newif\ifc@mpute %%% don't need to compute some values
\newif\if@atend
\c@mputetrue % but assume that we do
 
\let\then = \relax
\def\r@dian{pt }%
\let\r@dians = \r@dian
\let\dimensionless@nit = \r@dian
\let\dimensionless@nits = \dimensionless@nit
\def\internal@nit{sp }%
\let\internal@nits = \internal@nit
\newif\ifstillc@nverging
\def \Mess@ge #1{\ifdebug \then \message {#1} \fi}%
 
{ %%% Things that need abnormal catcodes %%%
        \catcode `\@ = \trig@letter
        \gdef \nodimen {\expandafter \n@dimen \the \dimen}%
        \gdef \term #1 #2 #3%
               {\edef \t@ {\the #1}%%% freeze parameter 1 (count, by value)
                \edef \t@@ {\expandafter \n@dimen \the #2\r@dian}%
                                   %%% freeze parameter 2 (dimen, by value)
                \t@rm {\t@} {\t@@} {#3}%
               }%
        \gdef \t@rm #1 #2 #3%
               {{%
                \count 0 = 0
                \dimen 0 = 1 \dimensionless@nit
                \dimen 2 = #2\relax
                \Mess@ge {Calculating term #1 of \nodimen 2}%
                \loop
                \ifnum  \count 0 < #1
                \then   \advance \count 0 by 1
                        \Mess@ge {Iteration \the \count 0 \space}%
                        \Multiply \dimen 0 by {\dimen 2}%
                        \Mess@ge {After multiplication, term = \nodimen 0}%
                        \Divide \dimen 0 by {\count 0}%
                        \Mess@ge {After division, term = \nodimen 0}%
                \repeat
                \Mess@ge {Final value for term #1 of
                                \nodimen 2 \space is \nodimen 0}%
                \xdef \Term {#3 = \nodimen 0 \r@dians}%
                \aftergroup \Term
               }}%
        \catcode `\p = \other
        \catcode `\t = \other
        \gdef \n@dimen #1pt{#1} %%% throw away the ``pt''
}%
 
\def \Divide #1by #2{\divide #1 by #2} %%% just a synonym
 
\def \Multiply #1by #2%%% allows division of a dimen by a dimen
       {{%%% should really freeze parameter 2 (dimen, passed by value)
        \count 0 = #1\relax
        \count 2 = #2\relax
        \count 4 = 65536
        \Mess@ge {Before scaling, count 0 = \the \count 0 \space and
                        count 2 = \the \count 2}%
        \ifnum  \count 0 > 32767 %%% do our best to avoid overflow
        \then   \divide \count 0 by 4
                \divide \count 4 by 4
        \else   \ifnum  \count 0 < -32767
                \then   \divide \count 0 by 4
                        \divide \count 4 by 4
                \else
                \fi
        \fi
        \ifnum  \count 2 > 32767 %%% while retaining reasonable accuracy
        \then   \divide \count 2 by 4
                \divide \count 4 by 4
        \else   \ifnum  \count 2 < -32767
                \then   \divide \count 2 by 4
                        \divide \count 4 by 4
                \else
                \fi
        \fi
        \multiply \count 0 by \count 2
        \divide \count 0 by \count 4
        \xdef \product {#1 = \the \count 0 \internal@nits}%
        \aftergroup \product
       }}%
 
\def\r@duce{\ifdim\dimen0 > 90\r@dian \then   % sin(x) = sin(180-x)
                \multiply\dimen0 by -1
                \advance\dimen0 by 180\r@dian
                \r@duce
            \else \ifdim\dimen0 < -90\r@dian \then  % sin(x) = sin(360+x)
                \advance\dimen0 by 360\r@dian
                \r@duce
                \fi
            \fi}%
 
\def\Sine#1%
       {{%
        \dimen 0 = #1 \r@dian
        \r@duce
        \ifdim\dimen0 = -90\r@dian \then
           \dimen4 = -1\r@dian
           \c@mputefalse
        \fi
        \ifdim\dimen0 = 90\r@dian \then
           \dimen4 = 1\r@dian
           \c@mputefalse
        \fi
        \ifdim\dimen0 = 0\r@dian \then
           \dimen4 = 0\r@dian
           \c@mputefalse
        \fi
%
        \ifc@mpute \then
                % convert degrees to radians
                \divide\dimen0 by 180
                \dimen0=3.141592654\dimen0
%
                \dimen 2 = 3.1415926535897963\r@dian %%% a well-known constant
                \divide\dimen 2 by 2 %%% we only deal with -pi/2 : pi/2
                \Mess@ge {Sin: calculating Sin of \nodimen 0}%
                \count 0 = 1 %%% see power-series expansion for sine
                \dimen 2 = 1 \r@dian %%% ditto
                \dimen 4 = 0 \r@dian %%% ditto
                \loop
                        \ifnum  \dimen 2 = 0 %%% then we've done
                        \then   \stillc@nvergingfalse
                        \else   \stillc@nvergingtrue
                        \fi
                        \ifstillc@nverging %%% then calculate next term
                        \then   \term {\count 0} {\dimen 0} {\dimen 2}%
                                \advance \count 0 by 2
                                \count 2 = \count 0
                                \divide \count 2 by 2
                                \ifodd  \count 2 %%% signs alternate
                                \then   \advance \dimen 4 by \dimen 2
                                \else   \advance \dimen 4 by -\dimen 2
                                \fi
                \repeat
        \fi
                        \xdef \sine {\nodimen 4}%
       }}%
 
%%% Now the Cosine can be calculated easily by calling \Sine:
%%%  cos(x) = sin(90-x)
\def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else
                             \edef\Savesine{\sine}\fi
        {\dimen0=#1\r@dian\multiply\dimen0 by -1
         \advance\dimen0 by 90\r@dian
         \Sine{\nodimen 0}%
         \xdef\cosine{\sine}%
         \xdef\sine{\Savesine}}}
%%% end of trig stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\def\psdraft{\def\@psdraft{0}}%
\def\psfull{\def\@psdraft{1}}%
\psfull
\newif\if@compress
\def\pscompress{\@compresstrue}
\def\psnocompress{\@compressfalse}
\@compressfalse
\newif\if@scalefirst
\def\psscalefirst{\@scalefirsttrue}%
\def\psrotatefirst{\@scalefirstfalse}%
\psrotatefirst
%
\newif\if@draftbox
\def\psnodraftbox{\@draftboxfalse}%
\@draftboxtrue
%
\newif\if@noisy
\@noisyfalse
\newif\ifno@bb
%%% These are for the option list.
%%% A specification of the form a = b maps to calling \@p@@sa{b}%
\newif\if@bbllx
\newif\if@bblly
\newif\if@bburx
\newif\if@bbury
\newif\if@height
\newif\if@width
\newif\if@rheight
\newif\if@rwidth
\newif\if@angle
\newif\if@clip
\newif\if@verbose
\newif\if@prologfile
\def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}}%
\def\@p@@sclip#1{\@cliptrue}%
%
\newif\ifepsfig@dos  % only single suffix possible
\def\epsfigdos{\epsfig@dostrue}%
\epsfig@dosfalse
%%% if this is true, the original Darrell macros and specials are used
\newif\ifuse@psfig
%
\def\ParseName#1{\expandafter\@Parse#1}%
\def\@Parse#1.#2:{\gdef\BaseName{#1}\gdef\FileType{#2}}%

\def\@p@@sfile#1{%
  \ifepsfig@dos
     \ParseName{#1:}%
  \else
     \gdef\BaseName{#1}\gdef\FileType{}%
  \fi
  \def\@p@sfile{NO FILE: #1}%
  \def\@p@sfilefinal{NO FILE: #1}%
  \openin1=#1
  \ifeof1\closein1\openin1=\BaseName.bb
    \ifeof1\closein1
      \if@bbllx                 % No postscript file but bb given explicitly.
        \if@bblly\if@bburx\if@bbury
          \def\@p@sfile{#1}%
          \def\@p@sfilefinal{#1}%
        \fi\fi\fi
      \else                     % No bounding box found.
        \@latexerr{ERROR. PostScript file #1 not found}\@whattodo
        \@p@@sbbllx{100bp}%
        \@p@@sbblly{100bp}%
        \@p@@sbburx{200bp}%
        \@p@@sbbury{200bp}%
        \psdraft
      \fi
    \else                       % Postscript file is compressed.
      \closein1%
      \edef\@p@sfile{\BaseName.bb}%
      \typeout{using BB from \@p@sfile}%
      \ifnum\fig@driver=3
        \edef\@p@sfilefinal{\BaseName.pcx}%
      \else
        \ifepsfig@dos
          \edef\@p@sfilefinal{"`gunzip -c `texfind \BaseName.{z,Z,gz}"}%
        \else
          \edef\@p@sfilefinal{"`epsfig \if@compress-c \fi#1"}%          
        \fi
      \fi
    \fi
  \else\closein1                % Postscript file is not compressed.
    \edef\@p@sfile{#1}%
    \if@compress  
      \edef\@p@sfilefinal{"`epsfig -c #1"}%
    \else
      \edef\@p@sfilefinal{#1}%
    \fi
  \fi%
}

% alternative syntax: figure=
\let\@p@@sfigure\@p@@sfile
%
\def\@p@@sbbllx#1{%
                                            \@bbllxtrue
                \ps@dimcent=#1
                \edef\@p@sbbllx{\number\ps@dimcent}%
                \divide\ps@dimcent by65536
                \global\edef\epsfllx{\number\ps@dimcent}%
}%
\def\@p@@sbblly#1{%
                \@bbllytrue
                \ps@dimcent=#1
                \edef\@p@sbblly{\number\ps@dimcent}%
                \divide\ps@dimcent by65536
                \global\edef\epsflly{\number\ps@dimcent}%
}%
\def\@p@@sbburx#1{%
                \@bburxtrue
                \ps@dimcent=#1
                \edef\@p@sbburx{\number\ps@dimcent}%
                \divide\ps@dimcent by65536
                \global\edef\epsfurx{\number\ps@dimcent}%
}%
\def\@p@@sbbury#1{%
                \@bburytrue
                \ps@dimcent=#1
                \edef\@p@sbbury{\number\ps@dimcent}%
                \divide\ps@dimcent by65536
                \global\edef\epsfury{\number\ps@dimcent}%
}%
\def\@p@@sheight#1{%
                \@heighttrue
                \global\epsfysize=#1
                \ps@dimcent=#1
                \edef\@p@sheight{\number\ps@dimcent}%
}%
\def\@p@@swidth#1{%
                \@widthtrue
                \global\epsfxsize=#1
                \ps@dimcent=#1
                \edef\@p@swidth{\number\ps@dimcent}% 
}%
\def\@p@@srheight#1{%
                \@rheighttrue\use@psfigtrue
                \ps@dimcent=#1
                \edef\@p@srheight{\number\ps@dimcent}%
}%
\def\@p@@srwidth#1{%
                \@rwidthtrue\use@psfigtrue
                \ps@dimcent=#1
                \edef\@p@srwidth{\number\ps@dimcent}%
}%
\def\@p@@sangle#1{%
                \use@psfigtrue
                \@angletrue
                \edef\@p@sangle{#1}%
}%
\def\@p@@ssilent#1{%
                \@verbosefalse
}%
\def\@p@@snoisy#1{%
                \@verbosetrue
}%
\def\@cs@name#1{\csname #1\endcsname}%
\def\@setparms#1=#2,{\@cs@name{@p@@s#1}{#2}}%
%
%%% initialize the defaults (size the size of the figure)
%
\def\ps@init@parms{%
                \@bbllxfalse \@bbllyfalse
                \@bburxfalse \@bburyfalse
                \@heightfalse \@widthfalse
                \@rheightfalse \@rwidthfalse
                \def\@p@sbbllx{}\def\@p@sbblly{}%
                \def\@p@sbburx{}\def\@p@sbbury{}%
                \def\@p@sheight{}\def\@p@swidth{}%
                \def\@p@srheight{}\def\@p@srwidth{}%
                \def\@p@sangle{0}%
                \def\@p@sfile{}%
                \use@psfigfalse
                \@prologfilefalse
                \def\@sc{}%
                \if@noisy
                        \@verbosetrue
                \else
                        \@verbosefalse
                \fi
                \@clipfalse
}%
%
%%% Go through the options setting things up.
%
\def\parse@ps@parms#1{%
                \@psdo\@psfiga:=#1\do
                   {\expandafter\@setparms\@psfiga,}%
\if@prologfile
\special{header=\@prologfileval}%
\fi
}%
%
%%% Compute bb height and width
%
\def\bb@missing{%
        \if@verbose
            \typeout{psfig: searching \@p@sfile \space  for bounding box}%
        \fi
        \epsfgetbb{\@p@sfile}%
        \ifepsfbbfound
            \ps@dimcent=\epsfllx bp\edef\@p@sbbllx{\number\ps@dimcent}%
            \ps@dimcent=\epsflly bp\edef\@p@sbblly{\number\ps@dimcent}%
            \ps@dimcent=\epsfurx bp\edef\@p@sbburx{\number\ps@dimcent}%
            \ps@dimcent=\epsfury bp\edef\@p@sbbury{\number\ps@dimcent}%
        \else
            \epsfbbfoundfalse
        \fi
}
%
% rotate point (#1,#2) about (0,0).
% The sine and cosine of the angle are already stored in \sine and
% \cosine.  The result is placed in (\p@intvaluex, \p@intvaluey).
\newdimen\p@intvaluex
\newdimen\p@intvaluey
\def\rotate@#1#2{{\dimen0=#1 sp\dimen1=#2 sp
%               calculate x' = x \cos\theta - y \sin\theta
                  \global\p@intvaluex=\cosine\dimen0
                  \dimen3=\sine\dimen1
                  \global\advance\p@intvaluex by -\dimen3
%               calculate y' = x \sin\theta + y \cos\theta
                  \global\p@intvaluey=\sine\dimen0
                  \dimen3=\cosine\dimen1
                  \global\advance\p@intvaluey by \dimen3
                  }}%
\def\compute@bb{%
                \epsfbbfoundfalse
                \if@bbllx\epsfbbfoundtrue\fi
                \if@bblly\epsfbbfoundtrue\fi
                \if@bburx\epsfbbfoundtrue\fi
                \if@bbury\epsfbbfoundtrue\fi
                \ifepsfbbfound\else\bb@missing\fi
                \ifepsfbbfound\else
                \@latexerr{ERROR. cannot locate BoundingBox}\@whattodobb
                        \@p@@sbbllx{100bp}%
                        \@p@@sbblly{100bp}%
                        \@p@@sbburx{200bp}%
                        \@p@@sbbury{200bp}%
                        \no@bbtrue
                        \psdraft
                \fi
                %
%
% store height/width of original (unrotated) bounding box
                \count203=\@p@sbburx
                \count204=\@p@sbbury
                \advance\count203 by -\@p@sbbllx
                \advance\count204 by -\@p@sbblly
                \edef\ps@bbw{\number\count203}%
                \edef\ps@bbh{\number\count204}%
                 \edef\@bbw{\number\count203}%
                \edef\@bbh{\number\count204}%
               \if@angle
                        \Sine{\@p@sangle}\Cosine{\@p@sangle}%
 
{\ps@dimcent=\maxdimen\xdef\r@p@sbbllx{\number\ps@dimcent}%
 
\xdef\r@p@sbblly{\number\ps@dimcent}%
 
\xdef\r@p@sbburx{-\number\ps@dimcent}%
 
\xdef\r@p@sbbury{-\number\ps@dimcent}}%
%
% Need to rotate all four points and take the X-Y extremes of the new
% points as the new bounding box.
                        \def\minmaxtest{%
                           \ifnum\number\p@intvaluex<\r@p@sbbllx
                              \xdef\r@p@sbbllx{\number\p@intvaluex}\fi
                           \ifnum\number\p@intvaluex>\r@p@sbburx
                              \xdef\r@p@sbburx{\number\p@intvaluex}\fi
                           \ifnum\number\p@intvaluey<\r@p@sbblly
                              \xdef\r@p@sbblly{\number\p@intvaluey}\fi
                           \ifnum\number\p@intvaluey>\r@p@sbbury
                              \xdef\r@p@sbbury{\number\p@intvaluey}\fi
                           }%
%                       lower left
                        \rotate@{\@p@sbbllx}{\@p@sbblly}%
                        \minmaxtest
%                       upper left
                        \rotate@{\@p@sbbllx}{\@p@sbbury}%
                        \minmaxtest
%                       lower right
                        \rotate@{\@p@sbburx}{\@p@sbblly}%
                        \minmaxtest
%                       upper right
                        \rotate@{\@p@sbburx}{\@p@sbbury}%
                        \minmaxtest
 
\edef\@p@sbbllx{\r@p@sbbllx}\edef\@p@sbblly{\r@p@sbblly}%
 
\edef\@p@sbburx{\r@p@sbburx}\edef\@p@sbbury{\r@p@sbbury}%
                \fi
                \count203=\@p@sbburx
                \count204=\@p@sbbury
                \advance\count203 by -\@p@sbbllx
                \advance\count204 by -\@p@sbblly
                \edef\@bbw{\number\count203}%
                \edef\@bbh{\number\count204}%
}%
%
% \in@hundreds performs #1 * (#2 / #3) correct to the hundreds,
%       then leaves the result in @result
%
\def\in@hundreds#1#2#3{\count240=#2 \count241=#3
                     \count100=\count240        % 100 is first digit #2/#3
                     \divide\count100 by \count241
                     \count101=\count100
                     \multiply\count101 by \count241
                     \advance\count240 by -\count101
                     \multiply\count240 by 10
                     \count101=\count240        %101 is second digit of #2/#3
                     \divide\count101 by \count241
                     \count102=\count101
                     \multiply\count102 by \count241
                     \advance\count240 by -\count102
                     \multiply\count240 by 10
                     \count102=\count240        % 102 is the third digit
                     \divide\count102 by \count241
                     \count200=#1\count205=0
                     \count201=\count200
                        \multiply\count201 by \count100
                        \advance\count205 by \count201
                     \count201=\count200
                        \divide\count201 by 10
                        \multiply\count201 by \count101
                        \advance\count205 by \count201
                        %
                     \count201=\count200
                        \divide\count201 by 100
                        \multiply\count201 by \count102
                        \advance\count205 by \count201
                        %
                     \edef\@result{\number\count205}%
}%
\def\compute@wfromh{%
                % computing : width = height * (bbw / bbh)
                \in@hundreds{\@p@sheight}{\@bbw}{\@bbh}%
                \edef\@p@swidth{\@result}%
}%
\def\compute@hfromw{%
                % computing : height = width * (bbh / bbw)
                \in@hundreds{\@p@swidth}{\@bbh}{\@bbw}%
                \edef\@p@sheight{\@result}%
}%
\def\compute@handw{%
                \if@height
                        \if@width
                        \else
                                \compute@wfromh
                        \fi
                \else
                        \if@width
                                \compute@hfromw
                        \else
                                \edef\@p@sheight{\@bbh}%
                                \edef\@p@swidth{\@bbw}%
                        \fi
                \fi
}%
\def\compute@resv{%
                \if@rheight \else \edef\@p@srheight{\@p@sheight} \fi
                \if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi
}%
%
% Compute any missing values
\def\compute@sizes{%
        \if@scalefirst\if@angle
% at this point the bounding box has been adjsuted correctly for
% rotation.  PSFIG does all of its scaling using \@bbh and \@bbw.  If
% a width= or height= was specified along with \psscalefirst, then the
% width=/height= value needs to be adjusted to match the new (rotated)
% bounding box size (specifed in \@bbw and \@bbh).
%    \ps@bbw       width=
%    -------  =  ----------
%    \@bbw       new width=
% so `new width=' = (width= * \@bbw) / \ps@bbw; where \ps@bbw is the
% width of the original (unrotated) bounding box.
        \if@width
           \in@hundreds{\@p@swidth}{\@bbw}{\ps@bbw}%
           \edef\@p@swidth{\@result}%
        \fi
        \if@height
           \in@hundreds{\@p@sheight}{\@bbh}{\ps@bbh}%
           \edef\@p@sheight{\@result}%
        \fi
        \fi\fi
        \compute@handw
        \compute@resv
}
%

%------------------------------------------------------------------
%%% by the way, possible parameters to the PSfile= command in dvips are:
%%%                    llx
%%%                    lly
%%%                    urx
%%%                    ury
%%%                    rwi
%       hoffset The horizontal offset (default 0)
%       voffset The vertical offset (default 0)
%       hsize   The horizontal clipping size (default 612)
%       vsize   The vertical clipping size (default 792)
%       hscale  The horizontal scaling factor (default 100)
%       vscale  The vertical scaling factor (default 100)
%       angle   The rotation (default 0)
%------------------------------------------------------------------
\long\def\graphic@verb#1{\def\next{#1}%
  {\expandafter\graphic@strip\meaning\next}}
\def\graphic@strip#1>{}
\def\graphic@zapspace#1{%
  #1\ifx\graphic@zapspace#1\graphic@zapspace%
  \else\expandafter\graphic@zapspace%
  \fi}
\def\psfig#1{%
\edef\@tempa{\graphic@zapspace#1{}}%
\ifvmode\leavevmode\fi\vbox {%
        %
        \ps@init@parms
        \parse@ps@parms{\@tempa}%
        %
        \ifnum\@psdraft=1
                \typeout{[\@p@sfilefinal]}%
                \if@verbose
                        \typeout{epsfig: using PSFIG macros}%
                \fi
                \psfig@method
        \else
                \epsfig@draft
        \fi
}
}%
\def\graphic@zapspace#1{%
  #1\ifx\graphic@zapspace#1\graphic@zapspace%
  \else\expandafter\graphic@zapspace%
  \fi}
\def\epsfig#1{%
\edef\@tempa{\graphic@zapspace#1{}}%
\ifvmode\leavevmode\fi\vbox {%
        %
        \ps@init@parms
        \parse@ps@parms{\@tempa}%
        %
        \ifnum\@psdraft=1
          \if@angle\use@psfigtrue\fi
          {\ifnum\fig@driver=1\global\use@psfigtrue\fi}%
          {\ifnum\fig@driver=3\global\use@psfigtrue\fi}%
          {\ifnum\fig@driver=4\global\use@psfigtrue\fi}%
          {\ifnum\fig@driver=5\global\use@psfigtrue\fi}%
                \ifuse@psfig
                        \if@verbose
                                \typeout{epsfig: using PSFIG macros}%
                        \fi
                        \psfig@method
                \else
                        \if@verbose
                                \typeout{epsfig: using EPSF macros}%
                        \fi
                        \epsf@method
                \fi
        \else
                \epsfig@draft
        \fi
}%
}%
 
 
\def\epsf@method{%
        \epsfbbfoundfalse
        \if@bbllx\epsfbbfoundtrue\fi
        \if@bblly\epsfbbfoundtrue\fi
        \if@bburx\epsfbbfoundtrue\fi
        \if@bbury\epsfbbfoundtrue\fi
        \ifepsfbbfound\else\epsfgetbb{\@p@sfile}\fi
        \ifepsfbbfound
           \typeout{<\@p@sfilefinal>}%
           \epsfig@gofer
        \else
          \@latexerr{ERROR - Cannot locate BoundingBox}\@whattodobb
          \@p@@sbbllx{100bp}%
          \@p@@sbblly{100bp}%
          \@p@@sbburx{200bp}%
          \@p@@sbbury{200bp}%
                \count203=\@p@sbburx
                \count204=\@p@sbbury
                \advance\count203 by -\@p@sbbllx
                \advance\count204 by -\@p@sbblly
                \edef\@bbw{\number\count203}%
                \edef\@bbh{\number\count204}%
          \compute@sizes
          \epsfig@@draft
       \fi
}%
\def\psfig@method{%
        \compute@bb
        \ifepsfbbfound
          \compute@sizes
          \psfig@start
          % Create the vbox to reserve the space for the figure%
          \vbox to \@p@srheight sp{\hbox to \@p@srwidth 
            sp{\hss}\vss\psfig@end}%
        \else
           \epsfig@draft
        \fi
}%
%
% draft figure, just reserve the space and print the
% path name.
\def\epsfig@draft{\compute@bb\compute@sizes\epsfig@@draft}%
%
\def\epsfig@@draft{%
\typeout{<(draft only) \@p@sfilefinal>}%
\if@draftbox
        % Verbose draft: print file name in box
        \hbox{{\fboxsep0pt\fbox{\vbox to \@p@srheight sp{%
        \vss\hbox to \@p@srwidth sp{ \hss 
           \expandafter\Literally\@p@sfilefinal\@nil
                          \hss }\vss
        }}}}%
\else
        % Non-verbose draft
        \vbox to \@p@srheight sp{%
        \vss\hbox to \@p@srwidth sp{\hss}\vss}%
\fi
}%
\def\Literally#1\@nil{{\tt\graphic@verb{#1}}}
% default to dvips
\psfigdriver{dvips}%
% and to DOS file conventions
%%% \epsfigdos
\epsfigRestoreAt
 



% Psfig/TeX 
%%%%%%%%%%%%%%% For use at Santa Cruz, file "psfig.tex" must %%%
%%%%%%%%%%%%%%% be in same directory as figure  %%%%%%%%%%%%%%%%
\def\PsfigVersion{1.9}
% dvips version
%
% All psfig/tex software, documentation, and related files
% in this distribution of psfig/tex are 
% Copyright 1987, 1988, 1991 Trevor J. Darrell
%
% Permission is granted for use and non-profit distribution of psfig/tex 
% providing that this notice is clearly maintained. The right to
% distribute any portion of psfig/tex for profit or as part of any commercial
% product is specifically reserved for the author(s) of that portion.
%
% *** Feel free to make local modifications of psfig as you wish,
% *** but DO NOT post any changed or modified versions of ``psfig''
% *** directly to the net. Send them to me and I'll try to incorporate
% *** them into future versions. If you want to take the psfig code 
% *** and make a new program (subject to the copyright above), distribute it, 
% *** (and maintain it) that's fine, just don't call it psfig.
%
% Bugs and improvements to trevor@media.mit.edu.
%
% Thanks to Greg Hager (GDH) and Ned Batchelder for their contributions
% to the original version of this project.
%
% Modified by J. Daniel Smith on 9 October 1990 to accept the
% %%BoundingBox: comment with or without a space after the colon.  Stole
% file reading code from Tom Rokicki's EPSF.TEX file (see below).
%
% More modifications by J. Daniel Smith on 29 March 1991 to allow the
% the included PostScript figure to be rotated.  The amount of
% rotation is specified by the "angle=" parameter of the \psfig command.
%
% Modified by Robert Russell on June 25, 1991 to allow users to specify
% .ps filenames which don't yet exist, provided they explicitly provide
% boundingbox information via the \psfig command. Note: This will only work
% if the "file=" parameter follows all four "bb???=" parameters in the
% command. This is due to the order in which psfig interprets these params.
%
%  3 Jul 1991	JDS	check if file already read in once
%  4 Sep 1991	JDS	fixed incorrect computation of rotated
%			bounding box
% 25 Sep 1991	GVR	expanded synopsis of \psfig
% 14 Oct 1991	JDS	\fbox code from LaTeX so \psdraft works with TeX
%			changed \typeout to \ps@typeout
% 17 Oct 1991	JDS	added \psscalefirst and \psrotatefirst
%

% From: gvr@cs.brown.edu (George V. Reilly)
%
% \psdraft	draws an outline box, but doesn't include the figure
%		in the DVI file.  Useful for previewing.
%
% \psfull	includes the figure in the DVI file (default).
%
% \psscalefirst width= or height= specifies the size of the figure
% 		before rotation.
% \psrotatefirst (default) width= or height= specifies the size of the
% 		 figure after rotation.  Asymetric figures will
% 		 appear to shrink.
%
% \psfigurepath#1	sets the path to search for the figure
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \psfig
% usage: \psfig{file=, figure=, height=, width=,
%			bbllx=, bblly=, bburx=, bbury=,
%			rheight=, rwidth=, clip=, angle=, silent=}
%%%%%%%%%%   EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \centerline{\psfig{file=fn.ft,height=6cm,angle=90}}  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	"file" is the filename.  If no path name is specified and the
%		file is not found in the current directory,
%		it will be looked for in directory \psfigurepath.
%	"figure" is a synonym for "file".
%	By default, the width and height of the figure are taken from
%		the BoundingBox of the figure.
%	If "width" is specified, the figure is scaled so that it has
%		the specified width.  Its height changes proportionately.
%	If "height" is specified, the figure is scaled so that it has
%		the specified height.  Its width changes proportionately.
%	If both "width" and "height" are specified, the figure is scaled
%		anamorphically.
%	"bbllx", "bblly", "bburx", and "bbury" control the PostScript
%		BoundingBox.  If these four values are specified
%               *before* the "file" option, the PSFIG will not try to
%               open the PostScript file.
%	"rheight" and "rwidth" are the reserved height and width
%		of the figure, i.e., how big TeX actually thinks
%		the figure is.  They default to "width" and "height".
%	The "clip" option ensures that no portion of the figure will
%		appear outside its BoundingBox.  "clip=" is a switch and
%		takes no value, but the `=' must be present.
%	The "angle" option specifies the angle of rotation (degrees, ccw).
%	The "silent" option makes \psfig work silently.
%

% check to see if macros already loaded in (maybe some other file says
% "\input psfig") ...
\ifx\undefined\psfig\else\endinput\fi

%
% from a suggestion by eijkhout@csrd.uiuc.edu to allow
% loading as a style file. Changed to avoid problems
% with amstex per suggestion by jbence@math.ucla.edu

\let\LaTeXAtSign=\@
\let\@=\relax
\edef\psfigRestoreAt{\catcode`\@=\number\catcode`@\relax}
%\edef\psfigRestoreAt{\catcode`@=\number\catcode`@\relax}
\catcode`\@=11\relax
\newwrite\@unused
\def\ps@typeout#1{{\let\protect\string\immediate\write\@unused{#1}}}
\ps@typeout{psfig/tex \PsfigVersion}

%% Here's how you define your figure path.  Should be set up with null
%% default and a user useable definition.

\def\figurepath{./}
\def\psfigurepath#1{\edef\figurepath{#1}}

%
% @psdo control structure -- similar to Latex @for.
% I redefined these with different names so that psfig can
% be used with TeX as well as LaTeX, and so that it will not 
% be vunerable to future changes in LaTeX's internal
% control structure,
%
\def\@nnil{\@nil}
\def\@empty{}
\def\@psdonoop#1\@@#2#3{}
\def\@psdo#1:=#2\do#3{\edef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
    \expandafter\@psdoloop#2,\@nil,\@nil\@@#1{#3}\fi}
\def\@psdoloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
       #5\def#4{#2}\ifx #4\@nnil \else#5\@ipsdoloop #3\@@#4{#5}\fi\fi}
\def\@ipsdoloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil 
       \let\@nextwhile=\@psdonoop \else
      #4\relax\let\@nextwhile=\@ipsdoloop\fi\@nextwhile#2\@@#3{#4}}
\def\@tpsdo#1:=#2\do#3{\xdef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
    \@tpsdoloop#2\@nil\@nil\@@#1{#3}\fi}
\def\@tpsdoloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil 
       \let\@nextwhile=\@psdonoop \else
      #4\relax\let\@nextwhile=\@tpsdoloop\fi\@nextwhile#2\@@#3{#4}}
% 
% \fbox is defined in latex.tex; so if \fbox is undefined, assume that
% we are not in LaTeX.
% Perhaps this could be done better???
\ifx\undefined\fbox
% \fbox code from modified slightly from LaTeX
\newdimen\fboxrule
\newdimen\fboxsep
\newdimen\ps@tempdima
\newbox\ps@tempboxa
\fboxsep = 3pt
\fboxrule = .4pt
\long\def\fbox#1{\leavevmode\setbox\ps@tempboxa\hbox{#1}\ps@tempdima\fboxrule
    \advance\ps@tempdima \fboxsep \advance\ps@tempdima \dp\ps@tempboxa
   \hbox{\lower \ps@tempdima\hbox
  {\vbox{\hrule height \fboxrule
          \hbox{\vrule width \fboxrule \hskip\fboxsep
          \vbox{\vskip\fboxsep \box\ps@tempboxa\vskip\fboxsep}\hskip 
                 \fboxsep\vrule width \fboxrule}
                 \hrule height \fboxrule}}}}
\fi
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% file reading stuff from epsf.tex
%   EPSF.TEX macro file:
%   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
%   Revised by Don Knuth, 3 Jan 1990.
%   Revised by Tomas Rokicki to accept bounding boxes with no
%      space after the colon, 18 Jul 1990.
%   Portions modified/removed for use in PSFIG package by
%      J. Daniel Smith, 9 October 1990.
%
\newread\ps@stream
\newif\ifnot@eof       % continue looking for the bounding box?
\newif\if@noisy        % report what you're making?
\newif\if@atend        % %%BoundingBox: has (at end) specification
\newif\if@psfile       % does this look like a PostScript file?
%
% PostScript files should start with `%!'
%
{\catcode`\%=12\global\gdef\epsf@start{%!}}
\def\epsf@PS{PS}
%
\def\epsf@getbb#1{%
%
%   The first thing we need to do is to open the
%   PostScript file, if possible.
%
\openin\ps@stream=#1
\ifeof\ps@stream\ps@typeout{Error, File #1 not found}\else
%
%   Okay, we got it. Now we'll scan lines until we find one that doesn't
%   start with %. We're looking for the bounding box comment.
%
   {\not@eoftrue \chardef\other=12
    \def\do##1{\catcode`##1=\other}\dospecials \catcode`\ =10
    \loop
       \if@psfile
	  \read\ps@stream to \epsf@fileline
       \else{
	  \obeyspaces
          \read\ps@stream to \epsf@tmp\global\let\epsf@fileline\epsf@tmp}
       \fi
       \ifeof\ps@stream\not@eoffalse\else
%
%   Check the first line for `%!'.  Issue a warning message if its not
%   there, since the file might not be a PostScript file.
%
       \if@psfile\else
       \expandafter\epsf@test\epsf@fileline:. \\%
       \fi
%
%   We check to see if the first character is a % sign;
%   if so, we look further and stop only if the line begins with
%   `%%BoundingBox:' and the `(atend)' specification was not found.
%   That is, the only way to stop is when the end of file is reached,
%   or a `%%BoundingBox: llx lly urx ury' line is found.
%
          \expandafter\epsf@aux\epsf@fileline:. \\%
       \fi
   \ifnot@eof\repeat
   }\closein\ps@stream\fi}%
%
% This tests if the file we are reading looks like a PostScript file.
%
\long\def\epsf@test#1#2#3:#4\\{\def\epsf@testit{#1#2}
			\ifx\epsf@testit\epsf@start\else
\ps@typeout{Warning! File does not start with `\epsf@start'.  It may not be a PostScript file.}
			\fi
			\@psfiletrue} % don't test after 1st line
%
%   We still need to define the tricky \epsf@aux macro. This requires
%   a couple of magic constants for comparison purposes.
%
{\catcode`\%=12\global\let\epsf@percent=%\global\def\epsf@bblit{%BoundingBox}}
%
%
%   So we're ready to check for `%BoundingBox:' and to grab the
%   values if they are found.  We continue searching if `(at end)'
%   was found after the `%BoundingBox:'.
%
\long\def\epsf@aux#1#2:#3\\{\ifx#1\epsf@percent
   \def\epsf@testit{#2}\ifx\epsf@testit\epsf@bblit
	\@atendfalse
        \epsf@atend #3 . \\%
	\if@atend	
	   \if@verbose{
		\ps@typeout{psfig: found `(atend)'; continuing search}
	   }\fi
        \else
        \epsf@grab #3 . . . \\%
        \not@eoffalse
        \global\no@bbfalse
        \fi
   \fi\fi}%
%
%   Here we grab the values and stuff them in the appropriate definitions.
%
\def\epsf@grab #1 #2 #3 #4 #5\\{%
   \global\def\epsf@llx{#1}\ifx\epsf@llx\empty
      \epsf@grab #2 #3 #4 #5 .\\\else
   \global\def\epsf@lly{#2}%
   \global\def\epsf@urx{#3}\global\def\epsf@ury{#4}\fi}%
%
% Determine if the stuff following the %%BoundingBox is `(atend)'
% J. Daniel Smith.  Copied from \epsf@grab above.
%
\def\epsf@atendlit{(atend)} 
\def\epsf@atend #1 #2 #3\\{%
   \def\epsf@tmp{#1}\ifx\epsf@tmp\empty
      \epsf@atend #2 #3 .\\\else
   \ifx\epsf@tmp\epsf@atendlit\@atendtrue\fi\fi}


% End of file reading stuff from epsf.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% trigonometry stuff from "trig.tex"
\chardef\psletter = 11 % won't conflict with \begin{letter} now...
\chardef\other = 12

\newif \ifdebug %%% turn me on to see TeX hard at work ...
\newif\ifc@mpute %%% don't need to compute some values
\c@mputetrue % but assume that we do

\let\then = \relax
\def\r@dian{pt }
\let\r@dians = \r@dian
\let\dimensionless@nit = \r@dian
\let\dimensionless@nits = \dimensionless@nit
\def\internal@nit{sp }
\let\internal@nits = \internal@nit
\newif\ifstillc@nverging
\def \Mess@ge #1{\ifdebug \then \message {#1} \fi}

{ %%% Things that need abnormal catcodes %%%
	\catcode `\@ = \psletter
	\gdef \nodimen {\expandafter \n@dimen \the \dimen}
	\gdef \term #1 #2 #3%
	       {\edef \t@ {\the #1}%%% freeze parameter 1 (count, by value)
		\edef \t@@ {\expandafter \n@dimen \the #2\r@dian}%
				   %%% freeze parameter 2 (dimen, by value)
		\t@rm {\t@} {\t@@} {#3}%
	       }
	\gdef \t@rm #1 #2 #3%
	       {{%
		\count 0 = 0
		\dimen 0 = 1 \dimensionless@nit
		\dimen 2 = #2\relax
		\Mess@ge {Calculating term #1 of \nodimen 2}%
		\loop
		\ifnum	\count 0 < #1
		\then	\advance \count 0 by 1
			\Mess@ge {Iteration \the \count 0 \space}%
			\Multiply \dimen 0 by {\dimen 2}%
			\Mess@ge {After multiplication, term = \nodimen 0}%
			\Divide \dimen 0 by {\count 0}%
			\Mess@ge {After division, term = \nodimen 0}%
		\repeat
		\Mess@ge {Final value for term #1 of 
				\nodimen 2 \space is \nodimen 0}%
		\xdef \Term {#3 = \nodimen 0 \r@dians}%
		\aftergroup \Term
	       }}
	\catcode `\p = \other
	\catcode `\t = \other
	\gdef \n@dimen #1pt{#1} %%% throw away the ``pt''
}

\def \Divide #1by #2{\divide #1 by #2} %%% just a synonym

\def \Multiply #1by #2%%% allows division of a dimen by a dimen
       {{%%% should really freeze parameter 2 (dimen, passed by value)
	\count 0 = #1\relax
	\count 2 = #2\relax
	\count 4 = 65536
	\Mess@ge {Before scaling, count 0 = \the \count 0 \space and
			count 2 = \the \count 2}%
	\ifnum	\count 0 > 32767 %%% do our best to avoid overflow
	\then	\divide \count 0 by 4
		\divide \count 4 by 4
	\else	\ifnum	\count 0 < -32767
		\then	\divide \count 0 by 4
			\divide \count 4 by 4
		\else
		\fi
	\fi
	\ifnum	\count 2 > 32767 %%% while retaining reasonable accuracy
	\then	\divide \count 2 by 4
		\divide \count 4 by 4
	\else	\ifnum	\count 2 < -32767
		\then	\divide \count 2 by 4
			\divide \count 4 by 4
		\else
		\fi
	\fi
	\multiply \count 0 by \count 2
	\divide \count 0 by \count 4
	\xdef \product {#1 = \the \count 0 \internal@nits}%
	\aftergroup \product
       }}

\def\r@duce{\ifdim\dimen0 > 90\r@dian \then   % sin(x+90) = sin(180-x)
		\multiply\dimen0 by -1
		\advance\dimen0 by 180\r@dian
		\r@duce
	    \else \ifdim\dimen0 < -90\r@dian \then  % sin(-x) = sin(360+x)
		\advance\dimen0 by 360\r@dian
		\r@duce
		\fi
	    \fi}

\def\Sine#1%
       {{%
	\dimen 0 = #1 \r@dian
	\r@duce
	\ifdim\dimen0 = -90\r@dian \then
	   \dimen4 = -1\r@dian
	   \c@mputefalse
	\fi
	\ifdim\dimen0 = 90\r@dian \then
	   \dimen4 = 1\r@dian
	   \c@mputefalse
	\fi
	\ifdim\dimen0 = 0\r@dian \then
	   \dimen4 = 0\r@dian
	   \c@mputefalse
	\fi
%
	\ifc@mpute \then
        	% convert degrees to radians
		\divide\dimen0 by 180
		\dimen0=3.141592654\dimen0
%
		\dimen 2 = 3.1415926535897963\r@dian %%% a well-known constant
		\divide\dimen 2 by 2 %%% we only deal with -pi/2 : pi/2
		\Mess@ge {Sin: calculating Sin of \nodimen 0}%
		\count 0 = 1 %%% see power-series expansion for sine
		\dimen 2 = 1 \r@dian %%% ditto
		\dimen 4 = 0 \r@dian %%% ditto
		\loop
			\ifnum	\dimen 2 = 0 %%% then we've done
			\then	\stillc@nvergingfalse 
			\else	\stillc@nvergingtrue
			\fi
			\ifstillc@nverging %%% then calculate next term
			\then	\term {\count 0} {\dimen 0} {\dimen 2}%
				\advance \count 0 by 2
				\count 2 = \count 0
				\divide \count 2 by 2
				\ifodd	\count 2 %%% signs alternate
				\then	\advance \dimen 4 by \dimen 2
				\else	\advance \dimen 4 by -\dimen 2
				\fi
		\repeat
	\fi		
			\xdef \sine {\nodimen 4}%
       }}

% Now the Cosine can be calculated easily by calling \Sine
\def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else
		             \edef\Savesine{\sine}\fi
	{\dimen0=#1\r@dian\advance\dimen0 by 90\r@dian
	 \Sine{\nodimen 0}
	 \xdef\cosine{\sine}
	 \xdef\sine{\Savesine}}}	      
% end of trig stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\psdraft{
	\def\@psdraft{0}
	%\ps@typeout{draft level now is \@psdraft \space . }
}
\def\psfull{
	\def\@psdraft{100}
	%\ps@typeout{draft level now is \@psdraft \space . }
}

\psfull

\newif\if@scalefirst
\def\psscalefirst{\@scalefirsttrue}
\def\psrotatefirst{\@scalefirstfalse}
\psrotatefirst

\newif\if@draftbox
\def\psnodraftbox{
	\@draftboxfalse
}
\def\psdraftbox{
	\@draftboxtrue
}
\@draftboxtrue

\newif\if@prologfile
\newif\if@postlogfile
\def\pssilent{
	\@noisyfalse
}
\def\psnoisy{
	\@noisytrue
}
\psnoisy
%%% These are for the option list.
%%% A specification of the form a = b maps to calling \@p@@sa{b}
\newif\if@bbllx
\newif\if@bblly
\newif\if@bburx
\newif\if@bbury
\newif\if@height
\newif\if@width
\newif\if@rheight
\newif\if@rwidth
\newif\if@angle
\newif\if@clip
\newif\if@verbose
\def\@p@@sclip#1{\@cliptrue}


\newif\if@decmpr

%%% GDH 7/26/87 -- changed so that it first looks in the local directory,
%%% then in a specified global directory for the ps file.
%%% RPR 6/25/91 -- changed so that it defaults to user-supplied name if
%%% boundingbox info is specified, assuming graphic will be created by
%%% print time.
%%% TJD 10/19/91 -- added bbfile vs. file distinction, and @decmpr flag

\def\@p@@sfigure#1{\def\@p@sfile{null}\def\@p@sbbfile{null}
	        \openin1=#1.bb
		\ifeof1\closein1
	        	\openin1=\figurepath#1.bb
			\ifeof1\closein1
			        \openin1=#1
				\ifeof1\closein1%
				       \openin1=\figurepath#1
					\ifeof1
					   \ps@typeout{Error, File #1 not found}
						\if@bbllx\if@bblly
				   		\if@bburx\if@bbury
			      				\def\@p@sfile{#1}%
			      				\def\@p@sbbfile{#1}%
							\@decmprfalse
				  	   	\fi\fi\fi\fi
					\else\closein1
				    		\def\@p@sfile{\figurepath#1}%
				    		\def\@p@sbbfile{\figurepath#1}%
						\@decmprfalse
	                       		\fi%
			 	\else\closein1%
					\def\@p@sfile{#1}
					\def\@p@sbbfile{#1}
					\@decmprfalse
			 	\fi
			\else
				\def\@p@sfile{\figurepath#1}
				\def\@p@sbbfile{\figurepath#1.bb}
				\@decmprtrue
			\fi
		\else
			\def\@p@sfile{#1}
			\def\@p@sbbfile{#1.bb}
			\@decmprtrue
		\fi}

\def\@p@@sfile#1{\@p@@sfigure{#1}}

\def\@p@@sbbllx#1{
		%\ps@typeout{bbllx is #1}
		\@bbllxtrue
		\dimen100=#1
		\edef\@p@sbbllx{\number\dimen100}
}
\def\@p@@sbblly#1{
		%\ps@typeout{bblly is #1}
		\@bbllytrue
		\dimen100=#1
		\edef\@p@sbblly{\number\dimen100}
}
\def\@p@@sbburx#1{
		%\ps@typeout{bburx is #1}
		\@bburxtrue
		\dimen100=#1
		\edef\@p@sbburx{\number\dimen100}
}
\def\@p@@sbbury#1{
		%\ps@typeout{bbury is #1}
		\@bburytrue
		\dimen100=#1
		\edef\@p@sbbury{\number\dimen100}
}
\def\@p@@sheight#1{
		\@heighttrue
		\dimen100=#1
   		\edef\@p@sheight{\number\dimen100}
		%\ps@typeout{Height is \@p@sheight}
}
\def\@p@@swidth#1{
		%\ps@typeout{Width is #1}
		\@widthtrue
		\dimen100=#1
		\edef\@p@swidth{\number\dimen100}
}
\def\@p@@srheight#1{
		%\ps@typeout{Reserved height is #1}
		\@rheighttrue
		\dimen100=#1
		\edef\@p@srheight{\number\dimen100}
}
\def\@p@@srwidth#1{
		%\ps@typeout{Reserved width is #1}
		\@rwidthtrue
		\dimen100=#1
		\edef\@p@srwidth{\number\dimen100}
}
\def\@p@@sangle#1{
		%\ps@typeout{Rotation is #1}
		\@angletrue
%		\dimen100=#1
		\edef\@p@sangle{#1} %\number\dimen100}
}
\def\@p@@ssilent#1{ 
		\@verbosefalse
}
\def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}}
\def\@p@@spostlog#1{\@postlogfiletrue\def\@postlogfileval{#1}}
\def\@cs@name#1{\csname #1\endcsname}
\def\@setparms#1=#2,{\@cs@name{@p@@s#1}{#2}}
%
% initialize the defaults (size the size of the figure)
%
\def\ps@init@parms{
		\@bbllxfalse \@bbllyfalse
		\@bburxfalse \@bburyfalse
		\@heightfalse \@widthfalse
		\@rheightfalse \@rwidthfalse
		\def\@p@sbbllx{}\def\@p@sbblly{}
		\def\@p@sbburx{}\def\@p@sbbury{}
		\def\@p@sheight{}\def\@p@swidth{}
		\def\@p@srheight{}\def\@p@srwidth{}
		\def\@p@sangle{0}
		\def\@p@sfile{} \def\@p@sbbfile{}
		\def\@p@scost{10}
		\def\@sc{}
		\@prologfilefalse
		\@postlogfilefalse
		\@clipfalse
		\if@noisy
			\@verbosetrue
		\else
			\@verbosefalse
		\fi
}
%
% Go through the options setting things up.
%
\def\parse@ps@parms#1{
	 	\@psdo\@psfiga:=#1\do
		   {\expandafter\@setparms\@psfiga,}}
%
% Compute bb height and width
%
\newif\ifno@bb
\def\bb@missing{
	\if@verbose{
		\ps@typeout{psfig: searching \@p@sbbfile \space  for bounding box}
	}\fi
	\no@bbtrue
	\epsf@getbb{\@p@sbbfile}
        \ifno@bb \else \bb@cull\epsf@llx\epsf@lly\epsf@urx\epsf@ury\fi
}	
\def\bb@cull#1#2#3#4{
	\dimen100=#1 bp\edef\@p@sbbllx{\number\dimen100}
	\dimen100=#2 bp\edef\@p@sbblly{\number\dimen100}
	\dimen100=#3 bp\edef\@p@sbburx{\number\dimen100}
	\dimen100=#4 bp\edef\@p@sbbury{\number\dimen100}
	\no@bbfalse
}
% rotate point (#1,#2) about (0,0).
% The sine and cosine of the angle are already stored in \sine and
% \cosine.  The result is placed in (\p@intvaluex, \p@intvaluey).
\newdimen\p@intvaluex
\newdimen\p@intvaluey
\def\rotate@#1#2{{\dimen0=#1 sp\dimen1=#2 sp
%            	calculate x' = x \cos\theta - y \sin\theta
		  \global\p@intvaluex=\cosine\dimen0
		  \dimen3=\sine\dimen1
		  \global\advance\p@intvaluex by -\dimen3
% 		calculate y' = x \sin\theta + y \cos\theta
		  \global\p@intvaluey=\sine\dimen0
		  \dimen3=\cosine\dimen1
		  \global\advance\p@intvaluey by \dimen3
		  }}
\def\compute@bb{
		\no@bbfalse
		\if@bbllx \else \no@bbtrue \fi
		\if@bblly \else \no@bbtrue \fi
		\if@bburx \else \no@bbtrue \fi
		\if@bbury \else \no@bbtrue \fi
		\ifno@bb \bb@missing \fi
		\ifno@bb \ps@typeout{FATAL ERROR: no bb supplied or found}
			\no-bb-error
		\fi
		%
%\ps@typeout{BB: \@p@sbbllx, \@p@sbblly, \@p@sbburx, \@p@sbbury} 
%
% store height/width of original (unrotated) bounding box
		\count203=\@p@sbburx
		\count204=\@p@sbbury
		\advance\count203 by -\@p@sbbllx
		\advance\count204 by -\@p@sbblly
		\edef\ps@bbw{\number\count203}
		\edef\ps@bbh{\number\count204}
		%\ps@typeout{ psbbh = \ps@bbh, psbbw = \ps@bbw }
		\if@angle 
			\Sine{\@p@sangle}\Cosine{\@p@sangle}
	        	{\dimen100=\maxdimen\xdef\r@p@sbbllx{\number\dimen100}
					    \xdef\r@p@sbblly{\number\dimen100}
			                    \xdef\r@p@sbburx{-\number\dimen100}
					    \xdef\r@p@sbbury{-\number\dimen100}}
%
% Need to rotate all four points and take the X-Y extremes of the new
% points as the new bounding box.
                        \def\minmaxtest{
			   \ifnum\number\p@intvaluex<\r@p@sbbllx
			      \xdef\r@p@sbbllx{\number\p@intvaluex}\fi
			   \ifnum\number\p@intvaluex>\r@p@sbburx
			      \xdef\r@p@sbburx{\number\p@intvaluex}\fi
			   \ifnum\number\p@intvaluey<\r@p@sbblly
			      \xdef\r@p@sbblly{\number\p@intvaluey}\fi
			   \ifnum\number\p@intvaluey>\r@p@sbbury
			      \xdef\r@p@sbbury{\number\p@intvaluey}\fi
			   }
%			lower left
			\rotate@{\@p@sbbllx}{\@p@sbblly}
			\minmaxtest
%			upper left
			\rotate@{\@p@sbbllx}{\@p@sbbury}
			\minmaxtest
%			lower right
			\rotate@{\@p@sbburx}{\@p@sbblly}
			\minmaxtest
%			upper right
			\rotate@{\@p@sbburx}{\@p@sbbury}
			\minmaxtest
			\edef\@p@sbbllx{\r@p@sbbllx}\edef\@p@sbblly{\r@p@sbblly}
			\edef\@p@sbburx{\r@p@sbburx}\edef\@p@sbbury{\r@p@sbbury}
%\ps@typeout{rotated BB: \r@p@sbbllx, \r@p@sbblly, \r@p@sbburx, \r@p@sbbury}
		\fi
		\count203=\@p@sbburx
		\count204=\@p@sbbury
		\advance\count203 by -\@p@sbbllx
		\advance\count204 by -\@p@sbblly
		\edef\@bbw{\number\count203}
		\edef\@bbh{\number\count204}
		%\ps@typeout{ bbh = \@bbh, bbw = \@bbw }
}
%
% \in@hundreds performs #1 * (#2 / #3) correct to the hundreds,
%	then leaves the result in @result
%
\def\in@hundreds#1#2#3{\count240=#2 \count241=#3
		     \count100=\count240	% 100 is first digit #2/#3
		     \divide\count100 by \count241
		     \count101=\count100
		     \multiply\count101 by \count241
		     \advance\count240 by -\count101
		     \multiply\count240 by 10
		     \count101=\count240	%101 is second digit of #2/#3
		     \divide\count101 by \count241
		     \count102=\count101
		     \multiply\count102 by \count241
		     \advance\count240 by -\count102
		     \multiply\count240 by 10
		     \count102=\count240	% 102 is the third digit
		     \divide\count102 by \count241
		     \count200=#1\count205=0
		     \count201=\count200
			\multiply\count201 by \count100
		 	\advance\count205 by \count201
		     \count201=\count200
			\divide\count201 by 10
			\multiply\count201 by \count101
			\advance\count205 by \count201
			%
		     \count201=\count200
			\divide\count201 by 100
			\multiply\count201 by \count102
			\advance\count205 by \count201
			%
		     \edef\@result{\number\count205}
}
\def\compute@wfromh{
		% computing : width = height * (bbw / bbh)
		\in@hundreds{\@p@sheight}{\@bbw}{\@bbh}
		%\ps@typeout{ \@p@sheight * \@bbw / \@bbh, = \@result }
		\edef\@p@swidth{\@result}
		%\ps@typeout{w from h: width is \@p@swidth}
}
\def\compute@hfromw{
		% computing : height = width * (bbh / bbw)
	        \in@hundreds{\@p@swidth}{\@bbh}{\@bbw}
		%\ps@typeout{ \@p@swidth * \@bbh / \@bbw = \@result }
		\edef\@p@sheight{\@result}
		%\ps@typeout{h from w : height is \@p@sheight}
}
\def\compute@handw{
		\if@height 
			\if@width
			\else
				\compute@wfromh
			\fi
		\else 
			\if@width
				\compute@hfromw
			\else
				\edef\@p@sheight{\@bbh}
				\edef\@p@swidth{\@bbw}
			\fi
		\fi
}
\def\compute@resv{
		\if@rheight \else \edef\@p@srheight{\@p@sheight} \fi
		\if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi
		%\ps@typeout{rheight = \@p@srheight, rwidth = \@p@srwidth}
}
%		
% Compute any missing values
\def\compute@sizes{
	\compute@bb
	\if@scalefirst\if@angle
% at this point the bounding box has been adjsuted correctly for
% rotation.  PSFIG does all of its scaling using \@bbh and \@bbw.  If
% a width= or height= was specified along with \psscalefirst, then the
% width=/height= value needs to be adjusted to match the new (rotated)
% bounding box size (specifed in \@bbw and \@bbh).
%    \ps@bbw       width=
%    -------  =  ---------- 
%    \@bbw       new width=
% so `new width=' = (width= * \@bbw) / \ps@bbw; where \ps@bbw is the
% width of the original (unrotated) bounding box.
	\if@width
	   \in@hundreds{\@p@swidth}{\@bbw}{\ps@bbw}
	   \edef\@p@swidth{\@result}
	\fi
	\if@height
	   \in@hundreds{\@p@sheight}{\@bbh}{\ps@bbh}
	   \edef\@p@sheight{\@result}
	\fi
	\fi\fi
	\compute@handw
	\compute@resv}

%
% \psfig
% usage : \psfig{file=, height=, width=, bbllx=, bblly=, bburx=, bbury=,
%			rheight=, rwidth=, clip=}
%
% "clip=" is a switch and takes no value, but the `=' must be present.
\def\psfig#1{\vbox {
	% do a zero width hard space so that a single
	% \psfig in a centering enviornment will behave nicely
	%{\setbox0=\hbox{\ }\ \hskip-\wd0}
	%
	\ps@init@parms
	\parse@ps@parms{#1}
	\compute@sizes
	%
	\ifnum\@p@scost<\@psdraft{
		%
		\special{ps::[begin] 	\@p@swidth \space \@p@sheight \space
				\@p@sbbllx \space \@p@sbblly \space
				\@p@sbburx \space \@p@sbbury \space
				startTexFig \space }
		\if@angle
			\special {ps:: \@p@sangle \space rotate \space} 
		\fi
		\if@clip{
			\if@verbose{
				\ps@typeout{(clip)}
			}\fi
			\special{ps:: doclip \space }
		}\fi
		\if@prologfile
		    \special{ps: plotfile \@prologfileval \space } \fi
		\if@decmpr{
			\if@verbose{
				\ps@typeout{psfig: including \@p@sfile.Z \space }
			}\fi
			\special{ps: plotfile "`zcat \@p@sfile.Z" \space }
		}\else{
			\if@verbose{
				\ps@typeout{psfig: including \@p@sfile \space }
			}\fi
			\special{ps: plotfile \@p@sfile \space }
		}\fi
		\if@postlogfile
		    \special{ps: plotfile \@postlogfileval \space } \fi
		\special{ps::[end] endTexFig \space }
		% Create the vbox to reserve the space for the figure.
		\vbox to \@p@srheight sp{
		% 1/92 TJD Changed from "true sp" to "sp" for magnification.
			\hbox to \@p@srwidth sp{
				\hss
			}
		\vss
		}
	}\else{
		% draft figure, just reserve the space and print the
		% path name.
		\if@draftbox{		
			% Verbose draft: print file name in box
			\hbox{\frame{\vbox to \@p@srheight sp{
			\vss
			\hbox to \@p@srwidth sp{ \hss \@p@sfile \hss }
			\vss
			}}}
		}\else{
			% Non-verbose draft
			\vbox to \@p@srheight sp{
			\vss
			\hbox to \@p@srwidth sp{\hss}
			\vss
			}
		}\fi	



	}\fi
}}
\psfigRestoreAt
\let\@=\LaTeXAtSign


