Ask Your Question

jmcshan1's profile - activity

2021-11-09 00:13:13 +0100 received badge  Famous Question (source)
2016-09-05 07:22:38 +0100 received badge  Notable Question (source)
2016-05-23 20:42:23 +0100 received badge  Popular Question (source)
2013-04-04 12:42:36 +0100 commented answer Convert a text file into a matrix

Nevermind, I got it: sage_eval(my_string, locals={'x':x})

2013-04-04 12:33:10 +0100 commented answer Convert a text file into a matrix

This does not seem to work with variable names, such as sage: my_string = '[[x, 3 - x],[x, 3+x]]' Is there a way to make sage_eval work with these variables?

2013-04-04 11:32:52 +0100 received badge  Supporter (source)
2013-04-02 13:00:00 +0100 received badge  Student (source)
2013-04-02 12:42:35 +0100 asked a question Convert a text file into a matrix

I have a file with a list of elements inside the square of a Quadratic field, i.e. QQ(sqrt[13])^2. The file looks like [[2 + sqrt[13],4 - 2*sqrt[13]],[2,sqrt[13]],...]. I want to import this file into a single matrix over the field, in the previous example F.<a> = QuadraticField(13). Currently, I read everything in as a string then convert to the matrix, but there must be an easier way to do this. I am somewhat new to python programming in general.