/// subroutine fdjac2
///
/// this subroutine computes a forward-difference approximation to the m by
/// n jacobian matrix associated with a specified problem of m functions in
/// n variables.
///
/// the subroutine statement is
///
/// subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa)
///
/// where
///
/// fcn is the name of the user-supplied subroutine which calculates the
/// functions. fcn must be declared in an external statement in the user
/// calling program, and should be written as follows.
///
/// subroutine fcn(m,n,x,fvec,iflag) integer m,n,iflag double precision
/// x(n),fvec(m)
/// ----------
/// calculate the functions at x and return this vector in fvec.
/// ----------
/// return end
///
/// the value of iflag should not be changed by fcn unless the user wants to
/// terminate execution of fdjac2. in this case set iflag to a negative
/// integer.
///
/// m is a positive integer input variable set to the number of functions.
///
/// n is a positive integer input variable set to the number of variables. n
/// must not exceed m.
///
/// x is an input array of length n.
///
/// fvec is an input array of length m which must contain the functions
/// evaluated at x.
///
/// fjac is an output m by n array which contains the approximation to the
/// jacobian matrix evaluated at x.
///
/// ldfjac is a positive integer input variable not less than m which
/// specifies the leading dimension of the array fjac.
///
/// iflag is an integer variable which can be used to terminate the
/// execution of fdjac2. see description of fcn.
///
/// epsfcn is an input variable used in determining a suitable step length
/// for the forward-difference approximation. this approximation assumes
/// that the relative errors in the functions are of the order of epsfcn. if
/// epsfcn is less than the machine precision, it is assumed that the
/// relative errors in the functions are of the order of the machine
/// precision.
///
/// wa is a work array of length m.
subroutine fdjac2
this subroutine computes a forward-difference approximation to the m by
n jacobian matrix associated with a specified problem of m functions in
n variables.

the subroutine statement is





fcn is the name of the user-supplied subroutine which calculates the
functions. fcn must be declared in an external statement in the user
calling program, and should be written as follows.



calculate the functions at x and return this vector in fvec.

return end

the value of iflag should not be changed by fcn unless the user wants to
terminate execution of fdjac2. in this case set iflag to a negative
integer.

m is a positive integer input variable set to the number of functions.

n is a positive integer input variable set to the number of variables. n
must not exceed m.

x is an input array of length n.

fvec is an input array of length m which must contain the functions
evaluated at x.

fjac is an output m by n array which contains the approximation to the
jacobian matrix evaluated at x.

ldfjac is a positive integer input variable not less than m which
specifies the leading dimension of the array fjac.

iflag is an integer variable which can be used to terminate the
execution of fdjac2. see description of fcn.

epsfcn is an input variable used in determining a suitable step length
for the forward-difference approximation. this approximation assumes
that the relative errors in the functions are of the order of epsfcn. if
epsfcn is less than the machine precision, it is assumed that the
relative errors in the functions are of the order of the machine
precision.

wa is a work array of length m.
subroutine fdjac2 this subroutine computes a forward - difference approximation to the m by n jacobian matrix associated with a specified problem of m functions in n variables . the subroutine statement is fcn is the name of the user - supplied subroutine which calculates the functions . fcn must be declared in an external statement in the user calling program and should be written as follows . calculate the functions at x and return this vector in fvec . return end the value of iflag should not be changed by fcn unless the user wants to terminate execution of fdjac2 . in this case set iflag to a negative integer . m is a positive integer input variable set to the number of functions . n is a positive integer input variable set to the number of variables . n must not exceed m . x is an input array of length n . fvec is an input array of length m which must contain the functions evaluated at x . fjac is an output m by n array which contains the approximation to the jacobian matrix evaluated at x . ldfjac is a positive integer input variable not less than m which specifies the leading dimension of the array fjac . iflag is an integer variable which can be used to terminate the execution of fdjac2 . see description of fcn . epsfcn is an input variable used in determining a suitable step length for the forward - difference approximation . this approximation assumes that the relative errors in the functions are of the order of epsfcn . if epsfcn is less than the machine precision it is assumed that the relative errors in the functions are of the order of the machine precision . wa is a work array of length m .
fn fdjac2(&mut self) -> Result<()> {
        // Calculate the Jacobian matrix
        let eps = self.cfg.epsfcn.max(f64::EPSILON).sqrt();
        // TODO: probably sides and analytical derivatives should be implemented at some point
        self.fjac.fill(0.);
        let mut ij = 0;
        /* Any parameters requiring numerical derivatives */
        for j in 0..self.nfree {
            let free_p = self.ifree[j];
            let temp = self.xnew[free_p];
            let mut h = eps * temp.abs();
            if free_p < self.step.len() && self.step[free_p] > 0. {
                h = self.step[free_p];
            }
            if free_p < self.dstep.len() && self.dstep[free_p] > 0. {
                h = (self.dstep[free_p] * temp).abs();
            }
            if h == 0. {
                h = eps;
            }
            if j < self.qulim.len()
                && self.qulim[j]
                && j < self.ulim.len()
                && temp > self.ulim[j] - h
            {
                h = -h;
            }
            self.xnew[free_p] = temp + h;
            self.f.eval(&self.xnew, &mut self.wa4)?;
            self.nfev += 1;
            self.xnew[free_p] = temp;
            for (wa4, fvec) in self.wa4.iter().zip(&self.fvec) {
                self.fjac[ij] = (wa4 - fvec) / h;
                ij += 1;
            }
        }
        Ok(())
    }
fn fdjac2 ( & mut self ) -> Result < ( ) > { // Calculate the Jacobian matrix let eps = self . cfg . epsfcn . max ( f64 :: EPSILON ) . sqrt ( ) ; // TODO: probably sides and analytical derivatives should be implemented at some point self . fjac . fill ( 0. ) ; let mut ij = 0 ; /* Any parameters requiring numerical derivatives */ for j in 0 .. self . nfree { let free_p = self . ifree [ j ] ; let temp = self . xnew [ free_p ] ; let mut h = eps * temp . abs ( ) ; if free_p < self . step . len ( ) && self . step [ free_p ] > 0. { h = self . step [ free_p ] ; } if free_p < self . dstep . len ( ) && self . dstep [ free_p ] > 0. { h = ( self . dstep [ free_p ] * temp ) . abs ( ) ; } if h == 0. { h = eps ; } if j < self . qulim . len ( ) && self . qulim [ j ] && j < self . ulim . len ( ) && temp > self . ulim [ j ] - h { h = - h ; } self . xnew [ free_p ] = temp + h ; self . f . eval ( & self . xnew , & mut self . wa4 ) ? ; self . nfev += 1 ; self . xnew [ free_p ] = temp ; for ( wa4 , fvec ) in self . wa4 . iter ( ) . zip ( & self . fvec ) { self . fjac [ ij ] = ( wa4 - fvec ) / h ; ij += 1 ; } } Ok ( ( ) ) }
subroutine fdjac2
this subroutine computes a forward-difference approximation to the m by
n jacobian matrix associated with a specified problem of m functions in
n variables.
subroutine fdjac2 this subroutine computes a forward - difference approximation to the m by n jacobian matrix associated with a specified problem of m functions in n variables .
&mut self