\section{Complex vectors math and signal processing}
\label{group__cxvec__math}\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ cxvec\+\_\+math.\+h}
\begin{DoxyCompactList}\small\item\em Osmocom Complex vectors math header. \end{DoxyCompactList}\item 
file \textbf{ cxvec\+\_\+math.\+c}
\begin{DoxyCompactList}\small\item\em Osmocom Complex vectors math implementation. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ osmo\+\_\+cxvec\+\_\+conv\+\_\+type} \{ \textbf{ C\+O\+N\+V\+\_\+\+F\+U\+L\+L\+\_\+\+S\+P\+AN}, 
\textbf{ C\+O\+N\+V\+\_\+\+O\+V\+E\+R\+L\+A\+P\+\_\+\+O\+N\+LY}, 
\textbf{ C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY}
 \}\begin{DoxyCompactList}\small\item\em Various possible types of convolution span. \end{DoxyCompactList}
\item 
enum \textbf{ osmo\+\_\+cxvec\+\_\+peak\+\_\+alg} \{ \textbf{ P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+IN}, 
\textbf{ P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+I\+N\+\_\+\+C\+E\+N\+T\+ER}, 
\textbf{ P\+E\+A\+K\+\_\+\+E\+A\+R\+L\+Y\+\_\+\+L\+A\+TE}
 \}\begin{DoxyCompactList}\small\item\em Various possible peak finding algorithms. \end{DoxyCompactList}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static float \textbf{ osmo\+\_\+sinc} (float x)
\begin{DoxyCompactList}\small\item\em Unnormalized sinc function. \end{DoxyCompactList}\item 
static float \textbf{ osmo\+\_\+normsqf} (float complex c)
\begin{DoxyCompactList}\small\item\em Squared norm of a given complex. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+cxvec} $\ast$ \textbf{ osmo\+\_\+cxvec\+\_\+scale} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$in, float complex scale, struct \textbf{ osmo\+\_\+cxvec} $\ast$out)
\begin{DoxyCompactList}\small\item\em Scale a complex vector (multiply by a constant) \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+cxvec} $\ast$ \textbf{ osmo\+\_\+cxvec\+\_\+rotate} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$in, float rps, struct \textbf{ osmo\+\_\+cxvec} $\ast$out)
\begin{DoxyCompactList}\small\item\em Rotate a complex vector (frequency shift) \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+cxvec} $\ast$ \textbf{ osmo\+\_\+cxvec\+\_\+delay} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$in, float delay, struct \textbf{ osmo\+\_\+cxvec} $\ast$out)
\begin{DoxyCompactList}\small\item\em Fractionally delay a vector while maintaining its length. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+cxvec} $\ast$ \textbf{ osmo\+\_\+cxvec\+\_\+convolve} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$f, const struct \textbf{ osmo\+\_\+cxvec} $\ast$g, enum \textbf{ osmo\+\_\+cxvec\+\_\+conv\+\_\+type} type, struct \textbf{ osmo\+\_\+cxvec} $\ast$out)
\begin{DoxyCompactList}\small\item\em Convolve two complex vectors. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+cxvec} $\ast$ \textbf{ osmo\+\_\+cxvec\+\_\+correlate} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$f, const struct \textbf{ osmo\+\_\+cxvec} $\ast$g, int g\+\_\+corr\+\_\+step, struct \textbf{ osmo\+\_\+cxvec} $\ast$out)
\begin{DoxyCompactList}\small\item\em Cross-\/correlate two complex vectors. \end{DoxyCompactList}\item 
float complex \textbf{ osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$cv, float pos)
\begin{DoxyCompactList}\small\item\em Interpolate any fractional position in a vector using sinc filtering. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$cv, int $\ast$peaks\+\_\+idx, int N)
\begin{DoxyCompactList}\small\item\em Find the index of the N highest energy ( $|x|^2$) peaks. \end{DoxyCompactList}\item 
float \textbf{ osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$cv, int win\+\_\+size, enum \textbf{ osmo\+\_\+cxvec\+\_\+peak\+\_\+alg} alg, float complex $\ast$peak\+\_\+val\+\_\+p)
\begin{DoxyCompactList}\small\item\em Find the maximum energy ( $|x|^2$) peak in a sequence. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+cxvec} $\ast$ \textbf{ osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize} (const struct \textbf{ osmo\+\_\+cxvec} $\ast$sig, int decim, float freq\+\_\+shift, struct \textbf{ osmo\+\_\+cxvec} $\ast$out)
\begin{DoxyCompactList}\small\item\em \textquotesingle{}Normalize\textquotesingle{} an IQ signal and apply decimation/frequency shift \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}


\subsection{Enumeration Type Documentation}
\mbox{\label{group__cxvec__math_ga2e183a0f24afa2e16199d1514629bf08}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+conv\+\_\+type@{osmo\+\_\+cxvec\+\_\+conv\+\_\+type}}
\index{osmo\+\_\+cxvec\+\_\+conv\+\_\+type@{osmo\+\_\+cxvec\+\_\+conv\+\_\+type}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+conv\+\_\+type}
{\footnotesize\ttfamily enum \textbf{ osmo\+\_\+cxvec\+\_\+conv\+\_\+type}}



Various possible types of convolution span. 

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{C\+O\+N\+V\+\_\+\+F\+U\+L\+L\+\_\+\+S\+P\+AN@{C\+O\+N\+V\+\_\+\+F\+U\+L\+L\+\_\+\+S\+P\+AN}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!C\+O\+N\+V\+\_\+\+F\+U\+L\+L\+\_\+\+S\+P\+AN@{C\+O\+N\+V\+\_\+\+F\+U\+L\+L\+\_\+\+S\+P\+AN}}}\mbox{\label{group__cxvec__math_gga2e183a0f24afa2e16199d1514629bf08ae758172bda42f9b44aa9015c0e142717}} 
C\+O\+N\+V\+\_\+\+F\+U\+L\+L\+\_\+\+S\+P\+AN&Full span (every possible overlap of f onto g) \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{C\+O\+N\+V\+\_\+\+O\+V\+E\+R\+L\+A\+P\+\_\+\+O\+N\+LY@{C\+O\+N\+V\+\_\+\+O\+V\+E\+R\+L\+A\+P\+\_\+\+O\+N\+LY}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!C\+O\+N\+V\+\_\+\+O\+V\+E\+R\+L\+A\+P\+\_\+\+O\+N\+LY@{C\+O\+N\+V\+\_\+\+O\+V\+E\+R\+L\+A\+P\+\_\+\+O\+N\+LY}}}\mbox{\label{group__cxvec__math_gga2e183a0f24afa2e16199d1514629bf08a47fb2e6e9d274d4512601828023ac1d2}} 
C\+O\+N\+V\+\_\+\+O\+V\+E\+R\+L\+A\+P\+\_\+\+O\+N\+LY&Every possible full overlap of f onto g. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY@{C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY@{C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY}}}\mbox{\label{group__cxvec__math_gga2e183a0f24afa2e16199d1514629bf08a03ece74c3bcd50aeb9fb42329b9a59a5}} 
C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY&Center f sequence on every g sample. \\
\hline

\end{DoxyEnumFields}
\mbox{\label{group__cxvec__math_ga7942b58b341e440c0e8796d395460b78}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+peak\+\_\+alg@{osmo\+\_\+cxvec\+\_\+peak\+\_\+alg}}
\index{osmo\+\_\+cxvec\+\_\+peak\+\_\+alg@{osmo\+\_\+cxvec\+\_\+peak\+\_\+alg}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+peak\+\_\+alg}
{\footnotesize\ttfamily enum \textbf{ osmo\+\_\+cxvec\+\_\+peak\+\_\+alg}}



Various possible peak finding algorithms. 

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+IN@{P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+IN}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+IN@{P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+IN}}}\mbox{\label{group__cxvec__math_gga7942b58b341e440c0e8796d395460b78abb4b91d1bfa5bd51ff0e48633d9b9891}} 
P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+IN&Weigthed position for the max pwr window. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+I\+N\+\_\+\+C\+E\+N\+T\+ER@{P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+I\+N\+\_\+\+C\+E\+N\+T\+ER}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+I\+N\+\_\+\+C\+E\+N\+T\+ER@{P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+I\+N\+\_\+\+C\+E\+N\+T\+ER}}}\mbox{\label{group__cxvec__math_gga7942b58b341e440c0e8796d395460b78ab0fb6b29112253cc5d51fb119b5d812a}} 
P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+I\+N\+\_\+\+C\+E\+N\+T\+ER&Weighted position of the peak centered window. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{P\+E\+A\+K\+\_\+\+E\+A\+R\+L\+Y\+\_\+\+L\+A\+TE@{P\+E\+A\+K\+\_\+\+E\+A\+R\+L\+Y\+\_\+\+L\+A\+TE}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!P\+E\+A\+K\+\_\+\+E\+A\+R\+L\+Y\+\_\+\+L\+A\+TE@{P\+E\+A\+K\+\_\+\+E\+A\+R\+L\+Y\+\_\+\+L\+A\+TE}}}\mbox{\label{group__cxvec__math_gga7942b58b341e440c0e8796d395460b78aa8df843abc147bca5860fee1ddff1378}} 
P\+E\+A\+K\+\_\+\+E\+A\+R\+L\+Y\+\_\+\+L\+A\+TE&Early-\/\+Late balancing around peak. \\
\hline

\end{DoxyEnumFields}


\subsection{Function Documentation}
\mbox{\label{group__cxvec__math_ga2ebadb16e25768896013420a98ec666f}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+convolve@{osmo\+\_\+cxvec\+\_\+convolve}}
\index{osmo\+\_\+cxvec\+\_\+convolve@{osmo\+\_\+cxvec\+\_\+convolve}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+convolve()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+cxvec} $\ast$ osmo\+\_\+cxvec\+\_\+convolve (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{f,  }\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{g,  }\item[{enum \textbf{ osmo\+\_\+cxvec\+\_\+conv\+\_\+type}}]{type,  }\item[{struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{out }\end{DoxyParamCaption})}



Convolve two complex vectors. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em f} & First input complex vector \\
\hline
\mbox{\tt in}  & {\em g} & Second input complex vector \\
\hline
\mbox{\tt in}  & {\em type} & The convolution span type \\
\hline
\mbox{\tt out}  & {\em out} & Output complex vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output complex vector (or N\+U\+LL if error)
\end{DoxyReturn}
The convolution of discrete sequences is defined as \+:

$(f * g)[n] = \sum_{m=-\infty}^{\infty} f[m] \; g[n-m]$

Altough the mathematical operation is commutative, the constraint of implementation limit this method. Depending on the type of span chosen, it might not be and it\textquotesingle{}s always recommended that \textquotesingle{}g\textquotesingle{} be the longer sequence. It should not be much of a limitation when this methos is used for filtering or pulseshaping \+: use \textquotesingle{}f\textquotesingle{} as the filter and \textquotesingle{}g\textquotesingle{} as the signal.

The output vector parameter \textquotesingle{}out\textquotesingle{} can be N\+U\+LL to allocate a new vector. If it\textquotesingle{}s not N\+U\+LL, it must be long enough to contain the result (length depends on the exact convolution type) 

References C\+O\+N\+V\+\_\+\+F\+U\+L\+L\+\_\+\+S\+P\+AN, C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY, C\+O\+N\+V\+\_\+\+O\+V\+E\+R\+L\+A\+P\+\_\+\+O\+N\+LY, osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::flags, osmo\+\_\+cxvec\+::len, osmo\+\_\+cxvec\+::max\+\_\+len, and osmo\+\_\+cxvec\+\_\+alloc().



Referenced by osmo\+\_\+cxvec\+\_\+delay().

\mbox{\label{group__cxvec__math_ga99ff6e3baec3253f4e431b156f042a0f}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+correlate@{osmo\+\_\+cxvec\+\_\+correlate}}
\index{osmo\+\_\+cxvec\+\_\+correlate@{osmo\+\_\+cxvec\+\_\+correlate}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+correlate()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+cxvec} $\ast$ osmo\+\_\+cxvec\+\_\+correlate (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{f,  }\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{g,  }\item[{int}]{g\+\_\+corr\+\_\+step,  }\item[{struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{out }\end{DoxyParamCaption})}



Cross-\/correlate two complex vectors. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em f} & First input complex vector \\
\hline
\mbox{\tt in}  & {\em g} & Second input complex vector \\
\hline
\mbox{\tt in}  & {\em g\+\_\+corr\+\_\+step} & Allow for oversampling of \textquotesingle{}g\textquotesingle{} compared to \textquotesingle{}f\textquotesingle{} \\
\hline
\mbox{\tt out}  & {\em out} & Output complex vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output complex vector (or N\+U\+LL if error)
\end{DoxyReturn}
The cross-\/correlation of discrete sequences is defined as \+:

$(f \star g)[n] = \sum_{m=-\infty}^{\infty} f^*[m] \; g[n+m]$

In this implementation, the output vector will be for every n value between 0 and (g-\/$>$len -\/ f-\/$>$len + 1). This assumes that g is the longer sequence and we \textquotesingle{}fit\textquotesingle{} f at every positition inside it.

With the parameter g\+\_\+corr\+\_\+step, it\textquotesingle{}s also possible to have a g sequence that is oversampled with regard to f. (if g\+\_\+corr\+\_\+step $>$ 1)

The output vector parameter \textquotesingle{}out\textquotesingle{} can be N\+U\+LL to allocate a new vector. If it\textquotesingle{}s not N\+U\+LL, it must be long enough to contain the result (i.\+e. g-\/$>$len -\/ f-\/$>$len + 1) 

References osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::flags, osmo\+\_\+cxvec\+::len, osmo\+\_\+cxvec\+::max\+\_\+len, and osmo\+\_\+cxvec\+\_\+alloc().

\mbox{\label{group__cxvec__math_ga9fa20d926f9d313a4751cef1eff740ba}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+delay@{osmo\+\_\+cxvec\+\_\+delay}}
\index{osmo\+\_\+cxvec\+\_\+delay@{osmo\+\_\+cxvec\+\_\+delay}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+delay()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+cxvec} $\ast$ osmo\+\_\+cxvec\+\_\+delay (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{in,  }\item[{float}]{delay,  }\item[{struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{out }\end{DoxyParamCaption})}



Fractionally delay a vector while maintaining its length. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em in} & Input complex vector \\
\hline
\mbox{\tt in}  & {\em delay} & The fractional delay to apply \\
\hline
\mbox{\tt out}  & {\em out} & Output complex vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output complex vector (or N\+U\+LL if error)
\end{DoxyReturn}
The output always has the same length. Samples pushed out by the delays are lost and new ones filled with zeroes are pushed in.

The output vector parameter \textquotesingle{}out\textquotesingle{} can be N\+U\+LL to allocate a new vector, or can be equal to the \textquotesingle{}in\textquotesingle{} input vector to perform the transform in-\/place. If it\textquotesingle{}s different, it must be long enough to contain the result (i.\+e. in-\/$>$len) 

References C\+O\+N\+V\+\_\+\+N\+O\+\_\+\+D\+E\+L\+AY, osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::flags, osmo\+\_\+cxvec\+::len, osmo\+\_\+cxvec\+::max\+\_\+len, osmo\+\_\+cxvec\+\_\+alloc(), osmo\+\_\+cxvec\+\_\+convolve(), osmo\+\_\+cxvec\+\_\+free(), osmo\+\_\+cxvec\+\_\+init\+\_\+from\+\_\+data(), and osmo\+\_\+sinc().



Referenced by osmo\+\_\+normsqf().

\mbox{\label{group__cxvec__math_gacb1c646e03a09b51b617467501639763}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point@{osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point}}
\index{osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point@{osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point()}
{\footnotesize\ttfamily float complex osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{cv,  }\item[{float}]{pos }\end{DoxyParamCaption})}



Interpolate any fractional position in a vector using sinc filtering. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cv} & Input complex vector \\
\hline
\mbox{\tt in}  & {\em pos} & Position to interpolate\\
\hline
\end{DoxyParams}
pos must be $>$= 0 and $<$ cv-\/$>$len 

References osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::flags, osmo\+\_\+cxvec\+::len, and osmo\+\_\+sinc().



Referenced by osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find().

\mbox{\label{group__cxvec__math_ga495219ee953336e15cd68c9b22d3850c}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find@{osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find}}
\index{osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find@{osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find()}
{\footnotesize\ttfamily float osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{cv,  }\item[{int}]{win\+\_\+size,  }\item[{enum \textbf{ osmo\+\_\+cxvec\+\_\+peak\+\_\+alg}}]{alg,  }\item[{float complex $\ast$}]{peak\+\_\+val\+\_\+p }\end{DoxyParamCaption})}



Find the maximum energy ( $|x|^2$) peak in a sequence. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cv} & Input complex vector \\
\hline
\mbox{\tt in}  & {\em win\+\_\+size} & Size of the window (for algorithms using windows) \\
\hline
\mbox{\tt in}  & {\em alg} & Peak detection algorithm to use \\
\hline
\mbox{\tt out}  & {\em peak\+\_\+val\+\_\+p} & Returns interpolated peak value if non-\/\+N\+U\+LL \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Peak position with sub-\/sample accuracy 
\end{DoxyReturn}


References osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::len, osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point(), osmo\+\_\+normsqf(), P\+E\+A\+K\+\_\+\+E\+A\+R\+L\+Y\+\_\+\+L\+A\+TE, P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+IN, and P\+E\+A\+K\+\_\+\+W\+E\+I\+G\+H\+\_\+\+W\+I\+N\+\_\+\+C\+E\+N\+T\+ER.

\mbox{\label{group__cxvec__math_gad25b04feb1cd30b24fe7de8f76e56c23}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan@{osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan}}
\index{osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan@{osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan()}
{\footnotesize\ttfamily int osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{cv,  }\item[{int $\ast$}]{peaks\+\_\+idx,  }\item[{int}]{N }\end{DoxyParamCaption})}



Find the index of the N highest energy ( $|x|^2$) peaks. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cv} & Input complex vector \\
\hline
\mbox{\tt out}  & {\em peaks\+\_\+idx} & Return array of the peak indexes \\
\hline
\mbox{\tt in}  & {\em Size} & of the peaks\+\_\+idx return array \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Number of peaks (will be N if there is enough points) 
\end{DoxyReturn}


References osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::len, and osmo\+\_\+normsqf().

\mbox{\label{group__cxvec__math_ga49125f3c259da9d7eec7fa4d98d609d4}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+rotate@{osmo\+\_\+cxvec\+\_\+rotate}}
\index{osmo\+\_\+cxvec\+\_\+rotate@{osmo\+\_\+cxvec\+\_\+rotate}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+rotate()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+cxvec} $\ast$ osmo\+\_\+cxvec\+\_\+rotate (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{in,  }\item[{float}]{rps,  }\item[{struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{out }\end{DoxyParamCaption})}



Rotate a complex vector (frequency shift) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em in} & Input complex vector \\
\hline
\mbox{\tt in}  & {\em rps} & Rotation to apply in radian per sample \\
\hline
\mbox{\tt out}  & {\em out} & Output complex vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output complex vector (or N\+U\+LL if error)
\end{DoxyReturn}
$out(k) = in(k) \cdot e^{j \cdot rps \cdot k}$

The output vector parameter \textquotesingle{}out\textquotesingle{} can be N\+U\+LL to allocate a new vector, or can be equal to the \textquotesingle{}in\textquotesingle{} input vector to perform the transform in-\/place. If it\textquotesingle{}s different, it must be long enough to contain the result (i.\+e. in-\/$>$len) 

References osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::flags, osmo\+\_\+cxvec\+::len, osmo\+\_\+cxvec\+::max\+\_\+len, and osmo\+\_\+cxvec\+\_\+alloc().



Referenced by osmo\+\_\+normsqf().

\mbox{\label{group__cxvec__math_ga5ac0adb49726087258381582582ef654}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+scale@{osmo\+\_\+cxvec\+\_\+scale}}
\index{osmo\+\_\+cxvec\+\_\+scale@{osmo\+\_\+cxvec\+\_\+scale}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+scale()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+cxvec} $\ast$ osmo\+\_\+cxvec\+\_\+scale (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{in,  }\item[{float complex}]{scale,  }\item[{struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{out }\end{DoxyParamCaption})}



Scale a complex vector (multiply by a constant) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em in} & Input complex vector \\
\hline
\mbox{\tt in}  & {\em scale} & Factor to apply to each sample \\
\hline
\mbox{\tt out}  & {\em out} & Output complex vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output complex vector (or N\+U\+LL if error)
\end{DoxyReturn}
$out(k) = in(k) \cdot scale$

The output vector parameter \textquotesingle{}out\textquotesingle{} can be N\+U\+LL to allocate a new vector, or can be equal to the \textquotesingle{}in\textquotesingle{} input vector to perform the transform in-\/place. If it\textquotesingle{}s different, it must be long enough to contain the result (i.\+e. in-\/$>$len) 

References osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::flags, osmo\+\_\+cxvec\+::len, osmo\+\_\+cxvec\+::max\+\_\+len, and osmo\+\_\+cxvec\+\_\+alloc().



Referenced by osmo\+\_\+normsqf().

\mbox{\label{group__cxvec__math_ga4579583a658fc33afd24a1d8508b212f}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize@{osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize}}
\index{osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize@{osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+cxvec} $\ast$ osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{sig,  }\item[{int}]{decim,  }\item[{float}]{freq\+\_\+shift,  }\item[{struct \textbf{ osmo\+\_\+cxvec} $\ast$}]{out }\end{DoxyParamCaption})}



\textquotesingle{}Normalize\textquotesingle{} an IQ signal and apply decimation/frequency shift 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em sig} & Input complex signal \\
\hline
\mbox{\tt in}  & {\em decim} & Decimation factor \\
\hline
\mbox{\tt in}  & {\em freq\+\_\+shift} & Frequency shift in radian per output sample \\
\hline
\mbox{\tt out}  & {\em out} & Output complex vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output complex vector (or N\+U\+LL if error)
\end{DoxyReturn}
The operation performed are DC removal, amplitude normalization (divided by the standard deviation), decimation, frequency shift.

The output vector parameter \textquotesingle{}out\textquotesingle{} can be N\+U\+LL to allocate a new vector, or can be equal to the \textquotesingle{}in\textquotesingle{} input vector to perform the transform in-\/place. If it\textquotesingle{}s different, it must be long enough to contain the result (i.\+e. (sig-\/$>$len + decim -\/ 1) / decim) 

References osmo\+\_\+cxvec\+::data, osmo\+\_\+cxvec\+::flags, osmo\+\_\+cxvec\+::len, osmo\+\_\+cxvec\+::max\+\_\+len, osmo\+\_\+cxvec\+\_\+alloc(), and osmo\+\_\+normsqf().

\mbox{\label{group__cxvec__math_ga1b169ec31cb01111c0def0c12d65f3a2}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+normsqf@{osmo\+\_\+normsqf}}
\index{osmo\+\_\+normsqf@{osmo\+\_\+normsqf}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+normsqf()}
{\footnotesize\ttfamily static float osmo\+\_\+normsqf (\begin{DoxyParamCaption}\item[{float complex}]{c }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Squared norm of a given complex. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em c} & Complex number for which to compute the squared norm \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$|c|^2$ 
\end{DoxyReturn}


References osmo\+\_\+cxvec\+\_\+delay(), osmo\+\_\+cxvec\+\_\+rotate(), and osmo\+\_\+cxvec\+\_\+scale().



Referenced by \+\_\+osmo\+\_\+iqbal\+\_\+estimate(), osmo\+\_\+cxvec\+\_\+peak\+\_\+energy\+\_\+find(), osmo\+\_\+cxvec\+\_\+peaks\+\_\+scan(), and osmo\+\_\+cxvec\+\_\+sig\+\_\+normalize().

\mbox{\label{group__cxvec__math_ga4e7a7183dc4e5ce77d72d2986495f348}} 
\index{Complex vectors math and signal processing@{Complex vectors math and signal processing}!osmo\+\_\+sinc@{osmo\+\_\+sinc}}
\index{osmo\+\_\+sinc@{osmo\+\_\+sinc}!Complex vectors math and signal processing@{Complex vectors math and signal processing}}
\subsubsection{osmo\+\_\+sinc()}
{\footnotesize\ttfamily static float osmo\+\_\+sinc (\begin{DoxyParamCaption}\item[{float}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Unnormalized sinc function. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & Value for which to compute the sinc function. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The sinc(x) value
\end{DoxyReturn}
The function is defined as $\frac{\sin(x)}{x}$ 

Referenced by osmo\+\_\+cxvec\+\_\+delay(), and osmo\+\_\+cxvec\+\_\+interpolate\+\_\+point().

