# robertgoss/Logarithmic-differential-forms

1 parent f6b8e1f commit 423c06984a76efbdaecb9060bf5c0773a9ef71b7 committed May 18, 2011
Showing with 68 additions and 64 deletions.
1. +1 −1 examples.py
2. +26 −1 logarithmic_forms.py
3. +17 −3 singular_module.py
4. +0 −57 tests/basis_run_test.py
5. +24 −2 tests/test_examples.py
 @@ -57,7 +57,7 @@ def rand_w_hom_divisor(n,degs=None,mon_num=None,var="z"): poly_ring = PolynomialRing(QQ,n,var) div = poly_ring.zero() min_w = min(degs) - for i in mon_num: + for i in range(mon_num): expo = [0]*n cur_deg = 0 while cur_deg!=deg:
 @@ -35,16 +35,41 @@ class SymbolicNotPolynomialException(Exception): pass -def homogenous_wieghts(divisor): +def _homogenous_wieghts(divisor): hw = singular_module.wieghts(divisor) for w in hw: if w!=0: + degree = sum([w*e_m for w,e_m in zip(hw,divisor.exponents()[0])]) + for ex in divisor.exponents(): + if degree != sum([w*e_m for w,e_m in zip(hw,ex)]): + raise NotWieghtHomogeneousException + return [degree]+hw + raise NotWieghtHomogeneousException + +def _qhhomogenous_wieghts(divisor): + hw = singular_module.qhwieghts(divisor) + for w in hw: + if w!=0: degree = sum([w*e_m for w,e_m in zip(hw,divisor.exponents()[0])]) for ex in divisor.exponents(): if degree != sum([w*e_m for w,e_m in zip(hw,ex)]): raise NotWieghtHomogeneousException return [degree]+hw raise NotWieghtHomogeneousException + +def homogenous_wieghts(divisor): + try: + hom = _qhhomogenous_wieghts(divisor) + for w in hom: + if w!=0: + return hom + raise NotWieghtHomogeneousException + except: + hom = _homogenous_wieghts(divisor) + for w in hom: + if w!=0: + return hom + raise NotWieghtHomogeneousException def _weighted_sum(weights,forms,diff_forms): part = LogarithmicDifferentialForm.make_zero(forms[0].degree,diff_forms)
 @@ -90,12 +90,26 @@ def wieghts(polynomial): ring = p_mod.create_ring_str() p_mod_str = p_mod.create_module_str("p_mod") mat_code = "matrix mat_p = p_mod;\n" - ideal_code = "ideal i_p = mat_p[1,1];\n" - qh_code = "weight(i_p);\n" + ideal_code = "poly d= mat_p[1,1];\n" + qh_code = "weight(d);\n" all_code = ring+p_mod_str+mat_code+ideal_code+qh_code output = _singular_inst.eval(all_code) last_line = output.split("\n")[-1] - return [int(w) for w in last_line.split(",")] + w_vec = [int(w) for w in last_line.split(",")] + return w_vec + +def qhwieghts(polynomial): + p_mod = SingularModule([[polynomial]]) + ring = p_mod.create_ring_str() + p_mod_str = p_mod.create_module_str("p_mod") + mat_code = "matrix mat_p = p_mod;\n" + ideal_code = "poly d= mat_p[1,1];\n" + qh_code = "qhweight(d);\n" + all_code = ring+p_mod_str+mat_code+ideal_code+qh_code + output = _singular_inst.eval(all_code) + last_line = output.split("\n")[-1] + w_vec = [int(w) for w in last_line.split(",")] + return w_vec class SingularModule(SageObject):
 @@ -1,57 +0,0 @@ -#!/usr/local/bin/sage - -import nose - -from logarithmic_forms import LogarithmicDifferentialForms - -from examples import * - -def _crossing_divisor(n): - div = examples.crossing_divisor(n) - logdf = LogarithmicDifferentialForms(div) - logdf.homology("complement") - -def test_crossing_divisor(): - for i in range(2,8): - yield _crossing_divisor, i - -def _braid_divisor(n): - div = examples.braid_divisor(n) - logdf = LogarithmicDifferentialForms(div) - logdf.homology("complement") - -def test_braid_divisor(): - for i in range(2,8): - yield _braid_divisor, i - -def _breiskorn_pham_divisor(n): - div = examples.breiskorn_pham_divisor(n) - logdf = LogarithmicDifferentialForms(div) - logdf.homology("complement") - -def test_breiskorn_pham_divisor(): - for i in range(2,8): - yield _breiskorn_pham_divisor, i - -def _rand_pham_divisor(n): - div = examples.rand_pham_divisor(n) - logdf = LogarithmicDifferentialForms(div) - logdf.homology("complement") - -def test_rand_pham_divisor(): - for i in range(2,8): - for _ in range(20): - yield _rand_pham_divisor, i - -def _rand_w_hom_divisor(): - div = examples.rand_w_hom_divisor(n) - logdf = LogarithmicDifferentialForms(div) - logdf.homology("complement") - -def test_rand_w_hom_divisor(): - for i in range(2,8): - for _ in range(20): - yield _rand_w_hom_divisor, i - -if __name__=="__main__": - nose.main()
 @@ -12,7 +12,7 @@ def _crossing_divisor(n): logdf.homology("complement") def test_crossing_divisor(): - for i in range(2,7): + for i in range(2,8): yield _crossing_divisor, i def _braid_divisor(n): @@ -32,5 +32,27 @@ def _breiskorn_pham_divisor(n): logdf.homology("complement") def test_breiskorn_pham_divisor(): - for i in range(2,6): + for i in range(2,7): yield _breiskorn_pham_divisor, i + +def _rand_pham_divisor(n): + print "Breiskorn Pham Divisor: ",n + div = examples.rand_pham_divisor(n) + logdf = LogarithmicDifferentialForms(div) + logdf.homology("complement") + +def test_rand_pham_divisor(): + for i in range(2,7): + for _ in range(15): + yield _rand_pham_divisor, i + +def _rand_w_hom_divisor(n): + print "Breiskorn Pham Divisor: ",n + div = examples.rand_w_hom_divisor(n) + logdf = LogarithmicDifferentialForms(div) + logdf.homology("complement") + +def test_rand_w_hom_divisor(): + for i in range(2,7): + for _ in range(15): + yield _rand_w_hom_divisor, i