Added output operator for easy dumping of tables.
This commit is contained in:
parent
ebb352dc04
commit
6f9ef5a32c
@ -24,6 +24,7 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <dune/common/ErrorMacros.hpp>
|
#include <dune/common/ErrorMacros.hpp>
|
||||||
#include <dune/porsol/common/linearInterpolation.hpp>
|
#include <dune/porsol/common/linearInterpolation.hpp>
|
||||||
@ -101,6 +102,8 @@ namespace Dune {
|
|||||||
std::vector<T> y_values_;
|
std::vector<T> y_values_;
|
||||||
RangePolicy left_;
|
RangePolicy left_;
|
||||||
RangePolicy right_;
|
RangePolicy right_;
|
||||||
|
template <typename U>
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const UniformTableLinear<U>& t);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -238,6 +241,19 @@ namespace Dune {
|
|||||||
right_ = rp;
|
right_ = rp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline std::ostream& operator<<(std::ostream& os, const UniformTableLinear<T>& t)
|
||||||
|
{
|
||||||
|
int n = t.y_values_.size();
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
double f = double(i)/double(n - 1);
|
||||||
|
os << (1.0 - f)*t.xmin_ + f*t.xmax_
|
||||||
|
<< " " << t.y_values_[i] << '\n';
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
} // namespace Dune
|
} // namespace Dune
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user