void findHistogram(IDataArray::Pointer inputData, int32_t* ensembleArray, int32_t* eIds, int NumberOfBins, bool removeBiasedFeatures, bool* biasedFeatures) { DataArray<T>* featureArray = DataArray<T>::SafePointerDownCast(inputData.get()); if (NULL == featureArray) { return; } T* fPtr = featureArray->getPointer(0); size_t numfeatures = featureArray->getNumberOfTuples(); int32_t bin; int32_t ensemble; float min = 1000000.0f; float max = 0.0f; float value; for (size_t i = 1; i < numfeatures; i++) { value = fPtr[i]; if(value > max) { max = value; } if(value < min) { min = value; } } float stepsize = (max - min) / NumberOfBins; for (size_t i = 1; i < numfeatures; i++) { if(removeBiasedFeatures == false || biasedFeatures[i] == false) { ensemble = eIds[i]; bin = (fPtr[i] - min) / stepsize; if(bin >= NumberOfBins) { bin = NumberOfBins - 1; } ensembleArray[(NumberOfBins * ensemble) + bin]++; } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void subtractVector3d(DataArray<double>::Pointer data, double* v) { size_t count = data->getNumberOfTuples(); for (size_t i = 0; i < count; ++i) { double* ptr = data->getPointer(i * 3); ptr[0] = ptr[0] - v[0]; ptr[1] = ptr[1] - v[1]; ptr[2] = ptr[2] - v[2]; } }