Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixMath
Commits
64d393de
Commit
64d393de
authored
Dec 20, 2020
by
Pierre Aubert
Browse files
Add test
parent
e6a273f8
Pipeline
#96651
passed with stages
in 50 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
502 additions
and
6 deletions
+502
-6
TESTS/TEST_PHISTOGRAM/main.cpp
TESTS/TEST_PHISTOGRAM/main.cpp
+37
-3
src/PHistogram/PHistogram.h
src/PHistogram/PHistogram.h
+2
-1
src/PHistogram/PHistogram_impl.h
src/PHistogram/PHistogram_impl.h
+14
-2
src/pMinMax.h
src/pMinMax.h
+77
-0
src/pMinMax_impl.h
src/pMinMax_impl.h
+372
-0
No files found.
TESTS/TEST_PHISTOGRAM/main.cpp
View file @
64d393de
...
...
@@ -12,30 +12,64 @@
bool
testPHistogram
(){
bool
b
(
true
);
PHistogram
<
float
>
hist
(
0
.0
f
,
1.0
f
,
10lu
);
PHistogram
<
float
>
hist
(
-
1
.0
f
,
1.0
f
,
10lu
);
hist
.
reset
();
for
(
size_t
i
(
0lu
);
i
<
100lu
;
++
i
){
hist
.
addValue
(((
float
)(
i
*
27lu
%
19
))
/
19
.0
f
);
hist
.
addValue
(((
(
float
)(
i
*
27lu
%
19
))
-
9.0
)
/
5
.0
f
);
}
std
::
cout
<<
"testPHistogram : min = "
<<
hist
.
getMin
()
<<
", max = "
<<
hist
.
getMax
()
<<
", range = "
<<
hist
.
getRange
()
<<
", nbValueUnderMin = "
<<
hist
.
getUnderXMin
()
<<
", nbValueUpperMax = "
<<
hist
.
getOverXMax
()
<<
std
::
endl
;
std
::
cout
<<
hist
<<
std
::
endl
;
PHistogram
<
float
>
hist2
(
hist
);
std
::
cout
<<
hist2
<<
std
::
endl
;
hist2
.
checkLogValue
(
0.001
f
);
PHistogram
<
float
>
hist3
;
hist3
=
hist
;
hist3
.
normalize
();
std
::
cout
<<
hist3
<<
std
::
endl
;
PHistogram
<
float
>
hist4
;
hist4
.
setRange
(
-
1.0
f
,
1.0
f
);
hist4
.
resize
(
20lu
);
for
(
size_t
i
(
0lu
);
i
<
200lu
;
++
i
){
hist4
.
addValue
((((
float
)(
i
*
27lu
%
19
))
-
9.0
)
/
5.0
f
);
}
std
::
cout
<<
hist4
<<
std
::
endl
;
return
b
;
}
///Test the graph conversion to dot
/** @return true on success, false otherwise
*/
bool
testPHistogram2
(){
bool
b
(
true
);
PHistogram
<
float
>
hist
(
-
1.0
f
,
1.0
f
,
10lu
);
float
tabValue
[]
=
{
1.0
f
,
4.0
f
,
6.0
f
,
3.0
f
,
6.0
f
,
6.0
f
,
7.0
f
,
4.0
f
,
3.0
f
,
7.0
f
,
5.0
f
,
3.0
f
,
5.0
f
,
6.0
f
};
hist
.
addValue
(
NULL
,
0lu
);
hist
.
setValueRange
(
tabValue
,
14lu
);
hist
.
addValue
(
tabValue
,
14lu
);
std
::
cout
<<
hist
<<
std
::
endl
;
PHistogram
<
float
>
hist4
;
hist4
.
setRange
(
-
1.0
f
,
1.0
f
);
hist4
.
resize
(
20lu
);
for
(
size_t
i
(
0lu
);
i
<
200lu
;
++
i
){
hist4
.
addAmplitude
((((
float
)(
i
*
27lu
%
19
))
-
9.0
)
/
5.0
f
,
1.0
f
);
}
std
::
cout
<<
hist4
<<
std
::
endl
;
return
b
;
}
int
main
(
int
argc
,
char
**
argv
){
bool
b
(
testPHistogram
());
b
&=
testPHistogram2
();
return
b
-
1
;
}
...
...
src/PHistogram/PHistogram.h
View file @
64d393de
...
...
@@ -19,6 +19,7 @@ class PHistogram{
PHistogram
(
const
PHistogram
<
T
>
&
other
);
virtual
~
PHistogram
();
void
resize
(
size_t
nbValue
);
void
setRange
(
T
min
,
T
max
);
void
reset
();
...
...
@@ -26,7 +27,7 @@ class PHistogram{
void
addValue
(
T
value
);
void
addValue
(
const
T
*
tabValue
,
size_t
nbValues
);
void
add
ValueRange
(
const
T
*
tabValue
,
size_t
nbValues
);
void
set
ValueRange
(
const
T
*
tabValue
,
size_t
nbValues
);
void
addAmplitude
(
T
value
,
T
amplitude
);
void
loadBins
(
const
T
*
tabValues
,
size_t
nbValues
);
...
...
src/PHistogram/PHistogram_impl.h
View file @
64d393de
...
...
@@ -7,6 +7,7 @@
#ifndef __PHISTOGRAM_IMPL_H__
#define __PHISTOGRAM_IMPL_H__
#include "pMinMax.h"
#include "PHistogram.h"
///Default constructor of PHistogram
...
...
@@ -18,6 +19,7 @@ PHistogram<T>::PHistogram(size_t nbValue)
{
initialisationPHistogram
();
allocateHist
(
nbValue
);
reset
();
}
///PHistogram constructor
...
...
@@ -32,6 +34,7 @@ PHistogram<T>::PHistogram(T min, T max, size_t nbValue)
initialisationPHistogram
();
allocateHist
(
nbValue
);
setRange
(
min
,
max
);
reset
();
}
///Copy constructor of PHistogram
...
...
@@ -52,6 +55,15 @@ PHistogram<T>::~PHistogram(){
}
}
///Resize the PHistogram
/** @param nbValue ; number of bins of the PHistogram
*/
template
<
typename
T
>
void
PHistogram
<
T
>::
resize
(
size_t
nbValue
){
allocateHist
(
nbValue
);
reset
();
}
///Set PHistogram boundaries
/** @param min : min boundaries of PHistogram
* @param max : max boundaries of PHistogram
...
...
@@ -67,7 +79,6 @@ void PHistogram<T>::setRange(T min, T max){
template
<
typename
T
>
void
PHistogram
<
T
>::
reset
(){
initialisationPHistogram
();
p_nbTirIn
=
0
;
for
(
size_t
i
(
0lu
);
i
<
p_nbValue
;
++
i
){
p_value
[
i
]
=
0
;
}
...
...
@@ -119,10 +130,11 @@ void PHistogram<T>::addValue(const T * tabValue, size_t nbValues){
* @param nbValues : number of values we want to add
*/
template
<
typename
T
>
void
PHistogram
<
T
>::
add
ValueRange
(
const
T
*
tabValue
,
size_t
nbValues
){
void
PHistogram
<
T
>::
set
ValueRange
(
const
T
*
tabValue
,
size_t
nbValues
){
if
(
p_nbValue
!=
nbValues
||
p_value
==
NULL
||
tabValue
==
NULL
||
nbValues
==
0lu
)
return
;
pminmaxTab
(
p_xMin
,
p_xMax
,
tabValue
,
nbValues
);
setRange
(
p_xMin
,
p_xMax
);
reset
();
addValue
(
tabValue
,
nbValues
);
}
...
...
src/pMinMax.h
0 → 100644
View file @
64d393de
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __PMIN_MAX_H__
#define __PMIN_MAX_H__
#include <stdio.h>
#include <math.h>
#include <iostream>
template
<
class
T
>
T
pmin
(
const
T
&
a
,
const
T
&
b
);
template
<
class
T
>
T
pmax
(
const
T
&
a
,
const
T
&
b
);
template
<
class
T
>
T
pmin4
(
const
T
&
x
,
const
T
&
y
,
const
T
&
z
,
const
T
&
t
);
template
<
class
T
>
T
pmax4
(
const
T
&
x
,
const
T
&
y
,
const
T
&
z
,
const
T
&
t
);
template
<
class
T
>
T
pminTab
(
const
T
*
tab
,
size_t
size
);
template
<
class
T
>
size_t
pminTabPos
(
const
T
*
tab
,
size_t
size
);
template
<
class
T
>
size_t
pminTabPos
(
T
&
minVal
,
const
T
*
tab
,
size_t
size
);
template
<
class
T
>
T
pmaxTab
(
const
T
*
tab
,
size_t
size
);
template
<
class
T
>
size_t
pmaxTabPos
(
const
T
*
tab
,
size_t
size
);
template
<
class
T
>
size_t
pmaxTabPos
(
T
&
maxVal
,
const
T
*
tab
,
size_t
size
);
template
<
class
T
>
void
pminmaxTab
(
T
&
xmin
,
T
&
xmax
,
const
T
*
tab
,
size_t
size
);
template
<
class
T
>
void
pminVec
(
T
*
vecMin
,
const
T
*
tab1
,
const
T
*
tab2
,
size_t
size
);
template
<
class
T
>
void
pmaxVec
(
T
*
vecMax
,
const
T
*
tab1
,
const
T
*
tab2
,
size_t
size
);
template
<
class
T
>
void
pminmaxMatrix
(
T
*
tabMin
,
T
*
tabMax
,
size_t
nbCol
,
const
T
*
matrix
,
size_t
nbRow
);
template
<
class
T
>
void
pminmaxMatrixPitch
(
T
&
xmin
,
T
&
xmax
,
const
T
*
mat
,
size_t
nbRow
,
size_t
nbCol
,
size_t
pitch
);
template
<
class
T
>
void
pminmaxTabXY
(
T
&
xmin
,
T
&
xmax
,
T
&
ymin
,
T
&
ymax
,
const
T
*
tab
,
size_t
sizeNbPair
);
template
<
class
T
>
void
tabXYtoTabXmY
(
T
*
tabX
,
const
T
*
tabXY
,
size_t
sizeTabX
);
template
<
class
T
>
void
tabXYtoTabXmYonX
(
T
*
tabX
,
const
T
*
tabXY
,
size_t
sizeTabX
);
template
<
class
T
>
size_t
getNumberOfDiffrentValues
(
const
T
*
tab
,
size_t
size
,
float
threshold
);
#include "pMinMax_impl.h"
#endif
src/pMinMax_impl.h
0 → 100644
View file @
64d393de
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __PMIN_MAX_IMPL_H__
#define __PMIN_MAX_IMPL_H__
#include "pMinMax.h"
///fonction qui renvoie la plus petite valeurs entre a et b
/** @param a : valeur
* @param b : valeur
* @return petite valeurs entre a et b
*/
template
<
class
T
>
T
pmin
(
const
T
&
a
,
const
T
&
b
){
return
(
a
<
b
)
?
a
:
b
;
}
///fonction qui renvoie la plus grande valeurs entre a et b
/** @param a : valeur
* @param b : valeur
* @return grande valeurs entre a et b
*/
template
<
class
T
>
T
pmax
(
const
T
&
a
,
const
T
&
b
){
return
(
a
>
b
)
?
a
:
b
;
}
///renvoie le minimum entre x, y, z et t
/** @param x : nombre
@param y : nombre
@param z : nombre
@param t : nombre
@return minimum entre x, y, z et t
*/
template
<
class
T
>
T
pmin4
(
const
T
&
x
,
const
T
&
y
,
const
T
&
z
,
const
T
&
t
){
if
(
x
<
y
){
if
(
x
<
z
){
if
(
x
<
t
)
return
x
;
else
return
t
;
}
else
{
if
(
z
<
t
)
return
z
;
else
return
t
;
}
}
else
{
if
(
y
<
z
){
if
(
y
<
t
)
return
y
;
else
return
t
;
}
else
{
if
(
z
<
t
)
return
z
;
else
return
t
;
}
}
}
///renvoie le maximum entre x, y, z et t
/** @param x : nombre
@param y : nombre
@param z : nombre
@param t : nombre
@return maximum entre x, y, z et t
*/
template
<
class
T
>
T
pmax4
(
const
T
&
x
,
const
T
&
y
,
const
T
&
z
,
const
T
&
t
){
if
(
x
>
y
){
if
(
x
>
z
){
if
(
x
>
t
)
return
x
;
else
return
t
;
}
else
{
if
(
z
>
t
)
return
z
;
else
return
t
;
}
}
else
{
if
(
y
>
z
){
if
(
y
>
t
)
return
y
;
else
return
t
;
}
else
{
if
(
z
>
t
)
return
z
;
else
return
t
;
}
}
}
///fonction qui renvoie le minimum d'un tableau
/** @param tab : tableau dont on veut le minimum
* @param size : taille du tableau
* @return minimum du tableau
*/
template
<
class
T
>
T
pminTab
(
const
T
*
tab
,
size_t
size
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
0.0
;
T
res
=
tab
[
0
];
if
(
size
==
1lu
)
return
res
;
size_t
i
;
for
(
i
=
1lu
;
i
<
size
;
++
i
){
if
(
tab
[
i
]
<
res
)
res
=
tab
[
i
];
}
return
res
;
}
///fonction qui renvoie la position du minimum d'un tableau
/** @param tab : tableau dont on veut le minimum
* @param size : taille du tableau
* @return position du minimum du tableau
*/
template
<
class
T
>
size_t
pminTabPos
(
const
T
*
tab
,
size_t
size
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
0lu
;
T
res
=
tab
[
0
];
if
(
size
==
1lu
)
return
0lu
;
size_t
i
,
pos
(
0lu
);
for
(
i
=
1lu
;
i
<
size
;
++
i
){
if
(
tab
[
i
]
<
res
){
res
=
tab
[
i
];
pos
=
i
;
}
}
return
pos
;
}
///fonction qui renvoie la position du minimum d'un tableau
/** @param[out] minVal : minimum value
* @param tab : tableau dont on veut le minimum
* @param size : taille du tableau
* @return position du minimum du tableau
*/
template
<
class
T
>
size_t
pminTabPos
(
T
&
minVal
,
const
T
*
tab
,
size_t
size
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
0lu
;
minVal
=
tab
[
0
];
if
(
size
==
1lu
)
return
0lu
;
size_t
i
,
pos
(
0lu
);
for
(
i
=
1lu
;
i
<
size
;
++
i
){
if
(
tab
[
i
]
<
minVal
){
minVal
=
tab
[
i
];
pos
=
i
;
}
}
return
pos
;
}
///fonction qui renvoie le maximum d'un tableau
/** @param tab : tableau dont on veut le maximum
* @param size : taille du tableau
* @return maximum du tableau
*/
template
<
class
T
>
T
pmaxTab
(
const
T
*
tab
,
size_t
size
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
0.0
;
T
res
=
tab
[
0
];
if
(
size
==
1lu
)
return
res
;
size_t
i
;
for
(
i
=
1lu
;
i
<
size
;
++
i
){
if
(
tab
[
i
]
>
res
)
res
=
tab
[
i
];
}
return
res
;
}
///fonction qui renvoie la position du maximum d'un tableau
/** @param tab : tableau dont on veut le maximum
* @param size : taille du tableau
* @return position du maximum du tableau
*/
template
<
class
T
>
size_t
pmaxTabPos
(
const
T
*
tab
,
size_t
size
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
0lu
;
T
res
=
tab
[
0
];
if
(
size
==
1lu
)
return
0lu
;
size_t
i
,
pos
(
0lu
);
for
(
i
=
1lu
;
i
<
size
;
++
i
){
if
(
tab
[
i
]
>
res
){
res
=
tab
[
i
];
pos
=
i
;
}
}
return
pos
;
}
///fonction qui renvoie la position du maximum d'un tableau
/** @param[out] maxVal : minimum value
* @param tab : tableau dont on veut le minimum
* @param size : taille du tableau
* @return position du maximum du tableau
*/
template
<
class
T
>
size_t
pmaxTabPos
(
T
&
maxVal
,
const
T
*
tab
,
size_t
size
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
0lu
;
maxVal
=
tab
[
0
];
if
(
size
==
1lu
)
return
0lu
;
size_t
i
,
pos
(
0lu
);
for
(
i
=
1lu
;
i
<
size
;
++
i
){
if
(
tab
[
i
]
>
maxVal
){
maxVal
=
tab
[
i
];
pos
=
i
;
}
}
return
pos
;
}
///Gets the minimum and maximum values in a table
/** @param[out] xmin : minimum value in the table
* @param[out] xmax : maximum value in the table
* @param tab : table we want min and max
* @param size : number of elements in the table
*/
template
<
class
T
>
void
pminmaxTab
(
T
&
xmin
,
T
&
xmax
,
const
T
*
tab
,
size_t
size
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
;
xmin
=
tab
[
0
];
xmax
=
xmin
;
if
(
size
==
1lu
)
return
;
size_t
i
;
T
tmp
;
for
(
i
=
1
;
i
<
size
;
++
i
){
tmp
=
tab
[
i
];
if
(
tmp
>
xmax
)
xmax
=
tmp
;
else
if
(
tmp
<
xmin
)
xmin
=
tmp
;
}
}
///Compute the miminum of two tables
/** @param[out] vecMin : vector of the minimum element of tab1 and tab2
* @param tab1 : table
* @param tab2 : table
* @param size : number of element in each table
*/
template
<
class
T
>
void
pminVec
(
T
*
vecMin
,
const
T
*
tab1
,
const
T
*
tab2
,
size_t
size
){
for
(
size_t
i
(
0lu
);
i
<
size
;
++
i
){
vecMin
[
i
]
=
pmin
(
tab1
[
i
],
tab2
[
i
]);
}
}
///Compute the miminum of two tables
/** @param[out] vecMax : vector of the maximum element of tab1 and tab2
* @param tab1 : table
* @param tab2 : table
* @param size : number of element in each table
*/
template
<
class
T
>
void
pmaxVec
(
T
*
vecMax
,
const
T
*
tab1
,
const
T
*
tab2
,
size_t
size
){
for
(
size_t
i
(
0lu
);
i
<
size
;
++
i
){
vecMax
[
i
]
=
pmax
(
tab1
[
i
],
tab2
[
i
]);
}
}
///Gets the minimum and maximum values in a matrix
/** @param[out] tabMin : minimum value in the matrix for each column
* @param[out] tabMax : maximum value in the matrix for each column
* @param nbCol : number of columns in the matrix (and number of elements in the tabXmin and tabXmax table)
* @param matrix : table we want min and max
* @param nbRow : number of rows in the matrix
*/
template
<
class
T
>
void
pminmaxMatrix
(
T
*
tabMin
,
T
*
tabMax
,
size_t
nbCol
,
const
T
*
matrix
,
size_t
nbRow
){
if
(
tabMax
==
NULL
||
tabMin
==
NULL
||
nbCol
==
0lu
||
matrix
==
NULL
||
nbRow
==
0lu
)
return
;
memcpy
(
tabMin
,
matrix
,
sizeof
(
T
)
*
nbCol
);
memcpy
(
tabMax
,
tabMin
,
sizeof
(
T
)
*
nbCol
);
if
(
nbRow
==
1lu
)
return
;
T
tmp
;
for
(
size_t
i
(
0lu
);
i
<
nbRow
;
++
i
){
for
(
size_t
j
(
0lu
);
j
<
nbCol
;
++
j
){
tmp
=
matrix
[
i
*
nbCol
+
j
];
if
(
tmp
>
tabMax
[
j
])
tabMax
[
j
]
=
tmp
;
else
if
(
tmp
<
tabMin
[
j
])
tabMin
[
j
]
=
tmp
;
}
}
}
///Get the minimum and maximum value in a Matrix pitch
/** @param [out] xmin : minimum value in the Matrix pitch
* @param[out] xmax : maximum value in the Matrix pitch
* @param mat : input matrix
* @param nbRow : number of rows in the matrix pitch
* @param nbCol : number of columns in the matrix pitch
* @param pitch : number of extra columns used to aligned the first element of each line of the matrix (so it is a matrix pitch)
*/
template
<
class
T
>
void
pminmaxMatrixPitch
(
T
&
xmin
,
T
&
xmax
,
const
T
*
mat
,
size_t
nbRow
,
size_t
nbCol
,
size_t
pitch
){
if
(
mat
==
NULL
||
nbRow
==
0lu
||
nbCol
==
0lu
)
return
;
xmin
=
mat
[
0
];
xmax
=
xmin
;
T
tmp
;
for
(
size_t
i
(
0lu
);
i
<
nbRow
;
++
i
){
for
(
size_t
j
(
0lu
);
j
<
nbCol
;
++
j
){
tmp
=
mat
[
i
*
(
nbCol
+
pitch
)
+
j
];
if
(
tmp
>
xmax
)
xmax
=
tmp
;
else
if
(
tmp
<
xmin
)
xmin
=
tmp
;
}
}
}
///Fonction qui calcule le minimum et le maximum des paires de valeurs dans un tableaux à une dimension
/** @param xmin : valeur minimale de x
* @param xmax : valeur maximale de x
* @param ymin : valeur minimale de y
* @param ymax : valeur maximale de y
* @param tab : tableau de valeurs de XY
* @param sizeNbPair : nombre de paires (moitié de la taille du tableau de XY totale)
*/
template
<
class
T
>
void
pminmaxTabXY
(
T
&
xmin
,
T
&
xmax
,
T
&
ymin
,
T
&
ymax
,
const
T
*
tab
,
size_t
sizeNbPair
){
if
(
tab
==
NULL
||
sizeNbPair
==
0lu
)
return
;
xmin
=
tab
[
0lu
];
xmax
=
tab
[
0lu
];
ymin
=
tab
[
1lu
];
ymax
=
tab
[
1lu
];
if
(
sizeNbPair
>
1lu
){
for
(
size_t
i
(
0lu
);
i
<
sizeNbPair
;
++
i
){
if
(
xmin
>
tab
[
2lu
*
i
])
xmin
=
tab
[
2lu
*
i
];
if
(
xmax
<
tab
[
2lu
*
i
])
xmax
=
tab
[
2lu
*
i
];
if
(
ymin
>
tab
[
2lu
*
i
+
1lu
])
ymin
=
tab
[
2lu
*
i
+
1lu
];
if
(
ymax
<
tab
[
2lu
*
i
+
1lu
])
ymax
=
tab
[
2lu
*
i
+
1lu
];
}
}
}
///Converts a table of couple (x,y) in a table of (x-y) values
/** @param tabX : table of (x-y) values
* @param tabXY : table of couple (x,y)
* @param sizeTabX : size of the tabX table and half-size of the tabXY one
*/
template
<
class
T
>
void
tabXYtoTabXmY
(
T
*
tabX
,
const
T
*
tabXY
,
size_t
sizeTabX
){
if
(
tabX
==
NULL
||
tabXY
==
NULL
||
sizeTabX
==
0lu
)
return
;
for
(
size_t
i
(
0lu
);
i
<
sizeTabX
;
++
i
){
tabX
[
i
]
=
tabXY
[
2lu
*
i
]
-
tabXY
[
2lu
*
i
+
1lu
];
}
}
///Converts a table of couple (x,y) in a table of (x-y) values
/** @param tabX : table of (x-y) values
* @param tabXY : table of couple (x,y)
* @param sizeTabX : size of the tabX table and half-size of the tabXY one
*/
template
<
class
T
>
void
tabXYtoTabXmYonX
(
T
*
tabX
,
const
T
*
tabXY
,
size_t
sizeTabX
){
if
(
tabX
==
NULL
||
tabXY
==
NULL
||
sizeTabX
==
0lu
)
return
;
for
(
size_t
i
(
0lu
);
i
<
sizeTabX
;
++
i
){
if
(
fabs
(
tabXY
[
2lu
*
i
])
>
0.00001
f
)
tabX
[
i
]
=
(
tabXY
[
2lu
*
i
]
-
tabXY
[
2lu
*
i
+
1lu
])
/
tabXY
[
2lu
*
i
];
else
tabX
[
i
]
=
0.0
f
;
}
}
///Get the number of diffrents value in a table
/** @param tab : table of value
* @param size : number of elements in the table
* @param threshold : considers the minimal distance between to values
* @return number of diffrents value in a table
*/
template
<
class
T
>
size_t
getNumberOfDiffrentValues
(
const
T
*
tab
,
size_t
size
,
float
threshold
){
if
(
tab
==
NULL
||
size
==
0lu
)
return
0lu
;
size_t
nb
(
1lu
);
float
max
(
tab
[
0
]);
for
(
size_t
i
(
1lu
);
i
<
size
;
++
i
){
if
(
max
+
threshold
<
tab
[
i
]){
++
nb
;
max
=
tab
[
i
];
}
}
return
nb
;
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment