📄 ft_05.cc
字号:
// file: $isip/class/algo/FourierTransform/ft_05.cc// version: $Id: ft_05.cc,v 1.23 2002/06/25 01:42:42 picone Exp $//// isip include files//#include "FourierTransform.h"// method: apply//// arguments:// Vector<AlgorithmData>& output: (output) output data// const Vector< CircularBuffer<AlgorithmData> >& input: (input) input data//// return: a boolean value indicating status//// this method calls the appropriate computation methods//boolean FourierTransform::apply(Vector<AlgorithmData>& output_a, const Vector< CircularBuffer<AlgorithmData> >& input_a) { // determine the number of input channels and force the output to be // that number // long len = input_a.length(); output_a.setLength(len); boolean res = true; // loop over the channels and call the compute method // for (long c = 0; c < len; c++) { // branch on input data type // if (input_a(c)(0).getDataType() == AlgorithmData::VECTOR_FLOAT) { if (algorithm_d == DCT) { // call AlgorithmData::makeVectorFloat to force the output // vector for this channel to be a VectorFloat. call // AlgorithmData::getVectorFloat on the input for this channel // to check that the input is already a VectorFloat and return // that vector. // res &= compute(output_a(c).makeVectorFloat(), input_a(c)(0).getVectorFloat(), input_a(c)(0).getCoefType(), c); } else { // call AlgorithmData::makeComplexVectorFloat to force the // output vector for this channel to be a VectorComplexFloat. // call AlgorithmData::getVectorFloat on the input for this // channel to check that the input is already a VectorFloat // and return that vector. // res &= compute(output_a(c).makeVectorComplexFloat(), input_a(c)(0).getVectorFloat(), input_a(c)(0).getCoefType(), c); } } else { // call AlgorithmData::makeComplexVectorFloat to force the output vector // for this channel to be a VectorComplexFloat. // call AlgorithmData::getComplexVectorFloat on the input for this // channel to check that the input is already a VectorFloat and return // that vector. // res &= compute(output_a(c).makeVectorComplexFloat(), input_a(c)(0).getVectorComplexFloat(), input_a(c)(0).getCoefType(), c); } // set the coefficient type for the output // if (direction_d == FORWARD) { output_a(c).setCoefType(AlgorithmData::SPECTRUM); } else { output_a(c).setCoefType(AlgorithmData::SIGNAL); } } // provide some useful debugging information // if (debug_level_d > Integral::NONE) { if (debug_level_d >= Integral::ALL) { debug(PARAM_DBGL); } if (debug_level_d >= Integral::DETAILED) { input_a.debug(CLASS_NAME); } if (debug_level_d >= Integral::BRIEF) { output_a.debug(CLASS_NAME); } } // exit gracefully // return true;}// method: compute//// arguments:// VectorComplexFloat& output: (output) output data vector// const VectorFloat& input: (input) input data vector// AlgorithmData::COEF_TYPE input_coef_type: (input) type of input// long chan: (input) channel number//// return: a boolean value indicating status//// this method selects the appropriate computational method to compute// fourier transform//boolean FourierTransform::compute(VectorComplexFloat& output_a, const VectorFloat& input_a, AlgorithmData::COEF_TYPE input_coef_type_a, long chan_a) { // declare local variable // boolean status = false; long M; // Direction: FORWARD // if (direction_d == FORWARD) { // call the corresponding compute method // status = computeForward(output_a, input_a); } // Direction: INVERSE // else if (direction_d == INVERSE) { // call the corresponding compute method // status = computeInverse(output_a, input_a); } // error: unknown algorithm // else { status = Error::handle(name(), L"compute", ERR_UNKALG, __FILE__, __LINE__); } // only output required number points // if (otype_d == FULL) { M = (olen_d == DEF_LENGTH) ? (long)order_d : (long)olen_d; } else { // under SYMMETRIC output mode, user specified output length can't // be greater than half of order length // if (olen_d > ((long)order_d / 2)) { return Error::handle(name(), L"compute", ERR_OUTLEN, __FILE__, __LINE__); } // here, order+1 is to garantee DFT has correct output length no // matter it has odd order or not // M = (olen_d == DEF_LENGTH) ? (long)(((long)order_d + 1) / 2) : (long)olen_d; } output_a.setLength(M, true); // normalization the output vector if necessary // if ((normalization_d == UNIT_ENERGY) && (M > 0)) { output_a.div(output_a.length()); } // provide some useful debugging information // if (debug_level_d > Integral::NONE) { if (debug_level_d >= Integral::ALL) { debug(PARAM_DBGL); } if (debug_level_d >= Integral::DETAILED) { input_a.debug(CLASS_NAME); } if (debug_level_d >= Integral::BRIEF) { output_a.debug(CLASS_NAME); } } // exit gracefully // return status;}// method: compute//// arguments:// VectorFloat& output: (output) output data vector// const VectorComplexFloat& input: (input) input data vector// AlgorithmData::COEF_TYPE input_coef_type: (input) type of input// long chan: (input) channel number//// return: a boolean value indicating status//// this method selects the appropriate computational method to compute// fourier transform//boolean FourierTransform::compute(VectorFloat& output_a, const VectorComplexFloat& input_a, AlgorithmData::COEF_TYPE input_coef_type_a, long chan_a) { // declare local variable // boolean status = false; // Direction: INVERSE // if (direction_d == INVERSE) { // call the corresponding compute method // status = computeInverse(output_a, input_a); } // error: unknown algorithm // else { status = Error::handle(name(), L"compute", ERR_UNKALG, __FILE__, __LINE__); } // only output required number points // Note: complex input can't be under SYMMETRIC output mode // if (otype_d == SYMMETRIC) { return Error::handle(name(), L"compute", ERR_OUTTYP, __FILE__, __LINE__); } long M = (olen_d == DEF_LENGTH) ? (long)order_d : (long)olen_d; output_a.setLength(M, true); // normalization the output vector if necessary // if ((normalization_d == UNIT_ENERGY) && (output_a.length() > 0)) { output_a.div(output_a.length()); } // provide some useful debugging information // if (debug_level_d > Integral::NONE) { if (debug_level_d >= Integral::ALL) { debug(PARAM_DBGL); } if (debug_level_d >= Integral::DETAILED) { input_a.debug(CLASS_NAME); } if (debug_level_d >= Integral::BRIEF) { output_a.debug(CLASS_NAME); } } // exit gracefully // return status;}// method: compute//// arguments:// VectorComplexFloat& output: (output) output data vector// const VectorComplexFloat& input: (input) input data vector// AlgorithmData::COEF_TYPE input_coef_type: (input) type of input// long chan: (input) channel number//// return: a boolean value indicating status//// this method selects the appropriate computational method to compute// fourier transform//boolean FourierTransform::compute(VectorComplexFloat& output_a, const VectorComplexFloat& input_a, AlgorithmData::COEF_TYPE input_coef_type_a, long chan_a) { // declare local variable // boolean status = false; // Direction: FORWARD // if (direction_d == FORWARD) { // call the corresponding compute method // status = computeForward(output_a, input_a); } // algorithm: INVERSE // else if (direction_d == INVERSE) { // call the corresponding compute method // status = computeInverse(output_a, input_a); } // error: unknown algorithm // else { status = Error::handle(name(), L"compute", ERR_UNKALG, __FILE__, __LINE__); } // only output required number points // Note: complex input can't be under SYMMETRIC output mode // if (otype_d == SYMMETRIC) { return Error::handle(name(), L"compute", ERR_OUTTYP, __FILE__, __LINE__); } long M = (olen_d == DEF_LENGTH) ? (long)order_d : (long)olen_d; output_a.setLength(M, true); // normalization the output vector if necessary // if ((normalization_d == UNIT_ENERGY) && (output_a.length() > 0)) { output_a.div(output_a.length()); } // provide some useful debugging information // if (debug_level_d > Integral::NONE) { if (debug_level_d >= Integral::ALL) { debug(PARAM_DBGL); } if (debug_level_d >= Integral::DETAILED) { input_a.debug(CLASS_NAME); } if (debug_level_d >= Integral::BRIEF) { output_a.debug(CLASS_NAME); } } // exit gracefully // return status;}// method: compute//// arguments:// VectorFloat& output: (output) output data vector// const VectorFloat& input: (input) input data vector// AlgorithmData::COEF_TYPE input_coef_type: (input) type of input// long chan: (input) channel number//// return: a boolean value indicating status//// this method selects the appropriate computational method to compute// fourier transform//boolean FourierTransform::compute(VectorFloat& output_a, const VectorFloat& input_a, AlgorithmData::COEF_TYPE input_coef_type_a, long chan_a) { // declare local variable // boolean status = false; // Direction: FORWARD // if (direction_d == FORWARD) { // call the corresponding compute method // status = computeForward(output_a, input_a); } // Direction: INVERSE // else if (direction_d == INVERSE) { // call the corresponding compute method // status = computeInverse(output_a, input_a); } // error: unknown algorithm // else { status = Error::handle(name(), L"compute", ERR_UNKALG, __FILE__, __LINE__); } // only output required number points // Note: DCT transform ignores output mode parameter // long M = (olen_d == DEF_LENGTH) ? (long)order_d : (long)olen_d; output_a.setLength(M, true); // normalization the output vector if necessary // if ((normalization_d == UNIT_ENERGY) && (output_a.length() > 0)) { output_a.div(output_a.length()); } // provide some useful debugging information // if (debug_level_d > Integral::NONE) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -