Commit 52fa03bc authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add branch test

parent 452118a7
......@@ -63,9 +63,11 @@ bool testPHistogram2(){
hist4.setRange(-1.0f, 1.0f);
hist4.resize(20lu);
for(size_t i(0lu); i < 200lu; ++i){
hist4.addAmplitude((((float)(i*27lu%19)) - 9.0)/5.0f, 1.0f);
hist4.addAmplitude((((float)(i*27lu%19)) - 9.0)/5.0f, -1.0f);
}
std::cout << hist4 << std::endl;
hist4.checkLogValue(0.001f);
hist4.resize(0lu);
PHistogram<float> emptyHist;
std::cout << emptyHist << std::endl;
......@@ -74,6 +76,7 @@ bool testPHistogram2(){
emptyHist.addAmplitude(3.0f, 4.0f);
emptyHist.setValueRange(tabValue, 14lu);
emptyHist.addValue(tabValue, 14lu);
emptyHist.checkLogValue(0.001f);
return b;
}
......
......@@ -101,7 +101,7 @@ void PHistogram<T>::checkLogValue(T lowValue){
*/
template<typename T>
void PHistogram<T>::addValue(T value){
if(p_nbValue == 0 || p_value == NULL) return;
if(p_value == NULL) return;
if(value >= p_xMax || value < p_xMin){
if(value >= p_xMax) ++p_overXMax;
if(value < p_xMin) ++p_underXMin;
......@@ -118,7 +118,7 @@ void PHistogram<T>::addValue(T value){
*/
template<typename T>
void PHistogram<T>::addValue(const T * tabValue, size_t nbValues){
if(p_nbValue == 0lu || p_value == NULL || tabValue == NULL || nbValues == 0lu) return;
if(p_value == NULL || tabValue == NULL || nbValues == 0lu) return;
for(size_t i(0lu); i < nbValues; ++i){
addValue(tabValue[i]);
}
......@@ -130,7 +130,7 @@ void PHistogram<T>::addValue(const T * tabValue, size_t nbValues){
*/
template<typename T>
void PHistogram<T>::setValueRange(const T * tabValue, size_t nbValues){
if(p_nbValue == 0lu || p_value == NULL || tabValue == NULL || nbValues == 0lu) return;
if(p_value == NULL || tabValue == NULL || nbValues == 0lu) return;
pminmaxTab(p_xMin, p_xMax, tabValue, nbValues);
setRange(p_xMin, p_xMax);
reset();
......@@ -143,7 +143,7 @@ void PHistogram<T>::setValueRange(const T * tabValue, size_t nbValues){
*/
template<typename T>
void PHistogram<T>::addAmplitude(T value, T amplitude){
if(p_nbValue == 0 || p_value == NULL) return;
if(p_value == NULL) return;
if(value >= p_xMax || value < p_xMin){
if(value >= p_xMax) ++p_overXMax;
if(value < p_xMin) ++p_underXMin;
......@@ -170,10 +170,10 @@ void PHistogram<T>::loadBins(const T* tabValues, size_t nbValues){
///Fonction qui normalise le PHistogram
template<typename T>
void PHistogram<T>::normalize(){
if(p_value == NULL || p_nbValue == 0) return;
if(p_value == NULL) return;
T coef(((p_nbTirIn)*p_xRange)/((T)p_nbValue));
if(coef == 0.0) return;
for(size_t i(0); i < p_nbValue; ++i){
for(size_t i(0lu); i < p_nbValue; ++i){
p_value[i] /= coef;
}
}
......@@ -238,6 +238,7 @@ void PHistogram<T>::allocateHist(size_t nbValue){
delete [] p_value;
}
p_nbValue = nbValue;
if(nbValue == 0lu){return;}
p_value = new T[p_nbValue];
}
......
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