⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcscl_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
// file: $isip/class/math/scalar/MComplexScalar/mcscl_02.cc// version: $Id: mcscl_02.cc,v 1.20 2002/08/02 23:46:45 zheng Exp $//// isip include files//#include "MComplexScalarMethods.h"#include "MComplexScalar.h"#include <typeinfo>// method: diagnose//// arguments://  Integral::DEBUG level: (input) debug level for diagnostics//// return: logical error status//template<class TCScalar, class TIntegral>boolean MComplexScalarMethods::diagnose(Integral::DEBUG level_a) {  //----------------------------------------------------------------------  //  // 0. preliminaries  //  //----------------------------------------------------------------------  // output the class name  //  if (level_a > Integral::NONE) {    SysString output(L"diagnosing class ");    output.concat(name());    output.concat(L": ");    Console::put(output);    Console::increaseIndention();  }  // call the sub diagnose methods  //  diagnose0<TCScalar, TIntegral>(level_a);  diagnose1<TCScalar, TIntegral>(level_a);  diagnose2<TCScalar, TIntegral>(level_a);     //---------------------------------------------------------------------  //  // print completion message  //  //---------------------------------------------------------------------    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    if (level_a > Integral::NONE) {    String output(L"diagnostics passed for class ");    output.concat(name());    output.concat(L"\n");    Console::put(output);     }    // exit gracefully  //  return true;}// method: diagnose0//// arguments://  Integral::DEBUG level: (input) debug level for diagnostics//// return: logical error status//// this method tests required methods. note that i/o methods will be// tested in the type-specific complex classes.// template<class TCScalar, class TIntegral>boolean MComplexScalarMethods::diagnose0(Integral::DEBUG level_a) {  //--------------------------------------------------------------------  //  // 1. testing required methods  //  //--------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing required public methods...\n");    Console::increaseIndention();  }  // declare local variables  TCScalar val6;  // test the debug method  //  val6.setDebug(level_a);  if (val6.debug_level_d != level_a) {    return Error::handle(name(), L"debug", Error::TEST, __FILE__, __LINE__);  }   // test assign  //  val6.assign(3);  if (val6 != 3) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }  // test the copy constructor  //  TCScalar val7(val6);  if (val6 != val7) {    return Error::handle(name(), L"copy", Error::TEST, __FILE__, __LINE__);  }    // test the sizeof method  //  if (val6.sofSize() != sizeof(val6)) {    return Error::handle(name(), L"sofSize",			 Error::TEST, __FILE__, __LINE__);  }      // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    // exit gracefully  //  return true;}// method: diagnose1//// arguments://  Integral::DEBUG level: (input) debug level for diagnostics//// return: logical error status//// this method tests all functions inherited from MScalar for the// case of complex numbers.//template<class TCScalar, class TIntegral>boolean MComplexScalarMethods::diagnose1(Integral::DEBUG level_a) {  //--------------------------------------------------------------------  //  // 2. testing methods inherited from MScalar  //  //--------------------------------------------------------------------    // declare some local variables  //  TCScalar val4;  TCScalar val5;  TCScalar val6;  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing methods inherited from MScalar...\n");    Console::increaseIndention();  }    // test assign method  //  val5.assign(3, 4);  if (val5.real() != 3, val5.imag() != 4) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }    // test operator +  //  val4.assign(1, 2);  val6 = val4 + val5;  if (val6.real() != (TIntegral)4, val6.imag() != (TIntegral)6) {    return Error::handle(name(), L"operator +", Error::TEST, __FILE__, __LINE__);  }        // test operator -  //  val6 = val5 - val4;  if (val6.real() != (TIntegral)2, val6.imag() != (TIntegral)2) {    return Error::handle(name(), L"operator -",			 Error::TEST, __FILE__, __LINE__);  }  // test operator *  //  val6 = val4 * val5;  if (val6.real() != (TIntegral)-5, val6.imag() != (TIntegral)10) {    return Error::handle(name(), L"operator *",			 Error::TEST, __FILE__, __LINE__);  }    // test operator /  //  val6 = val5 / val4;    if ((!val6.almostEqual(SysComplex<TIntegral>			   ((TIntegral)2.2, (TIntegral)-0.4)))) {    return Error::handle(name(),			 L"operator /", Error::TEST, __FILE__, __LINE__);  }  // test operator %  // not done for complex numbers  //    // test operator ++ (post increment)  //  val6.assign(val4++);  if (val6.real() != (TIntegral)1, val6.imag() != (TIntegral)2) {    return Error::handle(name(), L"operator ++",			 Error::TEST, __FILE__, __LINE__);  }     // test operator -- (post decrement)  //  val6.assign(val4--);    if (val6.real() != (TIntegral)1, val6.imag() != (TIntegral)2) {    return Error::handle(name(), L"operator --",			 Error::TEST, __FILE__, __LINE__);  }    // test operator ++ (pre increment)  //  val6.assign(++val4);  if (val6.real() != (TIntegral)2, val6.imag() != (TIntegral)2) {    return Error::handle(name(), L"++",			 Error::TEST, __FILE__, __LINE__);    }    // test operator -- (pre decrement)  //  val6.assign(--val4);  if (val6.real() != (TIntegral)0, val6.imag() != (TIntegral)2) {    return Error::handle(name(), L"--",			 Error::TEST, __FILE__, __LINE__);  }    // test operator +=  //  val6 = val5;  val6 += val4;  if (val6.real() != (TIntegral)4, val6.imag() != (TIntegral)6) {    return Error::handle(name(), L"+=", Error::TEST, __FILE__, __LINE__);  }        // test operator -=  //  val6 = val5;  val6 -= val4;  if (val6.real() != (TIntegral)2, val6.imag() != (TIntegral)2) {    return Error::handle(name(), L"-=", Error::TEST, __FILE__, __LINE__);  }      // test operator *=  //  val6 = val5;  val6 *= val4;  if (val6.real() != (TIntegral)-5, val6.imag() != (TIntegral)10) {    return Error::handle(name(), L"*=", Error::TEST, __FILE__, __LINE__);  }     // test operator /=  //  val6 = val5;  val6 /= val4;  if (!val6.almostEqual(SysComplex<TIntegral>			((TIntegral)2.2, (TIntegral)-0.4))) {    return Error::handle(name(), L"/=", Error::TEST, __FILE__, __LINE__);  }    // test operator ==  //  val6 = val5;  if (!val6.real() == (TIntegral)3, !val6.imag() == (TIntegral)4) {    return Error::handle(name(), L"==", Error::TEST, __FILE__, __LINE__);  }    // test operator !=  //  val6 = val5;  if (val6.real() != (TIntegral)3, val6.imag() != (TIntegral)4) {    return Error::handle(name(), L"!=", Error::TEST, __FILE__, __LINE__);  }      // test operator <  //  if (val5.real() < (TIntegral)1, val5.imag() < (TIntegral)2) {    return Error::handle(name(), L"<", Error::TEST, __FILE__, __LINE__);  }     // test operator <=  //  if (val5.real() <= (TIntegral)1, val5.imag() <= (TIntegral)2) {    return Error::handle(name(), L"<=", Error::TEST, __FILE__, __LINE__);  }      // test operator >  //  if (!val5.real() > (TIntegral)1, !val5.imag() > (TIntegral)2) {    return Error::handle(name(), L">", Error::TEST, __FILE__, __LINE__);  }    // test operator >=  //  if (!val5.real() >= (TIntegral)3, !val5.imag() > (TIntegral)2) {    return Error::handle(name(), L">=", Error::TEST, __FILE__, __LINE__);  }      //---------------------------------------------------------------------------  //  // class-specific public methods:  //  equality and comparison methods  //  //---------------------------------------------------------------------------    // test eq  //  if (val4.eq(val5)) {    return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);  }     // test ne  //  val6 = val5;  if (val6.ne(val5)) {    return Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);  }    // test lt  //  if (val5.lt(val4)) {    return Error::handle(name(), L"lt", Error::TEST, __FILE__, __LINE__);  }    // test le  //  if (val5.le(val4)) {    return Error::handle(name(), L"le", Error::TEST, __FILE__, __LINE__);  }    // test gt  //  if (val4.gt(val5)) {    return Error::handle(name(), L"gt", Error::TEST, __FILE__, __LINE__);  }      // test ge  //  if (val4.ge(val5)) {    return Error::handle(name(), L"ge", Error::TEST, __FILE__, __LINE__);  }  // bitwise and integer-specific operations not tested for complex numbers  //    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  basic mathematical methods  //  //---------------------------------------------------------------------------  // test add  //  val6.add(val5, val4);  if (val6.real() != (TIntegral)4, val6.imag() != (TIntegral)6) {    return Error::handle(name(), L"add",			 Error::TEST, __FILE__, __LINE__);  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -