本文整理汇总了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