Esempio n. 1
0
 def compute_cohomology(self):
     cohomology = ModVectorSpace([])
     ##### Tweak to check dimension before working
     if not self.get_cohomology_dim():
         self.cohomology = cohomology
         self.cohomology_flag = True
         return
     #####
     index_list = self.get_kernel().get_basis()[:]
     basis_list = []
     for ker_element in index_list:
         if not self.in_cohomology_subspace(basis_list, ker_element):
             basis_list.append(ker_element)
     cohomology.add_basis_element(basis_list)
     self.cohomology = cohomology
     if (self.get_B().col_count - self.get_B().get_rank() 
         - self.get_A().get_rank() != len(cohomology.get_basis())):
         print "A"
         print self.get_A()
         print "B"
         print self.get_B()
         print "rank A"
         print self.get_A().get_rank()
         print "nullity B"
         print self.get_B().col_count - self.get_B().get_rank() 
         print "basis for cohomology"
         for thing in cohomology.get_basis():
             print thing
         raise TypeError("cohomology basis computation incorrect!")
     self.cohomology_flag = True