示例#1
0
    def assertReductionWorks(t, filename):
        M = import_matrix_from_file(filename)
        x, eps = SR.var("x eps")
        t.assertIn(x, M.variables())
        M_pranks = singularities(M, x).values()
        t.assertNotEqual(M_pranks, [0] * len(M_pranks))

        #1 Fuchsify
        m, t1 = simplify_by_factorization(M, x)
        Mf, t2 = fuchsify(m, x)
        Tf = t1 * t2
        t.assertTrue((Mf - transform(M, x, Tf)).simplify_rational().is_zero())
        Mf_pranks = singularities(Mf, x).values()
        t.assertEqual(Mf_pranks, [0] * len(Mf_pranks))

        #2 Normalize
        t.assertFalse(is_normalized(Mf, x, eps))
        m, t1 = simplify_by_factorization(Mf, x)
        Mn, t2 = normalize(m, x, eps)
        Tn = t1 * t2
        t.assertTrue((Mn - transform(Mf, x, Tn)).simplify_rational().is_zero())
        t.assertTrue(is_normalized(Mn, x, eps))

        #3 Factorize
        t.assertIn(eps, Mn.variables())
        m, t1 = simplify_by_factorization(Mn, x)
        Mc, t2 = factorize(m, x, eps, seed=3)
        Tc = t1 * t2
        t.assertTrue((Mc - transform(Mn, x, Tc)).simplify_rational().is_zero())
        t.assertNotIn(eps, (Mc / eps).simplify_rational().variables())
示例#2
0
    def test_normalize_4(t):
        # Test with non-zero normalized eigenvalues
        x, e = SR.var("x eps")
        M = matrix([[1 / x / 2, 0], [0, 0]])

        with t.assertRaises(FuchsiaError):
            N, T = normalize(M, x, e)
示例#3
0
    def test_normalize_3(t):
        # Test with non-zero normalized eigenvalues
        x = SR.var("x")
        e = SR.var("epsilon")
        M = matrix([[(1 - e) / x, 0], [0, (1 + e) / 3 / x]])

        with t.assertRaises(FuchsiaError):
            N, T = normalize(M, x, e)
示例#4
0
    def test_normalize_5(t):
        # An unnormalizable example by A. A. Bolibrukh
        x, e = SR.var("x eps")
        b = import_matrix_from_file("test/data/bolibrukh.mtx")
        f, ft = fuchsify(b, x)
        f_pranks = singularities(f, x).values()
        t.assertEqual(f_pranks, [0] * len(f_pranks))

        with t.assertRaises(FuchsiaError):
            n, nt = normalize(f, x, e)
示例#5
0
    def test_normalize_1(t):
        # Test with apparent singularities at 0 and oo, but not at 1.
        x = SR.var("x")
        M = matrix([[1 / x, 5 / (x - 1), 0, 6 / (x - 1)], [0, 2 / x, 0, 0],
                    [0, 0, 3 / x, 7 / (x - 1)], [6 / (x - 1), 0, 0, 1 / x]])

        N, T = normalize(M, x, SR.var("epsilon"))
        N = N.simplify_rational()
        t.assertEqual(N, transform(M, x, T).simplify_rational())
        for point, prank in singularities(N, x).iteritems():
            R = matrix_c0(N, x, point, prank)
            evlist = R.eigenvalues()
            t.assertEqual(evlist, [0] * len(evlist))
示例#6
0
 def test_pap_3_52_slow(t):
     x, eps = SR.var("x eps")
     M = import_matrix_from_file("test/data/pap_3_52.mtx")
     N, T = normalize(M, x, eps)
     N = N.simplify_rational()
     t.assertEqual(N, transform(M, x, T).simplify_rational())