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

📄 hist_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 4 页
字号:
    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.setBins(test_data.min(), test_data.max(), DEF_NUM_BINS);  hist6.compute(short_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.setBins(test_data.min(), test_data.max(), DEF_NUM_BINS);  hist6.compute(ullong_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.setBins(test_data.min(), test_data.max(), DEF_NUM_BINS);  hist6.compute(ulong_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.setBins(test_data.min(), test_data.max(), DEF_NUM_BINS);  hist6.compute(ushort_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    // test a histogram with a specified number of bins in EDGES mode for  // all data types  //  expected_counts.assign(L"1, 1, 1, 1, 1, 1, 1, 1, 1, 1");  hist6.clear();  hist6.setMode(EDGES);  hist6.compute(byte_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(double_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(float_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(llong_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(long_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(short_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(ullong_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(ulong_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  hist6.compute(ushort_data, DEF_NUM_BINS);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    // test a histogram with specified bins in EDGES mode for each data type  //  test_data.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11");  expected_counts.assign(L"1, 1, 1, 1, 1, 1, 1, 1, 1, 1");  all_bins.assign(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9");  hist6.clear();  hist6.setMode(EDGES);  byte_bins.assign(all_bins);  hist6.compute(byte_data, byte_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  double_bins.assign(all_bins);  hist6.compute(double_data, double_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  float_bins.assign(all_bins);  hist6.compute(float_data, float_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  llong_bins.assign(all_bins);  hist6.compute(llong_data, llong_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  long_bins.assign(all_bins);  hist6.compute(long_data, long_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  short_bins.assign(all_bins);  hist6.compute(short_data, short_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  ullong_bins.assign(all_bins);  hist6.compute(ullong_data, ullong_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  ulong_bins.assign(all_bins);  hist6.compute(ulong_data, ulong_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  ushort_bins.assign(all_bins);  hist6.compute(ushort_data, ushort_bins);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    // update a histogram with specified bins in EDGES mode for each data type  //  expected_counts.assign(L"2, 2, 2, 2, 2, 2, 2, 2, 2, 2");  hist6.clear();  hist6.setMode(EDGES);  byte_bins.assign(all_bins);  hist6.compute(byte_data, byte_bins);  hist6.update(byte_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  double_bins.assign(all_bins);  hist6.compute(double_data, double_bins);  hist6.update(double_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  float_bins.assign(all_bins);  hist6.compute(float_data, float_bins);  hist6.update(float_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  llong_bins.assign(all_bins);  hist6.compute(llong_data, llong_bins);  hist6.update(llong_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  long_bins.assign(all_bins);  hist6.compute(long_data, long_bins);  hist6.update(long_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  short_bins.assign(all_bins);  hist6.compute(short_data, short_bins);  hist6.update(short_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  ullong_bins.assign(all_bins);  hist6.compute(ullong_data, ullong_bins);  hist6.update(ullong_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  ulong_bins.assign(all_bins);  hist6.compute(ulong_data, ulong_bins);  hist6.update(ulong_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    hist6.clear();  hist6.setMode(EDGES);  ushort_bins.assign(all_bins);  hist6.compute(ushort_data, ushort_bins);  hist6.update(ushort_data);  hist6.getCounts(actual_counts);  if (!actual_counts.eq(expected_counts)) {    actual_counts.debug(L"actual counts");    expected_counts.debug(L"expected counts");    return Error::handle(name(), L"compute", Error::TEST, __FILE__,			 __LINE__);  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------------  //  // 5. class-specific public methods:  //     normalization methods  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: get methods...\n");    Console::increaseIndention();  }  // test pdf  //  VectorDouble expected_pdf(L"0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1");  VectorDouble actual_pdf;  if (!hist6.pdf(actual_pdf) ||      !actual_pdf.almostEqual(expected_pdf)) {    actual_pdf.debug(L"actual pdf");    expected_pdf.debug(L"expected pdf");    return Error::handle(name(), L"pdf", Error::TEST, __FILE__,			 __LINE__);  }    // test cdf  //  VectorDouble expected_cdf(L"0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1");  VectorDouble actual_cdf;  if (!hist6.cdf(actual_cdf) ||      !actual_cdf.almostEqual(expected_cdf)) {    actual_cdf.debug(L"actual cdf");    expected_cdf.debug(L"expected cdf");    return Error::handle(name(), L"cdf", Error::TEST, __FILE__,			 __LINE__);  }        // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------------  //  // 6. print completion message  //  //---------------------------------------------------------------------------  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    if (level_a > Integral::NONE) {    SysString output(L"diagnostics passed for class ");    output.concat(name());    output.concat(L"\n");    Console::put(output);  }  // exit gracefully  //  return true;}

⌨️ 快捷键说明

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