pub fn try_gradient<E, F>(
    interval_width: f64,
    kind: Option<DerivativeKind>,
    point: &[f64],
    mut value_fn: F,
) -> Result<Vec<f64>, E>
where
    F: FnMut(&[f64]) -> Result<f64, E>,
{
    let kind = kind.unwrap_or_default();
    point.iter().enumerate()
        .map(|(i, &center)| {
            let mut point = point.to_vec(); // reset modifications
            try_slope(
                interval_width,
                Some(kind),
                center,
                |x| { point[i] = x; value_fn(&point) },
            )
        })
        .collect()
}
/// `gradient` for functions that can fail.
`gradient` for functions that can fail.
` gradient ` for functions that can fail .
pub fn try_gradient<E, F>(
    interval_width: f64,
    kind: Option<DerivativeKind>,
    point: &[f64],
    mut value_fn: F,
) -> Result<Vec<f64>, E>
where
    F: FnMut(&[f64]) -> Result<f64, E>,
{
    let kind = kind.unwrap_or_default();
    point.iter().enumerate()
        .map(|(i, &center)| {
            let mut point = point.to_vec(); // reset modifications
            try_slope(
                interval_width,
                Some(kind),
                center,
                |x| { point[i] = x; value_fn(&point) },
            )
        })
        .collect()
}
pub fn try_gradient < E , F > ( interval_width : f64 , kind : Option < DerivativeKind > , point : & [ f64 ] , mut value_fn : F , ) -> Result < Vec < f64 > , E > where F : FnMut ( & [ f64 ] ) -> Result < f64 , E > , { let kind = kind . unwrap_or_default ( ) ; point . iter ( ) . enumerate ( ) . map ( | ( i , & center ) | { let mut point = point . to_vec ( ) ; // reset modifications try_slope ( interval_width , Some ( kind ) , center , | x | { point [ i ] = x ; value_fn ( & point ) } , ) } ) . collect ( ) }
`gradient` for functions that can fail.
` gradient ` for functions that can fail .
interval_width
f64
kind
Option<DerivativeKind>
point
&[f64]
value_fn
F
interval_width
f64
kind
Option<DerivativeKind>
point
&[f64]
value_fn
F