\doxysection{cxvec\+\_\+math.\+h} \label{cxvec__math_8h_source}\index{include/osmocom/dsp/cxvec\_math.h@{include/osmocom/dsp/cxvec\_math.h}} \textbf{ Go to the documentation of this file.} \begin{DoxyCode}{0} \DoxyCodeLine{1 \textcolor{comment}{/*}} \DoxyCodeLine{2 \textcolor{comment}{ * cxvec\_math.h}} \DoxyCodeLine{3 \textcolor{comment}{ *}} \DoxyCodeLine{4 \textcolor{comment}{ * Complex vectors math and signal processing}} \DoxyCodeLine{5 \textcolor{comment}{ *}} \DoxyCodeLine{6 \textcolor{comment}{ * Copyright (C) 2011 Sylvain Munaut }} \DoxyCodeLine{7 \textcolor{comment}{ *}} \DoxyCodeLine{8 \textcolor{comment}{ * All Rights Reserved}} \DoxyCodeLine{9 \textcolor{comment}{ *}} \DoxyCodeLine{10 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}} \DoxyCodeLine{11 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}} \DoxyCodeLine{12 \textcolor{comment}{ * the Free Software Foundation; either version 2 of the License, or}} \DoxyCodeLine{13 \textcolor{comment}{ * (at your option) any later version.}} \DoxyCodeLine{14 \textcolor{comment}{ *}} \DoxyCodeLine{15 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}} \DoxyCodeLine{16 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}} \DoxyCodeLine{17 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the}} \DoxyCodeLine{18 \textcolor{comment}{ * GNU General Public License for more details.}} \DoxyCodeLine{19 \textcolor{comment}{ *}} \DoxyCodeLine{20 \textcolor{comment}{ * You should have received a copy of the GNU General Public License along}} \DoxyCodeLine{21 \textcolor{comment}{ * with this program; if not, write to the Free Software Foundation, Inc.,}} \DoxyCodeLine{22 \textcolor{comment}{ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-\/1301 USA.}} \DoxyCodeLine{23 \textcolor{comment}{ */}} \DoxyCodeLine{24 } \DoxyCodeLine{25 \textcolor{preprocessor}{\#ifndef \_\_OSMO\_DSP\_CXVEC\_MATH\_H\_\_}} \DoxyCodeLine{26 \textcolor{preprocessor}{\#define \_\_OSMO\_DSP\_CXVEC\_MATH\_H\_\_}} \DoxyCodeLine{27 } \DoxyCodeLine{37 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{38 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{39 } \DoxyCodeLine{40 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{41 } \DoxyCodeLine{42 } \DoxyCodeLine{43 \textcolor{comment}{/* Generic math stuff */}} \DoxyCodeLine{44 } \DoxyCodeLine{45 \textcolor{preprocessor}{\#define M\_PIf (3.14159265358979323846264338327f) }} \DoxyCodeLine{53 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{float}} \DoxyCodeLine{54 osmo\_sinc(\textcolor{keywordtype}{float} x)} \DoxyCodeLine{55 \{} \DoxyCodeLine{56 \textcolor{keywordflow}{if} ((x >= 0.01f) || (x <= -\/0.01f)) \textcolor{keywordflow}{return} (sinf(x)/x);} \DoxyCodeLine{57 \textcolor{keywordflow}{return} 1.0f;} \DoxyCodeLine{58 \}} \DoxyCodeLine{59 } \DoxyCodeLine{64 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{float}} \DoxyCodeLine{65 osmo\_normsqf(\textcolor{keywordtype}{float} complex c)} \DoxyCodeLine{66 \{} \DoxyCodeLine{67 \textcolor{keywordflow}{return} crealf(c) * crealf(c) + cimagf(c) * cimagf(c);} \DoxyCodeLine{68 \}} \DoxyCodeLine{69 } \DoxyCodeLine{70 } \DoxyCodeLine{71 \textcolor{comment}{/* Complex vector math */}} \DoxyCodeLine{72 } \DoxyCodeLine{73 \textcolor{keyword}{struct }osmo\_cxvec *} \DoxyCodeLine{74 osmo\_cxvec\_scale(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *in, \textcolor{keywordtype}{float} complex scale,} \DoxyCodeLine{75 \textcolor{keyword}{struct} osmo\_cxvec *out);} \DoxyCodeLine{76 } \DoxyCodeLine{77 \textcolor{keyword}{struct }osmo\_cxvec *} \DoxyCodeLine{78 osmo\_cxvec\_rotate(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *in, \textcolor{keywordtype}{float} freq\_shift,} \DoxyCodeLine{79 \textcolor{keyword}{struct} osmo\_cxvec *out);} \DoxyCodeLine{80 } \DoxyCodeLine{81 \textcolor{keyword}{struct }osmo\_cxvec *} \DoxyCodeLine{82 osmo\_cxvec\_delay(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *v, \textcolor{keywordtype}{float} delay,} \DoxyCodeLine{83 \textcolor{keyword}{struct} osmo\_cxvec *out);} \DoxyCodeLine{84 } \DoxyCodeLine{86 \textcolor{keyword}{enum} osmo\_cxvec\_conv\_type \{} \DoxyCodeLine{88 CONV\_FULL\_SPAN, } \DoxyCodeLine{90 CONV\_OVERLAP\_ONLY,} \DoxyCodeLine{92 CONV\_NO\_DELAY,} \DoxyCodeLine{93 \};} \DoxyCodeLine{94 } \DoxyCodeLine{95 \textcolor{keyword}{struct }osmo\_cxvec *} \DoxyCodeLine{96 osmo\_cxvec\_convolve(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *f, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *g,} \DoxyCodeLine{97 \textcolor{keyword}{enum} osmo\_cxvec\_conv\_type type, \textcolor{keyword}{struct} osmo\_cxvec *out);} \DoxyCodeLine{98 } \DoxyCodeLine{99 \textcolor{keyword}{struct }osmo\_cxvec *} \DoxyCodeLine{100 osmo\_cxvec\_correlate(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *f, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *g,} \DoxyCodeLine{101 \textcolor{keywordtype}{int} g\_corr\_step, \textcolor{keyword}{struct} osmo\_cxvec *out);} \DoxyCodeLine{102 } \DoxyCodeLine{103 \textcolor{keywordtype}{float} complex} \DoxyCodeLine{104 osmo\_cxvec\_interpolate\_point(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *cv, \textcolor{keywordtype}{float} pos);} \DoxyCodeLine{105 } \DoxyCodeLine{106 \textcolor{keywordtype}{int}} \DoxyCodeLine{107 osmo\_cxvec\_peaks\_scan(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *cv, \textcolor{keywordtype}{int} *peaks\_idx, \textcolor{keywordtype}{int} N);} \DoxyCodeLine{108 } \DoxyCodeLine{110 \textcolor{keyword}{enum} osmo\_cxvec\_peak\_alg \{} \DoxyCodeLine{112 PEAK\_WEIGH\_WIN, } \DoxyCodeLine{114 PEAK\_WEIGH\_WIN\_CENTER,} \DoxyCodeLine{116 PEAK\_EARLY\_LATE,} \DoxyCodeLine{117 \};} \DoxyCodeLine{118 } \DoxyCodeLine{119 \textcolor{keywordtype}{float}} \DoxyCodeLine{120 osmo\_cxvec\_peak\_energy\_find(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *cv, \textcolor{keywordtype}{int} win\_size,} \DoxyCodeLine{121 \textcolor{keyword}{enum} osmo\_cxvec\_peak\_alg alg,} \DoxyCodeLine{122 \textcolor{keywordtype}{float} complex *peak\_val\_p);} \DoxyCodeLine{123 } \DoxyCodeLine{124 \textcolor{keyword}{struct }osmo\_cxvec *} \DoxyCodeLine{125 osmo\_cxvec\_sig\_normalize(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cxvec *sig,} \DoxyCodeLine{126 \textcolor{keywordtype}{int} decim, \textcolor{keywordtype}{float} freq\_shift,} \DoxyCodeLine{127 \textcolor{keyword}{struct} osmo\_cxvec *out);} \DoxyCodeLine{128 } \DoxyCodeLine{131 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* \_\_OSMO\_DSP\_CXVEC\_MATH\_H\_\_ */}\textcolor{preprocessor}{}} \end{DoxyCode}