def _complex_relative(self,n,*args):
   if len(args)==2:
     complex = []
     for i in range(args[0],args[1]):
       complex.append(self._complex_relative(n,i))
     return complex
   if n<0 or n>self.poly_ring.ngens():
     return []
   if n==0:
     hom_basis = self._p_graded_module(n).homogeneous_part_basis(self.degree+args[0])
     return [LogarithmicDifferentialForm(n,b,self) for b in hom_basis]
   base = self._p_graded_module(n).homogeneous_part_basis(self.degree+args[0])
   if len(base)==0:
     return []
   vs_base = VectorSpace(QQ,len(base))
   df_base = [LogarithmicDifferentialForm(n,b,self) for b in base]
   pre_base = self._p_graded_module(n-1).homogeneous_part_basis(self.degree+args[0])
   if len(pre_base)==0:
     return df_base
   dh = [self.divisor.derivative(g) for g in self.poly_ring.gens()]
   dh = LogarithmicDifferentialForm(1,dh,self)
   rel_gens = []
   for b in pre_base:
     b_form = LogarithmicDifferentialForm(n-1,b,self)
     w = dh.wedge(b_form)
     rel_gens.append(lift_to_basis([w],df_base))
   rel = vs_base.subspace(rel_gens)
   comp = orth_complement(vs_base,rel)
   #Lift
   rel_complex = []
   for vec in comp.basis():
     rel_complex.append(_weighted_sum(vec,df_base,self))
   return rel_complex
 def test_derivative(self):
   x = self.x
   y = self.y
   z = self.z
   logdf = LogarithmicDifferentialForm(1,[y*z,x*z,x*y],self.normal_logdf)
   form = DifferentialForm(self.normal_logdf.form_space,2)
   logdf_der = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue(logdf_der.equals(logdf.derivative()))
 def test_interior_0_form(self):
   x = self.x
   y = self.y
   z = self.z
   logdf = LogarithmicDifferentialForm(0,[x*y-y*z+x**2-z**2+x*x-y*z],self.normal_logdf)
   int_product = logdf.interior_product()
   zero = LogarithmicDifferentialForm.make_zero(0,self.normal_logdf)
   self.assertTrue(int_product.equals(zero))
Ejemplo n.º 4
0
 def test_interior_0_form(self):
     x = self.x
     y = self.y
     z = self.z
     logdf = LogarithmicDifferentialForm(
         0, [x * y - y * z + x**2 - z**2 + x * x - y * z],
         self.normal_logdf)
     int_product = logdf.interior_product()
     zero = LogarithmicDifferentialForm.make_zero(0, self.normal_logdf)
     self.assertTrue(int_product.equals(zero))
Ejemplo n.º 5
0
 def test_derivative(self):
     x = self.x
     y = self.y
     z = self.z
     logdf = LogarithmicDifferentialForm(1, [y * z, x * z, x * y],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     logdf_der = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf_der.equals(logdf.derivative()))
 def test_interior_1_form(self):
   x = self.normal_logdf.form_vars[0]
   y = self.normal_logdf.form_vars[1]
   z = self.normal_logdf.form_vars[2]
   form = DifferentialForm(self.normal_logdf.form_space,0,(x+y+z)/(x*y*z))
   one = self.poly_ring.one()
   logdf = LogarithmicDifferentialForm(1,[one,one,one],self.normal_logdf)
   int_product = logdf.interior_product()
   logdf_form = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue(int_product.equals(logdf_form))
 def test_create_from_0_form(self):
   x = self.normal_logdf.form_vars[0]
   y = self.normal_logdf.form_vars[1]
   z = self.normal_logdf.form_vars[2]
   xp = self.x
   yp = self.y
   zp = self.z
   logdf = LogarithmicDifferentialForm(0,[xp+yp+zp],self.normal_logdf)
   form = DifferentialForm(self.normal_logdf.form_space,0,(x+y+z)/(x*y*z))
   logdf_form = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue(logdf.equals(logdf_form))
 def test_wedge(self):
   x = self.normal_logdf.form_vars[0]
   y = self.normal_logdf.form_vars[1]
   z = self.normal_logdf.form_vars[2]
   norm = self.x*self.y*self.z
   logdfA = LogarithmicDifferentialForm(1,[self.x*norm,self.y*norm,self.z*norm],self.normal_logdf)
   logdfB = LogarithmicDifferentialForm(1,[self.z,self.y,self.x],self.normal_logdf)
   form = DifferentialForm(self.normal_logdf.form_space,2)
   form[0,1] = 1/z - 1/x
   form[0,2] = (x/(y*z)) - (z/(x*y))
   form[1,2] = 1/z - 1/x
   logdf_wedge = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue(logdf_wedge.equals(logdfA.wedge(logdfB)))
Ejemplo n.º 9
0
 def test_interior_1_form(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     form = DifferentialForm(self.normal_logdf.form_space, 0,
                             (x + y + z) / (x * y * z))
     one = self.poly_ring.one()
     logdf = LogarithmicDifferentialForm(1, [one, one, one],
                                         self.normal_logdf)
     int_product = logdf.interior_product()
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(int_product.equals(logdf_form))
Ejemplo n.º 10
0
 def test_create_from_0_form(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     xp = self.x
     yp = self.y
     zp = self.z
     logdf = LogarithmicDifferentialForm(0, [xp + yp + zp],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 0,
                             (x + y + z) / (x * y * z))
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf.equals(logdf_form))
 def test_create_from_form(self):
   x = self.normal_logdf.form_vars[0]
   y = self.normal_logdf.form_vars[1]
   z = self.normal_logdf.form_vars[2]
   xp = self.x
   yp = self.y
   zp = self.z
   logdf = LogarithmicDifferentialForm(2,[xp*yp-yp*zp,xp**2-zp**2,xp*yp-yp*zp],self.normal_logdf)
   form = DifferentialForm(self.normal_logdf.form_space,2)
   form[0,1] = 1/z - 1/x
   form[0,2] = (x/(y*z)) - (z/(x*y))
   form[1,2] = 1/z - 1/x
   logdf_form = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue(logdf.equals(logdf_form))
Ejemplo n.º 12
0
 def test_mul(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     logdf = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = -5 / (y * z)
     form[0, 2] = -5 / (x * z)
     form[1, 2] = -5 / (x * y)
     self.assertTrue((logdf * (-5)).equals((-5) * logdf))
     logdf_mul = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue((-5 * logdf).equals(logdf_mul))
Ejemplo n.º 13
0
 def test_sub(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     logdfA = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                          self.normal_logdf)
     logdfB = LogarithmicDifferentialForm(2, [self.z, self.y, self.x],
                                          self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / (y * z) - 1 / (x * y)
     form[0, 2] = 0
     form[1, 2] = 1 / (x * y) - 1 / (y * z)
     logdf_diff = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf_diff.equals(logdfA - logdfB))
 def _compute_p_form_generators(self,p):
   if p==0:
     self._p_modules[0] = SingularModule([[self.divisor]])
     self._p_gens[0] = [LogarithmicDifferentialForm(0,[self.divisor],self)]
     return
   n = self.poly_ring.ngens()
   if p==n:
     self._p_modules[n] = SingularModule([[self.poly_ring.one()]])
     self._p_gens[n] = [LogarithmicDifferentialForm(0,[self.poly_ring.one()],self)]
     return
   if p > n:
     return
   if p==1:
     self._compute_1_form_generators()
   else:
     if not 1 in self._p_modules.keys():
       self._compute_1_form_generators()
     #compute wedges of 1 forms
     self._p_gens[p] = []
     for s in Set(range(len(self._p_gens[1]))).subsets(p):
       p_form = LogarithmicDifferentialForm.make_unit(self)
       for i in s:
         p_form = p_form.wedge(self._p_gens[1][i])
       self._p_gens[p].append(p_form)
     gens = []
     for p_form in self._p_gens[p]:
       gens.append(p_form.vec)
     self._p_modules[p] = SingularModule(gens)
     self._p_modules[p].reduce_generators()
 def test_interior(self):
   xp = self.x
   yp = self.y
   zp = self.z
   logdf = LogarithmicDifferentialForm(2,[xp**2,xp+4*yp+zp,xp**3*zp**3],self.whitney_logdf)
   int_product = logdf.interior_product()
   x = self.normal_logdf.form_vars[0]
   y = self.normal_logdf.form_vars[1]
   z = self.normal_logdf.form_vars[2]
   whitney = x**2*y - z**2
   form = DifferentialForm(self.normal_logdf.form_space,1)
   form[0] = (-2*x**2*y-2*x*z-8*y*z-2*z**2)/whitney
   form[1] = (x**3-2*x**3*z**4)/whitney
   form[2] = (x**2+4*x*y+x*z+2*x**3*y*z**3)/whitney
   logdf_form = LogarithmicDifferentialForm.create_from_form(form,self.whitney_logdf)
   self.assertTrue(int_product.equals(logdf_form))
 def homology(self,varient="complement",*args):
   hom = {}
   cc = self.chain_complex(varient,(-1,self.poly_ring.ngens()+1),*args)
   #Some need wider return range
   for i in range(self.poly_ring.ngens()+1):
     vs_am = VectorSpace(QQ,len(cc[i]))
     if len(cc[i])==0:
       hom[i] = []
       continue
     if len(cc[i-1])!=0:
       d_im = []
       for b in cc[i-1]:
         d_b = self.differential(b,varient,*args)
         d_im.append(lift_to_basis(d_b,cc[i]))
       img = vs_am.subspace(d_im)
     else:
       img = vs_am.subspace([vs_am.zero()])
     if len(cc[i+1])!=0:
       d_ker = []
       for b in cc[i]:
         d_b = self.differential(b,varient,*args)
         d_ker.append(lift_to_basis(d_b,cc[i+1]))
       ker = (matrix(QQ,d_ker)).left_kernel()
     else:
       ker = vs_am
     quo = ker.quotient(img)
     hom[i] = []
     for b in quo.basis():
       vec = quo.lift(b)
       part_sum = LogarithmicDifferentialForm.make_zero(i,self)
       for c,f in zip(vec,cc[i]):
         part_sum = part_sum + c*f
       hom[i].append(part_sum)
   return hom
Ejemplo n.º 17
0
 def test_wedge(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     norm = self.x * self.y * self.z
     logdfA = LogarithmicDifferentialForm(
         1, [self.x * norm, self.y * norm, self.z * norm],
         self.normal_logdf)
     logdfB = LogarithmicDifferentialForm(1, [self.z, self.y, self.x],
                                          self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / z - 1 / x
     form[0, 2] = (x / (y * z)) - (z / (x * y))
     form[1, 2] = 1 / z - 1 / x
     logdf_wedge = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf_wedge.equals(logdfA.wedge(logdfB)))
Ejemplo n.º 18
0
 def test_create_from_form(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     xp = self.x
     yp = self.y
     zp = self.z
     logdf = LogarithmicDifferentialForm(
         2, [xp * yp - yp * zp, xp**2 - zp**2, xp * yp - yp * zp],
         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / z - 1 / x
     form[0, 2] = (x / (y * z)) - (z / (x * y))
     form[1, 2] = 1 / z - 1 / x
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf.equals(logdf_form))
Ejemplo n.º 19
0
 def test_interior(self):
     xp = self.x
     yp = self.y
     zp = self.z
     logdf = LogarithmicDifferentialForm(
         2, [xp**2, xp + 4 * yp + zp, xp**3 * zp**3], self.whitney_logdf)
     int_product = logdf.interior_product()
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     whitney = x**2 * y - z**2
     form = DifferentialForm(self.normal_logdf.form_space, 1)
     form[0] = (-2 * x**2 * y - 2 * x * z - 8 * y * z - 2 * z**2) / whitney
     form[1] = (x**3 - 2 * x**3 * z**4) / whitney
     form[2] = (x**2 + 4 * x * y + x * z + 2 * x**3 * y * z**3) / whitney
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.whitney_logdf)
     self.assertTrue(int_product.equals(logdf_form))
Ejemplo n.º 20
0
 def test_creationA(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     logdf = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / (y * z)
     form[0, 2] = 1 / (x * z)
     form[1, 2] = 1 / (x * y)
     self.assertEqual(form, logdf.form)
Ejemplo n.º 21
0
 def test_creation_B(self):
     x = self.whitney_logdf.form_vars[0]
     y = self.whitney_logdf.form_vars[1]
     z = self.whitney_logdf.form_vars[2]
     whitney = x**2 * y - z**2
     logdf = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                         self.whitney_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = x / whitney
     form[0, 2] = y / whitney
     form[1, 2] = z / whitney
     self.assertEqual(form, logdf.form)
 def test_mul(self):
   x = self.normal_logdf.form_vars[0]
   y = self.normal_logdf.form_vars[1]
   z = self.normal_logdf.form_vars[2]
   logdf = LogarithmicDifferentialForm(2,[self.x,self.y,self.z],self.normal_logdf)
   form = DifferentialForm(self.normal_logdf.form_space,2)
   form[0,1] = -5/(y*z)
   form[0,2] = -5/(x*z)
   form[1,2] = -5/(x*y)
   self.assertTrue((logdf*(-5)).equals((-5)*logdf))
   logdf_mul = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue((-5*logdf).equals(logdf_mul))
 def test_sub(self):
   x = self.normal_logdf.form_vars[0]
   y = self.normal_logdf.form_vars[1]
   z = self.normal_logdf.form_vars[2]
   logdfA = LogarithmicDifferentialForm(2,[self.x,self.y,self.z],self.normal_logdf)
   logdfB = LogarithmicDifferentialForm(2,[self.z,self.y,self.x],self.normal_logdf)
   form = DifferentialForm(self.normal_logdf.form_space,2)
   form[0,1] = 1/(y*z) - 1/(x*y)
   form[0,2] = 0
   form[1,2] = 1/(x*y) - 1/(y*z)
   logdf_diff = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue(logdf_diff.equals(logdfA-logdfB))
Ejemplo n.º 24
0
 def test_unit(self):
     one = LogarithmicDifferentialForm.make_unit(self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 0, 1)
     one_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(one.equals(one_form))
Ejemplo n.º 25
0
 def test_zero_p(self):
     size = [1, 3, 3, 1]
     for s, i in zip(size, range(4)):
         zero = LogarithmicDifferentialForm.make_zero(i, self.normal_logdf)
         zero_vec = [self.normal_logdf.poly_ring.zero() for _ in range(s)]
         self.assertEqual(zero.vec, zero_vec)
 def test_zero_p(self):
   size = [1,3,3,1]
   for s,i in zip(size,range(4)):
     zero = LogarithmicDifferentialForm.make_zero(i,self.normal_logdf)
     zero_vec = [self.normal_logdf.poly_ring.zero() for _ in range(s)]
     self.assertEqual(zero.vec,zero_vec)
 def test_unit(self):
   one = LogarithmicDifferentialForm.make_unit(self.normal_logdf)
   form = DifferentialForm(self.normal_logdf.form_space,0,1)
   one_form = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
   self.assertTrue(one.equals(one_form))
def _weighted_sum(weights,forms,diff_forms):
  part = LogarithmicDifferentialForm.make_zero(forms[0].degree,diff_forms)
  for w,f in zip(weights,forms):
    part = part + w*f
  return part
Ejemplo n.º 29
0
 def test_creation_0_form(self):
     z = self.normal_logdf.form_vars[2]
     logdf = LogarithmicDifferentialForm(0, [self.x * self.y],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 0, 1 / z)
     self.assertEqual(form, logdf.form)