add more interpolation ops

This commit is contained in:
Magnus Ulimoen 2020-04-13 22:56:43 +02:00
parent f3ba234b28
commit 98c5998657
5 changed files with 183 additions and 5 deletions

View File

@ -6,6 +6,11 @@ mod interpolation4;
pub use interpolation4::Interpolation4;
mod interpolation9;
pub use interpolation9::Interpolation9;
mod interpolation8;
pub use interpolation8::Interpolation8;
mod interpolation9h2;
pub use interpolation9h2::Interpolation9h2;
fn interpolate(
input: ArrayView1<Float>,
@ -45,9 +50,19 @@ fn interpolate(
}
#[cfg(test)]
pub(crate) fn test_interpolation_operator<IO: InterpolationOperator>(op: IO) {
let x_c = ndarray::Array1::linspace(0.0, 1.0, 101);
let x_f = ndarray::Array1::linspace(0.0, 1.0, 2 * x_c.len() - 1);
pub(crate) fn test_interpolation_operator<IO: InterpolationOperator>(op: IO, h2: bool) {
let nc = 101;
let (x_c, x_f) = if h2 {
(
crate::utils::h2linspace(0.0, 1.0, nc),
crate::utils::h2linspace(0.0, 1.0, 2 * nc - 1),
)
} else {
(
ndarray::Array1::linspace(0.0, 1.0, 101),
ndarray::Array1::linspace(0.0, 1.0, 2 * nc - 1),
)
};
let mut ix_f = ndarray::Array1::zeros(x_f.raw_dim());
op.coarse2fine(x_c.view(), ix_f.view_mut());

View File

@ -95,5 +95,5 @@ impl InterpolationOperator for Interpolation4 {
#[test]
fn test_inter4() {
test_interpolation_operator(Interpolation4);
test_interpolation_operator(Interpolation4, false);
}

View File

@ -0,0 +1,81 @@
use super::*;
pub struct Interpolation8;
impl Interpolation8 {
#[rustfmt::skip]
const F2C_DIAG: &'static [[Float; 17]] = &[
[-2.35562114039117e-03, -1.22070312500000e-03, 1.88449691231294e-02, 1.19628906250000e-02, -6.59573919309528e-02, -5.98144531250000e-02, 1.31914783861906e-01, 2.99072265625000e-01, 3.35106520172618e-01, 2.99072265625000e-01, 1.31914783861906e-01, -5.98144531250000e-02, -6.59573919309528e-02, 1.19628906250000e-02, 1.88449691231294e-02, -1.22070312500000e-03, -2.35562114039117e-03]
];
#[rustfmt::skip]
const F2C_BLOCK: &'static [[Float; 23]] = &[
[4.96703239864108e-01, 8.06705917431925e-01, -1.44766564766981e-02, -1.94975552500834e-01, 1.60742688137659e-01, 2.21009112212771e-01, -5.30424189394722e-01, -8.62541396704564e-01, 6.42318251728667e-03, 6.97271640112489e-01, 6.18257423430940e-01, 4.33072396957210e-01, -1.58481878611992e-01, -8.38368317429209e-01, -4.17672390622387e-01, 3.92528996502338e-01, 3.30947369649078e-01, -7.35928650870138e-02, -9.96697627809582e-02, 1.07481607311012e-02, 1.80568338088148e-02, -7.72752347871259e-04, -1.49119939947106e-03],
[2.54878595843049e-03, 4.70070802794245e-01, 9.35891767592893e-02, 3.33862240417165e-01, -1.14183955014355e-01, -1.89982788188131e-01, 3.84844312844920e-01, 6.58280184360359e-01, 3.97045390505757e-02, -4.72524625455680e-01, -4.48926989185011e-01, -3.44029351949496e-01, 8.72844524728016e-02, 5.95394012908753e-01, 3.04844305262763e-01, -2.70963082168679e-01, -2.31087853447963e-01, 5.06082349187742e-02, 6.88018423193517e-02, -7.33227073163201e-03, -1.23334888572152e-02, 5.22750434020330e-04, 1.00876449671328e-03],
[-2.26569732773934e-02, -9.37711842287255e-01, -5.26996809653898e-02, 1.95814305550120e+00, 1.65861481011367e+00, 2.74358371092558e+00, -3.01647084622845e+00, -5.82350161296480e+00, -1.04727678300236e+00, 3.26152098915560e+00, 3.54785958267282e+00, 3.09216402082405e+00, -3.43647933686787e-01, -4.55665472473553e+00, -2.43290788346719e+00, 1.98824139678589e+00, 1.72596012622715e+00, -3.68954584536260e-01, -5.04483632782840e-01, 5.27977630520668e-02, 8.89723433740383e-02, -3.71751659260954e-03, -7.17378410521067e-03],
[2.16267486279437e-03, 2.76367092462810e-02, -5.52594846580351e-04, -3.35536494693914e-02, -4.92442453277949e-02, 9.34893762221034e-02, 4.57346205804429e-01, 6.65796091523885e-01, 2.47166233152219e-01, -1.58934640654239e-01, -2.58810843310230e-01, -2.68658082537024e-01, -1.80600205100413e-02, 3.08410430557262e-01, 1.77124611212295e-01, -1.25490155615361e-01, -1.12502985070320e-01, 2.29641177002937e-02, 3.17094466108080e-02, -3.21490514402454e-03, -5.43352862303885e-03, 2.21779945748522e-04, 4.27974269927444e-04],
];
#[rustfmt::skip]
const C2F_DIAG: &'static [[Float; 9]] = &[
[-2.44140625000000e-03, 2.39257812500000e-02, -1.19628906250000e-01, 5.98144531250000e-01, 5.98144531250000e-01, -1.19628906250000e-01, 2.39257812500000e-02, -2.44140625000000e-03, 0.00000000000000e+00],
[-4.71124228078234e-03, 3.76899382462588e-02, -1.31914783861906e-01, 2.63829567723811e-01, 6.70213040345236e-01, 2.63829567723811e-01, -1.31914783861906e-01, 3.76899382462588e-02, -4.71124228078234e-03],
];
#[rustfmt::skip]
const C2F_BLOCK: &'static [[Float; 16]] = &[
[9.93406479728215e-01, 2.63740810871388e-02, -3.95611216307082e-02, 2.63740810871388e-02, -6.59352027178470e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.11839598602877e-01, 9.40141605588491e-01, -3.16462408382736e-01, 6.51416055884908e-02, -6.60401397122704e-04, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-3.31635914674324e-02, 1.10925881915128e+00, -1.05399361930780e-01, -7.71891444099258e-03, 6.04185954063824e-02, -2.33955467184537e-02, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-6.39519875380412e-02, 5.66572075303674e-01, 5.60731574165718e-01, -6.71072989387827e-02, 5.49151185592384e-03, -1.73587484849126e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[2.29709689957704e-01, -8.44242373309120e-01, 2.06933277237064e+00, -4.29101155545423e-01, -1.31914783861906e-01, 1.16755671676913e-01, -1.05398212888044e-02, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[1.01954337766153e-01, -4.53444105476147e-01, 1.10496991032767e+00, 2.62974658127715e-01, -3.86174480800107e-02, 2.39257812500000e-02, -1.76313391538362e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-3.38823560499617e-01, 1.27188934494977e+00, -1.68223289417986e+00, 1.78135907280824e+00, 1.17930369056755e-01, -1.82662005975752e-01, 3.76899382462588e-02, -5.15026440579746e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-5.04006504823111e-01, 1.99012773182278e+00, -2.97082521952307e+00, 2.37221225007671e+00, 2.44576227277174e-01, -1.51529363117418e-01, 2.18862845369385e-02, -2.44140625000000e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.78827327147319e-03, 1.21156068183631e-01, -5.39248841565280e-01, 8.88865980757861e-01, 2.76602322166401e-01, 3.37302045431818e-01, -1.21796336850761e-01, 3.80417308856396e-02, -4.71124228078234e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[4.11237810864861e-01, -1.44188113271454e+00, 1.67937592400445e+00, -5.71565110006450e-01, 2.46859067752038e-01, 7.64718585544162e-01, -1.10452840357651e-01, 2.41491011631342e-02, -2.44140625000000e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.64636699295086e-01, -1.36987433204775e+00, 1.82681331338964e+00, -9.30742646905333e-01, 1.08884588474992e-01, 8.56857066226101e-01, 2.43592673701522e-01, -1.33146058099739e-01, 3.76899382462588e-02, -4.71124228078234e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[2.55418023945373e-01, -1.04978535499102e+00, 1.59217304653592e+00, -9.66155558456609e-01, -4.93718135504075e-02, 7.64718585544162e-01, 5.52264201788255e-01, -1.20745505815671e-01, 2.39257812500000e-02, -2.44140625000000e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-9.34696566916614e-02, 2.66343378566745e-01, -1.76946298394627e-01, -6.49479406569206e-02, -5.44422942374959e-02, 3.37302045431818e-01, 6.18804737679094e-01, 2.66292116199477e-01, -1.31914783861906e-01, 3.76899382462588e-02, -4.71124228078234e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-4.94454000025620e-01, 1.81680984968021e+00, -2.34624773661296e+00, 1.10911404174051e+00, 9.87436271008150e-03, -1.52943717108832e-01, 5.52264201788255e-01, 6.03727529078354e-01, -1.19628906250000e-01, 2.39257812500000e-02, -2.44140625000000e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-2.46335387382934e-01, 9.30214487234333e-01, -1.25271826807198e+00, 6.36980380587063e-01, 1.55549412107131e-02, -1.68651022715909e-01, 2.43592673701522e-01, 6.76468715609812e-01, 2.63829567723811e-01, -1.31914783861906e-01, 3.76899382462588e-02, -4.71124228078234e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[2.31506282395997e-01, -8.26827925559284e-01, 1.02375693548293e+00, -4.51291136430475e-01, -1.00758803164097e-03, 3.05887434217665e-02, -1.10452840357651e-01, 6.03727529078354e-01, 5.98144531250000e-01, -1.19628906250000e-01, 2.39257812500000e-02, -2.44140625000000e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[1.95186587230214e-01, -7.05151007875617e-01, 8.88706800114134e-01, -4.04586317828987e-01, -1.94436765133914e-03, 4.81860064902597e-02, -1.21796336850761e-01, 2.66292116199477e-01, 6.70213040345236e-01, 2.63829567723811e-01, -1.31914783861906e-01, 3.76899382462588e-02, -4.71124228078234e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-4.34036994947538e-02, 1.54428055509268e-01, -1.89976838530687e-01, 8.25841893594732e-02, 0.00000000000000e+00, -3.12130034915985e-03, 2.20905680715302e-02, -1.20745505815671e-01, 5.98144531250000e-01, 5.98144531250000e-01, -1.19628906250000e-01, 2.39257812500000e-02, -2.44140625000000e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-5.87833674819310e-02, 2.09944779577586e-01, -2.59761525302692e-01, 1.14034380835697e-01, 0.00000000000000e+00, -6.02325081128246e-03, 3.47989533859317e-02, -1.33146058099739e-01, 2.63829567723811e-01, 6.70213040345236e-01, 2.63829567723811e-01, -1.31914783861906e-01, 3.76899382462588e-02, -4.71124228078234e-03, 0.00000000000000e+00, 0.00000000000000e+00],
[6.33906477132592e-03, -2.23739933505050e-02, 2.71858719921617e-02, -1.15615299769810e-02, 0.00000000000000e+00, 0.00000000000000e+00, -2.25413959913573e-03, 2.41491011631342e-02, -1.19628906250000e-01, 5.98144531250000e-01, 5.98144531250000e-01, -1.19628906250000e-01, 2.39257812500000e-02, -2.44140625000000e-03, 0.00000000000000e+00, 0.00000000000000e+00],
[1.06495838630259e-02, -3.76349166281317e-02, 4.58123715473316e-02, -1.95402045291476e-02, 0.00000000000000e+00, 0.00000000000000e+00, -4.34986917324146e-03, 3.80417308856396e-02, -1.31914783861906e-01, 2.63829567723811e-01, 6.70213040345236e-01, 2.63829567723811e-01, -1.31914783861906e-01, 3.76899382462588e-02, -4.71124228078234e-03, 0.00000000000000e+00],
[-4.55754924763598e-04, 1.59514223667259e-03, -1.91417068400711e-03, 7.97571118336296e-04, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, -2.46419399623818e-03, 2.39257812500000e-02, -1.19628906250000e-01, 5.98144531250000e-01, 5.98144531250000e-01, -1.19628906250000e-01, 2.39257812500000e-02, -2.44140625000000e-03, 0.00000000000000e+00],
[-8.79481598452137e-04, 3.07818559458248e-03, -3.69382271349897e-03, 1.53909279729124e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, -4.75521636070495e-03, 3.76899382462588e-02, -1.31914783861906e-01, 2.63829567723811e-01, 6.70213040345236e-01, 2.63829567723811e-01, -1.31914783861906e-01, 3.76899382462588e-02, -4.71124228078234e-03],
];
}
impl InterpolationOperator for Interpolation8 {
fn fine2coarse(&self, fine: ArrayView1<Float>, coarse: ArrayViewMut1<Float>) {
assert_eq!(fine.len(), 2 * coarse.len() - 1);
use ndarray::prelude::*;
use std::iter::FromIterator;
let block = Array::from_iter(Self::F2C_BLOCK.iter().flatten().copied())
.into_shape((Self::F2C_BLOCK.len(), Self::F2C_BLOCK[0].len()))
.unwrap();
let diag = Array::from_iter(Self::F2C_DIAG.iter().flatten().copied())
.into_shape((Self::F2C_DIAG.len(), Self::F2C_DIAG[0].len()))
.unwrap();
super::interpolate(fine, coarse, block.view(), diag.view(), (0, 2))
}
fn coarse2fine(&self, coarse: ArrayView1<Float>, fine: ArrayViewMut1<Float>) {
assert_eq!(fine.len(), 2 * coarse.len() - 1);
use ndarray::prelude::*;
use std::iter::FromIterator;
let block = Array::from_iter(Self::C2F_BLOCK.iter().flatten().copied())
.into_shape((Self::C2F_BLOCK.len(), Self::C2F_BLOCK[0].len()))
.unwrap();
let diag = Array::from_iter(Self::C2F_DIAG.iter().flatten().copied())
.into_shape((Self::C2F_DIAG.len(), Self::C2F_DIAG[0].len()))
.unwrap();
super::interpolate(coarse, fine, block.view(), diag.view(), (8, 1))
}
}
#[test]
fn test_inter8() {
test_interpolation_operator(Interpolation8, false);
}

View File

@ -78,5 +78,5 @@ impl InterpolationOperator for Interpolation9 {
#[test]
fn test_inter9() {
test_interpolation_operator(Interpolation9);
test_interpolation_operator(Interpolation9, false);
}

View File

@ -0,0 +1,82 @@
use super::*;
pub struct Interpolation9h2;
impl Interpolation9h2 {
#[rustfmt::skip]
const F2C_DIAG: &'static [[Float; 16]] = &[
[-8.18252563476562e-04, -9.44137573242188e-04, 7.81059265136719e-03, 9.54627990722656e-03, -3.68213653564453e-02, -5.15499114990234e-02, 1.43194198608398e-01, 4.29582595825195e-01, 4.29582595825195e-01, 1.43194198608398e-01, -5.15499114990234e-02, -3.68213653564453e-02, 9.54627990722656e-03, 7.81059265136719e-03, -9.44137573242188e-04, -8.18252563476562e-04],
];
#[rustfmt::skip]
const F2C_BLOCK: &'static [[Float; 22]] = &[
[4.98468763769042e-01, 9.32469094155742e-01, -4.47597069467149e-01, -1.81157757160677e-01, 1.42745806009997e-01, 1.02548554399152e-01, -1.55504275103978e-02, -2.07196134317984e-02, -9.93591017092950e-03, -1.70215650692527e-02, 1.85405567588951e-03, 3.03693211456999e-02, 2.08763438591272e-02, -1.99391086696204e-02, -3.31826116004537e-02, -8.82508819207992e-03, 1.11096534576639e-02, 1.08785136199434e-02, 5.59911448552478e-03, 2.31188689682223e-03, -1.22322834392462e-03, -4.07872785832080e-03],
[5.43331120953906e-04, 4.15709886965222e-01, 5.62303547813314e-01, 1.32762946448570e-01, -8.12503360860233e-02, -5.44323565821045e-02, 1.25280770717829e-02, 1.26295521995461e-02, 2.16783282116490e-03, 5.26429940969954e-03, -2.34814210636475e-03, -1.50978170649302e-02, -1.01711580955386e-02, 9.23086048098951e-03, 1.58916733647247e-02, 5.04099884067871e-03, -4.14399297918794e-03, -4.43330581714441e-03, -2.61754215359290e-03, -1.65843050621059e-03, -1.15117625259092e-04, 2.19519247971019e-03],
[-3.45058804056092e-04, -8.89654633869497e-02, 1.85518726412554e-01, 4.20160684116314e-01, 4.11144931773164e-01, 1.30269059379738e-01, -4.58447989625376e-02, -3.33077078293749e-02, 7.08287913776931e-03, 2.54123993855832e-03, 5.12159073099977e-03, 2.04809128820745e-02, 1.41329843389036e-02, -1.11544739583814e-02, -2.06401541385524e-02, -8.05564802507851e-03, 3.21148227220337e-03, 4.25468500997349e-03, 3.14940350340504e-03, 3.03691249762324e-03, 1.38273903511233e-03, -3.17492592346295e-03],
[1.47463156015778e-04, 5.05544210813350e-02, -7.93266252800965e-02, -8.59293795803661e-02, 1.59607003973703e-01, 4.51185576057626e-01, 4.52489970916581e-01, 1.48185309501568e-01, -5.40096092306891e-02, -3.53390500228114e-02, -9.84032664896995e-04, -2.31469980446910e-02, -2.23071974342937e-02, 1.27335366234615e-02, 2.76604390038872e-02, 1.20464045113581e-02, -2.54277021453307e-03, -4.32878029373363e-03, -3.72837337928576e-03, -4.49415374116773e-03, -2.72364107536888e-03, 4.25048613639873e-03],
[2.59421962643151e-05, -1.42477713795767e-02, 2.11314911455577e-02, 1.97047530440994e-02, -3.94665492863321e-02, -5.12075730339598e-02, 1.40840051755253e-01, 4.18642860258771e-01, 4.16574028643841e-01, 1.37370521420820e-01, -4.17271574384278e-02, -1.41388594368134e-02, 2.46741374257187e-02, 7.34765401743540e-04, -1.73794314889100e-02, -8.38401581575818e-03, 9.95360219786184e-04, 2.03458874131448e-03, 1.81158133987371e-03, 2.53664021018666e-03, 1.76168400654014e-03, -2.28704792999105e-03],
[-2.36264228912252e-05, 1.89961094513449e-03, -2.97039583128230e-03, -2.46083932501624e-03, 8.85697874020858e-03, 1.00669173597962e-02, -3.77733033040942e-02, -5.29040607772972e-02, 1.45256803680282e-01, 4.35825667006775e-01, 4.31815130864164e-01, 1.36159165014146e-01, -5.92642476521202e-02, -3.61070314975954e-02, 1.48255240066877e-02, 1.03650291723254e-02, -1.26797734335656e-03, -1.37289331423299e-03, -3.86122073732290e-04, -6.15936054302941e-04, -4.75369985112521e-04, 5.50976791514329e-04],
];
#[rustfmt::skip]
const C2F_DIAG: &'static [[Float; 8]] = &[
[-1.88827514648438e-03, 1.90925598144531e-02, -1.03099822998047e-01, 8.59165191650391e-01, 2.86388397216797e-01, -7.36427307128906e-02, 1.56211853027344e-02, -1.63650512695312e-03],
[-1.63650512695312e-03, 1.56211853027344e-02, -7.36427307128906e-02, 2.86388397216797e-01, 8.59165191650391e-01, -1.03099822998047e-01, 1.90925598144531e-02, -1.88827514648438e-03],
];
#[rustfmt::skip]
const C2F_BLOCK: &'static [[Float; 15]] = &[
[9.96937527538084e-01, 6.36368890722002e-03, -5.35728009755299e-03, 2.00667748693136e-03, 3.84855768540464e-04, -3.35469603222343e-04, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.18456471124914e-01, 8.31419773930444e-01, -2.35862187479024e-01, 1.17473208745710e-01, -3.60930708382377e-02, 4.60580451619333e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-1.15317703518912e-01, 8.48386869129437e-01, 3.71037452825109e-01, -1.39056658040521e-01, 4.03831469230686e-02, -5.43310731818213e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-5.32503997909601e-02, 2.28537348061664e-01, 9.58743856381520e-01, -1.71858759160732e-01, 4.29633559895698e-02, -5.13540148106121e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.84885977358537e-02, -1.28294565819100e-01, 8.60567454226060e-01, 2.92809211475371e-01, -7.89330985726642e-02, 1.69542873632790e-02, -1.59188640879975e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[2.88891212777016e-02, -8.97999903984540e-02, 2.84883510128131e-01, 8.64816675025200e-01, -1.07004057671403e-01, 2.01338347195924e-02, -1.91909308076853e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-4.31038795002981e-03, 2.03363406057877e-02, -9.86473321298717e-02, 8.53389004507284e-01, 2.89575268064002e-01, -7.43334344170250e-02, 1.56211853027344e-02, -1.63064398288150e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-5.76386623423116e-03, 2.05747497150126e-02, -7.19280416718900e-02, 2.80479713147662e-01, 8.63847733233324e-01, -1.04483198655349e-01, 1.91611856119561e-02, -1.88827514648438e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-2.76299797941350e-03, 3.53031178031330e-03, 1.52898768305928e-02, -1.02189907052898e-01, 8.59263502495471e-01, 2.86770583829319e-01, -7.38803200290672e-02, 1.56154552526358e-02, -1.63650512695312e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-4.73339121265435e-03, 8.57290195060895e-03, 5.48579820462345e-03, -6.68639208579355e-02, 2.83352939116139e-01, 8.60420839566509e-01, -1.03432448040694e-01, 1.90855564198882e-02, -1.88827514648438e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[5.15579549137936e-04, -3.82394512114392e-03, 1.10560253719584e-02, -1.86185769523585e-03, -8.60702323821010e-02, 8.52503112052578e-01, 2.87312355668594e-01, -7.36157176195688e-02, 1.56211853027344e-02, -1.63650512695312e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[8.44516219633645e-03, -2.45867674485606e-02, 4.42123364318261e-02, -4.37957173257336e-02, -2.91640982048703e-02, 2.68809737344646e-01, 8.61937067005783e-01, -1.03062004667396e-01, 1.90925598144531e-02, -1.88827514648438e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[5.80533588851015e-03, -1.65637123368276e-02, 3.05090042604607e-02, -4.22067566288896e-02, 5.08951213653417e-02, -1.17001355315592e-01, 8.61937067005783e-01, 2.86283346298323e-01, -7.36427307128906e-02, 1.56211853027344e-02, -1.63650512695312e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-5.54470763299118e-03, 1.50324393930684e-02, -2.40792663006557e-02, 2.40927298408748e-02, 1.51559398618784e-03, -7.12836455199700e-02, 2.87312355668594e-01, 8.58850038894970e-01, -1.03099822998047e-01, 1.90925598144531e-02, -1.88827514648438e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-9.22748769125997e-03, 2.58795609793525e-02, -4.45560920078479e-02, 5.23354590250112e-02, -3.58483970331925e-02, 2.92690191939736e-02, -1.03432448040694e-01, 8.58850038894970e-01, 2.86388397216797e-01, -7.36427307128906e-02, 1.56211853027344e-02, -1.63650512695312e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-2.45409835871953e-03, 8.20925738278600e-03, -1.73898020421184e-02, 2.27926284761530e-02, -1.72936340229340e-02, 2.04629689752644e-02, -7.38803200290672e-02, 2.86283346298323e-01, 8.59165191650391e-01, -1.03099822998047e-01, 1.90925598144531e-02, -1.88827514648438e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.08939488455923e-03, -6.74848497962195e-03, 6.93265654128983e-03, -4.81109668411311e-03, 2.05312057374891e-03, -2.50328104311765e-03, 1.91541570445730e-02, -1.03062004667396e-01, 8.59165191650391e-01, 2.86388397216797e-01, -7.36427307128906e-02, 1.56211853027344e-02, -1.63650512695312e-03, 0.00000000000000e+00, 0.00000000000000e+00],
[3.02511905138470e-03, -7.21963040654873e-03, 9.18462795850447e-03, -8.19035097957536e-03, 4.19672789897912e-03, -2.71040947675354e-03, 1.56715830364688e-02, -7.36157176195688e-02, 2.86388397216797e-01, 8.59165191650391e-01, -1.03099822998047e-01, 1.90925598144531e-02, -1.88827514648438e-03, 0.00000000000000e+00, 0.00000000000000e+00],
[1.55701307116010e-03, -4.26266260482674e-03, 6.79864652781102e-03, -7.05433967241557e-03, 3.73673253760664e-03, -7.62294431022425e-04, -1.89436718023249e-03, 1.90855564198882e-02, -1.03099822998047e-01, 8.59165191650391e-01, 2.86388397216797e-01, -7.36427307128906e-02, 1.56211853027344e-02, -1.63650512695312e-03, 0.00000000000000e+00],
[6.42894180267613e-04, -2.70075104304404e-03, 6.55581115119397e-03, -8.50324895204775e-03, 5.23230494870665e-03, -1.21600047239618e-03, -1.64178488953483e-03, 1.56154552526358e-02, -7.36427307128906e-02, 2.86388397216797e-01, 8.59165191650391e-01, -1.03099822998047e-01, 1.90925598144531e-02, -1.88827514648438e-03, 0.00000000000000e+00],
[-3.40157809851543e-04, -1.87468841972547e-04, 2.98493156871497e-03, -5.15331683198425e-03, 3.63380975688274e-03, -9.38490485207875e-04, 0.00000000000000e+00, -1.88758250306587e-03, 1.90925598144531e-02, -1.03099822998047e-01, 8.59165191650391e-01, 2.86388397216797e-01, -7.36427307128906e-02, 1.56211853027344e-02, -1.63650512695312e-03],
[-1.13422088537901e-03, 3.57486693416318e-03, -6.85374201250215e-03, 8.04221303199895e-03, -4.71747319701321e-03, 1.08775583776953e-03, 0.00000000000000e+00, -1.63590483599042e-03, 1.56211853027344e-02, -7.36427307128906e-02, 2.86388397216797e-01, 8.59165191650391e-01, -1.03099822998047e-01, 1.90925598144531e-02, -1.88827514648438e-03],
];
}
impl InterpolationOperator for Interpolation9h2 {
fn fine2coarse(&self, fine: ArrayView1<Float>, coarse: ArrayViewMut1<Float>) {
assert_eq!(fine.len(), 2 * coarse.len() - 1);
use ndarray::prelude::*;
use std::iter::FromIterator;
let block = Array::from_iter(Self::F2C_BLOCK.iter().flatten().copied())
.into_shape((Self::F2C_BLOCK.len(), Self::F2C_BLOCK[0].len()))
.unwrap();
let diag = Array::from_iter(Self::F2C_DIAG.iter().flatten().copied())
.into_shape((Self::F2C_DIAG.len(), Self::F2C_DIAG[0].len()))
.unwrap();
super::interpolate(fine, coarse, block.view(), diag.view(), (4, 2))
}
fn coarse2fine(&self, coarse: ArrayView1<Float>, fine: ArrayViewMut1<Float>) {
assert_eq!(fine.len(), 2 * coarse.len() - 1);
use ndarray::prelude::*;
use std::iter::FromIterator;
let block = Array::from_iter(Self::C2F_BLOCK.iter().flatten().copied())
.into_shape((Self::C2F_BLOCK.len(), Self::C2F_BLOCK[0].len()))
.unwrap();
let diag = Array::from_iter(Self::C2F_DIAG.iter().flatten().copied())
.into_shape((Self::C2F_DIAG.len(), Self::C2F_DIAG[0].len()))
.unwrap();
super::interpolate(coarse, fine, block.view(), diag.view(), (8, 1))
}
}
#[test]
fn test_inter9h2() {
test_interpolation_operator(Interpolation9h2, true);
}