def test_singularities(self): S1 = sympify(singularities(f1,x,y)) S2 = sympify(singularities(f2,x,y)) S3 = sympify(singularities(f3,x,y)) S4 = sympify(singularities(f4,x,y)) S5 = sympify(singularities(f5,x,y)) S6 = sympify(singularities(f6,x,y)) # S7 = sympify(singularities(f7,x,y)) # S8 = sympify(singularities(f8,x,y)) S9 = sympify(singularities(f9,x,y)) S10= sympify(singularities(f10,x,y)) rt5 = sympy.roots(x**2 + 1, x).keys() S1act = sympify([ ((0,0,1),(2,2,1)), ((0,1,0),(2,1,2)) ]) S2act = sympify([ ((0,0,1),(3,4,2)), ((0,1,0),(4,9,1)) ]) S3act = sympify([ ((0,0,1),(2,1,2)), ((1,-1,1),(2,1,2)), ((1,1,1),(2,1,2)) ]) S4act = sympify([ ((0,0,1),(2,1,2)) ]) S5act = sympify([ ((0,0,1),(3,3,3)), ((1,rt5[1],0),(3,3,3)), ((1,rt5[0],0),(3,3,3)) ]) S6act = sympify([ ((0,0,1),(2,2,2)), ((1,0,0),(2,2,2)) ]) # S7act = sympify([((0,1,0),(3,6,3))]) # S8act = sympify([ # ((0,1,0),(6,21,3)), # ((1,0,0),(3,7,2)) # ]) S9act = sympify([((0,1,0),(5,12,1))]) S10act= sympify([ ((0,1,0),(3,6,1)), ((1,0,0),(4,6,4)) ]) self.assertItemsEqual(S1,S1act) self.assertItemsEqual(S2,S2act) self.assertItemsEqual(S3,S3act) self.assertItemsEqual(S4,S4act) self.assertItemsEqual(S5,S5act) self.assertItemsEqual(S6,S6act) # self.assertItemsEqual(S7,S7act) # self.assertItemsEqual(S8,S8act) self.assertItemsEqual(S9,S9act) self.assertItemsEqual(S10,S10act)
def test_f8(self): s = singularities(self.f8) s_actual = [ ((1, 0, 0), (5, 14, 1)), ((0, 1, 0), (2, 4, 2)), ] self.assertEqual(s, s_actual)
def test_f2(self): s = singularities(self.f2) s_actual = [ ((0, 0, 1), (3, 4, 2)), ((0, 1, 0), (4, 9, 1)), ] self.assertEqual(s, s_actual)
def test_issue71(self): R = QQ['x,y'] x,y = R.gens() f = -x**5 + x + y**3 s = singularities(f) s_actual = [((0,1,0),(2,2,1))] self.assertEqual(s,s_actual)
def test_f10(self): s = singularities(self.f10) s_actual = [ ((1,0,0),(4,6,4)), ((0,1,0),(3,6,1)), ] self.assertEqual(s,s_actual)
def test_f10(self): s = singularities(self.f10) s_actual = [ ((1, 0, 0), (4, 6, 4)), ((0, 1, 0), (3, 6, 1)), ] self.assertEqual(s, s_actual)
def test_f8(self): s = singularities(self.f8) s_actual = [ ((1,0,0),(5,14,1)), ((0,1,0),(2,4,2)), ] self.assertEqual(s,s_actual)
def test_issue71(self): R = QQ['x,y'] x, y = R.gens() f = -x**5 + x + y**3 s = singularities(f) s_actual = [((0, 1, 0), (2, 2, 1))] self.assertEqual(s, s_actual)
def test_f6(self): s = singularities(self.f6) s_actual = [ ((0,0,1),(2,2,2)), ((1,0,0),(2,2,2)), ] self.assertEqual(s,s_actual)
def test_f6(self): s = singularities(self.f6) s_actual = [ ((0, 0, 1), (2, 2, 2)), ((1, 0, 0), (2, 2, 2)), ] self.assertEqual(s, s_actual)
def test_f2(self): s = singularities(self.f2) s_actual = [ ((0,0,1),(3,4,2)), ((0,1,0),(4,9,1)), ] self.assertEqual(s,s_actual)
def test_f3(self): s = singularities(self.f3) s_actual = [ ((0,0,1),(2,1,2)), ((1,-1,1),(2,1,2)), ((1,1,1),(2,1,2)), ] self.assertEqual(s,s_actual)
def test_f3(self): s = singularities(self.f3) s_actual = [ ((0, 0, 1), (2, 1, 2)), ((1, -1, 1), (2, 1, 2)), ((1, 1, 1), (2, 1, 2)), ] self.assertEqual(s, s_actual)
def differentials_numerators(f): """Return the numerators of a basis of holomorphic differentials on a Riemann surface. Parameters ---------- f : plane algebraic curve Returns ------- differentials : list A list of :class:`Differential`s representing *a* basis of Abelian differentials of the first kind. """ # homogenize and compute total degree R = f.parent().change_ring(QQbar) x,y = R.gens() d = f.total_degree() # construct the generalized adjoint polynomial. we want to think of it as # an element of B[*c][x,y] where B is the base ring of f and *c are the # indeterminates cvars = ['c_%d_%d'%(i,j) for i in range(d-2) for j in range(d-2)] vars = list(R.variable_names()) + cvars C = PolynomialRing(QQbar, cvars) S = PolynomialRing(C, [x,y]) T = PolynomialRing(QQbar, vars) c = S.base_ring().gens() x,y = S(x),S(y) P = sum(c[j+(d-2)*i] * x**i * y**j for i in range(d-2) for j in range(d-2) if i+j <= d-3) # for each singular point [x:y:z] = [alpha:beta:gamma], map f onto the # "most convenient and appropriate" affine subspace, (u,v), and center at # u=0. determine the conditions on P singular_points = singularities(f) conditions = [] for singular_point, _ in singular_points: # recenter the curve and adjoint polynomial at the singular point: find # the affine plane u,v such that the singularity occurs at u=0 g = recenter_curve(f, singular_point) Ptilde = recenter_curve(P, singular_point) # compute the intergral basis at the recentered singular point # and determine the Mnuk conditions of the adjoint polynomial b = integral_basis(g) for bi in b: conditions_bi = mnuk_conditions(g, bi, Ptilde) conditions.extend(conditions_bi) # reduce the general adjoint modulo the ideal generated by the integral # basis conditions. the coefficients of the remaining c_ij's form the # numerators of a basis of abelian differentials of the first kind. # # additionally, we try to coerce the conditions to over QQ for speed. it's # questionable in this situation whether there is a noticible performance # gain but it does suppress the "slow toy implementation" warning. try: T = T.change_ring(QQ) ideal = T.ideal(conditions) basis = ideal.groebner_basis() except: pass ideal = T.ideal(conditions) basis = ideal.groebner_basis() P_reduced = P(T(x), T(y)) if basis != [0]: P_reduced = P_reduced.reduce(basis) U = R[S.base_ring().variable_names()] args = [U(x),U(y)] + [U(ci) for ci in c] Pc = P_reduced(*args) numerators = Pc.coefficients() return numerators
def test_f4(self): s = singularities(self.f4) s_actual = [((0,0,1),(2,1,2))] self.assertEqual(s,s_actual)
def differentials_numerators(f): """Return the numerators of a basis of holomorphic differentials on a Riemann surface. Parameters ---------- f : plane algebraic curve Returns ------- differentials : list A list of :class:`Differential`s representing *a* basis of Abelian differentials of the first kind. """ # homogenize and compute total degree R = f.parent().change_ring(QQbar) x,y = R.gens() d = f.total_degree() # construct the generalized adjoint polynomial. we want to think of it as # an element of B[*c][x,y] where B is the base ring of f and *c are the # indeterminates cvars = ['c_%d_%d'%(i,j) for i in range(d-2) for j in range(d-2)] vars = list(R.variable_names()) + cvars C = PolynomialRing(QQbar, cvars) S = PolynomialRing(C, [x,y]) T = PolynomialRing(QQbar, vars) c = S.base_ring().gens() x,y = S(x),S(y) P = sum(c[j+(d-2)*i] * x**i * y**j for i in range(d-2) for j in range(d-2) if i+j <= d-3) # for each singular point [x:y:z] = [alpha:beta:gamma], map f onto the # "most convenient and appropriate" affine subspace, (u,v), and center at # u=0. determine the conditions on P singular_points = singularities(f) conditions = [] for singular_point, _ in singular_points: # recenter the curve and adjoint polynomial at the singular point: find # the affine plane u,v such that the singularity occurs at u=0 g = recenter_curve(f, singular_point) Ptilde = recenter_curve(P, singular_point) # compute the intergral basis at the recentered singular point # and determine the Mnuk conditions of the adjoint polynomial b = integral_basis(g) for bi in b: conditions_bi = mnuk_conditions(g, bi, Ptilde) conditions.extend(conditions_bi) # reduce the general adjoint modulo the ideal generated by the integral # basis conditions. the coefficients of the remaining c_ij's form the # numerators of a basis of abelian differentials of the first kind. # # additionally, we try to coerce the conditions to over QQ for speed. it's # questionable in this situation whether there is a noticible performance # gain but it does suppress the "slow toy implementation" warning. try: T = T.change_ring(QQ) ideal = T.ideal(conditions) basis = ideal.groebner_basis() except: pass ideal = T.ideal(conditions) basis = ideal.groebner_basis() P_reduced = P(T(x), T(y)) if basis != [0]: P_reduced = P_reduced.reduce(basis) U = R[S.base_ring().variable_names()] args = [U(x),U(y)] + [U(ci) for ci in c] Pc = P_reduced(*args) numerators = Pc.coefficients() return numerators
def test_f7(self): s = singularities(self.f7) s_actual = [((0,1,0),(3,6,3))] self.assertEqual(s,s_actual)
def test_f9(self): s = singularities(self.f9) s_actual = [((0,1,0),(5,12,1))] self.assertEqual(s,s_actual)
def test_f9(self): s = singularities(self.f9) s_actual = [((0, 1, 0), (5, 12, 1))] self.assertEqual(s, s_actual)
def test_f4(self): s = singularities(self.f4) s_actual = [((0, 0, 1), (2, 1, 2))] self.assertEqual(s, s_actual)
def test_f7(self): s = singularities(self.f7) s_actual = [((0, 1, 0), (3, 6, 3))] self.assertEqual(s, s_actual)