subroutine dbfgsi (n,mat,y,s,ys,smmy,izs,rzs,dzs) 2
c
      integer n,izs(1)
      real rzs(1)
      double precision mat(n,n),y(n),s(n),ys,smmy(n),dzs(1)
c
c----
c
c     This routine updates the matrix MAT by the inverse BFGS formula.
c
c     Input:
c
c       n: order of the matrix
c       mat: original matrix
c       y: vector y
c       s: vector s
c       ys = (y,s)
c
c     Ouput:
c
c       mat: updated matrix
c
c     Working zone:
c
c       smmy(n)
c
c----
c
c --- local variables
c
      integer i,j
      double precision r,d
c
c --- compute (s-My)/(y,s)
c
      do i=1,n
          smmy(i)=s(i)
      enddo
      do j=1,n
          r=y(j)
          do i=1,n
              smmy(i)=smmy(i)-mat(i,j)*r
          enddo
      enddo
      do i=1,n
          smmy(i)=smmy(i)/ys
      enddo
c
c --- r=(s-My,y)/(y,s)^2
c
      call deuclid (n,y,smmy,d,izs,rzs,dzs)
      r=d/ys
c
c --- update M
c
      do i=1,n
          do j=1,n
              mat(i,j)=mat(i,j)+smmy(i)*s(j)+s(i)*smmy(j)-r*s(i)*s(j)
          enddo
      enddo
c
      return
      end
c
c--------0---------0---------0---------0---------0---------0---------0--
c