fdjac Subroutine

public subroutine fdjac(x, fvec, df)

Arguments

Type IntentOptional Attributes Name
real(kind=8), intent(inout), dimension(:) :: x
real(kind=8), intent(in), dimension(:) :: fvec
real(kind=8), intent(out), dimension(:,:) :: df

Calls

proc~~fdjac~~CallsGraph proc~fdjac fdjac proc~assert_eq4 assert_eq4 proc~fdjac->proc~assert_eq4

Called by

proc~~fdjac~~CalledByGraph proc~fdjac fdjac proc~broyden1~2 broyden1 proc~broyden1~2->proc~fdjac

Source Code

  subroutine fdjac(x,fvec,df)
    real(8), dimension(:), intent(in)    :: fvec
    real(8), dimension(:), intent(inout) :: x
    real(8), dimension(:,:), intent(out) :: df
    integer                              :: j,n
    real(8), parameter :: eps=1.0d-4
    real(8), dimension(size(x))          :: xsav,xph,h
    n=assert_eq4(size(x),size(fvec),size(df,1),size(df,2),'fdjac')
    xsav=x
    h=eps*abs(xsav)
    where (h == 0.0) h=eps
    xph=xsav+h
    h=xph-xsav
    do j=1,n
       x(j)=xph(j)
       df(:,j)=(funcv(x)-fvec(:))/h(j)
       x(j)=xsav(j)
    end do
  end subroutine fdjac