From e1de7abf329f20559b7cb09e362aebcb08356482 Mon Sep 17 00:00:00 2001 From: Kyle Carow <40699307+kylecarow@users.noreply.github.com> Date: Tue, 21 Nov 2023 12:03:35 -0700 Subject: [PATCH 1/3] fix interp3d bug --- rust/altrios-core/src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/altrios-core/src/utils.rs b/rust/altrios-core/src/utils.rs index 5a4ee80e..8de63d43 100644 --- a/rust/altrios-core/src/utils.rs +++ b/rust/altrios-core/src/utils.rs @@ -79,8 +79,8 @@ pub fn interp3d( let (zi0, zi1) = find_interp_indices(&z, z_points)?; let xd = compute_interp_diff(&x, &x_points[xi0], &x_points[xi1]); - let yd = compute_interp_diff(&x, &x_points[xi0], &x_points[xi1]); - let zd = compute_interp_diff(&x, &x_points[xi0], &x_points[xi1]); + let yd = compute_interp_diff(&y, &y_points[yi0], &y_points[yi1]); + let zd = compute_interp_diff(&z, &z_points[zi0], &z_points[zi1]); let c000 = values[xi0][yi0][zi0]; let c100 = values[xi1][yi0][zi0]; From 45e7685364889145851c09a59a534a8c4eb8c7a6 Mon Sep 17 00:00:00 2001 From: Kyle Carow <40699307+kylecarow@users.noreply.github.com> Date: Tue, 21 Nov 2023 12:11:52 -0700 Subject: [PATCH 2/3] change expected result in interp3d test --- rust/altrios-core/src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/altrios-core/src/utils.rs b/rust/altrios-core/src/utils.rs index 8de63d43..dce520c8 100644 --- a/rust/altrios-core/src/utils.rs +++ b/rust/altrios-core/src/utils.rs @@ -231,7 +231,7 @@ mod tests { vec![vec![0.0, 0.0], vec![1.0, 1.0]], ]; match interp3d(&point, &grid, &values) { - Ok(i) => assert!(i == 0.75), + Ok(i) => assert!(i == 0.25), Err(e) => panic!("test failed with: {e}"), }; } From 658d6a0a2484fc88453aaf705ae966bd291ec6c2 Mon Sep 17 00:00:00 2001 From: Kyle Carow <40699307+kylecarow@users.noreply.github.com> Date: Tue, 21 Nov 2023 13:30:49 -0700 Subject: [PATCH 3/3] fix other interp3d bug, tests pass now --- rust/altrios-core/src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/altrios-core/src/utils.rs b/rust/altrios-core/src/utils.rs index dce520c8..8b184c9f 100644 --- a/rust/altrios-core/src/utils.rs +++ b/rust/altrios-core/src/utils.rs @@ -99,7 +99,7 @@ pub fn interp3d( let c0 = c00 * (1.0 - yd) + c10 * yd; let c1 = c01 * (1.0 - yd) + c11 * yd; - let c = c0 * (1.0 - yd) + c1 * zd; + let c = c0 * (1.0 - zd) + c1 * zd; Ok(c) }