Commit ba0b0bd4 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add function to update a 1d histogram

parent 0b4a80e3
Pipeline #118220 passed with stages
in 36 seconds
......@@ -9,6 +9,37 @@
#include <iostream>
///Update the 1d histogram
/** @param[out] histValue : table of the histogram values
* @param xValue : value to be put in the histogram on x axis
* @param amplitude : aplitude to be added to the proper histogram bin, if (xValue, yValue) is in the histogram
* @param xMin : minimum value of x
* @param xRange : range of x
* @param nbX : number of value on x axis
*/
template<typename T>
void update_histogram1dRange(T* histValue, T xValue, T amplitude, T xMin, T xRange, size_t nbX){
size_t posX(((xValue - xMin)*((T)nbX))/xRange);
if(posX >= nbX){
return;
}
histValue[posX] += amplitude;
}
///Update the 1d histogram
/** @param[out] histValue : table of the histogram values
* @param xValue : value to be put in the histogram on x axis
* @param amplitude : aplitude to be added to the proper histogram bin, if (xValue, yValue) is in the histogram
* @param xMin : minimum value of x
* @param xMax : maximum value of x
* @param nbX : number of value on x axis
*/
template<typename T>
void update_histogram1d(T* histValue, T xValue, T amplitude, T xMin, T xMax, size_t nbX){
update_histogram1dRange(histValue, xValue, amplitude, xMin, xMax - xMin, nbX);
}
///Update the 2d histogram
/** @param[out] histValue : table of the histogram values
* @param xValue : value to be put in the histogram on x axis
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment