Based on dIbr_dV.m from MATPOWER by Ray Zimmerman, developed at
        PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
        information.

        @return: The partial derivatives of branch currents w.r.t. voltage
                 magnitude and voltage angle.
        @rtype: tuple

def dIbr_dV(self, Yf, Yt, V):
        """ Based on dIbr_dV.m from MATPOWER by Ray Zimmerman, developed at
        PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
        information.

        @return: The partial derivatives of branch currents w.r.t. voltage
                 magnitude and voltage angle.
        @rtype: tuple
        """
        i = range(len(V))

        Vnorm = V / abs(V)
        diagV = csr_matrix((V, (i, i)))
        diagVnorm = csr_matrix((Vnorm, (i, i)))
        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