コード例 #1
0
ファイル: test_cli.py プロジェクト: lds2/fuchsia
 def assertIsReduced(t, m_path, x_name, eps_name):
     M = fuchsia.import_matrix_from_file(m_path)
     x = SR.var(x_name)
     eps = SR.var(eps_name)
     pranks = fuchsia.singularities(M, x).values()
     t.assertEqual(pranks, [0]*len(pranks))
     t.assertTrue(eps not in (M/eps).simplify_rational().variables())
コード例 #2
0
ファイル: test_reduce.py プロジェクト: lds2/fuchsia
    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())
コード例 #3
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)
コード例 #4
0
ファイル: test_epsilon_form.py プロジェクト: lds2/fuchsia
    def assertReductionWorks(test, filename, fuchsian=False):
        m = import_matrix_from_file(filename)
        x, eps = SR.var("x eps")
        test.assertIn(x, m.variables())

        if not fuchsian:
            m_pranks = singularities(m, x).values()
            test.assertNotEqual(m_pranks, [0]*len(m_pranks))

        mt, t = epsilon_form(m, x, eps)
        test.assertTrue((mt-transform(m, x, t)).simplify_rational().is_zero())
        test.assertTrue(is_fuchsian(mt, x))
        test.assertTrue(is_normalized(mt, x, eps))
        test.assertNotIn(eps, (mt/eps).simplify_rational().variables())
コード例 #5
0
    def assertNormalizeBlocksWorks(test, filename):
        x, eps = SR.var("x eps")

        m = import_matrix_from_file(filename)
        test.assertIn(x, m.variables())
        test.assertIn(eps, m.variables())
        test.assertFalse(is_normalized(m, x, eps))

        m_pranks = singularities(m, x).values()
        test.assertNotEqual(m_pranks, [0] * len(m_pranks))

        m, t, b = block_triangular_form(m)
        mt, tt = reduce_diagonal_blocks(m, x, eps, b=b)
        t = t * tt
        test.assertTrue(
            (mt - transform(m, x, t)).simplify_rational().is_zero())
        test.assertTrue(are_diagonal_blocks_reduced(mt, b, x, eps))
コード例 #6
0
import sage.all

print "Welcome to the Normalize Assistant!"


def print_usage():
    print "Usage:"
    print "  normalize.py <matrix>"


if len(sys.argv) != 2:
    print "invalid arguments: normalize.py needs exactly 1 argument"
    print_usage()
    exit(1)
fname = sys.argv[1]

if not os.path.isfile(fname):
    print "'%s' does not exist or is not a file" % fname
    exit(1)

fuchsia.logger.setLevel(logging.INFO)
m0 = fuchsia.import_matrix_from_file(fname)
x, ep = sage.all.var("x ep")

print "You are normalizing matrix '%s' in (%s, %s)" % (fname, x, ep)

m = fuchsia.FuchsianSystem.from_M(m0, x, ep)
na = fuchsia.NormalizeAssistant(m)
na.start()
コード例 #7
0
 def test_import_matrix_from_file_1(t):
     x, eps = SR.var("x eps")
     m = import_matrix_from_file("test/data/henn_324.m")
     t.assertEqual(set(m.variables()), set([x, eps]))
     t.assertEqual(m, matrix([[eps / x, 0], [-1 / x**2, eps / (x + 1)]]))
コード例 #8
0
ファイル: test_cli.py プロジェクト: lds2/fuchsia
 def assertIsFuchsian(t, m_path, x_name):
     M = fuchsia.import_matrix_from_file(m_path)
     x = SR.var(x_name)
     pranks = fuchsia.singularities(M, x).values()
     t.assertEqual(pranks, [0]*len(pranks))
コード例 #9
0
ファイル: test_cli.py プロジェクト: lds2/fuchsia
 def assertTransformation(t, m1_path, x_name, t_path, m2_path):
     M1 = fuchsia.import_matrix_from_file(m1_path)
     T = fuchsia.import_matrix_from_file(t_path)
     M2 = fuchsia.import_matrix_from_file(m2_path)
     t.assertEqual(M2.simplify_rational(),
             fuchsia.transform(M1, SR.var(x_name), T).simplify_rational())
コード例 #10
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())