示例#1
0
def vector_mul(x,n):
    for i in range(n):
        xx = ModVector.random(x)
        yy = ModVector.random(x)
        print xx
        print yy
        print xx * yy, "\n"
示例#2
0
def vector_mul(x, n):
    for i in range(n):
        xx = ModVector.random(x)
        yy = ModVector.random(x)
        print xx
        print yy
        print xx * yy, "\n"
示例#3
0
def append_test(x, y, n):
    for i in range(n):
        AA = ModMatrix.random(x, y)
        zz = ModVector.random(x)
        print "AA\n", AA, "\n"
        print "zz\n", zz, "\n"
        print "append\n", AA.get_append_columns([zz, zz + zz]), "\n"
示例#4
0
def append_test(x,y,n):
    for i in range(n):
        AA = ModMatrix.random(x,y)
        zz = ModVector.random(x)
        print "AA\n", AA, "\n"
        print "zz\n", zz, "\n"
        print "append\n", AA.get_append_columns([zz,zz + zz]), "\n"
示例#5
0
def solve_test(x, y, n):
    for i in range(n):
        AA = ModMatrix.random(x, y)
        bb = ModVector.random(x)
        print AA.can_solve(bb)
        xx = AA.solve(bb)
        print "A\n", AA, "\n"
        print "rrefA\n", AA.get_rref(), "\n"
        print "b\n", bb, "\n"
        print "x\n", xx, "\n"
        print "Ax\n", AA * xx
        print AA * xx == ModMatrix([bb]).get_transpose()
示例#6
0
def solve_test(x,y,n):
    for i in range(n):
        AA = ModMatrix.random(x,y)
        bb = ModVector.random(x)
        print AA.can_solve(bb)
        xx = AA.solve(bb)
        print "A\n",  AA, "\n"
        print "rrefA\n", AA.get_rref(), "\n"
        print "b\n", bb, "\n"
        print "x\n", xx, "\n"
        print "Ax\n", AA * xx
        print AA * xx == ModMatrix([bb]).get_transpose()
示例#7
0
    def vector_from_element(self, elt, filt, deg, wt):
        """returns vector in standard basis as determined by the
        generate_modules algorithm corr. to elt.

        may need to add in a case to handle 0 elements
        """
        elt.simplify()
        try:
            basis = self.get_cplx()[filt]._dict[(deg, wt)]
        except KeyError:
            print elt
            print filt, (deg, wt)
            raise KeyError("Elt does not appear in complex!")
        vect = ModVector.null(len(basis))
        for i in range(len(basis)):
            mon = basis[i]
            vect[i] = elt.monomial_coefficient(mon)
        return vect
示例#8
0
    def vector_from_element(self, elt, filt, deg, wt):
        """returns vector in standard basis as determined by the
        generate_modules algorithm corr. to elt.

        may need to add in a case to handle 0 elements
        """
        elt.simplify()
        try:
            basis = self.get_cplx()[filt]._dict[(deg, wt)]
        except KeyError:
            print elt
            print filt, (deg, wt)
            raise KeyError("Elt does not appear in complex!")
        vect = ModVector.null(len(basis))
        for i in range(len(basis)):
            mon = basis[i]
            vect[i] = elt.monomial_coefficient(mon)
        return vect
示例#9
0
def leading_index(x, n):
    for i in range(n):
        xx = ModVector.random(x)
        print xx
        print xx.get_leading_index()
        print len(xx)
示例#10
0
def scalar_mul(x, n):
    for i in range(n):
        xx = ModVector.random(x)
        aa = random.randrange(opts.prime)
        print aa, xx
        print aa * xx
示例#11
0
def leading_index(x,n):
    for i in range(n):
        xx = ModVector.random(x)
        print xx
        print xx.get_leading_index()
        print len(xx)
示例#12
0
def scalar_mul(x,n):
    for i in range(n):
        xx = ModVector.random(x)
        aa = random.randrange(opts.prime)
        print aa,  xx
        print aa * xx
示例#13
0
 def get_zero_vector(self):
     dim = self.get_A().get_size()[0]
     return ModVector.null(dim)