本文整理匯總了Python中polynomial.Polynomial.coefs方法的典型用法代碼示例。如果您正苦於以下問題:Python Polynomial.coefs方法的具體用法?Python Polynomial.coefs怎麽用?Python Polynomial.coefs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類polynomial.Polynomial
的用法示例。
在下文中一共展示了Polynomial.coefs方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import coefs [as 別名]
def main(argv):
inputfile = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
except getopt.GetoptError:
print 'single.py -i <inputfile> -o <outputfile>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'single.py -i <inputfile> -o <outputfile> '
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
try:
fi = open(inputfile,"r")
fl = open(outputfile,"a")
except IOError:
print 'main.py -i <inputfile> -o <outputfile>'
sys.exit(2)
l = []
for i in fi:
p = Polynomial(i)
l.append(p)
name = outputfile
name = name + ".xlsx"
name = "" + name
workbook = xlsxwriter.Workbook(name)
worksheet = workbook.add_worksheet("irredutiveis")
worksheet.write(0,0, "Polynomials")
worksheet.write(0,1, "m")
worksheet.write(0,2, "a")
worksheet.write(0,3, "b")
worksheet.write(0,4, "c")
worksheet.write(0,5, "d")
row = 1
colum = 0
for p in l:
colum = 0
worksheet.write(row,colum, str(p.coefs()))
colum = 1
j = sorted(p.coefs(), reverse=True)
for num in j:
worksheet.write(row,colum, num)
colum = colum+1
row = row + 1
workbook.close()
示例2: main
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import coefs [as 別名]
def main(argv):
inputfile = ''
outputfile = ''
debug = False
try:
opts, args = getopt.getopt(argv,"hi:o:d",["ifile=","ofile="])
except getopt.GetoptError:
print 'single.py -i <inputfile> -o <outputfile>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'single.py -i <inputfile> -o <outputfile> -d for debug'
sys.exit()
elif opt in ("-d", "--debug"):
debug = True
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
try:
fi = open(inputfile,"r")
fl = open(outputfile,"a")
except IOError:
print 'main.py -i <inputfile> -o <outputfile>'
sys.exit(2)
l = []
pols = []
files = [inputfile]
for fileName in files:
save = outputfile
f = open(fileName,'r')
#read, pols = recoverfile(save, f)
if True:
for line in f:
try:
pol = Polynomial(line)
pols.append(pol)
except Exception as e:
print line
sys.exit(2)
result = defaultdict(list)
print len(pols)
for pol in pols:
if len(pol.coefs()) > 1:
red = Reduction(debug)
count = red.reduction(pol.coefs())
result = str(pol.coefs()) + ":" + str(count)
print result
fl.write(result + "\n")
示例3: main
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import coefs [as 別名]
def main(argv):
inputfile = ''
outputfile = ''
ka = ''
try:
opts, args = getopt.getopt(argv,"hi:o:k:",["ifile=","ofile=",])
except getopt.GetoptError:
print 'extract.py -i <inputfile> -o <outputfile> -k 1,2,3,4,5,...'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'extract.py -k 1,2,3,4,5,... -i <inputfile> -o <outputfile> '
sys.exit()
elif opt in ("-i", "--ifile"):
print "-i", arg
inputfile = arg
elif opt in ("-o", "--ofile"):
print "-o", arg + "_" + str(ka)
outputfile = arg + "_" + str(ka)
elif opt in ("-k"):
print "ka = ", arg
ka = arg
try:
f = open(inputfile,'r')
except IOError:
print 'Error to open the file'
print 'ka.py -i <inputfile> -o <outputfile> -k 1,2,3,4,5,6,...'
sys.exit(2)
to_save = open(outputfile,"a")
for line in f:
pol = Polynomial(line)
l = sorted(pol.coefs(), reverse=True)
k = math.floor((l[0]-2)/(l[0]-l[1]))
if k == int(ka):
to_save.write(line)
示例4: main
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import coefs [as 別名]
def main(argv):
inputfile = ''
outputfile = ''
debug = False
try:
opts, args = getopt.getopt(argv,"hi:o:d",["ifile=","ofile="])
except getopt.GetoptError:
print 'single.py -i <inputfile> -o <outputfile>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'single.py -i <inputfile> -o <outputfile> -d for debug'
sys.exit()
elif opt in ("-d", "--debug"):
debug = True
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
try:
fi = open(inputfile,"r")
fl = open(outputfile,"a")
except IOError:
print 'main.py -i <inputfile> -o <outputfile>'
sys.exit(2)
pols = []
for line in fi:
try:
pol = Polynomial(line)
pols.append(pol)
except Exception as e:
print line
sys.exit(2)
for pol in pols:
st = str(pol.coefs()) + ":0" + "\n"
fl.write(st)
fl.close()
示例5: open
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import coefs [as 別名]
import os
from collections import OrderedDict
from polynomial import Polynomial
if __name__ == '__main__':
f = open('pol_571_.txt','r')
pols = []
for line in f:
pol = Polynomial(line)
pols.append(pol.coefs()[1])
s = sorted(set(pols))
print s