- FirComplex: Added static process()

git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@105 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-12-22 17:36:24 +00:00
parent edbe93987d
commit 4f726e0285
2 changed files with 21 additions and 11 deletions
+4 -4
View File
@@ -71,7 +71,7 @@ public:
void update(ComplexScalar const &e, RealScalar const &mu) void update(ComplexScalar const &e, RealScalar const &mu)
{ {
m_w += m_x * conj(e) * mu; m_w += m_state * conj(e) * mu;
} }
private: private:
@@ -97,7 +97,7 @@ public:
RealScalar x1, x2; RealScalar x1, x2;
x1 = abs(x); x1 = abs(x);
x2 = abs(m_x[m_numTaps-1]); x2 = abs(m_state[m_numTaps-1]);
m_power = max(RealScalar(0), m_power + (x1*x1 - m_xLast)); m_power = max(RealScalar(0), m_power + (x1*x1 - m_xLast));
m_xLast = x2*x2; m_xLast = x2*x2;
@@ -175,10 +175,10 @@ public:
ComplexScalar process(ComplexScalar const &xs, ComplexScalar const &xh) ComplexScalar process(ComplexScalar const &xs, ComplexScalar const &xh)
{ {
int32_t i; int32_t i;
CVec &x = m_x; CVec &x = m_state;
// x(0:size-1) = [xs, x(0:m_numFeedforward-2), xh, x(m_numFeedforward:size-2)] // x(0:size-1) = [xs, x(0:m_numFeedforward-2), xh, x(m_numFeedforward:size-2)]
m_x.reverse() << m_x.segment(m_numFeedforward-1, m_numFeedBack).reverse(),xh,m_x.segment(0, m_numFeedforward-2).reverse(),xs; m_state.reverse() << m_state.segment(m_numFeedforward-1, m_numFeedBack).reverse(),xh,m_state.segment(0, m_numFeedforward-2).reverse(),xs;
return FirComplex::process(m_w); return FirComplex::process(m_w);
} }
+17 -7
View File
@@ -18,7 +18,7 @@ class FirComplex
public: public:
FirComplex(uint32_t numTaps = 0) FirComplex(uint32_t numTaps = 0)
: m_numTaps(numTaps) : m_numTaps(numTaps)
, m_x(numTaps) , m_state(numTaps)
{ {
} }
virtual ~FirComplex() virtual ~FirComplex()
@@ -29,28 +29,38 @@ public:
void setNumTaps(uint32_t numTaps) void setNumTaps(uint32_t numTaps)
{ {
m_numTaps = numTaps; m_numTaps = numTaps;
m_x.resize(numTaps); m_state.resize(numTaps);
m_x.fill(ComplexScalar(0,0)); m_state.fill(ComplexScalar(0,0));
} }
void feed(ComplexScalar const &x) void feed(ComplexScalar const &x)
{ {
m_x.reverse() << m_x.head(m_numTaps-1).reverse(), x; m_state.reverse() << m_state.head(m_numTaps-1).reverse(), x;
}
static void feed(CVec &state, ComplexScalar const &x)
{
state.reverse() << state.head(state.size()-1).reverse(), x;
} }
ComplexScalar process(CVec const &coeff) ComplexScalar process(CVec const &coeff)
{ {
return m_x.transpose() * coeff.conjugate(); return m_state.transpose() * coeff.conjugate();
} }
ComplexScalar processReal(RVec const &coeff) ComplexScalar processReal(RVec const &coeff)
{ {
return m_x.transpose() * coeff; return m_state.transpose() * coeff;
}
static ComplexScalar processReal(CVec const &state, RVec const &coeff)
{
return state.transpose() * coeff;
} }
protected: protected:
uint32_t m_numTaps; uint32_t m_numTaps;
CVec m_x; CVec m_state;
}; };