55 std::vector<realT> m_c;
57 realT _setCondition{ 0 };
58 realT _actCondition{ 0 };
87 Eigen::Array<realT, -1, -1> Rmat, Rvec, PInv, LPcoeff;
89 Rmat.resize( Nc, Nc );
92 for(
int i = 0; i < Nc && i < acSz; ++i )
94 for(
int j = 0; j < Nc && i < acSz; ++j )
96 Rmat( i, j ) = ac[abs( i - j )];
99 Rvec( 0, i ) = ac[i + Npred];
102 realT tmpCond = condition;
104 _setCondition = condition;
107 _actCondition = tmpCond;
110 Eigen::Map<Eigen::Array<realT,-1,-1>> cmap(m_c.data(), 1, m_c.size());
111 cmap = Rvec.matrix() * PInv.matrix();
132 if( acSz < Nc + Npred )
134 std::string msg =
"too many coefficients for size and prediction length\n";
135 msg +=
" acSz = " + std::to_string( acSz ) +
"\n";
136 msg +=
" Nc = " + std::to_string( Nc ) +
"\n";
137 msg +=
" Npred = " + std::to_string( Npred ) +
"\n";
138 mxThrowException(
err::invalidarg,
"linearPredictor::calcCoefficientsLevinson", msg );
141 std::vector<realT> r, x, y;
143 r.resize( 2. * Nc - 1 );
147 for(
size_t i = 0; i < Nc; ++i )
149 r[i] = ac[Nc - i - 1];
152 for(
size_t i = Nc; i < 2 * Nc - 1; ++i )
154 r[i] = ac[i - Nc + 1];
157 for(
size_t i = 0; i < Nc; ++i )
159 y[i] = ac[i + Npred];
162 levinsonRecursion( r.data(), m_c.data(), y.data(), Nc );
177 realT predict( std::vector<realT> &hist,
int idx )
181 if( idx < m_c.size() )
186 for(
int i = 0; i < m_c.size(); ++i )
188 x += m_c[i] * hist[idx - i];
194 realT spectralResponse( realT f, realT fs )
198 std::complex<realT> He = 0;
199 for(
int j = 0; j < n; ++j )
202 He += m_c[j] * exp( s * std::complex<realT>( 0, -1.0 ) * f / fs );
206 return std::norm( one / ( one - He ) );
int eigenPseudoInverse(Eigen::Array< dataT, -1, -1 > &PInv, dataT &condition, int &nRejected, Eigen::Array< dataT, -1, -1 > &U, Eigen::Array< dataT, -1, -1 > &S, Eigen::Array< dataT, -1, -1 > &VT, int minMN, dataT &maxCondition, dataT alpha=0, int interact=MX_PINV_NO_INTERACT)
Calculate the pseudo-inverse of a patrix given its SVD.