code: def dIbr_dV(Yf, Yt, V):
      
  #        nb = len(V)
  
      Vnorm = div(V, abs(V))
      diagV = spdiag(V)
      diagVnorm = spdiag(Vnorm)
      dIf_dVa = Yf * 1j * diagV
      dIf_dVm = Yf * diagVnorm
      dIt_dVa = Yt * 1j * diagV
      dIt_dVm = Yt * diagVnorm
  
      # Compute currents.
      If = Yf * V
      It = Yt * V
  
      return dIf_dVa, dIf_dVm, dIt_dVa, dIt_dVm, If, It
docs: Computes partial derivatives of branch currents w.r.t. voltage.
  
          Ray Zimmerman, "dIbr_dV.m", MATPOWER, version 4.0b1,
          PSERC (Cornell), http://www.pserc.cornell.edu/matpower/