\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mydefs}[2001/06/04 Aaron D'Souza's math macros]

\RequirePackage{amsmath}
%\RequirePackage{color}

% Matrix formatting
\newcommand{\zmatrix}[1]{\ensuremath{\mathbf{#1}}}

% Declarations for matrices
\newcommand{\mA}{\zmatrix{A}}
\newcommand{\mB}{\zmatrix{B}}
\newcommand{\mC}{\zmatrix{C}}
\newcommand{\mD}{\zmatrix{D}}
\newcommand{\mE}{\zmatrix{E}}
\newcommand{\mF}{\zmatrix{F}}
\newcommand{\mG}{\zmatrix{G}}
\newcommand{\mH}{\zmatrix{H}}
\newcommand{\mI}{\zmatrix{I}}
\newcommand{\mJ}{\zmatrix{J}}
\newcommand{\mK}{\zmatrix{K}}
\newcommand{\mL}{\zmatrix{L}}
\newcommand{\mM}{\zmatrix{M}}
\newcommand{\mN}{\zmatrix{N}}
\newcommand{\mO}{\zmatrix{O}}
\newcommand{\mP}{\zmatrix{P}}
\newcommand{\mQ}{\zmatrix{Q}}
\newcommand{\mR}{\zmatrix{R}}
\newcommand{\mS}{\zmatrix{S}}
\newcommand{\mT}{\zmatrix{T}}
\newcommand{\mU}{\zmatrix{U}}
\newcommand{\mV}{\zmatrix{V}}
\newcommand{\mW}{\zmatrix{W}}
\newcommand{\mX}{\zmatrix{X}}
\newcommand{\mY}{\zmatrix{Y}}
\newcommand{\mZ}{\zmatrix{Z}}

\newcommand{\zmatinv}[1]{#1^{-1}}

% Inverse matrices
\newcommand{\miA}{\zmatinv{\mA}}
\newcommand{\miB}{\zmatinv{\mB}}
\newcommand{\miC}{\zmatinv{\mC}}
\newcommand{\miD}{\zmatinv{\mD}}
\newcommand{\miE}{\zmatinv{\mE}}
\newcommand{\miF}{\zmatinv{\mF}}
\newcommand{\miG}{\zmatinv{\mG}}
\newcommand{\miH}{\zmatinv{\mH}}
\newcommand{\miI}{\zmatinv{\mI}}
\newcommand{\miJ}{\zmatinv{\mJ}}
\newcommand{\miK}{\zmatinv{\mK}}
\newcommand{\miL}{\zmatinv{\mL}}
\newcommand{\miM}{\zmatinv{\mM}}
\newcommand{\miN}{\zmatinv{\mN}}
\newcommand{\miO}{\zmatinv{\mO}}
\newcommand{\miP}{\zmatinv{\mP}}
\newcommand{\miQ}{\zmatinv{\mQ}}
\newcommand{\miR}{\zmatinv{\mR}}
\newcommand{\miS}{\zmatinv{\mS}}
\newcommand{\miT}{\zmatinv{\mT}}
\newcommand{\miU}{\zmatinv{\mU}}
\newcommand{\miV}{\zmatinv{\mV}}
\newcommand{\miW}{\zmatinv{\mW}}
\newcommand{\miX}{\zmatinv{\mX}}
\newcommand{\miY}{\zmatinv{\mY}}
\newcommand{\miZ}{\zmatinv{\mZ}}

% Greek matrix formatting
\newcommand{\zgreekmatrix}[1]{\ensuremath{\boldsymbol{#1}}}

% Declarations for greek matrices
\newcommand{\mDelta}{\zgreekmatrix{\Delta}}
\newcommand{\miDelta}{\mDelta^{-1}}

\newcommand{\mPsi}{\zgreekmatrix{\Psi}}
\newcommand{\miPsi}{\mPsi^{-1}}

\newcommand{\mPhi}{\zgreekmatrix{\Phi}}
\newcommand{\miPhi}{\mPhi^{-1}}

\newcommand{\mLambda}{\zgreekmatrix{\Lambda}}
\newcommand{\miLambda}{\mLambda^{-1}}

\newcommand{\mSigma}{\zgreekmatrix{\Sigma}}
\newcommand{\miSigma}{\mSigma^{-1}}

\newcommand{\mTheta}{\zgreekmatrix{\Theta}}
\newcommand{\miTheta}{\mTheta^{-1}}

\newcommand{\mOmega}{\zgreekmatrix{\Omega}}
\newcommand{\miOmega}{\mOmega^{-1}}

% Vector formatting
\newcommand{\zvector}[1]{\ensuremath{\mathbf{#1}}}

% Declarations for vectors
\newcommand{\va}{\zvector{a}}
\newcommand{\vb}{\zvector{b}}
\newcommand{\vc}{\zvector{c}}
\newcommand{\vd}{\zvector{d}}
\newcommand{\ve}{\zvector{e}}
\newcommand{\vf}{\zvector{f}}
\newcommand{\vg}{\zvector{g}}
\newcommand{\vh}{\zvector{h}}
\newcommand{\vi}{\zvector{i}}
\newcommand{\vj}{\zvector{j}}
\newcommand{\vk}{\zvector{k}}
\newcommand{\vl}{\zvector{l}}
\newcommand{\vm}{\zvector{m}}
\newcommand{\vn}{\zvector{n}}
\newcommand{\vo}{\zvector{o}}
\newcommand{\vp}{\zvector{p}}
\newcommand{\vq}{\zvector{q}}
\newcommand{\vr}{\zvector{r}}
\newcommand{\vs}{\zvector{s}}
\newcommand{\vt}{\zvector{t}}
\newcommand{\vu}{\zvector{u}}
\newcommand{\vv}{\zvector{v}}
\newcommand{\vw}{\zvector{w}}
\newcommand{\vx}{\zvector{x}}
\newcommand{\vy}{\zvector{y}}
\newcommand{\vz}{\zvector{z}}

% Some other vectors
\newcommand{\vzero}{\zvector{0}}
\newcommand{\vone}{\zvector{1}}

% Formatting for greek vectors
\newcommand{\zgreekvector}[1]{\ensuremath{\boldsymbol{#1}}}

% Declarations for greek vectors
\newcommand{\vdelta}{\zgreekvector{\delta}}
\newcommand{\vepsilon}{\zgreekvector{\epsilon}}
\newcommand{\veta}{\zgreekvector{\eta}}
\newcommand{\vtheta}{\zgreekvector{\theta}}
\newcommand{\valpha}{\zgreekvector{\alpha}}
\newcommand{\vbeta}{\zgreekvector{\beta}}
\newcommand{\vmu}{\zgreekvector{\mu}}
\newcommand{\vnu}{\zgreekvector{\nu}}
\newcommand{\vpi}{\zgreekvector{\pi}}
\newcommand{\vphi}{\zgreekvector{\phi}}

% Commonly used stuff
\newcommand{\frach}{\frac{1}{2}}
\newcommand{\sumin}{\sum_{i=1}^N}
\newcommand{\summd}{\sum_{m=1}^d}

% Variable sized delimiters. The first in each group is the general
% purpose command which automatically sizes the delimiters based on
% the contained content. If this produces strange results, only then
% should one try the specific sized ones that follow.

% Determinant |x|
\newcommand{\Det}[1]{\left|#1\right|}
\newcommand{\normalDet}[1]{|#1|}
\newcommand{\bigDet}[1]{\bigl|#1\bigr|}
\newcommand{\BigDet}[1]{\Bigl|#1\Bigr|}
\newcommand{\biggDet}[1]{\biggl|#1\biggr|}
\newcommand{\BiggDet}[1]{\Biggl|#1\Biggr|}

% Parenthesis (x)
\newcommand{\Paren}[1]{\left(#1\right)}
\newcommand{\normalParen}[1]{(#1)}
\newcommand{\bigParen}[1]{\bigl(#1\bigr)}
\newcommand{\BigParen}[1]{\Bigl(#1\Bigr)}
\newcommand{\biggParen}[1]{\biggl(#1\biggr)}
\newcommand{\BiggParen}[1]{\Biggl(#1\Biggr)}

% Braces {x}
\newcommand{\Brace}[1]{\left\{#1\right\}}
\newcommand{\normalBrace}[1]{\{#1\}}
\newcommand{\bigBrace}[1]{\bigl\{#1\bigr\}}
\newcommand{\BigBrace}[1]{\Bigl\{#1\Bigr\}}
\newcommand{\biggBrace}[1]{\biggl\{#1\biggr\}}
\newcommand{\BiggBrace}[1]{\Biggl\{#1\Biggr\}}

% Brackets [x]
\newcommand{\Bracket}[1]{\left[#1\right]}
\newcommand{\normalBracket}[1]{[#1]}
\newcommand{\bigBracket}[1]{\bigl[#1\bigr]}
\newcommand{\BigBracket}[1]{\Bigl[#1\Bigr]}
\newcommand{\biggBracket}[1]{\biggl[#1\biggr]}
\newcommand{\BiggBracket}[1]{\Biggl[#1\Biggr]}

% Triangular brackets <x>
\newcommand{\Tribracket}[1]{\left\langle #1\right\rangle}
\newcommand{\normalTribracket}[1]{\langle#1\rangle}
\newcommand{\bigTribracket}[1]{\bigl\langle #1\bigr\rangle}
\newcommand{\BigTribracket}[1]{\Bigl\langle #1\Bigr\rangle}
\newcommand{\biggTribracket}[1]{\biggl\langle #1\biggr\rangle}
\newcommand{\BiggTribracket}[1]{\Biggl\langle #1\Biggr\rangle}

% Convenient for arbitrary sized matrices. Use as follows:
% \BMatrix{x & y & z \\ a & b & c} which gives
%   |x  y  z|
%   |a  b  c|
\newcommand{\BMatrix}[1]{\begin{bmatrix}#1\end{bmatrix}}

% Declarations for calligraphic characters
\newcommand{\calA}{\mathcal{A}}
\newcommand{\calB}{\mathcal{B}}
\newcommand{\calC}{\mathcal{C}}
\newcommand{\calD}{\mathcal{D}}
\newcommand{\calE}{\mathcal{E}}
\newcommand{\calF}{\mathcal{F}}
\newcommand{\calG}{\mathcal{G}}
\newcommand{\calH}{\mathcal{H}}
\newcommand{\calI}{\mathcal{I}}
\newcommand{\calJ}{\mathcal{J}}
\newcommand{\calK}{\mathcal{K}}
\newcommand{\calL}{\mathcal{L}}
\newcommand{\calM}{\mathcal{M}}
\newcommand{\calN}{\mathcal{N}}
\newcommand{\calO}{\mathcal{O}}
\newcommand{\calP}{\mathcal{P}}
\newcommand{\calQ}{\mathcal{Q}}
\newcommand{\calR}{\mathcal{R}}
\newcommand{\calS}{\mathcal{S}}
\newcommand{\calT}{\mathcal{T}}
\newcommand{\calU}{\mathcal{U}}
\newcommand{\calV}{\mathcal{V}}
\newcommand{\calW}{\mathcal{W}}
\newcommand{\calX}{\mathcal{X}}
\newcommand{\calY}{\mathcal{Y}}
\newcommand{\calZ}{\mathcal{Z}}

% I use this a lot
\newcommand{\Data}{\calD}
\newcommand{\vxD}{{\vx_{\Data}}}
\newcommand{\vxH}{{\vx_{\calH}}}

% Standardize notation for various distributions
\newcommand{\Normdist}[3]{\ensuremath{\text{Normal}\Paren{#1;#2,#3}}}
\newcommand{\mNormZ}[2]{\ensuremath{\frac{1}{\Paren{2\pi}^{#1/2}\Det{#2}^{1/2}}}}
\newcommand{\mNormForm}[4]{\ensuremath{\mNormZ{#2}{#4}\exp\Brace{-\frach\AtBA{\Paren{#1-#3}}{#4^{-1}}}}}
\newcommand{\Gamdist}[3]{\ensuremath{\text{Gamma}\Paren{#1;#2,#3}}}
\newcommand{\Dirdist}[2]{\ensuremath{\text{Dirichlet}\Paren{#1;#2}}}
\newcommand{\Dirproc}[1]{\ensuremath{\text{DP}\Paren{#1}}}
%\newcommand{\Dirdist}[2]{\ensuremath{\text{Dirichlet}\Paren{#2}}}
\newcommand{\Berndist}[2]{\ensuremath{\text{Bernoulli}\Paren{#1;#2}}}
\newcommand{\Betadist}[3]{\ensuremath{\text{Beta}\Paren{#1;#2,#3}}}
%\newcommand{\Betadist}[3]{\ensuremath{\text{Beta}\Paren{#2,#3}}}
\newcommand{\Wishdist}[3]{\ensuremath{\text{Wishart}_{#2}\Paren{#1;#3}}}
\newcommand{\Bindist}[2]{\ensuremath{\text{Binomial}\Paren{#1;#2}}}
\newcommand{\Studist}[4]{\ensuremath{t_{#3}\Paren{#1;#2,#4}}}
\newcommand{\Multdist}[2]{\ensuremath{\text{Multinomial}\Paren{#1;#2}}}
\newcommand{\SIXdist}[3]{\ensuremath{\text{Scaled-Inv}_{\chi^2}\Paren{#1;#2,#3}}}

% Declare these as operators so we can use \Trace, \diag etc. in math mode
\DeclareMathOperator{\Trace}{Tr}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\Entropy}{Entropy}

\newcommand{\Expect}[1]{\ensuremath{\Tribracket{#1}}}
\newcommand{\Digamma}[1]{\ensuremath{\psi\Paren{#1}}}

\newcommand{\Comment}[1]{\textcolor{red}{#1}}
\newcommand{\AtBA}[2]{{#1}^T #2 #1}
\newcommand{\Abs}[1]{\left|#1\right|}
