Пример #1
0
    def eig(self, k=(0, 0, 0), gauge='R', eigvals_only=True, **kwargs):
        """ Returns the eigenvalues of the physical quantity (using the non-Hermitian solver)

        Setup the system and overlap matrix with respect to
        the given k-point and calculate the eigenvalues.

        All subsequent arguments gets passed directly to :code:`scipy.linalg.eig`

        Parameters
        ----------
        spin : int, optional
           the spin-component to calculate the eigenvalue spectrum of, note that
           this parameter is only valid for `Spin.POLARIZED` matrices.
        """
        spin = kwargs.pop('spin', 0)
        dtype = kwargs.pop('dtype', None)

        if self.spin.kind == Spin.POLARIZED:
            P = self.Pk(k=k, dtype=dtype, gauge=gauge, spin=spin, format='array')
        else:
            P = self.Pk(k=k, dtype=dtype, gauge=gauge, format='array')

        if self.orthogonal:
            if eigvals_only:
                return lin.eigvals_destroy(P, **kwargs)
            return lin.eig_destroy(P, **kwargs)

        S = self.Sk(k=k, dtype=dtype, gauge=gauge, format='array')
        if eigvals_only:
            return lin.eigvals_destroy(P, S, **kwargs)
        return lin.eig_destroy(P, S, **kwargs)
Пример #2
0
def test_eig_d1():
    np.random.seed(1204982)
    a = np.random.rand(10, 10)
    b = np.random.rand(10, 10)
    xs, vs = sl.eig(a, b)
    x, v = eig_destroy(a, b)
    assert np.allclose(xs, x)
    assert np.allclose(vs, v)
Пример #3
0
    def eig(self, k=(0, 0, 0), gauge='R', eigvals_only=True, **kwargs):
        """ Returns the eigenvalues of the physical quantity (using the non-Hermitian solver)

        Setup the system and overlap matrix with respect to
        the given k-point and calculate the eigenvalues.

        All subsequent arguments gets passed directly to :code:`scipy.linalg.eig`
        """
        dtype = kwargs.pop('dtype', None)
        P = self.Pk(k=k, dtype=dtype, gauge=gauge, format='array')
        if self.orthogonal:
            if eigvals_only:
                return lin.eigvals_destroy(P, **kwargs)
            return lin.eig_destroy(P, **kwargs)

        S = self.Sk(k=k, dtype=dtype, gauge=gauge, format='array')
        if eigvals_only:
            return lin.eigvals_destroy(P, S, **kwargs)
        return lin.eig_destroy(P, S, **kwargs)