% https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=2ahUKEwiwv6SOxr3gAhVp6KYKHUAfBMUQFjABegQIHBAC&url=http%3A%2F%2Fctan.math.washington.edu%2Ftex-archive%2Fmacros%2Flatex%2Fcontrib%2Fglossaries%2Fglossaries-user.pdf&usg=AOvVaw31Aw4LHCUnYYR1r6HL9_ZG
\newcommand*{\sym}[4]{
	\newglossaryentry{#1}{type=symbols,name={$#2$},sort={#3},description={#4}}
	}
% \newglossaryentry{}{type=symbols,name=$$,sort=,description={}}

% \macsym{macro}{name}{sort}{description}

% -----------------------------------------------------------------------------
% Mathematics basics
% -----------------------------------------------------------------------------


%	Define new math operators
\DeclareMathOperator{\imag}{im}
%\DeclareMathOperator{\kern}{kern} %somewhere already defined
\DeclareMathOperator{\essinf}{ess-inf}
\DeclareMathOperator*{\esssup}{ess-sup}
\DeclareMathOperator{\dist}{dist}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\graph}{graph}
\DeclareMathOperator{\sign}{sign}
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\sat}{sat}
\DeclareMathOperator{\spec}{spec}
\DeclareMathOperator{\loc}{loc}
\DeclareMathOperator{\grad}{grad}
\DeclareMathOperator{\fin}{fin}
\DeclareMathOperator{\vol}{vol}
\DeclareMathOperator{\col}{col}
\DeclareMathOperator{\row}{row}
\DeclareMathOperator{\lin}{lin}
\DeclareMathOperator{\step}{step}

%	Abbreviate sets, compact sets  (of numbers, ...)


\newcommand{\F}{\mathbb{F}}
\sym{sy:F}{\F}{F}{sets of fett numbers ...}
\newcommand{\X}{\mathbb{X}}
\sym{sy:X}{\X}{X}{sets of XXX numbers ...}

\newcommand{\N}{\mathbb{N}}
\newcommand{\B}{\mathbb{B}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Rp}{\mathbb{R}_{\geq 0}}
\newcommand{\Rsp}{\mathbb{R}_{> 0}}
%\newcommand{\C}{\mathbb{C}}
\newcommand{\Cn}{\mathbb{C}_{< 0}}
\newcommand{\Czp}{\mathbb{C}_{\geq 0}}
%	compact set
\newcommand{\cset}[1]{\mathfrak{#1}}
%	open set
\newcommand{\oset}[1]{\mathcal{#1}}
%	function set
\newcommand{\fset}[1]{\mathcal{#1}}
%	system class 
\newcommand{\sclass}[1]{\mathcal{#1}}
%	operator class 
\newcommand{\oclass}[1]{\mathcal{#1}}
%	boundary set
\newcommand{\bset}[1]{\mathcal{#1}}

%	for defining a set
\newcommand{\setdef}[2]{\left\{\ #1\ \left|\vphantom{#1}\ #2\ \right.\right\}}

%	function spaces
\newcommand{\Lp}[1]{\fset{L}^{#1}}
\newcommand{\Lone}{\fset{L}^{1}}
\newcommand{\Loneloc}{\fset{L}^{1}_{\loc}}
\newcommand{\Ltwo}{\fset{L}^{2}}
\newcommand{\Linf}{\fset{L}^{\infty}}
\newcommand{\Linfloc}{\fset{L}^{\infty}_{\loc}}
\newcommand{\Ck}{\fset{C}^{k}}
\newcommand{\Czero}{\fset{C}}
\newcommand{\Cone}{\fset{C}^{1}}
\newcommand{\Ctwo}{\fset{C}^{2}}
\newcommand{\Cinf}{\fset{C}^{\infty}}
\newcommand{\Wkinf}{\fset{W}^{k,\infty}}
\newcommand{\Woneinf}{\fset{W}^{1,\infty}}
\newcommand{\Wtwoinf}{\fset{W}^{2,\infty}}
%	Norms
%	norm ||.||
\newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
% ||.||_infty
\newcommand{\esnorm}[1]{\lVert #1 \rVert_{\infty}}
\newcommand{\Wnorm}[3]{\lVert #3 \rVert_{#1,#2}}
\newcommand{\Lnorm}[2]{\lVert #2 \rVert_{\fset{L}^{#1}}}

%	limits
\newcommand{\limtoinfty}[1]{\lim_{#1 \to \infty}}
\newcommand{\limtozero}[1]{\lim_{#1 \to 0}}
\newcommand{\limto}[2]{\lim_{#1 \to #2}}

%	General
%	lapace
\newcommand{\laplaceT}[1]{\mathscr{L}\left\{#1\right\}}
\newcommand{\laplaceIT}[1]{\mathscr{L}^{-1}\left\{#1\right\}}
%	myVector = \mv
\newcommand{\mv}[1]{\boldsymbol{#1}}
%	myMatrix = \mm
\newcommand{\mm}[1]{\boldsymbol{#1}}
%	myOperator = \mO
\newcommand{\mo}[1]{\boldsymbol{\mathfrak{#1}}}
%	inner product <.,.>
\newcommand{\iproduct}[2]{\langle #1,\, #2 \rangle}
%	myEnergy = \me
\newcommand{\me}[1]{\boldsymbol{\mathcal{#1}}}

%	Dimensions e.g. [Nm]
\newcommand{\di}[1]{\left[\rm{#1}\right]}

%	Differentiation
\newcommand{\fdiff}[2]{\frac{\textrm{d}^{#1}}{\textrm{d}{#2}^{#1}}\,}
\newcommand{\fpartial}[2]{\frac{\partial^{#1}}{\partial #2^{#1}}\,}
\newcommand{\fpartials}[3]{\dfrac{\partial^{#1}{#3}}{\partial #2^{#1}}\,}


%	Hackl
\newcommand{\Sonelin}{\sclass{S}_1^{\lin}}
\newcommand{\Stwolin}{\sclass{S}_2^{\lin}}
\newcommand{\Sone}{\sclass{S}_1}
\newcommand{\Stwo}{\sclass{S}_2}

\newcommand{\gsc}{\varsigma}

\newcommand{\myref}{\rm{ref}}
\newcommand{\yref}{y_{\rm{ref}}}
\newcommand{\Yref}{Y_{\rm{ref}}}
\newcommand{\pF}{\psi}


%\newtheoremstyle{break}
%{\topsep}{\topsep}{\itshape}{}{\bfseries}
%{:}{\newline}{}  
%\theoremstyle{break}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
%\newtheorem{proposition}[theorem]{Proposition}
%\newtheorem{lemma}[theorem]{Lemma}
%\newtheorem{claim}[theorem]{Claim}
%\newtheorem{assumption}[theorem]{Assumption}
%\newtheorem{motivation}[theorem]{Motivation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	(RE-)DEFINE NEW MATH EXPRESSIONS for ELECTRICAL DRIVES and DRIVES CONTROL

% PS-Frag
%\newcommand{\psf}[1]{\psfrag{#1}[cc][cc][1][0]{$#1$}}
% Real- und Imaginäranteil
\newcommand{\Rea}[1]{\operatorname{\mathfrak{Re}}\{#1\}}
\newcommand{\Ima}[1]{\operatorname{\mathfrak{Im}}\{#1\}}

% General
\newcommand{\einhalb}{\dfrac{1}{2}}

% Linear Algebra
\newcommand{\tr}{\mathrm{tr}}
%\newcommand{\diag}{diag}
\newcommand{\transpose}[1]{{#1}^\top}
\newcommand{\inv}[1]{{#1}^{-1}} 

\newcommand{\oneV}{\mv{1}} % unity vector e.g. 1_3 = (1,1,1)^\top
\newcommand{\oneM}{\mm{I}} % unity vector e.g. 1_3 = (1,1,1)^\top

% Differentiation
\newcommand{\ddtsmall}{\tfrac{{\rm d}}{{\rm d}t}}
\newcommand{\ddt}{\dfrac{{\rm d}}{{\rm d}t}}
\newcommand{\ddp}[1]{\frac{\partial}{\partial #1}}

% Optimierung
\newcommand{\argmin}[1]{\underset{#1}{\arg\min}}
\newcommand{\argmax}[1]{\underset{#1}{\max}}
	
% Integration
\newcommand{\intd}{~d}

% Stochastic
\newcommand{\Erwartungswert}[1]{E[#1]}
\newcommand{\Varianz}[1]{Var[#1]}

% Hidden Markov Model
\newcommand{\xkhat}[2] {\hat{\mv{x}}_{\mv{#1}#2}}
\newcommand{\xkkhat}[2]{\hat{x}_{\text{#1},\text{#2}}} 

\newcommand{\xk}[1]{\mv{x_{\text{#1}}}} 
\newcommand{\xkk}[2]{x_{\text{#1},\text{#2}}} 

\newcommand{\yk}[1]{\mv{y_{\text{#1}}}} 
\newcommand{\ykk}[2]{y_{\text{#1},\text{#2}}} 

\newcommand{\p}[1]{p\left(#1\right)}
\newcommand{\phat}[1]{\hat{p}\left(#1\left)}
\newcommand{\pk}[2]{p_{\text{#1}}(#2)}
\newcommand{\px}[1]{p(\xk{#1})}
\newcommand{\py}[1]{p(\yk{#1})}
\newcommand{\pxx}[2]{p(\xk{#1}|\xk{#2})}
\newcommand{\pxy}[2]{p(\xk{#1}|\yk{#2})}
\newcommand{\pyx}[1]{p(\yk{#1}|\xk{#1})}
\newcommand{\pxxy}[3]{p(\xk{#1},\xk{#2}|\yk{#3})}

\newcommand{\Likelihood}[2]{L_{#1}(#2)}
\newcommand{\LogLikelihood}[2]{\mathcal{L}_{#1}(#2)}

\newcommand{\MatrixML}[1]{\mm{\hat{#1}_{ML}}}

% Particle Filter
\newcommand{\xkp}[2]{\mv{x_{\text{#1}}}^{(#2)}}
\newcommand{\xkps}[1]{\mv{x_{\text{#1}}}^{(s)}}

\newcommand{\ykp}[2]{\mv{y_{\text{#1}}}^{(#2)}}

\newcommand{\pxxp}[3]{p(\xk{#1}|\xkp{#2}{#3})}
\newcommand{\pxxps}[3]{p(\mv{x_{#1}^{s}}|\xkp{#2}{#3})}

\newcommand{\pyxp}[2]{p(\yk{#1}|\xkp{#1}{#2})}

\newcommand{\wkp}[2]{\mathit{w}_{#1}^{(#2)}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\opensymdef

%\losstring -  Wenn output ein Makro enthält, dann ein \losstring am Anfang einfügen. 

% Syntax \newsym Befehl
%\newsym[ description ]{ macroname }{ output }

% Basics:

%\newsym[set of natural numbers]{N}{\mathbb{N}}
%\newsym[set of integer numbers]{Z}{\mathbb{Z}}
%\newcommand{\R}{\mathbb{R}}


\DeclarePairedDelimiter{\parens}{\lparen}{\rparen}          % (round) parentheses \parens{...} (no auto-size) and \parens*{...} (auto-size), useful for combination with functions f\parens{args}
\DeclarePairedDelimiter{\bracks}{\lbrack}{\rbrack}          % [square] brackets
\DeclarePairedDelimiter{\curls}{\{}{\}}                     % curly braces
\DeclarePairedDelimiter\abs{\lvert}{\rvert}                 % abs()


\newcommand{\mvbegin}[1]{\begin{bmatrix}#1\end{bmatrix}}		% Vector content - begin[ ]end
\newcommand{\mmbegin}[1]{\begin{bmatrix}#1\end{bmatrix}}		% Matrix content - begin[ ]end
\newcommand{\mrbegin}[2]{\left[ \begin{array}{*{#1}{r}}#2\end{array} \right] } 	% Matrix content - columns right aligned, number of columns in first argument

\newcommand{\simpleeq}[1]{\begin{IEEEeqnarray}{rCl}#1\end{IEEEeqnarray}}				% Einfache Gleichung mit Inhalt

\newcommand{\mtbegin}[1]{\parens*{#1}}                      % Tupel - begin ( )end
\newcommand{\msbegin}[1]{\curls*{#1}}                       % Set - begin { }end
\newcommand{\counterset}[1]{\bracks{#1}}                    % counter set {1, ..., N}, written as [N]
\newcommand{\normbegin}[1]{\left\Vert{#1}\right\Vert}       % Norm

\newcommand{\rechtsoffen}[1]{\left[#1\right)}								% Rechtsoffenes Intervall
\newcommand{\linkssoffen}[1]{\left(#1\right]}								% Linksoffenes Intervall

\newcommand{\closedSetR}[1]{\bracks{#1}}										% Geschlossene Menge [0,pi]

\newcommand{\del}{\partial}																	% Partielle Ableitung

\newcommand{\trans}[1]{{#1}^T}        											% Transpose
\newcommand{\pinv}[1]{{#1}^{+}}															% Pseudo-Inverse
%\newcommand{\norm}[1]{\left\lvert#1\right\rvert}						% Absolute value
\newcommand{\dimR}[1]{\R^{#1}}	        										% Dimension of real vector R^(a)
\newcommand{\dimRTwo}[2]{\R^{#1\times#2}}										% Dimension of real vector R^(a x b)
\newcommand{\dif}{\mathrm{d}}                               % Derivative operator d


\newcommand{\matfun}[3][]{\mm{#2}_{#1}\parens*{#3}}					% Matrix function R_a(u) = \matfun[a]{R}{u}


\newcommand{\const}{\text{const.}}                          	% const.
\newcommand{\sinBr}[1]{\sin{\left(#1\right)}}               	% \sin() with braces
\newcommand{\cosBr}[1]{\cos{\left(#1\right)}}               	% \cos() with braces

\newcommand{\diagBr}[1]{\symdiag\curls{#1}}							    	% Diagonal matrix diag{vector}
\newcommand{\nullV}{\mv{0}}																		% Nullvektor

\DeclareMathOperator{\signOp}{\text{sign}}                  	% sign operator
\newcommand{\signBr}[1]{\signOp\parens*{#1}}                	% sign(#1) with parentheses
\newcommand{\expBr}[1]{\exp\parens*{#1}}                    	% exp(#1) with parentheses
%\newsym[cost function]{costFun}{J}                          	% Cost function
\newcommand{\costFunBr}[1]{\costFun\parens*{#1}}            	% Cost function J(#1) with parentheses
\newcommand{\costFunSubBr}[2]{\costFun_{#1}\parens*{#2}}    	% Cost function J_#1(#2) with subscript and parentheses

% some constants:
%\newsym[generic constant]{constA}{c}                        				% a generic constant c

% calculus:
\DeclareMathOperator{\diff}{\mathrm{d}\!}  													% non-italic differential
\DeclareMathOperator{\supp}{\mathrm{supp}\!}  											% non-italic differential


% basic probability tools:
%\newcommand{\klBr}[2]{\klOp \parens*{#1 \mid\mid #2}}  						% old version of KL(#1 || #2) without automatic resizing of ||
\DeclarePairedDelimiterX{\infdivx}[2]{(}{)}{#1\;\delimsize\|\;#2}  	% helper for (1 || 2)
\newcommand{\klBr}{\kl\infdivx*}  																	% KL(#1 || #2), starred version for automatic sizing; usage: \klBr{p}{q}
\newcommand{\elboBr}[1]{\elbo\parens*{#1}}
\newcommand{\est}[1]{\hat{#1}}                               				% estimated value of some parameter, label etc.


\newcommand{\apr}[1]{\widetilde{#1}}  % approximate parameter, usually for an approximating density \pdfq

\newcommand{\suchThat}{s.t.}  				% text to add constraints to an optimization problem (english: s.t.); [Papageorgiou2012, p. 11]: "unter Berücksichtigung von (u.B.v.)"; [Papageorgiou2012, p. 12, p. 67] "wobei"

% -----------------------------------------------------------------------------
% Application variables and constants
% -----------------------------------------------------------------------------

% parameter estimation:
%\newsym[iteration number]{iteration}{i}

% -----------------------------------------------------------------------------
% Units
% -----------------------------------------------------------------------------
\newcommand{\mathSymbolWithUnit}[2]{ \SI[parse-numbers = false, number-math-rm = \ensuremath]{#1}{\bracks{#2}} }  % math symbol with unit, e.g. \varphi [rad]; do not use $

% -----------------------------------------------------------------------------
% Lists
% -----------------------------------------------------------------------------

% Itemize with smaller indentation and item spacing:
\newcommand{\myitemize}[1]{\begin{itemize}[leftmargin=3.5mm,listparindent=0mm, itemindent=0mm, parsep=0mm, itemsep=0mm]#1\end{itemize}} 
\newenvironment{myindentpar}[1]%
 {\begin{list}{}%
         {\setlength{\leftmargin}{#1}}%
         \item[]%
 }
 {\end{list}}
 
% -----------------------------------------------------------------------------
% Editing helpers
% -----------------------------------------------------------------------------

% Mark text sections for easy recognition:
\newcommand{\fixme}[1]{\hl{#1}}
\newcommand{\texttodo}[1]{\textcolor{orange}{#1}}
\newcommand{\textfixme}[1]{\textcolor{red}{#1}}
\newcommand{\textcaution}[1]{\textcolor{red}{#1}}
\newcommand{\textinfo}[1]{\textcolor{blue}{#1}}

% Quotes:
\newcommand{\deqq}[1]{\glqq{}#1\grqq}  	% german quotation
\newcommand{\enqq}[1]{``#1''}  					% english quotation
\newcommand{\citebeamer}[1]{\begin{small}#1\end{small}}

% References to figures, tables etc.:
\newcommand{\figref}[1]{Figure\;\ref{#1}}										% Reference to figure, middle of a sentence
\newcommand{\Figref}[1]{Figure\;\ref{#1}}										% Reference to figure, beginning of a sentence
\newcommand{\fullsubfigref}[1]{Fig.\;\ref*{#1}}							% Reference to figure and subfigure, middle of a sentence; the subcaption package needs \ref*
\newcommand{\Fullsubfigref}[1]{Figure\;\ref*{#1}}						% Reference to figure and subfigure, beginning of a sentence;  the subcaption package needs \ref*
\newcommand{\tabref}[1]{Table\;\ref{#1}}										% Reference to table, middle of a sentence
\newcommand{\Tabref}[1]{Table\;\ref{#1}}										% Reference to table, middle of a sentence
\newcommand{\lstref}[1]{Listing\;\ref{#1}}									% Reference to code listing, middle of a sentence
\newcommand{\Lstref}[1]{Listing\;\ref{#1}}									% Reference to code listing, beginning of a sentence
\newcommand{\defref}[1]{Def.\;\ref{#1}}                     % Reference to definition, middle of a sentence
\newcommand{\Defref}[1]{Def.\;\ref{#1}}                     % Reference to definition, beginning of a sentence
\newcommand{\chref}[1]{Chapter\;\ref{#1}}                   % Reference to chapter, middle of a sentence
\newcommand{\Chref}[1]{Chapter\;\ref{#1}}                   % Reference to chapter, beginning of a sentence
\newcommand{\secref}[1]{Section\;\ref{#1}}                  % Reference to section, middle of a sentence
\newcommand{\Secref}[1]{Section\;\ref{#1}}                  % Reference to section, beginning of a sentence
\newcommand{\appref}[1]{Appendix\;\ref{#1}}                 % Reference to appendix, middle of a sentence
\newcommand{\Appref}[1]{Appendix\;\ref{#1}}                 % Reference to appendix, beginning of a sentence
\newcommand{\algoref}[1]{Alg.\;\ref{#1}}                    % Reference to an algorithm, middle of a sentence
\newcommand{\Algoref}[1]{Alg.\;\ref{#1}}                    % Reference to an algorithm, beginning of a sentence
\newcommand{\algolineref}[1]{Line\;\ref{#1}}                % Reference to a line of an algorithm, middle of a sentence
\newcommand{\Algolineref}[1]{Line\;\ref{#1}}                % Reference to a line of an algorithm, beginning of a sentence
																														% use \algref{labelAlgo}{labelLine} to reference algorithm and line at once

%\newcommand{\matlab}{\textsc{Matlab}\textsuperscript{\textregistered}}                       % MATLAB
\newcommand{\writeMatlab}{\textsc{Matlab}}                  																	% MATLAB
%\newcommand{\simulink}{\textsc{Simulink}\textsuperscript{\textregistered}}                   % SIMULINK
\newcommand{\writeSimulink}{\textsc{Simulink}}              																	% SIMULINK
\newcommand{\writeFunction}[1]{\texttt{#1}}                 																	% Programming function name, e.g. quadprog

% tikz individual externalization:
\newcommand{\mytikzexton}{\tikzexternalenable}  	% turn externalization on for the rest of the document
\newcommand{\mytikzextoff}{\tikzexternaldisable}  % turn externalization off for the rest of the document

% macros for plot axis labels with default values to be overwritten in individual plots:
\newcommand\figureXLabel{Default XLabel}
\newcommand\figureYLabel{Default YLabel}
\newcommand\figureZLabel{Default ZLabel}

\newcommand{\tabitem}{~~\llap{\textbullet}~~}

% -----------------------------------------------------------------------------
% Finish
% -----------------------------------------------------------------------------
%\closesymdef