%=====================================================================================================================================
% Package akkmathnum by Igor Akkerman (c) 2000, 2001, 2002, 2003, 2004, 2005
% Package providing utilities for typesett	ing numeric elements.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License (latest version).
%
% The latest version of this license can be found at
%     http://www.latex-project.org/lppl.txt
%
% This file may only be distributed together with the full 'AkkTeX' bundle.
%=====================================================================================================================================
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{akkmathnum}[2005/04/30 1.1.0 by Igor Akkerman (c) 2000, 2001, 2002, 2003, 2004, 2005 Package providing utilities for typesetting numeric elements]
%=====================================================================================================================================

\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{amstext}
\RequirePackage{latexsym}
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

\makeatletter

%------------------------------------------------------------------------------
% numeric utilities
%------------------------------------------------------------------------------
% inverse
\providecommand \inv        {^{-1}}          % do not wrap twice! {{}}

% inverse of argument
\providecommand \Inv[1]     {{{#1}\inv}}

% faculty with text to follow
\newcommand     \fac        {{!\,}}

% 'divides' bar
\newcommand     \divides    {{\,|\,}}

\newcommand     \llceil     {{\left\lceil}}
\newcommand     \rrceil     {{\right\rceil}}
\newcommand     \llfloor    {{\left\lfloor}}
\newcommand     \rrfloor    {{\right\rfloor}}

\newcommand     \bfrac[2]   {{\frac{\displaystyle #1}{\displaystyle #2}}}
\newcommand     \sfrac[2]   {{\frac{\textstyle #1}{\textstyle #2}}}
\newcommand     \bpwr[1]    {^{\displaystyle #1}}                             % do not wrap twice! {{}}
\newcommand     \bsqrt[2][] {{\sqrt[{\displaystyle #1}]{{\displaystyle #2}}}}

% the absolute value
\newcommand     \abs[1]     {{|#1|}}
\newcommand     \Abs[1]     {{\left|#1\right|}}

% degree of a polynom
\newcommand     \grad       {\operatorname{grad}}

\newcommand     \Rang       {\operatorname{Rang}}
\newcommand     \rang       {\operatorname{rang}}
\newcommand     \rg         {\operatorname{rg}}

\newcommand     \Dim        {\operatorname{Dim}}
\newcommand     \codim      {\operatorname{codim}}
\newcommand     \Codim      {\operatorname{Codim}}

\newcommand     \norm[1]    {{\| #1 \|}}
\newcommand     \Norm[1]    {{\left\| #1 \right\|}}
\newcommand     \normfun    {{\norm{\ }}}

\newcommand     \scalar[2]  {{\langle #1,#2 \rangle}}
\newcommand     \Scalar[2]  {{\left\langle #1,#2 \right\rangle}}
\newcommand     \scalarfun  {{\scalar{}{}}}


%------------------------------------------------------------------------------
% integrals
%------------------------------------------------------------------------------
\newcommand     \Int         {\int\limits}
\newcommand     \intt        {\int\!}
\newcommand     \intd[2]     {\intt\frac{d #1}{#2}}
\newcommand     \dt          {\ dt}
\newcommand     \dx          {\ dx}
\newcommand     \dy          {\ dy}
\newcommand     \dz          {\ dz}

%------------------------------------------------------------------------------
% differentials
%------------------------------------------------------------------------------
\newcommand     \dd[1][]    {\ensuremath{\mathrm d^{#1}}}

% differential: \diff[<text on top of fraction bar>]{<variable>}
\newcommand     \diff[2][]  {\frac{\dd {#1}}{\dd {#2}}}

% multiple differential: \mdiff[<on top of fraction bar>]{<degree>}{<variable>}
\newcommand     \mdiff[3][] {\ensuremath{\frac{\dd[#2]#1}{\dd #3^{#2}}}}

% multiple differential of a function (= f^{(n)}}
\newcommand     \mdif[1]    {^{({#1})}}

%------------------------------------------------------------------------------
% limits
%------------------------------------------------------------------------------
\newcommand     \alim[1]    {{\lim_{{#1}\to\infty}}}
\newcommand     \aLim[1]    {{\lim\limits_{{#1}\to\infty}}}
\newcommand     \alimsup[1] {{\limsup_{{#1}\to\infty}}}
\newcommand     \aLimsup[1] {{\limsup\limits_{{#1}\to\infty}}}
\newcommand     \aliminf[1] {{\liminf_{{#1}\to\infty}}}
\newcommand     \aLiminf[1] {{\liminf\limits_{{#1}\to\infty}}}

\newcommand     \klim       {{\alim k}}
\newcommand     \kLim       {{\aLim k}}
\newcommand     \klimsup    {{\alimsup k}}
\newcommand     \kLimsup    {{\aLimsup k}}
\newcommand     \kliminf    {{\aliminf k}}
\newcommand     \kLiminf    {{\aLiminf k}}

\newcommand     \nlim       {{\alim n}}
\newcommand     \nLim       {{\aLim n}}
\newcommand     \nlimsup    {{\alimsup n}}
\newcommand     \nLimsup    {{\aLimsup n}}
\newcommand     \nliminf    {{\aliminf n}}
\newcommand     \nLiminf    {{\aLiminf n}}


\newcommand     \mlim       {{\alim m}}
\newcommand     \mLim       {{\aLim m}}
\newcommand     \mlimsup    {{\alimsup m}}
\newcommand     \mLimsup    {{\aLimsup m}}
\newcommand     \mliminf    {{\aliminf m}}
\newcommand     \mLiminf    {{\aLiminf m}}

\newcommand     \plim       {{\alim p}}
\newcommand     \pLim       {{\aLim p}}
\newcommand     \plimsup    {{\alimsup p}}
\newcommand     \pLimsup    {{\aLimsup p}}
\newcommand     \pliminf    {{\aliminf p}}
\newcommand     \pLiminf    {{\aLiminf p}}

%------------------------------------------------------------------------------
% limits arrows
%------------------------------------------------------------------------------
\newcommand     \upto       \nearrow
\newcommand     \downto     \searrow

%------------------------------------------------------------------------------
% dots
%------------------------------------------------------------------------------
\newcommand     \plusdots   {{+\cdots+}}
\newcommand     \minusdots  {{-\cdots-}}
\newcommand     \pmdots     {{+-\cdots+-}}
\newcommand     \dotdots    {{\cdot\cdots\cdot}}
\newcommand     \timesdots  {{\times\cdots\times}}
\newcommand     \eqdots     {{=\cdots=}}
\newcommand     \commadots  {{,\dots,}}
\newcommand     \svdots     {{\parbox[b][10pt]{\widthof{\vdots}}{\vdots}}} % vertical dots for small matrix

%------------------------------------------------------------------------------
% sums and products
%------------------------------------------------------------------------------
\newcommand     \Sum        {\sum\limits}
\newcommand     \summ[3]    {\sum_{{#1}={#2}}^{{#3}}}
\newcommand     \Summ[3]    {\sum\limits_{{#1}={#2}}^{{#3}}}
\newcommand     \Prod       {\prod\limits}
\newcommand     \prodd[3]   {\prod_{{#1}={#2}}^{{#3}}}
\newcommand     \Prodd[3]   {\prod\limits_{{#1}={#2}}^{{#3}}}

%------------------------------------------------------------------------------
% sequences and series
%------------------------------------------------------------------------------
\newcommand     \seq[2]     {{\({#1_{#2}}\)}}
\newcommand     \nnseq[2]   {{{\({#1_{#2}}\)}_{{#2}\in\NN}}}
\newcommand     \nnnseq[2]  {{\left({#1_{#2}}\right)_{{#2}\geq1}}}
\newcommand     \partseq[3] {{\folge{#1}{#2_{#3}}}}
% the operator before the underscore should not be wrapped because a'_{ij} looks better than {a'}_{ij}

\newcommand     \Nsum[2]    {{\summ #1 #2 N}}
\newcommand     \NSum[2]    {{\Summ #1 #2 N}}
\newcommand     \Nprod[2]   {{\prodd #1 #2 N}}
\newcommand     \NProd[2]   {{\Prodd #1 #2 N}}
\newcommand     \isum       {\sum_{i \in I}}
\newcommand     \iSum       {\sum\limits_{i \in I}}
\newcommand     \iprod      {\prod_{i \in I}}
\newcommand     \iProd      {\prod\limits_{i \in I}}
\newcommand     \series[2]  {{\summ #1 #2 \infty}}
\newcommand     \Series[2]  {{\Summ #1 #2 \infty}}

%------------------------------------------------------------------------------
% complex numbers
%------------------------------------------------------------------------------
\newcommand     \real       {{\mathrm{Re}}}
\newcommand     \imag       {{\mathrm{Im}}}
\newcommand     \coco[1]    {\overline{#1}}

\newcommand     \cocofun    {\coco{\phantom{o}}}
%------------------------------------------------------------------------------
% Vectors
%------------------------------------------------------------------------------
\newcommand     \avec[1]    {\mtx{#1}}
\newcommand     \rvec[1]    {\rmtx{#1}}
\newcommand     \tvec[1]    {{\textstyle\avec{#1}}}
\newcommand     \trvec[1]   {{\textstyle\rvec{#1}}}
\newcommand     \dvec[1]    {{\displaystyle\avec{#1}}}
\newcommand     \drvec[1]   {{\displaystyle\rvec{#1}}}
\newcommand     \svec[1]    {\smtx{#1}}

\newcommand     \lvec[3][]   {\overrightarrow{#2#3}\ifset{#1}{\text{\scriptsize{\ensuremath{#1}}}}}
\newcommand     \vecfun[1][] {\lvec[#1]{\mbox{\phantom o}}{}}
%\newcommand     \vecfun {\overrightarrow{\mbox{\phantom o}}}

%------------------------------------------------------------------------------
% Matrices
%------------------------------------------------------------------------------

% matrix template
% \akk@mtx{columntype}{matrixcontent}
\newcommand \akk@mtx[2] {%
    \hspace{-\arraycolsep}%
    \begin{array}{*{\value{MaxMatrixCols}}{#1}}%
        #2%
    \end{array}%
    \hspace{-\arraycolsep}%
}

% matrix with parantheses (default matrix)
\newcommand     \mtx[1]     {{\left(\akk@mtx{c}{#1}\right)}}
\newcommand     \Mtx[1]     {{\left(\akk@mtx{C}{#1}\right)}}
\newcommand     \lmtx[1]    {{\left(\akk@mtx{l}{#1}\right)}}
\newcommand     \rmtx[1]    {{\left(\akk@mtx{r}{#1}\right)}}
\newcommand     \lMtx[1]    {{\left(\akk@mtx{L}{#1}\right)}}
\newcommand     \rMtx[1]    {{\left(\akk@mtx{R}{#1}\right)}}
\newcommand     \smtx[1]    {{\left(\begin{smallmatrix}#1\end{smallmatrix}\right)}}

% matrix with nothing around (free matrix)
\newcommand     \fmtx[1]    {\akk@mtx{c}{#1}}
\newcommand     \fMtx[1]    {\akk@mtx{C}{#1}}
\newcommand     \lfmtx[1]   {\akk@mtx{l}{#1}}
\newcommand     \rfmtx[1]   {\akk@mtx{r}{#1}}
\newcommand     \lfMtx[1]   {\akk@mtx{L}{#1}}
\newcommand     \rfMtx[1]   {\akk@mtx{R}{#1}}
\newcommand     \sfmtx[1]   {{\begin{smallmatrix}#1\end{smallmatrix}}}

% matrix with brackets
\newcommand     \bmtx[1]    {{\left[\akk@mtx{c}{#1}\right]}}
\newcommand     \bMtx[1]    {{\left[\akk@mtx{C}{#1}\right]}}
\newcommand     \lbmtx[1]   {{\left[\akk@mtx{l}{#1}\right]}}
\newcommand     \rbmtx[1]   {{\left[\akk@mtx{r}{#1}\right]}}
\newcommand     \lbMtx[1]   {{\left[\akk@mtx{L}{#1}\right]}}
\newcommand     \rbMtx[1]   {{\left[\akk@mtx{R}{#1}\right]}}
\newcommand     \sbmtx[1]   {{\left[\begin{smallmatrix}#1\end{smallmatrix}\right]}}

% matrix with curly braces
\newcommand     \cbmtx[1]   {{\left\lbrace\akk@mtx{c}{#1}\right\rbrace}}
\newcommand     \cbMtx[1]   {{\left\lbrace\akk@mtx{C}{#1}\right\rbrace}}
\newcommand     \lcbmtx[1]  {{\left\lbrace\akk@mtx{l}{#1}\right\rbrace}}
\newcommand     \rcbmtx[1]  {{\left\lbrace\akk@mtx{r}{#1}\right\rbrace}}
\newcommand     \lcbMtx[1]  {{\left\lbrace\akk@mtx{L}{#1}\right\rbrace}}
\newcommand     \rcbMtx[1]  {{\left\lbrace\akk@mtx{R}{#1}\right\rbrace}}
\newcommand     \scbmtx[1]  {{\left\lbrace\begin{smallmatrix}#1\end{smallmatrix}\right\rbrace}}

% determinant of a matrix
\newcommand     \detmtx[1]  {{\left\lvert\akk@mtx{c}{#1}\right\rvert}}
\newcommand     \detMtx[1]  {{\left\lvert\akk@mtx{C}{#1}\right\rvert}}
\newcommand     \ldetmtx[1] {{\left\lvert\akk@mtx{l}{#1}\right\rvert}}
\newcommand     \rdetmtx[1] {{\left\lvert\akk@mtx{r}{#1}\right\rvert}}
\newcommand     \ldetMtx[1] {{\left\lvert\akk@mtx{L}{#1}\right\rvert}}
\newcommand     \rdetMtx[1] {{\left\lvert\akk@mtx{R}{#1}\right\rvert}}
\newcommand     \sdetmtx[1] {{\left\lvert\begin{smallmatrix}#1\end{smallmatrix}\right\rvert}}

% norm of a matrix
\newcommand     \normmtx[1]  {{\left\lVert\akk@mtx{c}{#1}\right\rVert}}
\newcommand     \normMtx[1]  {{\left\lVert\akk@mtx{C}{#1}\right\rVert}}
\newcommand     \lnormmtx[1] {{\left\lVert\akk@mtx{l}{#1}\right\rVert}}
\newcommand     \rnormmtx[1] {{\left\lVert\akk@mtx{r}{#1}\right\rVert}}
\newcommand     \lnormMtx[1] {{\left\lVert\akk@mtx{L}{#1}\right\rVert}}
\newcommand     \rnormMtx[1] {{\left\lVert\akk@mtx{R}{#1}\right\rVert}}
\newcommand     \snormmtx[1] {{\left\lVert\begin{smallmatrix}#1\end{smallmatrix}\right\rVert}}

% (M)1<=i<=n,1<=j<=m
% \ijmtx {matrixelementsname}{number of rows} {number of columns} (any matrix)
% \ijsmtx{matrixelementsname}{number of rows&columns}             {square matrix)
\newcommand     \ijmtx[3]   {{(#1_{ij})}_{\substack{1 \leq i \leq #2 \\ 1 \leq j \leq #3}}}
\newcommand     \ijsmtx[2]  {{(#1_{ij})}_{1 \leq i,j \leq #2}}
% the operator before the underscore should not be wrapped because a'_{ij} looks better than {a'}_{ij}

\newcommand     \sgn        {\operatorname{sgn}}
\newcommand     \spur       {\operatorname{spur}}
\newcommand     \fchar      {\operatorname{char}}

\newcommand     \MM         {{\mathcal M}}
\newcommand     \mtxset[2]  {\MM(#1 \times #2; K)}

\newcounter{refmtxrow}
\newcommand \mtxrow[1] {%
    \setcounter{refmtxrow}{#1}%
    \mathrm{\Roman{refmtxrow}}%
}

%------------------------------------------------------------------------------
% Linear equation systems
%------------------------------------------------------------------------------
% linear equation system environment
% \begin{les}{<number of variables>}
%     ...
% \end{les}
% example:                           for
% \begin{les}{4}                       
%     &  1 &  3 &  2 & -2 & 5      \\  I     1  3  2 -2 | 5
%     & -1 &  3 & -3 & -1 & 0 & +I \\  II   -1  3 -3 -1 | 0 |+I
%     &  1 &  3 &  2 & -1 & 9 & -I \\  III   1  3  2 -1 | 9 |-I
%     & -1 & -3 &  0 &  2 & 1 & +I     IV   -1 -3  0  2 | 1 |+I
% \end{les}
\newcounter {lesrow}
\newcommand \resetlesrow {\setcounter{lesrow}{-1}}

\newenvironment {les}[1] {%
    \setcounter{lesrow}{0}%
    \begin{array}{@{}r<{\stepcounter{lesrow}\lesrow\thelesrow\ }*{#1}{r}|r>{|}l}%
}{%
    \end{array}%
}

\newenvironment {les*}[1] {%
    \setcounter{lesrow}{0}\begin{array}{*{#1}{c}|r>{|}l}%
}{%
    \end{array}%
}

\newcommand \lesrow[1] {%
    \mathrm{\Romannum{#1}}%
}

%------------------------------------------------------------------------------
% array for solving equations (in displaystyle)
%
% format: c R c L c L
%------------------------------------------------------------------------------
\newenvironment{eqsolving}
{\begin{displaymath}\begin{array}{cRcLcL}}
{\end{array}\end{displaymath}}

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

\makeatother
