/// Takes values computed at the endpoints of an interval together with
/// one additional point, and attempts to construct a shorter interval
///  that satisfies the opposite slope conditions.
///
/// # Citation:
/// Hager 2004, p. 182
Takes values computed at the endpoints of an interval together with
one additional point, and attempts to construct a shorter interval
that satisfies the opposite slope conditions.
Takes values computed at the endpoints of an interval together with one additional point and attempts to construct a shorter interval that satisfies the opposite slope conditions .
fn update_interval<E>(
        &self,
        input: Interval, // Current boundaries, written as 'a' and 'b' in the paper.
        guess: Bound, // Guess for next bound, written as 'c' in the paper
        compute: &mut dyn FnMut(f64, How) -> Result<Bound, E>,
    ) -> Result<Interval, E>
    {
        self.validate_opposite_slope(input);
        let (lo, hi) = input;
        if !(lo.alpha < guess.alpha && guess.alpha < hi.alpha) {
            debug!("update_interval: Exit by strange guess (U0),  ({:e}, {:e}) vs {:e}",
                lo.alpha, hi.alpha, guess.alpha);
            return Ok((lo, hi));
        }
        let out = match (guess.strictly_downhill(), self.reasonable_value(guess)) {
            // easy cases where guess is already suitable for one of the bounds
            (true, true) => (guess, hi),   // condition (U2), p. 182
            (false, _) => (lo, guess),     // condition (U1), p. 182
            // tough case; bisect until we have a good interval again.
            (true, false) => match self.funky_loop_in_u3((lo, guess), compute)? {
                Ok(ivl) => ivl,
                Err(new_lo) => (new_lo, hi), // Today is just not our day, huh?
            },
        };
        let is_improper_subset = |a: Interval, b: Interval|
            b.0.alpha <= a.0.alpha && a.1.alpha <= b.1.alpha;
        assert!(is_improper_subset(out, input));
        self.validate_opposite_slope(out);
        Ok(out)
    }
fn update_interval < E > ( & self , input : Interval , // Current boundaries, written as 'a' and 'b' in the paper. guess : Bound , // Guess for next bound, written as 'c' in the paper compute : & mut dyn FnMut ( f64 , How ) -> Result < Bound , E > , ) -> Result < Interval , E > { self . validate_opposite_slope ( input ) ; let ( lo , hi ) = input ; if ! ( lo . alpha < guess . alpha && guess . alpha < hi . alpha ) { debug ! ( " " lo alpha hi alpha guess alpha ) ; return Ok ( ( lo , hi ) ) ; } let out = match ( guess . strictly_downhill ( ) , self . reasonable_value ( guess ) ) { // easy cases where guess is already suitable for one of the bounds ( true , true ) => ( guess , hi ) , // condition (U2), p. 182 ( false , _ ) => ( lo , guess ) , // condition (U1), p. 182 // tough case; bisect until we have a good interval again. ( true , false ) => match self . funky_loop_in_u3 ( ( lo , guess ) , compute ) ? { Ok ( ivl ) => ivl , Err ( new_lo ) => ( new_lo , hi ) , // Today is just not our day, huh? } , } ; let is_improper_subset = | a : Interval , b : Interval | b . 0 . alpha <= a . 0 . alpha && a . 1 . alpha <= b . 1 . alpha ; assert ! ( is_improper_subset ( out input ) ) ; self . validate_opposite_slope ( out ) ; Ok ( out ) }
Takes values computed at the endpoints of an interval together with
one additional point, and attempts to construct a shorter interval
that satisfies the opposite slope conditions.
Takes values computed at the endpoints of an interval together with one additional point and attempts to construct a shorter interval that satisfies the opposite slope conditions .
&self
input
Interval
guess
Bound
compute
&mut dyn FnMut(f64, How) -> Result<Bound, E>
citation:
None