typename ScalarTraits<BasisFunctionType>::RealType L2NormOfDifference( const GridFunction<BasisFunctionType, ResultType> &gridFunction, const Fiber::Function<ResultType> &refFunction, const Fiber::QuadratureStrategy<BasisFunctionType, ResultType, GeometryFactory> &quadStrategy, const EvaluationOptions &options) { // First, construct the evaluator. typedef Fiber::EvaluatorForIntegralOperators<ResultType> Evaluator; std::unique_ptr<Evaluator> evaluator = makeEvaluator(gridFunction, refFunction, quadStrategy, options); typedef typename Fiber::ScalarTraits<BasisFunctionType>::RealType MagnitudeType; typedef MagnitudeType CoordinateType; arma::Mat<CoordinateType> evaluationPoints(1, 1); evaluationPoints(0, 0) = 0.; arma::Mat<ResultType> resultMatrix; evaluator->evaluate(Evaluator::FAR_FIELD, evaluationPoints, resultMatrix); ResultType result = resultMatrix(0, 0); if (fabs(imagPart(result)) > 1000. * std::numeric_limits<MagnitudeType>::epsilon()) std::cout << "Warning: squared L2 norm has non-negligible imaginary part: " << imagPart(result) << std::endl; return sqrt(realPart(result)); }
void GetImagPartOfDiagonal ( const DistMatrix<T,U,V>& A, ElementalMatrix<Base<T>>& d, Int offset ) { DEBUG_ONLY(CSE cse("GetImagPartOfDiagonal")) function<Base<T>(T)> imagPart ( []( T alpha ) { return ImagPart(alpha); } ); GetMappedDiagonal( A, d, imagPart, offset ); }
void GetImagPartOfDiagonal ( const DistMatrix<T,U,V>& A, AbstractDistMatrix<Base<T>>& d, Int offset ) { DEBUG_ONLY(CallStackEntry cse("GetImagPartOfDiagonal")) std::function<Base<T>(T)> imagPart ( []( T alpha ) { return ImagPart(alpha); } ); GetMappedDiagonal( A, d, imagPart, offset ); }
/** * Calculates MFCC given audio frame */ NumberArray Mfcc::calculate( NumberArrayRef audioFrame) { //------------calculate FFT-spectrum------------------// NumberArray realPart = audioFrame; realPart.resize(m_fftSize, 0.0); // zero padding NumberArray imagPart(m_fftSize, 0.0); Dsp::fft(Dsp::FORWARD_FFT, m_pow2Size, m_fftSize, realPart, imagPart); //---------Calculate LOG of( Mel-spectrum)------------------// NumberArray filterOutput = m_bank.applyFilter(realPart, imagPart); //---------Calculate Mel-cepstrum------------------// return m_dct.applyDct(filterOutput); }