00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef UTILS_H
00020 #define UTILS_H
00021
00022 #include "Typedefs.h"
00023 #include "Debug.h"
00024
00025 #include <limits>
00026
00031 void roots(const MatrixXR& poly, MatrixXC* result);
00032
00037 void poly(const MatrixXC& roots, MatrixXC* result);
00038
00043 void convolve(const MatrixXC& a, const MatrixXC& b, MatrixXC* c);
00044 void convolve(const MatrixXR& a, const MatrixXR& b, MatrixXR* c);
00045
00046
00051 void correlate(const MatrixXC& a, const MatrixXC& b, MatrixXC* c,
00052 int _minlag = -std::numeric_limits<int>::infinity(),
00053 int _maxlag = std::numeric_limits<int>::infinity());
00054
00055 void correlate(const MatrixXR& a, const MatrixXR& b, MatrixXR* c,
00056 int _minlag = -std::numeric_limits<int>::infinity(),
00057 int _maxlag = std::numeric_limits<int>::infinity());
00058
00063 void autocorrelate(const MatrixXR& a, MatrixXR* c,
00064 int _minlag = 0,
00065 int _maxlag = std::numeric_limits<int>::infinity());
00066
00067 void autocorrelate(const MatrixXC& a, MatrixXC* c,
00068 int _minlag = 0,
00069 int _maxlag = std::numeric_limits<int>::infinity());
00070
00071
00075 void reverseCols(MatrixXC* in);
00076 void reverseCols(MatrixXR* in);
00077
00078
00082 void rowCumsum(MatrixXR* in);
00083 void colCumsum(MatrixXR* in);
00084
00088 void rowShift(MatrixXR* in, int num);
00089 void colShift(MatrixXR* in, int num);
00090
00094 void range(Real start, Real end, int steps, MatrixXC* in);
00095 void range(Real start, Real end, int steps, int rows, MatrixXC* in);
00096 void range(Real start, Real end, int steps, MatrixXR* in);
00097 void range(Real start, Real end, int steps, int rows, MatrixXR* in);
00098 void range(Real start, Real end, int steps, MatrixXI* in);
00099 void range(Real start, Real end, int steps, int rows, MatrixXI* in);
00100
00104 void polar(const MatrixXR& mag, const MatrixXR& phase, MatrixXC* complex);
00105
00110 int combination(int N, int k);
00111
00117 Real asinc(int M, Real omega);
00118
00122 void raisedCosTransform(Real position, Real magnitude,
00123 int windowSize, int fftSize,
00124 Real alpha, Real beta,
00125 MatrixXR* spectrum, int* begin, int* end, int bandwidth);
00126
00127 void raisedCosTransform(Real position, Real magnitude,
00128 int windowSize, int fftSize,
00129 Real alpha, Real beta,
00130 MatrixXR* spectrum, int bandwidth);
00131
00132 void hannTransform(Real position, Real magnitude,
00133 int windowSize, int fftSize,
00134 MatrixXR* spectrum, int bandwidth = 4);
00135
00136 void hannTransform(Real position, Real magnitude,
00137 int windowSize, int fftSize,
00138 MatrixXR* spectrum, int* begin, int* end, int bandwidth = 4);
00139
00140
00141 void hammingTransform(Real position, Real magnitude,
00142 int windowSize, int fftSize,
00143 MatrixXR* spectrum, int bandwidth = 4);
00144
00145 void hammingTransform(Real position, Real magnitude,
00146 int windowSize, int fftSize,
00147 MatrixXR* spectrum, int* begin, int* end, int bandwidth = 4);
00148
00149 void dbToMag(const MatrixXR& db, MatrixXR* mag);
00150
00151 void magToDb(const MatrixXR& mag, MatrixXR* db, Real minMag = 0.0001 );
00152
00153 void unwrap(const MatrixXR& phases, MatrixXR* unwrapped);
00154
00155 void freqz(const MatrixXR& b, const MatrixXR& a, const MatrixXR& w, MatrixXC* resp);
00156 void freqz(const MatrixXR& b, const MatrixXR& w, MatrixXC* resp);
00157
00158 void derivate(const MatrixXR& a, MatrixXR* b);
00159
00160 int nextPowerOf2(Real a, int factor = 0);
00161
00162 Real gaussian(Real x, Real mu, Real fi);
00163
00164 void gaussian(Real x, MatrixXR mu, MatrixXR fi, MatrixXR* result);
00165
00166 #endif