use super::*;
use f2rust_std::*;
pub const NONE: i32 = 0;
const LOWER: i32 = 1;
const UPPER: i32 = 2;
pub fn ZZINREC(
P: &[f64],
BOUNDS: &[f64],
MARGIN: f64,
EXCLUD: i32,
INSIDE: &mut bool,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let P = DummyArray::new(P, 1..=3);
let BOUNDS = DummyArray2D::new(BOUNDS, 1..=2, 1..=3);
let mut AMNCOR = StackArray::<f64, 3>::new(1..=3);
let mut AMXCOR = StackArray::<f64, 3>::new(1..=3);
let mut DELTA = StackArray::<f64, 3>::new(1..=3);
let mut MAXCOR = StackArray::<f64, 3>::new(1..=3);
let mut MINCOR = StackArray::<f64, 3>::new(1..=3);
let mut L = StackArray::<f64, 3>::new(1..=3);
if RETURN(ctx) {
return Ok(());
}
*INSIDE = false;
if (MARGIN < 0.0) {
CHKIN(b"ZZINREC", ctx)?;
SETMSG(b"Margin must be non-negative but was #.", ctx);
ERRDP(b"#", MARGIN, ctx);
SIGERR(b"SPICE(VALUEOUTOFRANGE)", ctx)?;
CHKOUT(b"ZZINREC", ctx)?;
return Ok(());
}
if ((EXCLUD < NONE) || (EXCLUD > 3)) {
CHKIN(b"ZZINREC", ctx)?;
SETMSG(b"EXCLUD was #; allowed range is 0:3.", ctx);
ERRINT(b"#", EXCLUD, ctx);
SIGERR(b"SPICE(INDEXOUTOFRANGE)", ctx)?;
CHKOUT(b"ZZINREC", ctx)?;
return Ok(());
}
for I in 1..=3 {
MINCOR[I] = BOUNDS[[LOWER, I]];
MAXCOR[I] = BOUNDS[[UPPER, I]];
L[I] = (MAXCOR[I] - MINCOR[I]);
if (L[I] < 0.0) {
CHKIN(b"ZZINREC", ctx)?;
SETMSG(b"Bounds are out of order for index #; bounds are #:#.", ctx);
ERRDP(b"#", BOUNDS[[LOWER, I]], ctx);
ERRDP(b"#", BOUNDS[[UPPER, I]], ctx);
SIGERR(b"SPICE(BOUNDSOUTOFORDER)", ctx)?;
CHKOUT(b"ZZINREC", ctx)?;
return Ok(());
}
}
for I in 1..=3 {
if (EXCLUD != I) {
DELTA[I] = (MARGIN * f64::abs(L[I]));
AMNCOR[I] = (MINCOR[I] - DELTA[I]);
AMXCOR[I] = (MAXCOR[I] + DELTA[I]);
if ((P[I] < AMNCOR[I]) || (P[I] > AMXCOR[I])) {
return Ok(());
}
}
}
*INSIDE = true;
Ok(())
}