28 template <
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)
54 template <
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);
167 (std::log(max_value) - std::log(min_value)) / n_intervals;
169 for (
unsigned int n = 0; n < n_intervals; ++n)
170 intervals[0].emplace_back(std::exp(std::log(min_value) + n * delta),
171 std::exp(std::log(min_value) +
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)
209 template <
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")
314 Histogram::evaluate<float>(
const std::vector<Vector<float>> &values,
315 const std::vector<double> &
y_values,
316 const unsigned int n_intervals,
319 Histogram::evaluate<float>(
const Vector<float> & values,
320 const unsigned int n_intervals,
326 Histogram::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,