Marshall,
Here is an indented version of the program. I did not think that I was
creating too many variables, as I intended the program to simply
overwrite their values during each loop, but would gladly delete them
during each iteration of the master loop if someone would let me know
what the proper command is.
As for the total number of iterations, yes it is very big, but I never
intended the program to run until completion. Rather, I planned on
terminating the program after a few interesting examples were
outputted. The problem seems to be that the program expands its memory
footprint so rapidly that it cannot get through very many iterations.
for c in range (1,5000):
for i in range (3,100):
if is_prime(i)==True:
c2=1
c1=1
while c1<30:
a4=c1*i
c1+=1
while c2<30:
a7=c2*i
c2+=1
a1=randint(3,100)
a2=randint(3,100)
a3=randint(3,100)
a5=randint(3,100)
a6=randint(3,100)
a8=randint(3,100)
a9=randint(3,100)
A= MatrixSpace(RationalField(),3)([[a1,a2,a3],
[a4,a5,a6],[a7,a8,a9]])
f=A.charpoly()
if f.is_irreducible() == True:
K=NumberField(f,'t');
if K.is_galois()==True:
if f.discriminant()%i != 0:
print
"======================================"
A
f
print "disc =
",factor(f.discriminant())
print "prime=",i
L = FiniteField(i,'q');
P.<w>=L[]
f.factor_mod(i)
print "(2,1) is in prime:",0==a4%i
print "(3,1) is in prime:",0==a7%i
print "(3,2) is in prime:",0==a8%i
Best,
Ben
On Mar 4, 10:15 am, Marshall Hampton <[email protected]> wrote:
> If Ben or Justin could post a properly indented version I am willing
> to take a look. Maybe I'm not looking at it correctly, but I'm not
> sure what variables would be stored in large quantity. In the inner
> loop, the value of A is over-ridden, isn't it? What else would stick
> around? It seems possible that it might speed things up to declare
>
> R = MatrixSpace(RationalField(),3)
>
> outside the loop, and then do A= R([[23,4,17],[2,2,2],[3,4,5]]) inside
> the loop. But it looks like there are about 100*5000*30*30 = 450
> million total iterations, so its not such a "little" program.
>
> -Marshall
>
> On Mar 3, 8:27 pm, Ben Linowitz <[email protected]> wrote:
>
>
>
> > Justin and Alasdair,
>
> > Thanks for your help.
>
> > I'm sorry that you had to reformat the code. I had it written up in a
> > text file and was just copying and pasting it into the terminal
> > running sage. I suppose that the formatting must have gotten screwed
> > up when I copied from the text file to post here.
>
> > Anyway, I'm a complete novice when it comes to this. How do I delete
> > variables so that the program does not hog so much memory when set to
> > run for a long period of time?
>
> > Thanks again,
> > Ben
>
> > On Mar 3, 9:12 pm, "Justin C. Walker" <[email protected]> wrote:
>
> > > On Mar 3, 2010, at 14:09 , Ben Linowitz wrote:
>
> > > > Thank you for your response Alex. Here is the code:
>
> > > [snip]
>
> > > The code isn't usable as-is (no indenting, wrapped comments), but if
> > > I've reformatted it correctly, using 'top' while this is running shows
> > > that the python process is continually expanding its memory footprint.
>
> > > If this is the case, Alasdair may be correct, and deleting variables
> > > will help.
>
> > > HTH
>
> > > Justin
>
> > > --
> > > Justin C. Walker
> > > Curmudgeon at Large
> > > Director
> > > Institute for the Enhancement of the Director's Income
> > > --
> > > Build a man a fire and he'll be warm
> > > for a night.
> > > Set a man on fire and he'll be warm
> > > for the rest of his life.
>
> > > --
> > > Justin C. Walker, Curmudgeon at Large
> > > Director
> > > Institute for the Enhancement of the Director's income
> > > -----------
> > > --
> > > They said it couldn't be done, but sometimes,
> > > it doesn't work out that way.
> > > - Casey Stengel
> > > --
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org