28template <
typename number>
32 return (((n1 < n2) && (n1 > 0)) || ((n1 < n2) && (n2 <= 0)) ||
33 ((n2 < n1) && (n1 > 0) && (n2 <= 0)));
39 : left_point(left_point)
40 , right_point(right_point)
54template <
typename number>
57 const std::vector<double> & y_values_,
58 const unsigned int n_intervals,
63 "Your input data needs to contain at least one input vector."));
65 ExcMessage(
"The number of intervals needs to be at least one."));
66 for (
unsigned int i = 0; i < values.size(); ++i)
68 Assert(values.size() == y_values_.size(),
76 number min_value = 0, max_value = 0;
77 switch (interval_spacing)
81 min_value = *std::min_element(values[0].begin(), values[0].end());
82 max_value = *std::max_element(values[0].begin(), values[0].end());
84 for (
unsigned int i = 1; i < values.size(); ++i)
88 *std::min_element(values[i].begin(), values[i].end()));
91 *std::max_element(values[i].begin(), values[i].end()));
99 const auto logarithmic_less_function =
100 &Histogram::template logarithmic_less<number>;
102 min_value = *std::min_element(values[0].begin(),
104 logarithmic_less_function);
106 max_value = *std::max_element(values[0].begin(),
108 logarithmic_less_function);
110 for (
unsigned int i = 1; i < values.size(); ++i)
113 *std::min_element(values[i].begin(),
115 logarithmic_less_function),
116 logarithmic_less_function);
119 *std::max_element(values[i].begin(),
121 logarithmic_less_function),
122 logarithmic_less_function);
137 if (max_value <= min_value)
138 max_value = min_value + 1;
151 switch (interval_spacing)
155 const float delta = (max_value - min_value) / n_intervals;
157 for (
unsigned int n = 0; n < n_intervals; ++n)
158 intervals[0].emplace_back(min_value + n * delta,
159 min_value + (n + 1) * delta);
169 for (
unsigned int n = 0; n < n_intervals; ++n)
182 for (
unsigned int i = 1; i < values.size(); ++i)
187 for (
unsigned int i = 0; i < values.size(); ++i)
198 for (
unsigned int n = 0; n < n_intervals; ++n)
209template <
typename number>
212 const unsigned int n_intervals,
215 std::vector<Vector<number>> values_list(1, values);
217 std::vector<double>(1, 0.),
229 ExcMessage(
"There is nothing to write into the output file. "
230 "Did you forget to call the evaluate() function?"));
236 for (
const auto &interval :
intervals[0])
237 out << interval.left_point <<
' ' << interval.content << std::endl
238 << interval.right_point <<
' ' << interval.content << std::endl;
249 for (
int i =
intervals.size() - 1; i >= 0; --i)
251 for (
unsigned int n = 0; n <
intervals[i].size(); ++n)
253 << (i <
static_cast<int>(
intervals.size()) - 1 ?
256 <<
' ' <<
intervals[i][n].content << std::endl
258 << (i < static_cast<int>(
intervals.size()) - 1 ?
261 <<
' ' <<
intervals[i][n].content << std::endl;
264 for (
unsigned int n = 0; n <
intervals[i].size(); ++n)
281 return "linear|logarithmic";
289 if (name ==
"linear")
291 else if (name ==
"logarithmic")
314Histogram::evaluate<float>(
const std::vector<
Vector<float>> &values,
315 const std::vector<double> &
y_values,
316 const unsigned int n_intervals,
320 const unsigned int n_intervals,
326Histogram::evaluate<double>(
const std::vector<
Vector<double>> &values,
327 const std::vector<double> &
y_values,
328 const unsigned int n_intervals,
332 const unsigned int n_intervals,
void write_gnuplot(std::ostream &out) const
static std::string get_interval_spacing_names()
std::vector< double > y_values
static IntervalSpacing parse_interval_spacing(const std::string &name)
static bool logarithmic_less(const number n1, const number n2)
std::vector< std::vector< Interval > > intervals
std::size_t memory_consumption() const
void evaluate(const std::vector< Vector< number > > &values, const std::vector< double > &y_values, const unsigned int n_intervals, const IntervalSpacing interval_spacing=linear)
const value_type * const_iterator
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcInvalidName(std::string arg1)
static ::ExceptionBase & ExcIO()
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcIncompatibleArraySize(int arg1, int arg2)
static ::ExceptionBase & ExcEmptyData()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)
::VectorizedArray< Number, width > log(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > exp(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
Interval(const double left_point, const double right_point)
std::size_t memory_consumption() const