Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Save boolean polynomial ring to file and read it again

I have BooleanPolynomialRing of 256 variables and I need many thick polynomials. Generate them is very time consuming so I want to save them to file and when needed read again. Is there some good way? Till now I have found out something like this (simplified) variables=[] for i in range(1,257): variables.append('x'+str(i)) R = BooleanPolynomialRing(names=variables) R.inject_variables() fw = open('/home/pro/Desktop/polynomials.txt', 'w') polynomial = R.random_element(degree=2,terms=+infinity) fw.write(str(polynomial) + "\n") fr = open('/home/pro/Desktop/polynomials.txt', 'r') polynomial = fr.readline()

How can I convert string back to polynomial?

Thanks f.close()

Save boolean polynomial ring to file and read it again

I have BooleanPolynomialRing of 256 variables and I need many thick polynomials. Generate them is very time consuming so I want to save them to file and when needed read again. Is there some good way? Till now I have found out something like this (simplified) (simplified)

variables=[]
for i in range(1,257):
    variables.append('x'+str(i))
R = BooleanPolynomialRing(names=variables)
R.inject_variables()
fw = open('/home/pro/Desktop/polynomials.txt', 'w')
polynomial = R.random_element(degree=2,terms=+infinity)
fw.write(str(polynomial) + "\n")
fr = open('/home/pro/Desktop/polynomials.txt', 'r')
polynomial = fr.readline()

fr.readline()

How can I convert string back to polynomial?

Thanks f.close()