Re: [sage-support] Bug in polynomia roots in Qp()
On 2013-11-14 18:29, Georgi Guninski wrote: Cremona already confirmed it is a bug And I disagree with him, as I explained in my first post on this thread. are you an ultrafinitarist about Qp() ? What do you mean by this? I created the bug report at http://trac.sagemath.org/ticket/15422 Jeroen. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] numpy.count_nonzero
Hi everyone, I want to count the number of non-zero entries in a matrix but I can't find a Sage command to do this. Instead, I found a NumPy command numpy.count_nonzero to do it. I tested it in the online Sage Cell server: https://sagecell.sagemath.org/ The code goes like this: import numpy as np mm = matrix(ZZ, 2, 3, [1,0,2,0,0,0]) print mm print np.count_nonzero(mm) It worked in the Sage Cell Server. However, when I tried it out in Sage v5.12 in Linux. There is an error message: " 'module' object has no attribute 'count_nonzero' ". Also, when I typed numpy. to see all possible commands, numpy.count_nonzero does not appear. It seems as though there is no such command. I am willing to use other simple commands as long as I get to count the nonzero entries of a matrix. Perhaps someone can help me with this... Thanks! Cheers, Eileen. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Bug in polynomia roots in Qp()
On 15 November 2013 08:23, Jeroen Demeyer wrote: > On 2013-11-14 18:29, Georgi Guninski wrote: >> >> Cremona already confirmed it is a bug > > And I disagree with him, as I explained in my first post on this thread. I would not like to recommend to any mathematician to use a piece of software which, when asked to give the roots of (t-1)^2 over a field, returns the empty list. I do understand the reasons for this -- and have also followed the discussion on pari-dev -- (an inexact coefficient field, etc, etc) but still! John > > >> are you an ultrafinitarist about Qp() ? > > What do you mean by this? > > I created the bug report at http://trac.sagemath.org/ticket/15422 > > Jeroen. > > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To post to this group, send email to sage-support@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] numpy.count_nonzero
Try this: sage: M = random_matrix(GF(2),4,5) sage: len([a for a in M.list() if a]) 12 Here M.list() is a list of all the entries, we select the nonzero ones and count. John Cremona On 15 November 2013 08:25, Eileen Ee wrote: > Hi everyone, > > I want to count the number of non-zero entries in a matrix but I can't find > a Sage command to do this. Instead, I found a NumPy command > numpy.count_nonzero to do it. > > I tested it in the online Sage Cell server: https://sagecell.sagemath.org/ > The code goes like this: import numpy as np > mm = matrix(ZZ, 2, 3, > [1,0,2,0,0,0]) > print mm > print np.count_nonzero(mm) > > It worked in the Sage Cell Server. However, when I tried it out in Sage > v5.12 in Linux. There is an error message: " 'module' object has no > attribute 'count_nonzero' ". Also, when I typed numpy. to see all > possible commands, numpy.count_nonzero does not appear. It seems as though > there is no such command. > > I am willing to use other simple commands as long as I get to count the > nonzero entries of a matrix. Perhaps someone can help me with this... > > Thanks! > > Cheers, > Eileen. > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To post to this group, send email to sage-support@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Bug in polynomia roots in Qp()
On 2013-11-15 10:07, John Cremona wrote: I would not like to recommend to any mathematician to use a piece of software which, when asked to give the roots of (t-1)^2 over a field My whole point was that the original poster *did not ask that question*. He asked for the roots of the polynomial (1 + O(3^5))*t^2 + (1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + O(3^5))*t + (1 + O(3^5)) which is not the same as asking for the roots of the polynomial t^2 - 2*t + 1 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Bug in polynomia roots in Qp()
On Fri, Nov 15, 2013 at 10:58:58AM +0100, Jeroen Demeyer wrote: > On 2013-11-15 10:07, John Cremona wrote: > >I would not like to recommend to any mathematician to use a piece of > >software which, when asked to give the roots of (t-1)^2 over a field > My whole point was that the original poster *did not ask that question*. > > He asked for the roots of the polynomial > (1 + O(3^5))*t^2 + (1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + O(3^5))*t + (1 > + O(3^5)) > which is not the same as asking for the roots of the polynomial > t^2 - 2*t + 1 > Sorry but are you smoking bad stuff, sage claims your polynomial have zeros, which appears to contradict your claims: sage: Kz.=Qp(3,5)[];pol=(1 + O(3^5))*t^2 + (1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + O(3^5))*t + (1 + O(3^5)) sage: (pol(1),pol(1).is_zero()) (O(3^5), True) sage: pol.roots() [] -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Bug in polynomia roots in Qp()
On Fri, Nov 15, 2013 at 09:23:53AM +0100, Jeroen Demeyer wrote: > > I created the bug report at http://trac.sagemath.org/ticket/15422 > Usually sound open source vendors cite sources for bugs. After reading this list I am not surprised this doesn't apply to sage. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Bug in polynomia roots in Qp()
On 2013-11-15 11:45, Georgi Guninski wrote: sage: Kz.=Qp(3,5)[];pol=(1 + O(3^5))*t^2 + (1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + O(3^5))*t + (1 + O(3^5)) sage: (pol(1),pol(1).is_zero()) (O(3^5), True) There is some mathematical subtlety going on here: the value of that polynomial at 1 equals O(3^5), but from this fact one cannot conclude that the original polynomial has a p-adic zero. The problem is that your zero modulo 3^5 is not Hensel-liftable to a 3-adic zero. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Possible memory leak involving IntegerModRing()
Everyone knows sage has no bugs. Appears to me the following program should use O(1) memory. Watching memory usage in top(1), the proggie uses 3GB ram in less than a minute and memory usage increases constantly. Is there something wrong with the program? While I am still using sage, is there a workaround for this ``feature''? Program: def wief(): """ 2^(n-1) \equiv 1 \mod n^2 not necessarily prime """ n=2 while n<10**20: K=IntegerModRing(n**2) if K(2)**(n-1)==1: print n n += 1 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Possible memory leak involving IntegerModRing()
Hi Georgi, On 2013-11-15, Georgi Guninski wrote: > Everyone knows sage has no bugs. OMG, this means I lost my main occupation! > Appears to me the following program should use > O(1) memory. > > Watching memory usage in top(1), the proggie uses > 3GB ram in less than a minute and memory usage > increases constantly. There is supposed to be a slow increase, because the memory consumption of IntegerModRing(n**2) depends on the size of n, if I am not mistaken. However, it seems that you are right, there is a leak. Even with the git branch of trac ticket #15367 (that is supposed to fix some memory leak), I obtain: sage: def wief(): : n=2 : while n<10**20: : K=IntegerModRing(n**2) : if K(2)**(n-1)==1: : print n : print n, get_memory_usage() : n += 1 sage: get_memory_usage() 189.44140625 sage: import gc sage: _ = gc.collect() sage: len(gc.get_objects()) 9 sage: wief() ... 60275 563.58203125 ^C--- KeyboardInterrupt Traceback (most recent call last) ... sage: _ = gc.collect() sage: len(gc.get_objects()) 3775157 > While I am still using sage, is there a workaround > for this ``feature''? If you do not do computations in your function "wief", but only create the IntegerModRing, then the memory consumption is rather steady. Hence, the fact that the memory consumption increases when doing computations indicates that Sage's coercion framework is responsible for the leak. Do you have a trac account? Then please create a ticket and put me as Cc. Otherwise I'll open a ticket myself. As a work-around, try this (I tested vanilla sage-5.13.beta2): sage: import gc sage: _ = gc.collect() sage: len(gc.get_objects()) 114412 sage: def wief(): : n=2 : while n<10**20: : K=IntegerModRing(n**2) : if K(2)**(n-1)==K.one(): : print n : print n, get_memory_usage() : n += 1 # after more than 300,000 rounds sage: _ = gc.collect() sage: len(gc.get_objects()) 115199 The difference is as follows: If you compare an element of K with the integer "1", then Sage needs to compute a homomorphism from ZZ to K. This homomorphism is cached for later use. We try to make the caching that does not prevent unused rings from garbage collection. But it seems you've hit an example where Sage fails. With the new version of the function, the memory consumption first increases and then remains steady even for n>300,000. Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Re: Possible memory leak involving IntegerModRing()
Thanks for the workaround :) Another workaround is | == K(1) |. Don't have a trac account. Note that modification of your workaround still leaks (probably this known/the same): if K(2)**(n-1)== 2 *K.one(): #leaks On Fri, Nov 15, 2013 at 02:42:36PM +, Simon King wrote: > Hi Georgi, > > On 2013-11-15, Georgi Guninski wrote: > > Everyone knows sage has no bugs. > > OMG, this means I lost my main occupation! > > > Appears to me the following program should use > > O(1) memory. > > > > Watching memory usage in top(1), the proggie uses > > 3GB ram in less than a minute and memory usage > > increases constantly. > > There is supposed to be a slow increase, because the memory consumption > of IntegerModRing(n**2) depends on the size of n, if I am not mistaken. > > However, it seems that you are right, there is a leak. Even with the git > branch of trac ticket #15367 (that is supposed to fix some memory leak), > I obtain: > > sage: def wief(): > : n=2 > : while n<10**20: > : K=IntegerModRing(n**2) > : if K(2)**(n-1)==1: > : print n > : print n, get_memory_usage() > : n += 1 > sage: get_memory_usage() > 189.44140625 > sage: import gc > sage: _ = gc.collect() > sage: len(gc.get_objects()) > 9 > sage: wief() > ... > 60275 563.58203125 > ^C--- > KeyboardInterrupt Traceback (most recent call last) > ... > sage: _ = gc.collect() > sage: len(gc.get_objects()) > 3775157 > > > While I am still using sage, is there a workaround > > for this ``feature''? > > If you do not do computations in your function "wief", but only create > the IntegerModRing, then the memory consumption is rather steady. Hence, > the fact that the memory consumption increases when doing computations > indicates that Sage's coercion framework is responsible for the leak. > > Do you have a trac account? Then please create a ticket and put me as > Cc. Otherwise I'll open a ticket myself. > > As a work-around, try this (I tested vanilla sage-5.13.beta2): > > sage: import gc > sage: _ = gc.collect() > sage: len(gc.get_objects()) > 114412 > sage: def wief(): > : n=2 > : while n<10**20: > : K=IntegerModRing(n**2) > : if K(2)**(n-1)==K.one(): > : print n > : print n, get_memory_usage() > : n += 1 > # after more than 300,000 rounds > sage: _ = gc.collect() > sage: len(gc.get_objects()) > 115199 > > The difference is as follows: If you compare an element of K with the > integer "1", then Sage needs to compute a homomorphism from ZZ to K. > This homomorphism is cached for later use. We try to make the caching > that does not prevent unused rings from garbage collection. But it seems > you've hit an example where Sage fails. > > With the new version of the function, the memory consumption first > increases and then remains steady even for n>300,000. > > Best regards, > Simon > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To post to this group, send email to sage-support@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Possible memory leak involving IntegerModRing()
Hi Georgi, On 2013-11-15, Georgi Guninski wrote: > Note that modification of your workaround still > leaks (probably this known/the same): > > if K(2)**(n-1)== 2 *K.one(): #leaks Yes, it is the same underlying problem: If you want to multiply the integer "2" with the element K.one() of K, then Sage would test whether there is a coercion homomorphism from ZZ to K, would use this homomorphism to map "2" into K, and would then multiply the result (which is K(2)) by K.one(). Again, the coercion homomorphism is cached, in a way that seemingly prevents K from garbage collection (which is bad). Work-around: Do K(2)*K.one() instead of 2*K.one(). Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: which version of ipython for building a sagecell server
Jason I have try to follow your instructions as: mkdir sage git init git remote add -f jason https://github.com/jasongrout/sage.git git checkout jason/sagecell mkdir upstream wget -O ipython-1.0.0.tar.gz https://github.com/ipython/ipython/releases/download/rel-1.0.0/ipython-1.0.0.tar.gz make but I get a checksum error for Ipython /home4/local/sage/build/pipestatus "sage-spkg ${SAGE_SPKG_OPTS} ipython-1.0.0 2>&1" "tee -a /home4/local/sage/logs/pkgs/ipython-1.0.0.log" Found local metadata for ipython-1.0.0 Found local sources at /home4/local/sage/upstream/ipython-1.0.0.tar.gz Checksum: a1b3033953e47027c9409e9c33c90c6a79ff640c vs a1b3033953e47027c9409e9c33c90c6a79ff640c Invalid checksum for /home4/local/sage/upstream/ipython-1.0.0.tar.gz make[2]: *** [/home4/local/sage/local/var/lib/sage/installed/ipython-1.0.0] Erreur 1 Is the ipython version correct Thanks Marc -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Tensor products of vector spaces
Is there some way to take tensor products of vector spaces in Sage? I have been looking through the sources and I don't see anything similar. There is a very old message from 2009 where the command "tensor_product" is discussed, but this doesn't seem to exist in Sage any more (or maybe it was never merged from combinat): https://groups.google.com/forum/#!topic/sage-combinat-devel/8Vszh4PHDjM Is there some other way to take the tensor product of vector spaces? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] How create a plot of f(x, y, z) using color for function value? (i.e. a 4D plot)
I've been searching the Internet and can't find examples of plots of functions of THREE variables like f(x, y, z). I'd like to use a different color at each point in space to denote the function value. Is that possible in Sage? Are there examples somewhere? (All the examples I saw were for 2 variable functions like g(x, y). ) Thanks, cs -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.