def test_mult_with_coeffs(): now = np.array([1.0, 2.0, 3.0, 4.0, 6.0]) coeffs = np.array( [[[ 0.33333333, 0.83333333, -0.16666667], [-0.16666667, 0.83333333, 0.33333333], [ 0.33333333, -1.16666667, 1.83333333]]]) correct = np.array([[21.0/6.0, 21.0/6.0, 20.0/6.0]]) result = ext_weno.mult_with_coeffs(1, 3, now, coeffs) np.testing.assert_almost_equal(result, correct)
def compute_helper(now, padded, half_width, side_index, coeffs, smoothness, weights, eps): cells = len(now) weights = weights[:, side_index] coeffs = coeffs[:, side_index] beta = ext_weno.mult_with_smoothness(cells, half_width, padded, smoothness) s_weights = ext_weno.scaled_weights(cells, half_width, eps, weights, beta) small_polynomials = ext_weno.mult_with_coeffs(cells, half_width, padded, coeffs) reconstruction = ext_weno.mult_polynomials(cells, half_width, s_weights, small_polynomials) return np.array(reconstruction)