'Test np.linalg.eig'

def checker_for_linalg_eig(self, name, func, expected_res_len, check_for_domain_change=None):

    n = 10
    cfunc = jit(nopython=True)(func)
    def check(a):
        expected = func(a)
        got = cfunc(a)
        self.assertEqual(len(expected), len(got))
        res_is_tuple = False
        if isinstance(got, tuple):
            res_is_tuple = True
            self.assertEqual(len(got), expected_res_len)
        else:
            self.assertEqual(got.ndim, expected_res_len)
        self.assert_contig_sanity(got, 'F')
        use_reconstruction = False
        for k in range(len(expected)):
            try:
                np.testing.assert_array_almost_equal_nulp(got[k], expected[k], nulp=10)
            except AssertionError:
                use_reconstruction = True
        resolution = (5 * np.finfo(a.dtype).resolution)
        if use_reconstruction:
            if res_is_tuple:
                (w, v) = got
                if (name[(-1)] == 'h'):
                    idxl = np.nonzero(np.eye(a.shape[0], a.shape[1], (-1)))
                    idxu = np.nonzero(np.eye(a.shape[0], a.shape[1], 1))
                    cfunc(a)
                    a[idxu] = np.conj(a[idxl])
                    a[np.diag_indices(a.shape[0])] = np.real(np.diag(a))
                lhs = np.dot(a, v)
                rhs = np.dot(v, np.diag(w))
                np.testing.assert_allclose(lhs.real, rhs.real, rtol=resolution, atol=resolution)
                if np.iscomplexobj(v):
                    np.testing.assert_allclose(lhs.imag, rhs.imag, rtol=resolution, atol=resolution)
            else:
                np.testing.assert_allclose(np.sort(expected), np.sort(got), rtol=resolution, atol=resolution)
        with self.assertNoNRTLeak():
            cfunc(a)
    for (dtype, order) in product(self.dtypes, 'FC'):
        a = self.sample_matrix(n, dtype, order)
        check(a)
    for ty in [np.float32, np.complex64]:
        self.assert_non_square(cfunc, (np.ones((2, 3), dtype=ty),))
        self.assert_wrong_dtype(name, cfunc, (np.ones((2, 2), dtype=np.int32),))
        self.assert_wrong_dimensions(name, cfunc, (np.ones(10, dtype=ty),))
        self.assert_no_nan_or_inf(cfunc, (np.array([[1.0, 2.0], [np.inf, np.nan]], dtype=ty),))
    if check_for_domain_change:
        A = np.array([[1, (-2)], [2, 1]])
        check(A.astype(np.complex128))
        (l, _) = func(A)
        self.assertTrue(np.any(l.imag))
        for ty in [np.float32, np.float64]:
            self.assert_no_domain_change(name, cfunc, (A.astype(ty),))
