
* mln/debug/histo.hh: new. Print a histogram into a plot data file. * mln/debug/all.hh: include this new header. --- milena/ChangeLog | 8 ++++ milena/mln/debug/all.hh | 1 + milena/mln/debug/{all.hh => histo.hh} | 63 ++++++++++++++++++++++---------- 3 files changed, 52 insertions(+), 20 deletions(-) copy milena/mln/debug/{all.hh => histo.hh} (54%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 1599b96..205f6d9 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,11 @@ +2009-02-05 Guillaume Lazzara <z@lrde.epita.fr> + + Add debug::histo. + + * mln/debug/histo.hh: new. Print a histogram into a plot data file. + + * mln/debug/all.hh: include this new header. + 2009-02-04 Roland Levillain <roland@lrde.epita.fr> Fix the generation of milena/headers.mk. diff --git a/milena/mln/debug/all.hh b/milena/mln/debug/all.hh index c01d416..dd1fda8 100644 --- a/milena/mln/debug/all.hh +++ b/milena/mln/debug/all.hh @@ -50,6 +50,7 @@ namespace mln # include <mln/debug/colorize.hh> # include <mln/debug/format.hh> # include <mln/debug/draw_graph.hh> +# include <mln/debug/histo.hh> # include <mln/debug/iota.hh> # include <mln/debug/println.hh> # include <mln/debug/println_with_border.hh> diff --git a/milena/mln/debug/all.hh b/milena/mln/debug/histo.hh similarity index 54% copy from milena/mln/debug/all.hh copy to milena/mln/debug/histo.hh index c01d416..1b0bbeb 100644 --- a/milena/mln/debug/all.hh +++ b/milena/mln/debug/histo.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -26,36 +26,59 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_DEBUG_ALL_HH -# define MLN_DEBUG_ALL_HH +#ifndef MLN_DEBUG_HISTO_HH +# define MLN_DEBUG_HISTO_HH -/// \file mln/debug/all.hh +/// \file mln/debug/histo.hh /// -/// File that includes all debug-related routines. +/// save a histogram to a plot data file. +# include <vector> +# include <mln/core/image/image2d.hh> +# include <mln/draw/line.hh> namespace mln { - /// Namespace of routines that help to debug. namespace debug { - /// Implementation namespace of debug namespace. - namespace impl {} - } -} + void + histo_plot(const histo::array<unsigned>& h, const std::string& filename); -# include <mln/debug/colorize.hh> -# include <mln/debug/format.hh> -# include <mln/debug/draw_graph.hh> -# include <mln/debug/iota.hh> -# include <mln/debug/println.hh> -# include <mln/debug/println_with_border.hh> -# include <mln/debug/put_word.hh> -# include <mln/debug/quiet.hh> -# include <mln/debug/slices_2d.hh> + void + histo_plot(const std::vector<unsigned>& h, const std::string& filename); +# ifndef MLN_INCLUDE_ONLY -#endif // ! MLN_DEBUG_ALL_HH + void + histo_plot(const histo::array<unsigned>& h, const std::string& filename) + { + mln_precondition(h.is_valid()); + histo_plot(h.vect(), filename); + } + + void + histo_plot(const std::vector<unsigned>& h, const std::string& filename) + { + std::ofstream file(filename.c_str()); + if (! file) + { + std::cerr << "error: cannot open file '" << filename << "'!"; + abort(); + } + + for (unsigned i = 0; i < h.size(); ++i) + file << i << ' ' << h[i] << std::endl; + } + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::debug + +} // end of namespace mln + + +#endif // ! MLN_DEBUG_HISTO_HH -- 1.5.6.5
participants (1)
-
Guillaume Lazzara