diff_op_row as function factory
This commit is contained in:
		@@ -232,13 +232,13 @@ pub(crate) fn diff_op_col(
 | 
			
		||||
 | 
			
		||||
#[inline(always)]
 | 
			
		||||
pub(crate) fn diff_op_row(
 | 
			
		||||
    block: &[&[Float]],
 | 
			
		||||
    diag: &[Float],
 | 
			
		||||
    block: &'static [&'static [Float]],
 | 
			
		||||
    diag: &'static [Float],
 | 
			
		||||
    symmetric: bool,
 | 
			
		||||
    is_h2: bool,
 | 
			
		||||
    prev: ArrayView2<Float>,
 | 
			
		||||
    mut fut: ArrayViewMut2<Float>,
 | 
			
		||||
) {
 | 
			
		||||
) -> impl Fn(ArrayView2<Float>, ArrayViewMut2<Float>) {
 | 
			
		||||
    #[inline(always)]
 | 
			
		||||
    move |prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>| {
 | 
			
		||||
        assert_eq!(prev.shape(), fut.shape());
 | 
			
		||||
        let nx = prev.shape()[1];
 | 
			
		||||
        assert!(nx >= 2 * block.len());
 | 
			
		||||
@@ -293,6 +293,7 @@ pub(crate) fn diff_op_row(
 | 
			
		||||
                *f = idx * if symmetric { diff } else { -diff };
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mod upwind4;
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP4) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(SBP4::BLOCK, SBP4::DIAG, false, false, prev, fut);
 | 
			
		||||
                diff_op_row(SBP4::BLOCK, SBP4::DIAG, false, false)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(SBP4::BLOCK, SBP4::DIAG, false, false, prev, fut);
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP8) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(SBP8::BLOCK, SBP8::DIAG, false, false, prev, fut);
 | 
			
		||||
                diff_op_row(SBP8::BLOCK, SBP8::DIAG, false, false)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(SBP8::BLOCK, SBP8::DIAG, false, false, prev, fut);
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4h2) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(Upwind4h2::BLOCK, Upwind4h2::DIAG, false, true, prev, fut);
 | 
			
		||||
                diff_op_row(Upwind4h2::BLOCK, Upwind4h2::DIAG, false, true)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(Upwind4h2::BLOCK, Upwind4h2::DIAG, false, true, prev, fut);
 | 
			
		||||
@@ -81,14 +81,7 @@ impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind4h2) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(
 | 
			
		||||
                    Upwind4h2::DISS_BLOCK,
 | 
			
		||||
                    Upwind4h2::DISS_DIAG,
 | 
			
		||||
                    true,
 | 
			
		||||
                    true,
 | 
			
		||||
                    prev,
 | 
			
		||||
                    fut,
 | 
			
		||||
                );
 | 
			
		||||
                diff_op_row(Upwind4h2::DISS_BLOCK, Upwind4h2::DISS_DIAG, true, true)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(Upwind9::BLOCK, Upwind9::DIAG, false, false, prev, fut);
 | 
			
		||||
                diff_op_row(Upwind9::BLOCK, Upwind9::DIAG, false, false)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(Upwind9::BLOCK, Upwind9::DIAG, false, false, prev, fut);
 | 
			
		||||
@@ -96,14 +96,7 @@ impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind9) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(
 | 
			
		||||
                    Upwind9::DISS_BLOCK,
 | 
			
		||||
                    Upwind9::DISS_DIAG,
 | 
			
		||||
                    true,
 | 
			
		||||
                    false,
 | 
			
		||||
                    prev,
 | 
			
		||||
                    fut,
 | 
			
		||||
                );
 | 
			
		||||
                diff_op_row(Upwind9::DISS_BLOCK, Upwind9::DISS_DIAG, true, false)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9h2) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(Upwind9h2::BLOCK, Upwind9h2::DIAG, false, true, prev, fut);
 | 
			
		||||
                diff_op_row(Upwind9h2::BLOCK, Upwind9h2::DIAG, false, true)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(Upwind9h2::BLOCK, Upwind9h2::DIAG, false, true, prev, fut);
 | 
			
		||||
@@ -123,14 +123,7 @@ impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind9h2) {
 | 
			
		||||
 | 
			
		||||
        match (prev.strides(), fut.strides()) {
 | 
			
		||||
            ([_, 1], [_, 1]) => {
 | 
			
		||||
                diff_op_row(
 | 
			
		||||
                    Upwind9h2::DISS_BLOCK,
 | 
			
		||||
                    Upwind9h2::DISS_DIAG,
 | 
			
		||||
                    true,
 | 
			
		||||
                    true,
 | 
			
		||||
                    prev,
 | 
			
		||||
                    fut,
 | 
			
		||||
                );
 | 
			
		||||
                diff_op_row(Upwind9h2::DISS_BLOCK, Upwind9h2::DISS_DIAG, true, true)(prev, fut);
 | 
			
		||||
            }
 | 
			
		||||
            ([1, _], [1, _]) => {
 | 
			
		||||
                diff_op_col(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user