make precision selectable using feature

This commit is contained in:
Magnus Ulimoen
2020-02-27 20:26:43 +01:00
parent afa2ce655f
commit ba420b1554
15 changed files with 252 additions and 211 deletions

View File

@@ -1,5 +1,6 @@
use super::SbpOperator;
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayView2, ArrayViewMut1, ArrayViewMut2};
#[derive(Debug)]
@@ -9,15 +10,15 @@ diff_op_1d!(SBP4, diff_1d, SBP4::BLOCK, SBP4::DIAG, false);
impl SBP4 {
#[rustfmt::skip]
const HBLOCK: &'static [f32] = &[
const HBLOCK: &'static [Float] = &[
17.0 / 48.0, 59.0 / 48.0, 43.0 / 48.0, 49.0 / 48.0,
];
#[rustfmt::skip]
const DIAG: &'static [f32] = &[
const DIAG: &'static [Float] = &[
1.0 / 12.0, -2.0 / 3.0, 0.0, 2.0 / 3.0, -1.0 / 12.0,
];
#[rustfmt::skip]
const BLOCK: &'static [[f32; 6]] = &[
const BLOCK: &'static [[Float; 6]] = &[
[-1.41176470588235e+00, 1.73529411764706e+00, -2.35294117647059e-01, -8.82352941176471e-02, 0.00000000000000e+00, 0.00000000000000e+00],
[-5.00000000000000e-01, 0.00000000000000e+00, 5.00000000000000e-01, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[9.30232558139535e-02, -6.86046511627907e-01, 0.00000000000000e+00, 6.86046511627907e-01, -9.30232558139535e-02, 0.00000000000000e+00],
@@ -26,7 +27,7 @@ impl SBP4 {
}
impl SbpOperator for SBP4 {
fn diffxi(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
fn diffxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Self::BLOCK.len());
@@ -35,12 +36,12 @@ impl SbpOperator for SBP4 {
}
}
fn diffeta(prev: ArrayView2<f32>, fut: ArrayViewMut2<f32>) {
fn diffeta(prev: ArrayView2<Float>, fut: ArrayViewMut2<Float>) {
// transpose then use diffxi
Self::diffxi(prev.reversed_axes(), fut.reversed_axes());
}
fn h() -> &'static [f32] {
fn h() -> &'static [Float] {
Self::HBLOCK
}
}

View File

@@ -1,5 +1,6 @@
use super::SbpOperator;
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayView2, ArrayViewMut1, ArrayViewMut2};
#[derive(Debug)]
@@ -9,15 +10,15 @@ diff_op_1d!(SBP8, diff_1d, SBP8::BLOCK, SBP8::DIAG, false);
impl SBP8 {
#[rustfmt::skip]
const HBLOCK: &'static [f32] = &[
const HBLOCK: &'static [Float] = &[
2.94890676177879e-01, 1.52572062389771e+00, 2.57452876984127e-01, 1.79811370149912e+00, 4.12708057760141e-01, 1.27848462301587e+00, 9.23295579805997e-01, 1.00933386085916e+00
];
#[rustfmt::skip]
const DIAG: &'static [f32] = &[
const DIAG: &'static [Float] = &[
3.57142857142857e-03, -3.80952380952381e-02, 2.00000000000000e-01, -8.00000000000000e-01, -0.00000000000000e+00, 8.00000000000000e-01, -2.00000000000000e-01, 3.80952380952381e-02, -3.57142857142857e-03
];
#[rustfmt::skip]
const BLOCK: &'static [[f32; 12]] = &[
const BLOCK: &'static [[Float; 12]] = &[
[-1.69554360443190e+00, 2.24741246341404e+00, -3.38931922601500e-02, -7.81028168126749e-01, 2.54881486107905e-02, 3.43865227388873e-01, -8.62858162633335e-02, -2.00150583315761e-02, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-4.34378988266985e-01, 0.00000000000000e+00, 9.18511925072956e-02, 4.94008626807984e-01, -2.46151762937235e-02, -1.86759403432935e-01, 5.27267838475813e-02, 7.16696483080115e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.88218088704253e-02, -5.44329744454984e-01, 0.00000000000000e+00, 3.89516189693211e-01, 1.36433486528546e-01, 1.03290582800845e-01, -1.79720579323281e-01, 5.59882558852296e-02, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
@@ -30,7 +31,7 @@ impl SBP8 {
}
impl SbpOperator for SBP8 {
fn diffxi(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
fn diffxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Self::BLOCK.len());
@@ -39,12 +40,12 @@ impl SbpOperator for SBP8 {
}
}
fn diffeta(prev: ArrayView2<f32>, fut: ArrayViewMut2<f32>) {
fn diffeta(prev: ArrayView2<Float>, fut: ArrayViewMut2<Float>) {
// transpose then use diffxi
Self::diffxi(prev.reversed_axes(), fut.reversed_axes());
}
fn h() -> &'static [f32] {
fn h() -> &'static [Float] {
Self::HBLOCK
}
}

View File

@@ -1,12 +1,16 @@
use super::{SbpOperator, UpwindOperator};
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayView2, ArrayViewMut1, ArrayViewMut2, Axis};
#[derive(Debug)]
pub struct Upwind4 {}
/// Simdtype used in diff_simd_col
#[cfg(feature = "f32")]
type SimdT = packed_simd::f32x8;
#[cfg(not(feature = "f32"))]
type SimdT = packed_simd::f64x8;
diff_op_1d!(Upwind4, diff_1d, Upwind4::BLOCK, Upwind4::DIAG, false);
diff_op_1d!(
@@ -21,44 +25,48 @@ macro_rules! diff_simd_row_7_47 {
($self: ident, $name: ident, $BLOCK: expr, $DIAG: expr, $symmetric: expr) => {
impl $self {
#[inline(never)]
fn $name(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
use packed_simd::{f32x8, u32x8};
fn $name(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
#[cfg(feature = "f32")]
type SimdIndex = packed_simd::u32x8;
#[cfg(not(feature = "f32"))]
type SimdIndex = packed_simd::u64x8;
assert_eq!(prev.shape(), fut.shape());
assert!(prev.len_of(Axis(1)) >= 2 * $BLOCK.len());
assert!(prev.len() >= f32x8::lanes());
assert!(prev.len() >= SimdT::lanes());
// The prev and fut array must have contigous last dimension
assert_eq!(prev.strides()[1], 1);
assert_eq!(fut.strides()[1], 1);
let nx = prev.len_of(Axis(1));
let dx = 1.0 / (nx - 1) as f32;
let dx = 1.0 / (nx - 1) as Float;
let idx = 1.0 / dx;
for j in 0..prev.len_of(Axis(0)) {
use std::slice;
let prev =
unsafe { slice::from_raw_parts(prev.uget((j, 0)) as *const f32, nx) };
let fut =
unsafe { slice::from_raw_parts_mut(fut.uget_mut((j, 0)) as *mut f32, nx) };
unsafe { slice::from_raw_parts(prev.uget((j, 0)) as *const Float, nx) };
let fut = unsafe {
slice::from_raw_parts_mut(fut.uget_mut((j, 0)) as *mut Float, nx)
};
//let mut fut = fut.slice_mut(s![j, ..]);
let first_elems = unsafe { f32x8::from_slice_unaligned_unchecked(prev) };
let first_elems = unsafe { SimdT::from_slice_unaligned_unchecked(prev) };
let block = {
let bl = $BLOCK;
[
f32x8::new(
SimdT::new(
bl[0][0], bl[0][1], bl[0][2], bl[0][3], bl[0][4], bl[0][5],
bl[0][6], 0.0,
),
f32x8::new(
SimdT::new(
bl[1][0], bl[1][1], bl[1][2], bl[1][3], bl[1][4], bl[1][5],
bl[1][6], 0.0,
),
f32x8::new(
SimdT::new(
bl[2][0], bl[2][1], bl[2][2], bl[2][3], bl[2][4], bl[2][5],
bl[2][6], 0.0,
),
f32x8::new(
SimdT::new(
bl[3][0], bl[3][1], bl[3][2], bl[3][3], bl[3][4], bl[3][5],
bl[3][6], 0.0,
),
@@ -71,7 +79,7 @@ macro_rules! diff_simd_row_7_47 {
let diag = {
let diag = $DIAG;
f32x8::new(
SimdT::new(
diag[0], diag[1], diag[2], diag[3], diag[4], diag[5], diag[6], 0.0,
)
};
@@ -79,8 +87,8 @@ macro_rules! diff_simd_row_7_47 {
.iter_mut()
.skip(block.len())
.zip(
prev.windows(f32x8::lanes())
.map(f32x8::from_slice_unaligned)
prev.windows(SimdT::lanes())
.map(SimdT::from_slice_unaligned)
.skip(1),
)
.take(nx - 2 * block.len())
@@ -89,8 +97,8 @@ macro_rules! diff_simd_row_7_47 {
}
let last_elems =
unsafe { f32x8::from_slice_unaligned_unchecked(&prev[nx - 8..]) }
.shuffle1_dyn(u32x8::new(7, 6, 5, 4, 3, 2, 1, 0));
unsafe { SimdT::from_slice_unaligned_unchecked(&prev[nx - 8..]) }
.shuffle1_dyn(SimdIndex::new(7, 6, 5, 4, 3, 2, 1, 0));
if $symmetric {
fut[nx - 4] = idx * (block[3] * last_elems).sum();
fut[nx - 3] = idx * (block[2] * last_elems).sum();
@@ -121,7 +129,7 @@ macro_rules! diff_simd_col_7_47 {
($self: ident, $name: ident, $BLOCK: expr, $DIAG: expr, $symmetric: expr) => {
impl $self {
#[inline(never)]
fn $name(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
fn $name(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
use std::slice;
assert_eq!(prev.shape(), fut.shape());
assert_eq!(prev.stride_of(Axis(0)), 1);
@@ -132,38 +140,38 @@ macro_rules! diff_simd_col_7_47 {
assert!(ny >= SimdT::lanes());
assert!(ny % SimdT::lanes() == 0);
let dx = 1.0 / (nx - 1) as f32;
let dx = 1.0 / (nx - 1) as Float;
let idx = 1.0 / dx;
for j in (0..ny).step_by(SimdT::lanes()) {
let a = unsafe {
[
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, 0)) as *const f32,
prev.uget((j, 0)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, 1)) as *const f32,
prev.uget((j, 1)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, 2)) as *const f32,
prev.uget((j, 2)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, 3)) as *const f32,
prev.uget((j, 3)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, 4)) as *const f32,
prev.uget((j, 4)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, 5)) as *const f32,
prev.uget((j, 5)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, 6)) as *const f32,
prev.uget((j, 6)) as *const Float,
SimdT::lanes(),
)),
]
@@ -180,7 +188,7 @@ macro_rules! diff_simd_col_7_47 {
+ a[6] * bl[6]);
unsafe {
b.write_to_slice_unaligned(slice::from_raw_parts_mut(
fut.uget_mut((j, i)) as *mut f32,
fut.uget_mut((j, i)) as *mut Float,
SimdT::lanes(),
));
}
@@ -191,7 +199,7 @@ macro_rules! diff_simd_col_7_47 {
// Push a onto circular buffer
a = [a[1], a[2], a[3], a[4], a[5], a[6], unsafe {
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, i + 3)) as *const f32,
prev.uget((j, i + 3)) as *const Float,
SimdT::lanes(),
))
}];
@@ -205,7 +213,7 @@ macro_rules! diff_simd_col_7_47 {
+ a[6] * $DIAG[6]);
unsafe {
b.write_to_slice_unaligned(slice::from_raw_parts_mut(
fut.uget_mut((j, i)) as *mut f32,
fut.uget_mut((j, i)) as *mut Float,
SimdT::lanes(),
));
}
@@ -214,31 +222,31 @@ macro_rules! diff_simd_col_7_47 {
let a = unsafe {
[
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, nx - 1)) as *const f32,
prev.uget((j, nx - 1)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, nx - 2)) as *const f32,
prev.uget((j, nx - 2)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, nx - 3)) as *const f32,
prev.uget((j, nx - 3)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, nx - 4)) as *const f32,
prev.uget((j, nx - 4)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, nx - 5)) as *const f32,
prev.uget((j, nx - 5)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, nx - 6)) as *const f32,
prev.uget((j, nx - 6)) as *const Float,
SimdT::lanes(),
)),
SimdT::from_slice_unaligned(slice::from_raw_parts(
prev.uget((j, nx - 7)) as *const f32,
prev.uget((j, nx - 7)) as *const Float,
SimdT::lanes(),
)),
]
@@ -256,7 +264,7 @@ macro_rules! diff_simd_col_7_47 {
+ a[6] * bl[6]);
unsafe {
b.write_to_slice_unaligned(slice::from_raw_parts_mut(
fut.uget_mut((j, nx - 1 - i)) as *mut f32,
fut.uget_mut((j, nx - 1 - i)) as *mut Float,
SimdT::lanes(),
));
}
@@ -278,15 +286,15 @@ diff_simd_col_7_47!(
impl Upwind4 {
#[rustfmt::skip]
const HBLOCK: &'static [f32] = &[
const HBLOCK: &'static [Float] = &[
49.0 / 144.0, 61.0 / 48.0, 41.0 / 48.0, 149.0 / 144.0
];
#[rustfmt::skip]
const DIAG: &'static [f32] = &[
const DIAG: &'static [Float] = &[
-1.0 / 24.0, 1.0 / 4.0, -7.0 / 8.0, 0.0, 7.0 / 8.0, -1.0 / 4.0, 1.0 / 24.0
];
#[rustfmt::skip]
const BLOCK: &'static [[f32; 7]] = &[
const BLOCK: &'static [[Float; 7]] = &[
[ -72.0 / 49.0, 187.0 / 98.0, -20.0 / 49.0, -3.0 / 98.0, 0.0, 0.0, 0.0],
[-187.0 / 366.0, 0.0, 69.0 / 122.0, -16.0 / 183.0, 2.0 / 61.0, 0.0, 0.0],
[ 20.0 / 123.0, -69.0 / 82.0, 0.0, 227.0 / 246.0, -12.0 / 41.0, 2.0 / 41.0, 0.0],
@@ -294,7 +302,7 @@ impl Upwind4 {
];
#[rustfmt::skip]
const DISS_BLOCK: &'static [[f32; 7]; 4] = &[
const DISS_BLOCK: &'static [[Float; 7]; 4] = &[
[-3.0 / 49.0, 9.0 / 49.0, -9.0 / 49.0, 3.0 / 49.0, 0.0, 0.0, 0.0],
[ 3.0 / 61.0, -11.0 / 61.0, 15.0 / 61.0, -9.0 / 61.0, 2.0 / 61.0, 0.0, 0.0],
[-3.0 / 41.0, 15.0 / 41.0, -29.0 / 41.0, 27.0 / 41.0, -12.0 / 41.0, 2.0 / 41.0, 0.0],
@@ -302,13 +310,13 @@ impl Upwind4 {
];
#[rustfmt::skip]
const DISS_DIAG: &'static [f32; 7] = &[
const DISS_DIAG: &'static [Float; 7] = &[
1.0 / 24.0, -1.0 / 4.0, 5.0 / 8.0, -5.0 / 6.0, 5.0 / 8.0, -1.0 / 4.0, 1.0 / 24.0
];
}
impl SbpOperator for Upwind4 {
fn diffxi(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
fn diffxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Self::BLOCK.len());
@@ -329,12 +337,12 @@ impl SbpOperator for Upwind4 {
}
}
fn diffeta(prev: ArrayView2<f32>, fut: ArrayViewMut2<f32>) {
fn diffeta(prev: ArrayView2<Float>, fut: ArrayViewMut2<Float>) {
// transpose then use diffxi
Self::diffxi(prev.reversed_axes(), fut.reversed_axes());
}
fn h() -> &'static [f32] {
fn h() -> &'static [Float] {
Self::HBLOCK
}
}
@@ -343,13 +351,13 @@ impl SbpOperator for Upwind4 {
fn upwind4_test() {
use ndarray::prelude::*;
let nx = 20;
let dx = 1.0 / (nx - 1) as f32;
let mut source: ndarray::Array1<f32> = ndarray::Array1::zeros(nx);
let dx = 1.0 / (nx - 1) as Float;
let mut source: ndarray::Array1<Float> = ndarray::Array1::zeros(nx);
let mut res = ndarray::Array1::zeros(nx);
let mut target = ndarray::Array1::zeros(nx);
for i in 0..nx {
source[i] = i as f32 * dx;
source[i] = i as Float * dx;
target[i] = 1.0;
}
res.fill(0.0);
@@ -374,7 +382,7 @@ fn upwind4_test() {
}
for i in 0..nx {
let x = i as f32 * dx;
let x = i as Float * dx;
source[i] = x * x;
target[i] = 2.0 * x;
}
@@ -400,7 +408,7 @@ fn upwind4_test() {
}
for i in 0..nx {
let x = i as f32 * dx;
let x = i as Float * dx;
source[i] = x * x * x;
target[i] = 3.0 * x * x;
}
@@ -428,7 +436,7 @@ fn upwind4_test() {
}
impl UpwindOperator for Upwind4 {
fn dissxi(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
fn dissxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Self::BLOCK.len());
@@ -449,7 +457,7 @@ impl UpwindOperator for Upwind4 {
}
}
fn disseta(prev: ArrayView2<f32>, fut: ArrayViewMut2<f32>) {
fn disseta(prev: ArrayView2<Float>, fut: ArrayViewMut2<Float>) {
// diffeta = transpose then use dissxi
Self::dissxi(prev.reversed_axes(), fut.reversed_axes());
}

View File

@@ -1,5 +1,6 @@
use super::{SbpOperator, UpwindOperator};
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayView2, ArrayViewMut1, ArrayViewMut2};
#[derive(Debug)]
@@ -16,15 +17,15 @@ diff_op_1d!(
impl Upwind9 {
#[rustfmt::skip]
const HBLOCK: &'static [f32] = &[
const HBLOCK: &'static [Float] = &[
1070017.0/3628800.0, 5537111.0/3628800.0, 103613.0/403200.0, 261115.0/145152.0, 298951.0/725760.0, 515677.0/403200.0, 3349879.0/3628800.0, 3662753.0/3628800.0
];
#[rustfmt::skip]
const DIAG: &'static [f32] = &[
const DIAG: &'static [Float] = &[
-1.0/1260.0, 5.0/504.0, -5.0/84.0, 5.0/21.0, -5.0/6.0, 0.0, 5.0/6.0, -5.0/21.0, 5.0/84.0, -5.0/504.0, 1.0/1260.0,
];
#[rustfmt::skip]
const BLOCK: &'static [[f32; 13]] = &[
const BLOCK: &'static [[Float; 13]] = &[
[-1.69567399396458e+00, 2.29023358159400e+00, -2.16473500425698e-01, -5.05879766354449e-01, -1.01161106778154e-01, 2.59147072064383e-01, 1.93922119400659e-02, -4.95844980755642e-02, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-4.42575354959737e-01, 0.00000000000000e+00, 1.91582959381899e-01, 2.82222626681305e-01, 1.12083989713257e-01, -1.51334868892111e-01, -2.23600502721044e-02, 3.03806983474913e-02, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[2.48392603571843e-01, -1.13758367065272e+00, 0.00000000000000e+00, 1.95334726810969e+00, -1.58879011773212e+00, 3.93797129320378e-01, 2.52140821030291e-01, -1.21304033647356e-01, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
@@ -36,7 +37,7 @@ impl Upwind9 {
];
#[rustfmt::skip]
const DISS_BLOCK: &'static [[f32; 13]] = &[
const DISS_BLOCK: &'static [[Float; 13]] = &[
[-3.99020778658945e-04, 2.05394169917502e-03, -4.24493243399805e-03, 4.38126393542801e-03, -2.18883813216888e-03, 2.98565988131608e-04, 1.38484104084115e-04, -3.94643819928825e-05, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[3.96913216138553e-04, -2.28230530115522e-03, 5.43069719436758e-03, -6.81086901935894e-03, 4.69064759201504e-03, -1.61429862514855e-03, 1.62083873811316e-04, 2.71310693302277e-05, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
[-4.87084939816571e-03, 3.22464611075207e-02, -9.06094757860846e-02, 1.39830191253413e-01, -1.27675500367419e-01, 6.87310321912961e-02, -2.00917702215270e-02, 2.43991122096699e-03, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00],
@@ -48,13 +49,13 @@ impl Upwind9 {
];
#[rustfmt::skip]
const DISS_DIAG: &'static [f32] = &[
const DISS_DIAG: &'static [Float] = &[
1.0/1260.0, -1.0/126.0, 1.0/28.0, -2.0/21.0, 1.0/6.0, -1.0/5.0, 1.0/6.0, -2.0/21.0, 1.0/28.0, -1.0/126.0, 1.0/1260.0,
];
}
impl SbpOperator for Upwind9 {
fn diffxi(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
fn diffxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Self::BLOCK.len());
@@ -63,18 +64,18 @@ impl SbpOperator for Upwind9 {
}
}
fn diffeta(prev: ArrayView2<f32>, fut: ArrayViewMut2<f32>) {
fn diffeta(prev: ArrayView2<Float>, fut: ArrayViewMut2<Float>) {
// transpose then use diffxi
Self::diffxi(prev.reversed_axes(), fut.reversed_axes());
}
fn h() -> &'static [f32] {
fn h() -> &'static [Float] {
Self::HBLOCK
}
}
impl UpwindOperator for Upwind9 {
fn dissxi(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
fn dissxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Self::BLOCK.len());
@@ -83,7 +84,7 @@ impl UpwindOperator for Upwind9 {
}
}
fn disseta(prev: ArrayView2<f32>, fut: ArrayViewMut2<f32>) {
fn disseta(prev: ArrayView2<Float>, fut: ArrayViewMut2<Float>) {
// diffeta = transpose then use dissxi
Self::dissxi(prev.reversed_axes(), fut.reversed_axes());
}