20#include "pism/util/ColumnInterpolation.hh"
28 const std::vector<double> &new_z_fine)
29 : m_z_fine(new_z_fine), m_z_coarse(new_z_coarse) {
34 unsigned int k_max_result)
const {
35 std::vector<double> result(
Mz_fine());
41 unsigned int k_max_result,
42 double *result)
const {
51 double *result)
const {
52 const unsigned int Mzfine =
Mz_fine();
53 const unsigned int Mzcoarse =
Mz_coarse();
55 for (
unsigned int k = 0;
k < Mzfine; ++
k) {
56 if (
k > k_max_result) {
64 if (m == Mzcoarse - 1) {
65 result[
k] = input[Mzcoarse - 1];
70 result[
k] = input[m] + incr * (input[m + 1] - input[m]);
75 double *result)
const {
76 unsigned int k = 0, m = 0;
78 for (m = 0; m < Mz - 2 and
k <= k_max_result; ++m) {
91 d1 = (f1 - f0) * dz_inv,
92 d2 = (f2 - f0) * dz1_inv,
93 b = (d2 - d1) * dz2_inv,
94 a = d1 - b * (z1 -
z0),
97 for (;
m_z_fine[
k] < z1 and
k <= k_max_result; ++
k) {
100 result[
k] = s * (a + b * s) + c;
112 lambda = (f1 - f0) / (z1 -
z0);
120 const double f0 = input[Mz - 1];
121 for (;
k <= k_max_result; ++
k) {
135 for (
unsigned int k = 0;
k < N - 1; ++
k) {
139 result[
k] = input[m] + increment * (input[m + 1] - input[m]);
181 const std::vector<double>& z_output) {
182 std::vector<unsigned int> result(z_output.size());
185 for (
unsigned int k = 0;
k < z_output.size(); ++
k) {
187 if (z_output[
k] <= z_input.front()) {
192 if (z_output[
k] >= z_input.back()) {
193 result[
k] = z_input.size() - 1;
197 while (z_input[m + 1] < z_output[
k]) {
220 dz_min = std::min(dz, dz_min);
221 dz_max = std::max(dz, dz_max);
224 const double eps = 1.0e-8;
231 for (
unsigned int m = 0; m < N; ++m) {
std::vector< double > m_z_fine
std::vector< double > coarse_to_fine(const std::vector< double > &input, unsigned int k_max_result) const
void coarse_to_fine_linear(const double *input, unsigned int k_max_result, double *result) const
std::vector< double > m_z_coarse
unsigned int Mz_fine() const
const std::vector< double > & z_coarse() const
std::vector< unsigned int > m_coarse2fine
std::vector< double > m_constants
void init_interpolation()
unsigned int Mz_coarse() const
std::vector< unsigned int > m_fine2coarse
void coarse_to_fine_quadratic(const double *input, unsigned int k_max_result, double *result) const
ColumnInterpolation(const std::vector< double > &z_coarse, const std::vector< double > &z_fine)
const std::vector< double > & z_fine() const
void coarse_to_fine(const double *input, unsigned int k_max_result, double *result) const
bool m_use_linear_interpolation
void fine_to_coarse(const double *input, double *result) const
static std::vector< unsigned int > init_interpolation_indexes(const std::vector< double > &z_input, const std::vector< double > &z_output)