Пример #1
0
 def _randomele1(self):
     """
     Return a reduced random form with the given discriminant.
     """
     while True:
         nextp = prime.nextPrime(self.cnt)
         self.cnt += 1
         if kronecker(self.disc, nextp) == 1:
             nxtfm = sqroot(self.disc, nextp)
             if not self.previous or nxtfm != self.previous:
                 self.previous = nxtfm
                 return nxtfm
Пример #2
0
 def _randomele1(self):
     """
     Return a reduced random form with the given discriminant.
     """
     while True:
         nextp = prime.nextPrime(self.cnt)
         self.cnt += 1
         if kronecker(self.disc, nextp) == 1:
             nxtfm = sqroot(self.disc, nextp)
             if not self.previous or nxtfm != self.previous:
                 self.previous = nxtfm
                 return nxtfm
Пример #3
0
 def testNextPrime(self):
     self.assertEqual(2, prime.nextPrime(0))
     self.assertEqual(3, prime.nextPrime(2))
     self.assertEqual(547, prime.nextPrime(541))
     self.assertEqual(547, prime.nextPrime(542))
Пример #4
0
from nzmath import finitefield, vector, matrix, prime
from nzmath.rational import theIntegerRing
import numpy as np
import random
from math import ceil
#import functools

GF = lambda n: finitefield.FinitePrimeField(n)
GF2 = finitefield.FinitePrimeField(2)
next_prime_field = lambda n: GF(prime.nextPrime(n))

class DimensionError(vector.VectorSizeError, matrix.MatrixSizeError):
    pass

def matrixToSet(X):
    return set( X[i] for i in range1(X.column) )

def ffvector(compo, field):
    ffcmp = map(field.createElement, compo)
    return vector.Vector(ffcmp)
    
def ffmatrix(M, field):
    return M.map(field.createElement)

def zerovector(l, field):
    return vector.Vector([ field.zero for i in range(l) ])

def range1(start, stop=None, step=None):
    if stop is None:
        return range(1, start+1)
    elif step is None: