\doxysection{Misc.\+hpp}
\hypertarget{Misc_8hpp_source}{}\label{Misc_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Math/Misc.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Math/Misc.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_MATH\_MISC\_H}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_MATH\_MISC\_H}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#if\ defined(\_\_x86\_64\_\_)}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ <xmmintrin.h>}}
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#include\ "{}Defs.hpp"{}}}
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <cmath>}}
\DoxyCodeLine{00010\ \textcolor{preprocessor}{\#include\ <vector>}}
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00012\ \textcolor{keyword}{namespace\ }math\ \{}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00014\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{inline}\ Real\ Radians(Real\ D)}
\DoxyCodeLine{00015\ \{}
\DoxyCodeLine{00016\ \ \ \ \ \textcolor{keywordflow}{return}\ M\_PI\ *\ (D\ /\ 180.0);}
\DoxyCodeLine{00017\ \}}
\DoxyCodeLine{00018\ }
\DoxyCodeLine{00019\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T>\ \textcolor{keyword}{inline}\ T\ squared(T\ v)\ \{\ \textcolor{keywordflow}{return}\ v\ *\ v;\ \}}
\DoxyCodeLine{00020\ }
\DoxyCodeLine{00021\ \textcolor{keyword}{namespace\ }approx\ \{}
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ rsqrt(\textcolor{keywordtype}{float}\ x)}
\DoxyCodeLine{00024\ \{}
\DoxyCodeLine{00025\ \textcolor{preprocessor}{\#if\ defined(\_\_x86\_64\_\_)}}
\DoxyCodeLine{00026\ \ \ \ \ \textcolor{keywordflow}{return}\ \_mm\_cvtss\_f32(\_mm\_rsqrt\_ss(\_mm\_set\_ss(x)));}
\DoxyCodeLine{00027\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00028\ \ \ \ \ \textcolor{keywordflow}{return}\ 1.0f\ /\ std::sqrtf(x);}
\DoxyCodeLine{00029\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00030\ \}}
\DoxyCodeLine{00031\ }
\DoxyCodeLine{00032\ \}\ \textcolor{comment}{//\ approx}}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00034\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T>\ T\ reduce\_max(\textcolor{keyword}{const}\ std::vector<T>\ \&V)}
\DoxyCodeLine{00035\ \{}
\DoxyCodeLine{00036\ \ \ \ \ \textcolor{keywordflow}{if}\ (V.empty())}
\DoxyCodeLine{00037\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{throw}\ std::runtime\_error(\textcolor{stringliteral}{"{}maximum(empty\ vector)"{}});}
\DoxyCodeLine{00038\ \ \ \ \ T\ mx\ =\ V[0];}
\DoxyCodeLine{00039\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{size\_t}\ i\ =\ 1;\ i\ <\ V.size();\ ++i)}
\DoxyCodeLine{00040\ \ \ \ \ \ \ \ \ mx\ =\ std::max(mx,\ V[i]);}
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{keywordflow}{return}\ mx;}
\DoxyCodeLine{00042\ \}}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T>\ \textcolor{keywordtype}{void}\ multiply(std::vector<T>\ \&V,\ T\ s)}
\DoxyCodeLine{00045\ \{}
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{keywordflow}{if}\ (s\ !=\ T(1))\ \{}
\DoxyCodeLine{00047\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (T\ \&x\ :\ V)}
\DoxyCodeLine{00048\ \ \ \ \ \ \ \ \ \ \ \ \ x\ *=\ s;}
\DoxyCodeLine{00049\ \ \ \ \ \}}
\DoxyCodeLine{00050\ \}}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00052\ \}\ \textcolor{comment}{//\ math}}
\DoxyCodeLine{00053\ }
\DoxyCodeLine{00054\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ GYM\_PCB\_MATH\_MISC\_H}}

\end{DoxyCode}
