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

📄 mvec_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 5 页
字号:
    if (level_a > Integral::BRIEF) {      Console::put(L"testing signed mathematical methods:\n");    }        // use these vectors for testing    //    val0.assign((TIntegral)-44);    val1.assign((TIntegral)200);#ifndef ISIP_TEMPLATE_complex     // test abs    //    val2.abs(val0);    if (!val2.almostEqual((TIntegral)44)) {      val2.debug(L"val2");      val0.debug(L"val0");            return Error::handle(TVector::name(), L"abs",			   Error::TEST, __FILE__, __LINE__);    }        val2.abs(val1);    if (!val2.almostEqual((TIntegral)200)) {      return Error::handle(TVector::name(), L"abs",			   Error::TEST, __FILE__, __LINE__);    }        // test sign    //    val2.sign(val0);    if (!val2.almostEqual((TIntegral)-1)) {      return Error::handle(TVector::name(), L"sign",			   Error::TEST, __FILE__, __LINE__);    }#endif        val2.sign(val1);    if (!val2.almostEqual((TIntegral)1)) {      return Error::handle(TVector::name(), L"sign",			   Error::TEST, __FILE__, __LINE__);    }        // test neg    //    val2.neg(val0);    if (!val2.almostEqual((TIntegral)44)) {      return Error::handle(TVector::name(), L"neg",			   Error::TEST, __FILE__, __LINE__);    }        val2.neg(val1);    if (!val2.almostEqual((TIntegral)-200)) {      return Error::handle(TVector::name(), L"neg",			   Error::TEST, __FILE__, __LINE__);    }        // test mins and maxes (signed version)    //    if (level_a > Integral::BRIEF) {      Console::put(L"testing mins and maxes (signed):\n");    }        // test min, minMag, max, maxMag    //    val0.assign(L"-1, 3, 5, 7, -9");        long pos = 0;    TIntegral min = 0;    TIntegral max = 0;    double min_mag = 0;    double max_mag = 0;        // test min    //    min = val0.min(pos);#ifndef ISIP_TEMPLATE_complex        if ((min != (TIntegral)-9) || (pos != 4)) {      return Error::handle(TVector::name(), L"min",			   Error::TEST, __FILE__, __LINE__);    }#endif        // test minMag    //    min_mag = val0.minMag(pos);    if ((min_mag != (double)1) || (pos != 0)) {      return Error::handle(TVector::name(), L"minMag",			   Error::TEST, __FILE__, __LINE__);    }        // test max    //    max = val0.max(pos);#ifndef ISIP_TEMPLATE_complex            if ((max != (TIntegral)7) || (pos != 3)) {      return Error::handle(TVector::name(), L"max",			   Error::TEST, __FILE__, __LINE__);    }#endif        // test maxMag    //    max_mag = val0.maxMag(pos);    if ((max_mag != (double)9) || (pos != 4)) {      return Error::handle(TVector::name(), L"maxMag",			   Error::TEST, __FILE__, __LINE__);    }    #ifndef ISIP_TEMPLATE_complex    // test DSP functions (signed version)    //    if (level_a > Integral::BRIEF) {      Console::put(L"testing DSP methods (signed):\n");    }        // test limit    //    val2.setLength((long)5);    val2.limit(1, 7, val0);    val1.assign(L"1, 3, 5, 7, 1");    if (val2.ne(val1)) {      val2.debug(L"limit");      val1.debug(L"limit");            return Error::handle(TVector::name(), L"limit",			   Error::TEST, __FILE__, __LINE__);    }        // test limitMin    //    val2.limitMin((TIntegral)3, val0);    val1.assign(L"3, 3, 5, 7, 3");    if (val2.ne(val1)) {      val2.debug(L"limitMin");      return Error::handle(TVector::name(), L"limitMin",			   Error::TEST, __FILE__, __LINE__);    }        // test limitMax    //    val2.limitMax((TIntegral)5, val0);    val1.assign(L"-1, 3, 5, 5, -9");    if (val2.ne(val1)) {      val2.debug(L"limitMax");      return Error::handle(TVector::name(), L"limitMax",			   Error::TEST, __FILE__, __LINE__);    }        val2.limitMag((TIntegral)5, (TIntegral)-1, val0);    val1.assign(L"-1, 3, -1, -1, -1");    if (val2.ne(val1)) {      val2.debug(L"limitMag");      return Error::handle(TVector::name(), L"limitMag",			   Error::TEST, __FILE__, __LINE__);    }        // test centerClip    //    //    if ((typeid(TIntegral) == typeid(float)) ||	(typeid(TIntegral) == typeid(double))) {          val2.centerClip((TIntegral)0, (TIntegral)8, val0);      val1.assign(L"-1, 0, 8, 8, -9");      if (val2.ne(val1)) {	val2.debug(L"centerclip");	return Error::handle(TVector::name(), L"centerClip",			     Error::TEST, __FILE__, __LINE__);      }    }#endif  }  // do unsigned-specific testing  //  else {        // test DSP functions (unsigned version)    //    if (level_a > Integral::BRIEF) {      Console::put(L"testing DSP methods (unsigned):\n");    }        // use these vectors for testing    //    val0.assign((TIntegral)44);    val1.assign((TIntegral)200);    // test mins and maxes (unsigned version)    //    if (level_a > Integral::BRIEF) {      Console::put(L"testing mins and maxes (unsigned):\n");    }        // test min, minMag, max, maxMag    //    val0.assign(L"1, 3, 5, 7, 27");    long pos = 0;    TIntegral min = 0;    TIntegral max = 0;    double min_mag = 0;    double max_mag = 0;        // test min    //    min = val0.min(pos);    if ((min != (TIntegral)1) || (pos != 0)) {      return Error::handle(TVector::name(), L"min",			   Error::TEST, __FILE__, __LINE__);    }        // test minMag    //    min_mag = val0.minMag(pos);    if ((min_mag != (double)1) || (pos != 0)) {      return Error::handle(TVector::name(), L"minMag",			   Error::TEST, __FILE__, __LINE__);    }        // test max    //    max = val0.max(pos);    if ((max != (TIntegral)27) || (pos != 4)) {      return Error::handle(TVector::name(), L"max",			   Error::TEST, __FILE__, __LINE__);    }        // test maxMag    //    max_mag = val0.maxMag(pos);    if ((max_mag != (double)27) || (pos != 4)) {      return Error::handle(TVector::name(), L"maxMag",			   Error::TEST, __FILE__, __LINE__);    }#ifndef ISIP_TEMPLATE_complex    // test DSP functions (unsigned version)    //    if (level_a > Integral::BRIEF) {      Console::put(L"testing DSP methods (unsigned):\n");    }        val2.assign(L"1, 3, 5, 7, 27");        // test limit    //    val2.limit(1, 7, val0);    val1.assign(L"1, 3, 5, 7, 7");    if (val2.ne(val1)) {      val2.debug(L"limit");      val1.debug(L"limit");      return Error::handle(TVector::name(), L"limit",			   Error::TEST, __FILE__, __LINE__);    }        // test limitMin    //    val2.limitMin((TIntegral)3, val0);    val1.assign(L"3, 3, 5, 7, 27");    if (val2.ne(val1)) {      val2.debug(L"limitMin");      return Error::handle(TVector::name(), L"limit",			   Error::TEST, __FILE__, __LINE__);    }        // test limitMax    //    val2.limitMax((TIntegral)5, val0);    val1.assign(L"1, 3, 5, 5, 5");    if (val2.ne(val1)) {      val2.debug(L"limitMax");      return Error::handle(TVector::name(), L"limitMax",			   Error::TEST, __FILE__, __LINE__);    }        val2.limitMag((TIntegral)5, (TIntegral)200, val0);    val1.assign(L"1, 3, 200, 200, 200");    if (val2.ne(val1)) {      val2.debug(L"limitmag");      return Error::handle(TVector::name(), L"limitMag",			   Error::TEST, __FILE__, __LINE__);    }        // test centerClip    //    if ((typeid(TIntegral) == typeid(float)) &&	(typeid(TIntegral) == typeid(double))) {            val2.centerClip((TIntegral)0, (TIntegral)8, val0);      val1.assign(L"0, 0, 8, 8, 27");      if (val2.ne(val1)) {	val2.debug(L"centerclip");	return Error::handle(TVector::name(), L"centerClip",			     Error::TEST, __FILE__, __LINE__);      }    }#endif      }  // test random number generation methods  //  if (level_a > Integral::BRIEF) {    Console::put(L"testing rand methods:\n");  }  // test rand  //  val0.rand();  val0.rand((TIntegral)3, (TIntegral)20);  if (val0.lt((TIntegral)3) || val0.gt((TIntegral)20)) {    return Error::handle(TVector::name(), L"rand",			 Error::TEST, __FILE__, __LINE__);  }  // test grand: a simple test simply to make sure it doesn't crash  //  TIntegral mean = 10;  TIntegral stvar = 2;  val0.grand(mean, stvar);    // exit gracefully  //  return true;}// method: diagnose8//// arguments://  Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//// this method tests position operation and search methods//template<class TVector, class TScalar, class TIntegral>boolean MVectorMethods::diagnose8(Integral::DEBUG level_a) {  // declare local variables  //  long num_elem = 5;  // test constructors  //  TVector val0;  TVector val1(num_elem);    val0.assign(L"1, 3, 5, 7, 9");  val1.assign(L"0, 2, 4, 6, 8");    // assign values  //  val0.setLength(num_elem);  val0.assign((TIntegral)0);  val1.assign(L"40, 41, 42, 43, 44");    // move 4 elements starting from the 2nd element in val1, put into val0  // starting from 2nd element, val0 will be resized  //   val0.move(val1, 4, 1, 1);    TVector result;  result.assign(L"0, 41, 42, 43, 44");    if (val0.ne(result)) {    val0.debug(L"move ->");    return Error::handle(TVector::name(), L"move",			 Error::TEST, __FILE__, __LINE__);  }    // move 2 elements starting from the 1st element  // in val1, put into val0 starting from 0st element  //  val0.move(val1, 2, 1, 0);    result.assign(L"41, 42, 42, 43, 44");    if (val0.ne(result)) {    val0.debug(L"move ->");    return Error::handle(TVector::name(), L"move",			 Error::TEST, __FILE__, __LINE__);  }     // test shift  //  val0.assign(L"43, 43, 0, 0, 0");  val0.shift(2);  result.assign(L"0, 0, 43, 43, 0");    if (val0.ne(result)) {    return Error::handle(TVector::name(), L"shift right",			 Error::TEST, __FILE__, __LINE__);  }    val0.shift(-1);  result.assign(L"0, 43, 43, 0, 0");    if (val0.ne(result)) {    return Error::handle(TVector::name(), L"shift left",			 Error::TEST, __FILE__, __LINE__);  }    // test concat  //  val0.assign((long)2, (TIntegral)0);  val1.setLength(3);  val0.concat(val1);    result.assign(L"0, 0, 40, 41, 42");  if (val0.ne(result)) {    return Error::handle(TVector::name(), L"concat",			 Error::TEST, __FILE__, __LINE__);  }    // test deleteRange for deleting from the start  //  val0.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9");  val0.deleteRange(0, 3);  result.assign(L"3, 4, 5, 6, 7, 8, 9");  if (result.ne(val0)) {    return Error::handle(TVector::name(), L"deleteRange",			 Error::TEST, __FILE__, __LINE__);  }    // test deleteRange for deleting from the middle  //  val0.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9");  val0.deleteRange(2, 3);  result.assign(L"0, 1, 5, 6, 7, 8, 9");  if (result.ne(val0)) {    return Error::handle(TVector::name(), L"deleteRange",			 Error::TEST, __FILE__, __LINE__);  }    // test deleteRange for deleting from the end  //  val0.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9");  val0.deleteRange(6, 4);  result.assign(L"0, 1, 2, 3, 4, 5");  if (result.ne(val0)) {    return Error::handle(TVector::name(), L"deleteRange",			 Error::TEST, __FILE__, __LINE__);  }  // test deleteRange for deleting from the start  //  val0.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9");  val1.deleteRange(val0, 0, 3);  result.assign(L"3, 4, 5, 6, 7, 8, 9");  if (result.ne(val1)) {    return Error::handle(TVector::name(), L"deleteRange",			 Error::TEST, __FILE__, __LINE__);  }    // test deleteRange for deleting from the middle  //  val0.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9");  val1.deleteRange(val0, 2, 3);  result.assign(L"0, 1, 5, 6, 7, 8, 9");  if (result.ne(val1)) {    return Error::handle(TVector::name(), L"deleteRange",			 Error::TEST, __FILE__, __LINE__);  }    // test deleteRange for deleting from the end  //  val0.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9");  val1.deleteRange(val0, 6, 4);  result.assign(L"0, 1, 2, 3, 4, 5");  if (result.ne(val1)) {    return Error::handle(TVector::name(), L"deleteRange",			 Error::TEST, __FILE__, __LINE__);  }  // test setRange for setting from the start  //  val0.assign(L"0, 1, 2, 3, 4, 5");  val0.setRange(0, 3, 7);  result.assign(L"7, 7, 7, 3, 4, 5");  if (result.ne(val0)) {    val0.debug(L"output vector");    result.debug(L"result vector");    return Error::handle(TVector::name(), L"setRange",			 Error::TEST, __FILE__, __LINE__);  }    // test setRange for setting from the middle  //  val0.assign(L"0, 1, 2, 3, 4, 5");  val0.setRange(2, 3, 7);  result.assign(L"0, 1, 7, 7, 7, 5");  if (result.ne(val0)) {    val0.debug(L"output vector");    result.debug(L"result vector");        return Error::handle(TVector::name(), L"setRange",			 Error::TEST, __FILE__, __LINE__);  }    // test setRange for setting from the end  //  val0.assign(L"0, 1, 2, 3, 4, 5");  val0.setRange(5, 1, 7);  result.assign(L"0, 1, 2, 3, 4, 7");  if (result.ne(val0)) {    val0.debug(L"output vector");    result.debug(L"result vector");        return Error::handle(TVector::name(), L"setRange",			 Error::TEST, __FILE__, __LINE__);  } 

⌨️ 快捷键说明

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