本文整理汇总了Python中Euclid.modinv方法的典型用法代码示例。如果您正苦于以下问题:Python Euclid.modinv方法的具体用法?Python Euclid.modinv怎么用?Python Euclid.modinv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Euclid
的用法示例。
在下文中一共展示了Euclid.modinv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testConversion
# 需要导入模块: import Euclid [as 别名]
# 或者: from Euclid import modinv [as 别名]
def testConversion(number,text):
#both outputs should be true
print convertStringToNumber(convertNumberToString(number,ALPHABET),ALPHABET) == number
print convertNumberToString(convertStringToNumber(text,ALPHABET),ALPHABET) == text
def calculateMOD():
lastPage = generateAllSpacePage()
MOD = convertStringToNumber(lastPage,ALPHABET)
return MOD
#Parameters for the LCG
MOD = calculateMOD()
C = 982451653 #MOD and C are relatively prime
A = MOD + 1
AINV = Euclid.modinv(A,MOD)
def lcg(x):
return ((A * x + C) % MOD)
def lcgInverse(x):
return ((AINV * (x - C)) % MOD)
def pageAtAddress(address):
addressAsNumber = convertStringToNumber(address,ADDRESSCHARSET)
pageAsNumber = lcg(addressAsNumber)
page = convertNumberToString(pageAsNumber,ALPHABET)
page = fillWithXBefore(page,'a',3200)
return page
示例2: lcg
# 需要导入模块: import Euclid [as 别名]
# 或者: from Euclid import modinv [as 别名]
import Euclid
import time
DATANUMBER = 2646520
PARTS = 40
PARTLENGTH = DATANUMBER/PARTS
#mainLCG
MOD = (2 ** (DATANUMBER/PARTS)) + 1
C = (2 ** 86243) - 1
A = (2*MOD) + 1
AINV = Euclid.modinv(A,MOD)
#permutationLCG
m = 640
a = 21
c = 1997
ainv = Euclid.modinv(a,m)
def lcg(x):
return ((A * x + C) % MOD)
def lcgInverse(x):
return ((AINV * (x - C)) % MOD)
def permLcg(x):
return ((a * x + c) % m)
def permLcgInverse(x):