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
9d0ef8e6
Commit
9d0ef8e6
authored
May 08, 2021
by
Pierre Aubert
Browse files
Add save function to histogram
parent
53e86d6b
Pipeline
#118674
passed with stages
in 38 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
src/PHistogram/PHistogram.h
src/PHistogram/PHistogram.h
+1
-0
src/PHistogram/PHistogram_impl.h
src/PHistogram/PHistogram_impl.h
+19
-0
No files found.
src/PHistogram/PHistogram.h
View file @
9d0ef8e6
...
...
@@ -19,6 +19,7 @@ class PHistogram{
PHistogram
(
const
PHistogram
<
T
>
&
other
);
virtual
~
PHistogram
();
bool
save
(
const
std
::
string
&
fileName
)
const
;
void
resize
(
size_t
nbValue
);
void
setRange
(
T
min
,
T
max
);
void
reset
();
...
...
src/PHistogram/PHistogram_impl.h
View file @
9d0ef8e6
...
...
@@ -55,6 +55,25 @@ PHistogram<T>::~PHistogram(){
}
}
///Fonction qui permet de sauvegarder la PFunction dans un fichier
/** @param fileName : nom du fichier de sauvegarde
* @return true si la fonction a réussie, false sinon
*/
template
<
typename
T
>
bool
PHistogram
<
T
>::
save
(
const
std
::
string
&
fileName
)
const
{
std
::
ofstream
fs
;
fs
.
open
(
fileName
.
c_str
());
if
(
!
fs
.
is_open
()){
return
false
;}
T
dx
=
p_xRange
/
((
T
)
p_nbValue
);
for
(
long
unsigned
int
i
(
0lu
);
i
<
p_nbValue
;
++
i
){
fs
<<
(
dx
*
((
T
)
i
)
+
p_xMin
)
<<
"
\t
"
<<
p_value
[
i
]
<<
"
\n
"
;
}
fs
<<
(
dx
*
((
T
)
p_nbValue
)
+
p_xMin
)
<<
"
\t
"
<<
0
<<
"
\n
"
;
fs
.
close
();
return
true
;
}
///Resize the PHistogram
/** @param nbValue ; number of bins of the PHistogram
*/
...
...
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