def make_map(self, i):
        """
        make matrices in all given bidegrees

        this needs a map defined on CobarMonomial objects

        does this handle 0 dim vector spaces? 

        this is a huge timesink. try to do multiprocessing,
        check methods for too much simplification
        """
        dom = self.get_cplx()[i]
        rng = self.get_cplx()[i + 1]
        for bideg in dom._dict.keys():
            out = []
            dom_basis = dom._dict[bideg]
            cols = len(dom_basis)
            try:
                rng_basis = rng._dict[bideg]
                rows = len(rng_basis)
            except KeyError:
                rng._dict[bideg] = []
                rows = 0
                if cols == 0:
                    # we must account for this later!
                    cols = 1
                #print "bideg in make maps",bideg
                dom._maps[bideg] = ModMatrix.null(1, cols)
                continue
            if cols == 0:
                cols = 1
                if rows == 0:
                    rows = 1
                #print "bideg in make maps. somethings 0", bideg
                dom._maps[bideg] = ModMatrix.null(rows, cols)
                continue
            for mon in dom_basis:
                value = mon._map_reduced()
                vect = self.vector_from_element(value, i + 1, bideg[0],
                                                bideg[1])
                out.append(vect)
            matrix = ModMatrix(out).get_transpose()
            print " Made matrix: i, bideg, size", i, bideg, matrix.get_size()
            dom._maps[bideg] = matrix
    def make_map(self, i):
        """
        make matrices in all given bidegrees

        this needs a map defined on CobarMonomial objects

        does this handle 0 dim vector spaces? 

        this is a huge timesink. try to do multiprocessing,
        check methods for too much simplification
        """
        dom = self.get_cplx()[i]
        rng = self.get_cplx()[i+1]
        for bideg in dom._dict.keys():
            out = []
            dom_basis = dom._dict[bideg]
            cols = len(dom_basis)
            try:
                rng_basis = rng._dict[bideg]
                rows = len(rng_basis)
            except KeyError:
                rng._dict[bideg] = []
                rows = 0
                if cols == 0:
                    # we must account for this later!
                    cols = 1
                #print "bideg in make maps",bideg
                dom._maps[bideg] = ModMatrix.null(1,cols)
                continue
            if cols == 0:
                cols = 1
                if rows == 0:
                    rows = 1
                #print "bideg in make maps. somethings 0", bideg
                dom._maps[bideg] = ModMatrix.null(rows, cols)
                continue
            for mon in dom_basis:
                value = mon._map_reduced()
                vect = self.vector_from_element(value, i+1, bideg[0],
                                                bideg[1])
                out.append(vect)
            matrix = ModMatrix(out).get_transpose()
            print " Made matrix: i, bideg, size", i, bideg, matrix.get_size()
            dom._maps[bideg] = matrix 
    def make_cohomology(self, filt, deg, wt):
        """
        returns a cohomology object corr. to filt, deg, wt
        #Returns 0 cohomology object if deg, wt doesn't appera

        THIS MUTATES ._maps and ._dict IF NECESSARY!
        """
        cplx = self.get_maps()
        if filt == 0:
            return "you know what this is!"
        try:
            #this checks to make sure cohom is non-zero here
            B = cplx[filt]._maps[(deg, wt)]
            B_basis = cplx[filt]._dict[(deg, wt)]
        except KeyError:
            if deg <= opts.bounds:
                return Cohomology(ModMatrix.identity(1), \
                                  ModMatrix.null(1,1))
            else:
                print filt, deg, wt
                raise TypeError("We aren't computing that far!")
        try:
            #this checks to see if incoming map is 0 or not
            A_basis = cplx[filt - 1]._dict[(deg, wt)]
            A = cplx[filt - 1]._maps[(deg, wt)]
        except KeyError:
            A = ModMatrix.null(len(B_basis), 1)
            A_basis = []
            cplx[filt - 1]._maps[(deg, wt)] = A
            cplx[filt - 1]._dict[(deg, wt)] = []
            # We must now check dimensions of A_basis and B_basis
            # to account for 0 diml vspaces
        if len(B_basis) == 0:
            #this means cohom is 0 diml
            #resulting cohom object will not match up with vect/elt
            #translation
            A = ModMatrix.null(1, 1)
            B = ModMatrix.identity(1)
        elif not B.row_count:
            #print "B has no rows"
            B = ModMatrix.null(1, len(B_basis))
        cohom = Cohomology(B, A)
        self.cohomology[filt][(deg, wt)] = cohom
    def make_cohomology(self, filt, deg, wt):
        """
        returns a cohomology object corr. to filt, deg, wt
        #Returns 0 cohomology object if deg, wt doesn't appera

        THIS MUTATES ._maps and ._dict IF NECESSARY!
        """
        cplx = self.get_maps()
        if filt == 0:
            return "you know what this is!"
        try:
            #this checks to make sure cohom is non-zero here
            B = cplx[filt]._maps[(deg, wt)]
            B_basis = cplx[filt]._dict[(deg, wt)]
        except KeyError:
            if deg <= opts.bounds:
                return Cohomology(ModMatrix.identity(1), \
                                  ModMatrix.null(1,1))
            else:
                print filt, deg, wt
                raise TypeError("We aren't computing that far!")
        try:
            #this checks to see if incoming map is 0 or not
            A_basis = cplx[filt - 1]._dict[(deg, wt)]
            A = cplx[filt - 1]._maps[(deg, wt)]
        except KeyError:
            A = ModMatrix.null(len(B_basis), 1)
            A_basis = []
            cplx[filt - 1]._maps[(deg, wt)] = A
            cplx[filt - 1]._dict[(deg, wt)] = []
            # We must now check dimensions of A_basis and B_basis
            # to account for 0 diml vspaces
        if len(B_basis) == 0:
            #this means cohom is 0 diml
            #resulting cohom object will not match up with vect/elt
            #translation
            A = ModMatrix.null(1,1)
            B = ModMatrix.identity(1)
        elif not B.row_count:
            #print "B has no rows"
            B = ModMatrix.null(1, len(B_basis))
        cohom = Cohomology(B, A)
        self.cohomology[filt][(deg,wt)] = cohom
Beispiel #5
0
 def extend_ker_basis(self):
     ker_basis = self.get_kernel().get_basis()
     #assuming vectors are bit vectors
     if not ker_basis:
         C = ModMatrix.null(1, self.B.col_count)
     else:
         C = ModMatrix(ker_basis)
     comp = C.complement_row_space()
     tot = ker_basis[:] + comp[:]
     self.extended_ker_basis = tot
     self.extended_ker_basis_flag = True