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"
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"
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"
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"
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()
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()
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
def leading_index(x, n): for i in range(n): xx = ModVector.random(x) print xx print xx.get_leading_index() print len(xx)
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
def leading_index(x,n): for i in range(n): xx = ModVector.random(x) print xx print xx.get_leading_index() print len(xx)
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
def get_zero_vector(self): dim = self.get_A().get_size()[0] return ModVector.null(dim)