simplify macro invocation

This commit is contained in:
Magnus Ulimoen 2020-04-08 23:22:03 +02:00
parent c3a40d81ee
commit fe2c7f1253
5 changed files with 7 additions and 4 deletions

View File

@ -34,6 +34,9 @@ pub trait UpwindOperator: SbpOperator {
#[macro_export] #[macro_export]
macro_rules! diff_op_1d { macro_rules! diff_op_1d {
($name: ident, $BLOCK: expr, $DIAG: expr) => {
diff_op_1d!($name, $BLOCK, $DIAG, false);
};
($name: ident, $BLOCK: expr, $DIAG: expr, $symmetric: expr) => { ($name: ident, $BLOCK: expr, $DIAG: expr, $symmetric: expr) => {
fn $name(prev: ArrayView1<Float>, mut fut: ArrayViewMut1<Float>) { fn $name(prev: ArrayView1<Float>, mut fut: ArrayViewMut1<Float>) {
assert_eq!(prev.shape(), fut.shape()); assert_eq!(prev.shape(), fut.shape());

View File

@ -6,7 +6,7 @@ use ndarray::{s, ArrayView1, ArrayViewMut1};
#[derive(Debug)] #[derive(Debug)]
pub struct SBP4 {} pub struct SBP4 {}
diff_op_1d!(diff_1d, SBP4::BLOCK, SBP4::DIAG, false); diff_op_1d!(diff_1d, SBP4::BLOCK, SBP4::DIAG);
impl SBP4 { impl SBP4 {
#[rustfmt::skip] #[rustfmt::skip]

View File

@ -6,7 +6,7 @@ use ndarray::{s, ArrayView1, ArrayViewMut1};
#[derive(Debug)] #[derive(Debug)]
pub struct SBP8 {} pub struct SBP8 {}
diff_op_1d!(diff_1d, SBP8::BLOCK, SBP8::DIAG, false); diff_op_1d!(diff_1d, SBP8::BLOCK, SBP8::DIAG);
impl SBP8 { impl SBP8 {
#[rustfmt::skip] #[rustfmt::skip]

View File

@ -12,7 +12,7 @@ type SimdT = packed_simd::f32x8;
#[cfg(not(feature = "f32"))] #[cfg(not(feature = "f32"))]
type SimdT = packed_simd::f64x8; type SimdT = packed_simd::f64x8;
diff_op_1d!(diff_1d, Upwind4::BLOCK, Upwind4::DIAG, false); diff_op_1d!(diff_1d, Upwind4::BLOCK, Upwind4::DIAG);
diff_op_1d!(diss_1d, Upwind4::DISS_BLOCK, Upwind4::DISS_DIAG, true); diff_op_1d!(diss_1d, Upwind4::DISS_BLOCK, Upwind4::DISS_DIAG, true);
macro_rules! diff_simd_row_7_47 { macro_rules! diff_simd_row_7_47 {

View File

@ -6,7 +6,7 @@ use ndarray::{s, ArrayView1, ArrayViewMut1};
#[derive(Debug)] #[derive(Debug)]
pub struct Upwind9 {} pub struct Upwind9 {}
diff_op_1d!(diff_1d, Upwind9::BLOCK, Upwind9::DIAG, false); diff_op_1d!(diff_1d, Upwind9::BLOCK, Upwind9::DIAG);
diff_op_1d!(diss_1d, Upwind9::DISS_BLOCK, Upwind9::DISS_DIAG, true); diff_op_1d!(diss_1d, Upwind9::DISS_BLOCK, Upwind9::DISS_DIAG, true);
impl Upwind9 { impl Upwind9 {