00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __deal2__histogram_h
00013 #define __deal2__histogram_h
00014
00015
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/base/exceptions.h>
00018 #include <deal.II/lac/vector.h>
00019 #include <vector>
00020 #include <string>
00021
00022 DEAL_II_NAMESPACE_OPEN
00023
00024
00066 class Histogram
00067 {
00068 public:
00073 enum IntervalSpacing {
00074 linear, logarithmic
00075 };
00076
00077
00114 template <typename number>
00115 void evaluate (const std::vector<Vector<number> > &values,
00116 const std::vector<double> &y_values,
00117 const unsigned int n_intervals,
00118 const IntervalSpacing interval_spacing = linear);
00119
00125 template <typename number>
00126 void evaluate (const Vector<number> &values,
00127 const unsigned int n_intervals,
00128 const IntervalSpacing interval_spacing = linear);
00129
00137 void write_gnuplot (std::ostream &out) const;
00138
00144 static std::string get_interval_spacing_names ();
00145
00153 static IntervalSpacing parse_interval_spacing (const std::string &name);
00154
00160 std::size_t memory_consumption () const;
00161
00165 DeclException0 (ExcEmptyData);
00169 DeclException0 (ExcInvalidIntervals);
00173 DeclException0 (ExcInvalidData);
00177 DeclException2 (ExcIncompatibleArraySize,
00178 int, int,
00179 << "The two array sizes " << arg1 << " and " << arg2
00180 << " must match, but don't.");
00184 DeclException1 (ExcInvalidName,
00185 std::string,
00186 << "The given name <" << arg1
00187 << "> does not match any of the known formats.");
00188
00189 private:
00194 struct Interval
00195 {
00201 Interval (const double left_point,
00202 const double right_point);
00203
00209 std::size_t memory_consumption () const;
00210
00214 double left_point;
00215
00219 double right_point;
00220
00225 unsigned int content;
00226 };
00227
00245 template <typename number>
00246 static bool logarithmic_less (const number n1,
00247 const number n2);
00248
00254 std::vector<std::vector<Interval> > intervals;
00255
00261 std::vector<double> y_values;
00262 };
00263
00264
00265 DEAL_II_NAMESPACE_CLOSE
00266
00267 #endif
00268