// file: $isip_ifc/class/numeric/Histogram/hist_07.cc // version: $Id: hist_07.cc 10427 2006-02-13 19:33:54Z srinivas $ // // isip include files // #include "Histogram.h" // method: compute // // arguments: // const Vector& values: (input) values to histogram // // return: bool8 value indicating status // // this method bins the elements of 'values' into the bins that are already // set. // template bool8 Histogram::compute(const Vector& values_a) { // see if we are already binned // if (bins_d.length() == 0) { return Error::handle(name(), L"compute", ERR_BINS, __FILE__, __LINE__); } // update the counts // return update(values_a); } // explicit instantiations // template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); template bool8 Histogram::compute(const Vector&); // method: compute // // arguments: // const TVector& values: (input) 1D data to histogram // // return: bool8 value indicating status // // 1D histogram compute // template bool8 Histogram::compute(const TVector& values_a) { // see if we are already binned // if (bins_d.length() == 0) { return Error::handle(name(), L"compute", ERR_BINS, __FILE__, __LINE__); } // update the counts // return update(values_a); } // explicit instantiations // template bool8 Histogram::compute(const VectorByte&); template bool8 Histogram::compute(const VectorDouble&); template bool8 Histogram::compute(const VectorFloat&); template bool8 Histogram::compute(const VectorLlong&); template bool8 Histogram::compute(const VectorLong&); template bool8 Histogram::compute(const VectorShort&); template bool8 Histogram::compute(const VectorUllong&); template bool8 Histogram::compute(const VectorUlong&); template bool8 Histogram::compute(const VectorUshort&); // method: update // // arguments: // const Vector& values: (input) values to histogram // // return: bool8 value indicating status // // this method updates the current histogram counts with the values passed // in as input (possibly vector) time series // template bool8 Histogram::update(const Vector& values_a) { // verify that the bins are set // if ((bins_d.length() == 0) || (values_a.length() != dim_d)) { return Error::handle(name(), L"update", ERR_BINS, __FILE__, __LINE__); } // define local variables // float64 value = 0; int32 data_length = values_a(0).length(); for (int32 i = 0; i < dim_d; i++) { if (values_a(i).length() != data_length) { return Error::handle(name(), L"update", ERR_BINS, __FILE__, __LINE__); } } // loop over the input data and accumulate the counts // for (int32 k = 0; k < data_length; k++) { VectorLong bin_1d_index(dim_d); int32 bin_global_index = 0; for (int32 i = 0; i < dim_d; i++) { value = (float64)values_a(i)(k); bin_1d_index(i) = findBinIndex(value, i); bin_global_index += bin_1d_index(i) * block_boundary_index_d(i); } counts_d(bin_global_index) += 1; } // exit gracefully // return true; } // explicit instantiations // template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); template bool8 Histogram::update(const Vector&); // method: update // // arguments: // const TVector& values: (input) values to histogram // // return: bool8 value indicating status // // this method updates the current (1D) histogram counts with the values // passed in as a scalar time series // template bool8 Histogram::update(const TVector& values_a) { Vector values(1); values(0).assign(values_a); return update(values); } // explicit instantiations // template bool8 Histogram::update(const VectorByte&); template bool8 Histogram::update(const VectorDouble&); template bool8 Histogram::update(const VectorFloat&); template bool8 Histogram::update(const VectorLlong&); template bool8 Histogram::update(const VectorLong&); template bool8 Histogram::update(const VectorShort&); template bool8 Histogram::update(const VectorUllong&); template bool8 Histogram::update(const VectorUlong&); template bool8 Histogram::update(const VectorUshort&);