
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%               Newcommands              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

% LITERAL ABBREVIATIONS
\newcommand{\ie}{i.e.~}
\newcommand{\eg}{e.g.~}
\newcommand{\etc}{\textit{etc.}}
\newcommand{\etal}{\textit{et~al.}}
\newcommand{\wrt}{w.r.t.~}

% DIRAC NOTATION
\newcommand{\bra}[1]{\langle #1 |}
\newcommand{\ket}[1]{|#1\rangle}
\newcommand{\braket}[2]{\langle #1 | #2 \rangle}
\newcommand{\bigbra}[1]{\big\langle #1 \big|}
\newcommand{\bigket}[1]{\big| #1 \big\rangle}
\newcommand{\bigbraket}[2]{\big\langle #1 \big| #2 \big\rangle}
%

% EQUATIONS
\newcommand{\beq}[1]{\begin{equation} \eqlab{#1}}
\newcommand{\eeq}{\end{equation}}
\newcommand{\bal}{\begin{align}}
\newcommand{\eal}{\end{align}}

\newcommand{\bsubal}[2]{\bsub \eqlab{#1}\bal#2\eal}
\newcommand{\esubal}{\esub}
% begin/end align with a,b,c-equation labels
\newcommand{\bsub}{\begin{subequations}}
\newcommand{\esub}{\end{subequations}}
\newcommand{\nn}{\nonumber}
\newcommand{\bsubalat}[3]{\bsub\eqlab{#1}\begin{alignat}{#2}#3\end{alignat}}
\newcommand{\esubalat}{\esub}
%
% LABELS
\newcommand{\eqlab}[1]{\label{eq:#1}}
\renewcommand{\eqref}[1]{Eq.~(\ref{eq:#1})}
\newcommand{\eqnoref}[1]{(\ref{eq:#1})}
\newcommand{\eqsref}[2]{Eqs.~(\ref{eq:#1}) and~(\ref{eq:#2})}
\newcommand{\eqsnoref}[2]{(\ref{eq:#1}) and~(\ref{eq:#2})}
\newcommand{\figref}[1]{Figure~\ref{fig:#1}}
\newcommand{\figsrefs}[2]{Figs.~\ref{fig:#1} and~\ref{fig:#2}}
\newcommand{\figlab}[1]{\label{fig:#1}}
\newcommand{\tabref}[1]{Table~\ref{tab:#1}}
\newcommand{\tabsref}[2]{Tables~\ref{tab:#1} and~\ref{tab:#2}}
\newcommand{\tablab}[1]{\label{tab:#1}}
\newcommand{\appref}[1]{Appendix~\ref{app:#1}}
\newcommand{\appsref}[2]{Appendices~\ref{app:#1} and~\ref{app:#2}}
\newcommand{\applab}[1]{\label{app:#1}}
\newcommand{\chapref}[1]{Chapter~\ref{chap:#1}}
\newcommand{\chapsref}[2]{Chapters~\ref{chap:#1} and~\ref{chap:#2}}
\newcommand{\chaplab}[1]{\label{chap:#1}}
\newcommand{\secref}[1]{Section~\ref{sec:#1}}
\newcommand{\secsref}[2]{Sections~\ref{sec:#1} and~\ref{sec:#2}}
\newcommand{\seclab}[1]{\label{sec:#1}}
\newcommand{\algref}[1]{Algorithm~\ref{alg:#1}}
\newcommand{\algsref}[2]{Algorithms~\ref{alg:#1} and~\ref{alg:#2}}
\newcommand{\alglab}[1]{\label{alg:#1}}

% MATH SYMBOLS
\newcommand{\grad}{\boldsymbol{\nabla}}
\newcommand{\divop}{\grad\scap}
\renewcommand{\vec}[1]{\bm{#1}}
\newcommand{\trans}[1]{#1^\mr{T}}
\newcommand{\dm}{\mathrm{d}}
\newcommand{\mN}{\mathcal{N}}
\newcommand{\mMN}{\mathcal{MN}}
\newcommand{\mL}{\mathcal{L}}
\newcommand{\mO}{\mathcal{O}}
\newcommand{\mI}{\mathcal{I}}
\newcommand{\mE}{\mathcal{E}}
\newcommand{\mA}{\mathcal{A}}
\newcommand{\mG}{\mathcal{G}}
\newcommand{\mD}{\mathcal{D}}
\newcommand{\mU}{\mathcal{U}}
\newcommand{\mT}{\mathcal{T}}
\newcommand{\mF}{\mathcal{F}}
\newcommand{\mS}{\mathcal{S}}
\newcommand{\mH}{\mathcal{H}}
\newcommand{\mX}{\mathcal{X}}
\newcommand{\complex}{\mathbb{C}}
\newcommand{\real}{\mathbb{R}}

% MATH STYLE
\newcommand{\scap}{\!\cdot\!}
\newcommand{\intd}[1]{\int\!\dm#1\: }

% MATH NOTATION
\newcommand{\ave}[1]{\left\langle #1 \right\rangle}
\newcommand{\br}[1]{\left\lbrack #1 \right\rbrack}
\newcommand{\paren}[1]{\left(#1\right)}
\newcommand{\tub}[1]{\left\{#1\right\}}
\newcommand{\mr}[1]{\mathrm{#1}}
\newcommand{\vt}[1]{\left.#1\right\vert}
\newcommand{\abs}[1]{\left\lvert#1\right\rvert}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}

% VECTORS, MATRICES
\newcommand{\sigv}{\vec{\sigma}}
\newcommand{\sigvt}{\trans{\sigv}}
\newcommand{\yyy}{\vec{y}}
\newcommand{\yyyt}{\trans{\yyy}}
\newcommand{\aaa}{\vec{a}}
\newcommand{\aaat}{\trans{\aaa}}
\newcommand{\AAA}{\vec{A}}
\newcommand{\AAAt}{\trans{\AAA}}
\newcommand{\fff}{\vec{f}}
\newcommand{\ffft}{\trans{\fff}}
\newcommand{\FFF}{\vec{F}}
\newcommand{\FFFt}{\trans{\FFF}}
\newcommand{\vvv}{\vec{v}}
\newcommand{\vvvt}{\trans{\vvv}}
\newcommand{\VVV}{\vec{V}}
\newcommand{\VVVt}{\trans{\VVV}}
\newcommand{\III}{\vec{I}}
\newcommand{\IIIt}{\trans{\III}}
\newcommand{\eee}{\vec{e}}
\newcommand{\eeet}{\trans{\eee}}
\newcommand{\ooo}{\vec{0}}
\newcommand{\ooot}{\trans{\vec{0}}}
\newcommand{\xxx}{\vec{x}}
\newcommand{\xxxt}{\trans{\xxx}}
\newcommand{\alalal}{\vec{\alpha}}
\newcommand{\alalalt}{\trans{\alalal}}
\newcommand{\ththth}{\vec{\theta}}
\newcommand{\XXX}{\vec{X}}
\newcommand{\XXXt}{\trans{\XXX}}
\newcommand{\JJJ}{\vec{J}}
\newcommand{\JJJt}{\trans{\JJJ}}
\newcommand{\www}{\vec{w}}
\newcommand{\wwwt}{\trans{\www}}
\renewcommand{\ggg}{\vec{g}}
\newcommand{\gggt}{\trans{\ggg}}
\newcommand{\bbb}{\vec{b}}
\newcommand{\bbbt}{\trans{\bbb}}
\newcommand{\ttt}{\vec{t}}
\newcommand{\tttt}{\trans{\ttt}}
\newcommand{\TTT}{\vec{T}}
\newcommand{\TTTt}{\trans{\TTT}}
\newcommand{\WWW}{\vec{W}}
\newcommand{\WWWt}{\trans{\WWW}}
\newcommand{\QQQ}{\vec{Q}}
\newcommand{\ZZZ}{\vec{Z}}
\newcommand{\ZZZt}{\trans{\ZZZ}}
\newcommand{\HHH}{\vec{H}}
\newcommand{\HHHt}{\trans{\HHH}}
\newcommand{\ppi}{\vec{\pi}}
\newcommand{\ppit}{\trans{\ppi}}
\newcommand{\lamm}{\vec{\lambda}}
\newcommand{\lammt}{\trans{\lamm}}
\newcommand{\ccc}{\vec{c}}
\newcommand{\ccct}{\trans{\ccc}}
\newcommand{\ppp}{\vec{p}}
\newcommand{\pppt}{\trans{\ppp}}
\newcommand{\uuu}{\vec{u}}
\newcommand{\uuut}{\trans{\uuu}}
\newcommand{\muu}{\vec{\mu}}
\newcommand{\muut}{\trans{\muu}}
\newcommand{\CCC}{\vec{C}}
\newcommand{\CCCt}{\trans{\CCC}}
\newcommand{\zzz}{\vec{z}}
\newcommand{\zzzt}{\trans{\zzz}}
\newcommand{\sss}{\vec{s}}
\newcommand{\ssst}{\trans{\sss}}
\newcommand{\SSS}{\vec{S}}
\newcommand{\SSSt}{\trans{\SSS}}
\newcommand{\LLL}{\vec{L}}
\newcommand{\LLLt}{\trans{\LLL}}
\renewcommand{\lll}{\vec{l}}
\newcommand{\lllt}{\trans{\lll}}
\newcommand{\rrrt}{\trans{\rrr}}
\newcommand{\RRRt}{\trans{\RRR}}
\newcommand{\SiSiSi}{\vec{\Sigma}}
\newcommand{\SiSiSit}{\trans{\Sigma}}
\newcommand{\hhh}{\vec{h}}
\newcommand{\hhht}{\trans{\hhh}}
\newcommand{\one}{\vec{1}}
\newcommand{\onet}{\trans{\one}}

\newcommand\xlat{\xxx_{\mr{lat}}}
\newcommand\xobs{\xxx_{\mr{obs}}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% New Math operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\newcommand{\trace}[1]{\mr{Tr}\paren{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Stat and Machine Learning notation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\mean}[1]{\mathbb{E}\br{#1}}
\newcommand{\meanq}[1]{\mathbb{E}_{q}\br{#1}}
\newcommand{\meannni}[1]{\mathbb{E}_{-i}\br{#1}}
\newcommand{\meanp}[2]{\mathbb{E}_{#1}\br{#2}}
\newcommand{\kl}[2]{\mr{KL}\paren{\vt{\vt{#1~}}#2}}
\newcommand{\js}[2]{\mr{JS}\paren{\vt{\vt{#1}}#2}}
\newcommand{\elbo}[1]{\mr{ELBO}\paren{#1}}
\newcommand{\loss}{\mL}
\newcommand{\lossq}{\loss_\mr{sq}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Prior notation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\IBP}{\mathcal{IBP}}
\newcommand{\BeP}{\mathcal{BeP}}
\newcommand{\bp}{\mathcal{bp}}
\newcommand{\npbNMFinf}{\mr{npbNMF}^i_\infty}
\newcommand{\npbNMFfinite}{\mr{npbNMF}^i_\approx}
\newcommand{\npbNMFinfshared}{\mr{npbNMF}^\text{shared}_\infty}
\newcommand{\npbNMFfiniteshared}{\mr{npbNMF}^\text{shared}_\approx}
\newcommand{\npbNMFinfsparse}{\mr{npbNMF}^\text{sparse}_\infty}
\newcommand{\npbNMFfinitesparse}{\mr{npbNMF}^\text{sparse}_\approx}
\newcommand{\npbNMFfinitess}{\mr{npbNMF}^\text{ss}_\approx}
\newcommand{\npbNMFinfss}{\mr{npbNMF}^\text{ss}_\infty}
% \newenvironment{rcases}{\left.\begin{aligned}}{\end{aligned}\right\rbrace}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% underbrace inside matrices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\newcommand{\block}[1]{\underbrace{\begin{matrix}1 & \cdots & 1\end{matrix}}_{#1}}
%\newcommand{\blockt}[1]{\begin{rcases} \begin{matrix} ~\\ ~\\ ~ \end{matrix} \end{rcases}{#1}}
