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

📄 hist_06.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
字号:
// file: $isip/class/numeric/Histogram/hist_06.cc// version: $Id: hist_06.cc,v 1.2 2001/12/26 22:32:50 alphonso Exp $//// isip include files//#include "Histogram.h"// method: setBins//// arguments://  const TVector& bins: (input) input binscomputed result//// return: boolean value indicating status//// this method sets the bins to be used for histograms. the counts are reset// to zero//template <class TVector>boolean Histogram::setBins(const TVector& bins_a) {  // assign the bins and reset the counts  //  bins_d.assign(bins_a);  counts_d.setLength(bins_d.length(), false);  counts_d.assign(0.0);  // exit gracefully  //  return true;}// explicit instantiations//template booleanHistogram::setBins<VectorByte>(const VectorByte&);template booleanHistogram::setBins<VectorDouble>(const VectorDouble&);template booleanHistogram::setBins<VectorFloat>(const VectorFloat&);template booleanHistogram::setBins<VectorLlong>(const VectorLlong&);template booleanHistogram::setBins<VectorLong>(const VectorLong&);template booleanHistogram::setBins<VectorShort>(const VectorShort&);template booleanHistogram::setBins<VectorUllong>(const VectorUllong&);template booleanHistogram::setBins<VectorUlong>(const VectorUlong&);template booleanHistogram::setBins<VectorUshort>(const VectorUshort&);// method: setBins//// arguments://  TIntegral min: (input) minimum of the histogram range//  TIntegral max: (input) maximum of the histogram range//  long num_bins: (input) number of bins to use//// return: boolean value indicating status//// this method computes the bin locations from the min, max, num_bins// and binning mode//// if mode_d == CENTERS then the bin width will be (max - min) / num_bins//    and the bin centers will be (min + (i * bin_width) + bin_width / 2) for//    0 <= i < num_bins//// if mode_d == EDGES then num_bins must be >= 2. the bin width will be//    (max - min) / (num_bins - 1). The bin edges will be//    (min + i * bin_width) for 0 <= i < num_bins//template <class T1, class T2>boolean Histogram::setBins(T1 min_a, T2 max_a, long num_bins_a) {  // error checking  //  if ((num_bins_a <= 0) || (max_a < min_a)) {    return Error::handle(name(), L"setBins", Error::ARG, __FILE__, __LINE__);  }    // set the number of bins and initialize the count vector  //  bins_d.setLength(num_bins_a, false);  counts_d.setLength(num_bins_a, false);  counts_d.assign(0.0);    // which mode are we computing for?  //  if (mode_d == CENTERS) {    // determine the bin width    //    double bin_width = (double)(max_a - min_a) / (double)num_bins_a;    double first = min_a + bin_width / 2;        // loop and add to get the bin centers    //    for (long i = 0; i < num_bins_a; i++) {      bins_d(i) = first + i * bin_width;    }  }  else if (mode_d == EDGES) {        // determine the bin width    //    double bin_width = (double)(max_a - min_a) / ((double)num_bins_a - 1);        // loop and add to get the bin edges    //    for (long i = 0; i < num_bins_a; i++) {      bins_d(i) = min_a + i * bin_width;    }    // set the last bin    //    bins_d(num_bins_a - 1) = max_a;  }  // exit gracefully  //  return true;}// explicit instantiations//template booleanHistogram::setBins<byte, byte>(byte, byte, long);template booleanHistogram::setBins<double, double>(double, double, long);template booleanHistogram::setBins<float, float>(float, float, long);template booleanHistogram::setBins<llong, llong>(llong, llong, long);template booleanHistogram::setBins<long, long>(long, long, long);template booleanHistogram::setBins<short, short>(short, short, long);template booleanHistogram::setBins<ullong, ullong>(ullong, ullong, long);template booleanHistogram::setBins<ulong, ulong>(ulong, ulong, long);template booleanHistogram::setBins<ushort, ushort>(ushort, ushort, long);// method: setCounts//// arguments://  const TVector& counts: (input) counts to initialize histogram with//// return: boolean value indicating status//// this method sets the counts vector. the input vector must be the same// length as the internal bin vector//template <class TVector>boolean Histogram::setCounts(const TVector& counts_a) {  // verify the input vector length  //  if (counts_a.length() != bins_d.length()) {    return Error::handle(name(), L"setCounts", Error::ARG, __FILE__, __LINE__);  }  // assign the counts vector  //  return (counts_d.assign(counts_a));}// explicit instantiations//template booleanHistogram::setCounts<VectorByte>(const VectorByte&);template booleanHistogram::setCounts<VectorDouble>(const VectorDouble&);template booleanHistogram::setCounts<VectorFloat>(const VectorFloat&);template booleanHistogram::setCounts<VectorLlong>(const VectorLlong&);template booleanHistogram::setCounts<VectorLong>(const VectorLong&);template booleanHistogram::setCounts<VectorShort>(const VectorShort&);template booleanHistogram::setCounts<VectorUllong>(const VectorUllong&);template booleanHistogram::setCounts<VectorUlong>(const VectorUlong&);template booleanHistogram::setCounts<VectorUshort>(const VectorUshort&);

⌨️ 快捷键说明

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