Re: [sage-support] Coercion problem
I assume you meant sage: v = P(5) sage: v(oo) A positive finite number This is because the elements of QQ coerce to the parent of oo, which is the signed infinity ring. This is so we have sage: P.x = PolynomialRing(QQ) sage: w = x + 5 sage: v = w - x w(1.0) 6.00 sage: v(1.0) 5.00 sage: parent(w(1.0)) is parent(v(1.0)) True I suppose now that we have pushouts we could let the result lie in the (affine) extension of the rationals. Manipulation with the unsigned infinity would yield the projective extension. There is the open question of what the parent of oo should be though. Some kind of affine extension of ZZ? On Thu, Jan 15, 2015 at 11:49 AM, michalg0...@gmail.com wrote: I recently sumbled at following behaviour: sage: P.x = PolynomialRing(QQ) sage: w = x + 1 sage: w(oo) + Infinity sage: v = 5 sage: v(oo) A positive finite number This behaviour is strange (altough works as desined). For nonconstant polynomial it has the same effect as calculating limit, for constant polynomial it gives (seemingly) non-sensical result. Could the default behaviour be changed so in case of constant polynomial instead of coercing operands it would return simply the value of the polynomial (5 in this example)? Regards, MG -- 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/d/optout. -- 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/d/optout.
Re: [sage-support] Real Interval Field (RIF) question
I do find this behavior quite surprising--diameter should be an alias for either relative or absolute diameter, not depending on the interval. On Wed, Oct 22, 2014 at 2:44 AM, John Cremona john.crem...@gmail.com wrote: I am trying to use the Real Interval Field (RIF), which in principle does exactly what I want. But I cannot understand this: sage: a=RIF(-1,1) sage: a.diameter() 2.00 sage: [b.diameter() for b in a.bisection()] [1.00, 1.00] sage: [[c.diameter() for c in b.bisection()] for b in a.bisection()] [[0.667, 0.500], [0.500, 0.667]] I bisect an interval of length (diameter) 2 twice, but 2 of the 4 pieces have diameter 2/3! I assumed that the diameters of the output of bisection() added to the original diameter, but this appears not to be happening. If this is not a bug then I don't understand something. Perhaps this makes it clearer: sage: a=RIF(-1,1) sage: b=a.bisection()[0] sage: c=b.bisection()[0] sage: c.lower() -1.00 sage: c.upper() -0.500 sage: c.diameter() 0.667 I think that what I need is sage: c.absolute_diameter() 0.500 but did not understand diameter. OK, so I have answered my own question, but I think I might as well post it anyway! John Cremona -- 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/d/optout. -- 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/d/optout.
Re: [sage-support] Why Sage is called Sage ?
http://sagemath.blogspot.com/2009/12/mathematical-software-and-me-very.html On Thu, Aug 14, 2014 at 1:14 AM, John Cremona john.crem...@gmail.com wrote: When William Stein first started the project it was an acronym SAGE for (I think) System for Algebra and Geometry Experimentation. But soon it became a much wider project (mathematically) than that, so the nsam echnged subtlely to Sage, not an acronym. (Similarly -perhaps -- the company called BT was formed from a predecessor called British Telecom, but apparently BT is *not* an acronym.) There are probably some good links to the history of Sage, which I will let others find and post. John On 14 August 2014 07:49, Christophe Bal projet...@gmail.com wrote: Hello, I let you find where is my question. ;-) Christophe BAL Hint: see the title of my message. :-) -- 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/d/optout. -- 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/d/optout. -- 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/d/optout.
Re: [sage-support] Typo in Documentation of Eigenmatrix
https://github.com/sagemath/sage/pull/21 aka http://trac.sagemath.org/ticket/16672 On Thu, Jul 17, 2014 at 9:45 AM, Mahrud Sayrafi sayraf...@gmail.com wrote: Hi, In this page: http://www.sagemath.org/doc/constructions/linear_algebra.html#eigenvectors-and-eigenvalues in the eigenvectors and eigenvalues section, in the end of second line inside the parentheses says: (resp. PA=PD.) but it should be: (resp. PA=DP.) Thanks, Mahrud -- 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/d/optout. -- 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/d/optout.
Re: [sage-support] GIT repository and installation
The very short answer is to type make and wait an hour or three. On Jul 14, 2014 4:54 AM, Oscar Alberto Castillo Felisola o.castillo.felis...@gmail.com wrote: Checking it out! Thank you John. -- 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/d/optout. -- 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/d/optout.
Re: [sage-support] Re: Simplify number
What exactly do you mean by simplify a real number? On Thu, May 29, 2014 at 8:32 AM, SiL588 . ch4r...@hotmail.com wrote: Unfortunately I don't know the rules of Phyton language, i just started using Sage notebook to do linear algebra computation. I think I did what you said, I assinged m a value that was the result of multiplication between real numbers. So, if a real number have no simplify methods, how can I simplify it? Il giorno giovedì 29 maggio 2014 16:56:22 UTC+2, Simon King ha scritto: Hi! On 2014-05-29, SiL588 . ch4...@hotmail.com wrote: Hi, i tried to simplify a number doing this: m1.simplify() but the output is AttributeError: 'sage.rings.real_mpfr.RealNumber' object has no attribute 'simplify' What does it mean? What did I do wrong? I declared m1 like this: m1 = var('m1') In order to be able to help, we need code that actually results in the error you mention. If one just defines m1 as a symbolic variable, then it works (in a trivial way, of course): sage: m1 = var('m1') sage: m1.simplify() m1 But let me guess, based on your using the word declare: Do you expect that m1 will always be a symbolic variable after you did m1=var('m1')? That's not how Python works. In contrast to C, there are no static types associated with a variable. So, is it perhaps the case that at some point you did this: sage: m1 = 1324.67 sage: m1.simplify() ? It is then no surprise to get an attribute error, because after re-defining m1 as 1324.67 it is a real number, and real numbers have no simplify method. 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/d/optout. -- 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/d/optout.
Re: [sage-support] Re: bug in comparison of function field elements
On Tue, Apr 29, 2014 at 10:57 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Apr 29, 2014 at 9:07 AM, Volker Braun vbraun.n...@gmail.com wrote: On Tuesday, April 29, 2014 3:58:14 PM UTC+1, Simon King wrote: Yes there is! The hook is the hash function. CPython implementation detail and subject to change... really Python makes no guarantee that __hash__() is called at any particular point. Its of course safe to normalize elements there for the hash, but you might be doing it too early then. Might, but it's probably the better thing to do here. For a fraction field the equality a/b == c/d can easily be resolved without normalization as a*d == b*c. Similarly, for a fraction field over a polynomial ring, you can can also produce a hash without normalization by evaluating the numerator and denominator at a fixed point and using the hash of the resulting field element. May or may not be cheaper in practice, and you'd probably want to cache it. Unfortunately this breaks hash(a) == hash(a / 1) unless hash is so defined in the polynomial ring as well. I posted a fix to simply always reduce. ... in some cases only a trivial hash function (such as: hash of the parent) should be used. or, better, just 1: set([ZZ(1), QQ(1)]) This is probably a bad idea--it'll lead to very poor and hard-to-diagnose performance issues. - Robert -- 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/d/optout.
Re: [sage-support] Re: bug in comparison of function field elements
On Tue, Apr 29, 2014 at 9:07 AM, Volker Braun vbraun.n...@gmail.com wrote: On Tuesday, April 29, 2014 3:58:14 PM UTC+1, Simon King wrote: Yes there is! The hook is the hash function. CPython implementation detail and subject to change... really Python makes no guarantee that __hash__() is called at any particular point. Its of course safe to normalize elements there for the hash, but you might be doing it too early then. Might, but it's probably the better thing to do here. For a fraction field the equality a/b == c/d can easily be resolved without normalization as a*d == b*c. Similarly, for a fraction field over a polynomial ring, you can can also produce a hash without normalization by evaluating the numerator and denominator at a fixed point and using the hash of the resulting field element. May or may not be cheaper in practice, and you'd probably want to cache it. ... in some cases only a trivial hash function (such as: hash of the parent) should be used. or, better, just 1: set([ZZ(1), QQ(1)]) This is probably a bad idea--it'll lead to very poor and hard-to-diagnose performance issues. - Robert -- 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/d/optout.
Re: [sage-support] Re: Optimizing this function with Cython
On Fri, Mar 14, 2014 at 2:03 PM, Georgios Tzanakis gtzana...@gmail.com wrote: On Fri, Mar 14, 2014 at 4:49 PM, Robert Bradshaw rober...@math.washington.edu wrote: Note that intL[i][introws[i]] + j %w == 0: would probably be just (or nearly) as fast as ((int(tupleL[i])[int(rows[i])])+j %w)==0 Good to know, thanks.. If you're going to be dealing with arrays of ints you might want to look into NumPy Hmm.. I wish I knew that earlier, I deal with many of such arrays. and/or memory views for even more speed. Could you elaborate a bit on that? Or just give me a link? https://www.google.com/search?q=numpy+cython On Thu, Mar 13, 2014 at 7:58 PM, Georgios Tzanakis gtzana...@gmail.com wrote: Hi Simon, I really appreciate your thorough answer! Indeed there was a bug and I had to do a couple of changes to the code, but I understood a lot of things about how to use Cython and was able to use it properly and have improvements. On top of that, I didn't know about the timeit function which is a life saver. Everything is clear.. Thank you, sir! Best, George On Thu, Mar 13, 2014 at 8:48 AM, Simon King simon.k...@uni-jena.de wrote: Hi! On 2014-03-12, geo909 gtzana...@gmail.com wrote: But I'm still not sure how to use things properly. So, for instance, is the following optimization reasonable? (there is an ~30% increase in speed from pure python code) It is easy to get more. But first: Is there a bug in your code? You write if all( [(L[i][rows[i]]+j %w)==0] ): Thus, the argument to all is a list with precisely one item. If it is not a bug, then you should replace it with if (L[i][rows[i]]+j%w)==0: I assume that it is not a bug, and thus I used this improvement in all my attempts that I describe below. # L: A list of tuples of positive integers, each having a couple of hundred elements. # L itself has length at most 3 or 4. # e: A tuple of integers. e has length no more than a couple of hundred. # w a small integer Since there is frequent access to the items of L and e, you should tell Cython that L is a list and that e is a tuple. Also, itertools.product yields tuples, so, rows in your function is a tuple. Again, there is frequent acces to the items, thus, you should declare that rows is a tuple. On the other hand, commonzeros is accessed at most a couple of times, thus, no need to make it cdef int. But it seems to me that the most important line is (after removing the needless all) this: if (L[i][rows[i]]+j %w)==0: Let's try to be particularly careful here, since it occurs in an inner loop, and the annotation appears dark yellow. The items of L are tuples. Thus, one could do (tupleL[i])[rows[i]]+j to make access to the tuple items faster. Furthermore, the items in the tuple L[i] are ints, and we want to add it with an int. Hence, if ((int(tupleL[i])[rows[i]])+j %w)==0: will make it faster (actually, inserting the int makes the execution time drop to 50% compared with a version that only has tuple). With L = [tuple([randint(1,10^8) for i in range(400)]), tuple([randint(1,10^8) for i in range(300)]), tuple([randint(1,10^8) for i in range(500)]), tuple([randint(1,10^8) for i in range(200)])] e = tuple([randint(1,10^8) for i in range(350)]) w = 5 and a pure Python version of your function (where I have replaced the all(...) as indicated above), I get sage: timeit(myfunction(L,e,w)) 5 loops, best of 3: 1.11 s per loop However, when cythoning your function as follows {{{ %cython import itertools def myfunction(list L, tuple e, int w): cdef int lenL = len(L) cdef int i,j cdef tuple rows for rows in itertools.product(range(w), repeat=lenL): commonzeros=0 for j in e: for i in range(lenL): if ((int(tupleL[i])[int(rows[i])])+j %w)==0: commonzeros+=1 if commonzeros==4: return(1) return(0) }}} I get sage: timeit(myfunction(L,e,w)) 5 loops, best of 3: 18.6 ms per loop If you now look at the annotated version of the function, you'll see that for rows in itertools.product remains dark yellow. So, if one wanted to optimise further, one should try to improve that. Since you iterate over len(L) copes of range(w) (rather than over the product of lists of different size), it should be not too difficult to write a custom iterator in Cython. But perhaps the speedup (111 ms -- 18.6 ms) is good enough for you? Best regards, Simon -- You received this message because you are subscribed to a topic in the Google Groups sage-support group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/S9eXmSVoo9E/unsubscribe
Re: [sage-support] Re: Optimizing this function with Cython
Note that intL[i][introws[i]] + j %w == 0: would probably be just (or nearly) as fast as ((int(tupleL[i])[int(rows[i])])+j %w)==0 If you're going to be dealing with arrays of ints you might want to look into NumPy and/or memory views for even more speed. On Thu, Mar 13, 2014 at 7:58 PM, Georgios Tzanakis gtzana...@gmail.com wrote: Hi Simon, I really appreciate your thorough answer! Indeed there was a bug and I had to do a couple of changes to the code, but I understood a lot of things about how to use Cython and was able to use it properly and have improvements. On top of that, I didn't know about the timeit function which is a life saver. Everything is clear.. Thank you, sir! Best, George On Thu, Mar 13, 2014 at 8:48 AM, Simon King simon.k...@uni-jena.de wrote: Hi! On 2014-03-12, geo909 gtzana...@gmail.com wrote: But I'm still not sure how to use things properly. So, for instance, is the following optimization reasonable? (there is an ~30% increase in speed from pure python code) It is easy to get more. But first: Is there a bug in your code? You write if all( [(L[i][rows[i]]+j %w)==0] ): Thus, the argument to all is a list with precisely one item. If it is not a bug, then you should replace it with if (L[i][rows[i]]+j%w)==0: I assume that it is not a bug, and thus I used this improvement in all my attempts that I describe below. # L: A list of tuples of positive integers, each having a couple of hundred elements. # L itself has length at most 3 or 4. # e: A tuple of integers. e has length no more than a couple of hundred. # w a small integer Since there is frequent access to the items of L and e, you should tell Cython that L is a list and that e is a tuple. Also, itertools.product yields tuples, so, rows in your function is a tuple. Again, there is frequent acces to the items, thus, you should declare that rows is a tuple. On the other hand, commonzeros is accessed at most a couple of times, thus, no need to make it cdef int. But it seems to me that the most important line is (after removing the needless all) this: if (L[i][rows[i]]+j %w)==0: Let's try to be particularly careful here, since it occurs in an inner loop, and the annotation appears dark yellow. The items of L are tuples. Thus, one could do (tupleL[i])[rows[i]]+j to make access to the tuple items faster. Furthermore, the items in the tuple L[i] are ints, and we want to add it with an int. Hence, if ((int(tupleL[i])[rows[i]])+j %w)==0: will make it faster (actually, inserting the int makes the execution time drop to 50% compared with a version that only has tuple). With L = [tuple([randint(1,10^8) for i in range(400)]), tuple([randint(1,10^8) for i in range(300)]), tuple([randint(1,10^8) for i in range(500)]), tuple([randint(1,10^8) for i in range(200)])] e = tuple([randint(1,10^8) for i in range(350)]) w = 5 and a pure Python version of your function (where I have replaced the all(...) as indicated above), I get sage: timeit(myfunction(L,e,w)) 5 loops, best of 3: 1.11 s per loop However, when cythoning your function as follows {{{ %cython import itertools def myfunction(list L, tuple e, int w): cdef int lenL = len(L) cdef int i,j cdef tuple rows for rows in itertools.product(range(w), repeat=lenL): commonzeros=0 for j in e: for i in range(lenL): if ((int(tupleL[i])[int(rows[i])])+j %w)==0: commonzeros+=1 if commonzeros==4: return(1) return(0) }}} I get sage: timeit(myfunction(L,e,w)) 5 loops, best of 3: 18.6 ms per loop If you now look at the annotated version of the function, you'll see that for rows in itertools.product remains dark yellow. So, if one wanted to optimise further, one should try to improve that. Since you iterate over len(L) copes of range(w) (rather than over the product of lists of different size), it should be not too difficult to write a custom iterator in Cython. But perhaps the speedup (111 ms -- 18.6 ms) is good enough for you? Best regards, Simon -- You received this message because you are subscribed to a topic in the Google Groups sage-support group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/S9eXmSVoo9E/unsubscribe. To unsubscribe from this group and all its topics, 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/d/optout. -- 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
Re: [sage-support] README.txt build-from-source buries fact -j8 in make -j8 ignored -- need export MAKE=make -j8
How hard would it be to let make -jN actually work from the top-level make? On Tue, Dec 31, 2013 at 4:57 PM, Joseph P. Skudlarek jsku...@gmail.com wrote: This is a request to update the README.txt file used when building from sources -- the README.txt buries the fact that -jN in make -jN is effectively ignored -- but it does make claar, in the details below, that you need export MAKE=make -jN. Since ignoring -jN is non-standard, and since it's important to avoid surprises when building in parallel, I suggest changing README.txt (at the top level of the source tree downloaded as sage-6.0.tar.gz) as follows. replace 3. cd into the Sage directory and type make: cd sage-*/ make That's it! Everything is automatic and non-interactive. The build should work fine on all fully supported platforms. If it does not, we want to know! with 3. cd into the Sage directory and type make: cd sage-*/ make That's it! Everything is automatic and non-interactive. The build should work fine on all fully supported platforms. If it does not, we want to know! If you want to build in parallel, see below. [] Thanks. /J -- 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] Re: README.txt build-from-source buries fact -j8 in make -j8 ignored -- need export MAKE=make -j8
Does the end user care about this distinction? make -jN uses N cores/processes to make whatever it is you're making. Building in parallel should be standard and encouraged, not buried in some environment variable. On Thu, Jan 2, 2014 at 4:44 PM, P Purkayastha ppu...@gmail.com wrote: It should not be enabled in the top-level make, in my opinion. Typically, make -jN makes parallel compiles within the same package (if the package supports it). The parallel build in sage compiles different packages in parallel, but each package still compiles as -j1. On 01/03/2014 02:48 AM, Robert Bradshaw wrote: How hard would it be to let make -jN actually work from the top-level make? On Tue, Dec 31, 2013 at 4:57 PM, Joseph P. Skudlarek jsku...@gmail.com wrote: This is a request to update the README.txt file used when building from sources -- the README.txt buries the fact that -jN in make -jN is effectively ignored -- but it does make claar, in the details below, that you need export MAKE=make -jN. Since ignoring -jN is non-standard, and since it's important to avoid surprises when building in parallel, I suggest changing README.txt (at the top level of the source tree downloaded as sage-6.0.tar.gz) as follows. replace 3. cd into the Sage directory and type make: cd sage-*/ make That's it! Everything is automatic and non-interactive. The build should work fine on all fully supported platforms. If it does not, we want to know! with 3. cd into the Sage directory and type make: cd sage-*/ make That's it! Everything is automatic and non-interactive. The build should work fine on all fully supported platforms. If it does not, we want to know! If you want to build in parallel, see below. [] Thanks. /J -- 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. -- 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: (unknown)
sage: Integers(45)['t'] Univariate Polynomial Ring in t over Ring of integers modulo 45 I don't think we have linear algebra over general non-integral-domains, but sage: R = GF(5)['x'] sage: M = random_matrix(R, 4, 4); b = random_vector(R, 4); x = M \ b sage: M*x (4*x^2 + x + 4, x^2 + 2*x + 4, 4*x^2 + 2*x + 3, x^2 + 2*x + 4) sage: b (4*x^2 + x + 4, x^2 + 2*x + 4, 4*x^2 + 2*x + 3, x^2 + 2*x + 4) On Wed, Oct 23, 2013 at 11:36 AM, Juan Grados juan...@gmail.com wrote: thanks, and if the system coefficients are polynomials over finite field? Is there PolynomialModRing(p(x))? 2013/10/23 P Purkayastha ppu...@gmail.com Exists in Sage: sage: I6 = IntegerModRing(6) sage: M = random_matrix(I6, 4, 4) sage: v = random_vector(I6, 4) sage: M \ v (4, 0, 2, 1) On 10/23/2013 09:11 PM, Juan Grados wrote: Exists in python, any instruction to solve a linear system equations module n (integer). In mathematica for example If exists http://mathematica.stackexchange.com/questions/31696/solving-a-system-of-linear-equations-modulo-n. thanks -- - MSc.Juan del Carmen Grados Vásquez Laboratório Nacional de Computação Científica Tel: +55 24 2233-6260 tel:%2B55%2024%202233-6260 (http://www.lncc.br/) http://juaninf.blogspot.com - -- 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. -- - MSc. Juan del Carmen Grados Vásquez Laboratório Nacional de Computação Científica Tel: +55 24 2233-6260 (http://www.lncc.br/) http://juaninf.blogspot.com - -- 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] Re: Left and right limits (is default of 'dir' None?)
On Mon, Aug 19, 2013 at 6:30 PM, Dima Pasechnik dimp...@gmail.com wrote: On 2013-08-19, Vincent Knight knigh...@cf.ac.uk wrote: --001a1133aa8653f2ed04e4510b09 Content-Type: text/plain; charset=ISO-8859-1 Thanks for the answer kcrisman but I'm afraid I'm still not sure I understand. If by 'unsigned infinity' you mean that Sage is returning positive infinity (but assuming that there is no need to return the '+') then I agree but I also still don't think that this is the required behaviour right? The undirected limit should is not defined (so Sage should return that the 'undefined') and given the help file, the output is a bit confusing... If I'm missing something please do forgive me :) IMHO unsigned infinity simply means NaN (Not a Number). Correct me if I'm wrong here. No, the unsigned infinity is the infinity in the real projective line, and is indeed the limit here. It comes up more naturally, of course, in other areas like doing complex analysis on the Riemann sphere. On 19 August 2013 19:17, kcrisman kcris...@gmail.com wrote: On Monday, August 19, 2013 1:55:04 PM UTC-4, Vince wrote: When computing the limit of a function I don't quite seem to be getting the behaviour that I expected. --- sage: f(x) = 1 / x sage: print f.limit(x=0) sage: print f.limit(x=0, dir='minus') --- The first limit returns infinity, but I would expect it to return that the limit is not defined. I think we have an unsigned infinity and a signed infinity. It should return the former, from Maxima. The second (directional) limit confirms this (it returns -infinity). I was assuming that the default 'direction' for a limit is None and that a two directional limit would be computed (which in this case does not exist). Here's some of the help file that shows why I am perhaps confused: --- INPUT: - ``dir`` - (default: None); dir may have the value 'plus' (or '+' or 'right') for a limit from above, 'minus' (or '-' or 'left') for a limit from below, or may be omitted (implying a two-sided limit is to be computed). --- If anyone could clarify this I'd appreciate it. Vince -- 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. -- Dr Vincent Knight Cardiff School of Mathematics Senghennydd Road, Cardiff CF24 4AG (+44) 29 2087 5548 www.vincent-knight.com +Vincent Knight @drvinceknight Skype: drvinceknight -- 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] arrays in Sage's cython
Using a Python list is probably the fastest way to iterate over an array of Python objects--it's a PyObject** under the hood and Cython uses the C API calls to get at it. Your check might be the bottleneck, especially if it's a Python call. Also, no need to write this as a while loop; just use for a in range(100) and it'll do the right thing (a C for loop). On Wed, Aug 21, 2013 at 12:33 PM, Daniel Krenn kr...@aon.at wrote: I need an array of Elements of RealIntervalField and I want to iterate (a lot of times) through it. How can I do that in a fast way in Sage's cython (i.e. in the notebook or in a .spyx-file)? An (minimal) example what I basically want is given below (PS). I tried the following things (and a lot more) in the Sage notebook as well as in a .spyx-file: 1. using vector from libcpp cimport vector gives filename.c:317:18: fatal error: vector: file or directory not found compilation terminated. error: command 'gcc' failed with exit status 1 At least I found the file in Cython/include/... 2. using C arrays cimport sage.rings.real_mpfi # do not know whether that is needed... from sage.rings.real_mpfi cimport RealIntervalFieldElement cdef RealIntervalFieldElement L[10] says cdef RealIntervalFieldElement L[10] ^ filename.pyx:12:31: Array element cannot be a Python object I thought that with cimport I get a C/cython object (but maybe I have too less understanding of it) 3. using some pointers from sage.rings.real_mpfi cimport RealIntervalFieldElement from sage.all import RIF cdef void* L[10] cdef RealIntervalFieldElement r = RIF(100) L[0] = r gives cdef RealIntervalFieldElement r = RIF(100) L[0] = r ^ filename.pyx:15:7: Cannot take address of Python variable I am thankful for any input. Daniel PS: Here is what I want faster: L = [blabla] # a python list of length about 500 a=0 while a1000: b = something(a) for ell in L: if check(a,b,ell): print yeah # or do whatever a += 1 L is a list of RealIntervalField elements; b is a RealIntervalElement, too. -- 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] Solve Binary Linear System
sage: A = random_matrix(GF(2), 1, 1) sage: A.det() 1 sage: b = random_vector(GF(2), 1) sage: %time x = A \ b CPU times: user 1.61 s, sys: 0.06 s, total: 1.67 s Wall time: 1.67 s sage: A * x == b True On Wed, Apr 17, 2013 at 1:45 PM, Juan Grados juan...@gmail.com wrote: I have the equation Ax=b where all matrix entries and all entrie of vector b are in GF(2). How I will be able to solve this linear system equation over GF(2) in SAGE software? -- - MSc. Juan del Carmen Grados Vásquez Laboratório Nacional de Computação Científica Tel: +55 24 2233-6260 (http://www.lncc.br/) http://juaninf.blogspot.com - -- 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?hl=en. 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Inconsistency regarding QQ and ZZ?
The syntax R.A,d = QQ[] creates a polynomial ring in two variables, with generators A and d (bound to the current session). A^d is not a polynomial in A and d over QQ. sage: R.A,d=QQ[] sage: R Multivariate Polynomial Ring in A, d over Rational Field On Sun, Mar 17, 2013 at 12:51 AM, Rolandb roland.vandenbr...@gmail.com wrote: Hi, QQ[] is a field of rationals fractions and ZZ[] of integers. The following puzzles me: sage: R.A,d=QQ[] sage: factor(A^d+2*A-3) Traceback (most recent call last): ... TypeError: non-integral exponents not supported sage: R.A,d=ZZ[] sage: factor(A^d+2*A-3) Traceback (most recent call last): ... TypeError: non-integral exponents not supported Or is the message non-integral exponents not supported not clear to me? Sage Version 5.7 Windows Roland -- 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?hl=en. 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] sage vs matlab
On Mon, Mar 4, 2013 at 11:54 AM, Luis Finotti luis.fino...@gmail.com wrote: On Monday, March 4, 2013 2:42:48 PM UTC-5, Dr. David Kirkby wrote: I think Sage would have a hard job breaking into the MATLAB strongholds in engineering. It is used to control a lot of instruments and data collection. Agilent, who are probably the world's premier test equipment manufacturer do not generally sell products like MATLAB. However, if you purchase an eligible instrument Agilent well sell a MATLAB license. http://www.home.agilent.com/agilent/editorial.jspx?cc=USlc=engckey=2001996nid=-0.781262id=2001996 Perhaps Sage, linked into all the required open-source sotware could perhaps do everything MATLAB can. What it wont have what is acceptance in the industry like MATLAB does. Dave (a Chartered Engineer, not a mathematician!) Thanks all for the replies so far. I can see the stronghold of MATLAB... Can anyone comment on how fast is Sage (with SciPy and/or NumPy) in some concrete applications or benchmarks? Performance is typically dominated by the underlying system BLAS which both NumPy and MATLAB will call under the hood to do the actual number crunching. Python (and, if necessary, Cython) tends to have better performance when you can't express your problem as a large linear algebra expression (whereas the typical modus operandi is to contort your problem into matrix multiplies and system solves, no matter how inefficient, and then let it churn on that as element-wise manipulation is really slow). I agree that asking on NumPy/SciPy lists makes more sense, I know a lot of people who have switched from MATLAB to those tools (of which Sage is a superset). It also depends on how much freedom you'll have--if you get a job where everyone uses MATLAB you might not have much choice but if you're doing research than you can use whatever tools allow you to work/collaborate best. - Robert -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] using cpickle to store matrix object
It's cPickle with a capital P. On Wed, Feb 20, 2013 at 2:30 AM, akhil lalwani.ak...@gmail.com wrote: Hello, I want to use cpickle to store a matrix object in a text file. Sample code is as follows: A = matrix(GF(2),2,3) #creating a 2 * 3 matrix having all entries zero import cpickle as pickle pickle.dump(A,open(testpickle.txt,'w')) sage: Traceback (most recent call last): File s_rough.py, line 6, in module import cpickle as pickle ImportError: No module named cpickle The same code when tried with the pickle module, works as desired. Is this because cpickle is not supported in SAGE? Or is there a mistake in the way it is being called? Please help. Thanks and regards, AKHIL. -- 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?hl=en. 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Link explaining types of decimal numbers
First, I would recommend reading up on floating point arithmetic. A cannonical reference is http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html , but if that's a bit dense there are many other good sources on the web. Things get more interesting for Sage, as there are several models for floating point numbers available depending on the use. In turn these are (1) float, created with float(3.0) or 3.0r, which is the native Python floating point represented by the machine (typically IEEE 754 double or extended precision), fastest but potentially less accurate and platform dependant. (2) sage.rings.real_double.RealDoubleElement, created by RDF(3.0), which is also IEEE 754 double or extended precision, but has more sage-specific functionality. (3) sage.rings.real_mpfr.RealNumber, the default, created by RR(3.0) or doing arithmetic with 3.0, back by http://www.mpfr.org/ to 53-bits of precision, accurate rounding on all operations, platform-independent, but slower than the above (3b) sage.rings.real_mpfr.RealNumber with alternative precision, e.g. RealField(1000)(3) for 1000 bits (not digits) of precision. Less common: (4) sage.rings.real_mpfi.RealIntervalFieldElement, created by RIF(3.0), which does arithmetic on intervals (as most real numbers can't be represented accurately) and can bue used to provide provable statements of inequality. Can also be arbitrary precision, e.g. RealIntervalField(1000)(3) (5) RLF, the real lazy field (mostly used under the hood for coercion from exact to in-exact domains). (5) sage.rings.real_mpfr.RealLiteral, which is what you get when typing 3.0, which stores the typed value to infinite precision and converts to a fixed precision (53-bit if implicit) upon demand. This is needed so that RealField(1000)(1.2) is 1.2 to 1000 bits, not just 53 bits (as it would be if 1.2 was parsed to 53 bits then passed in to RealField(1000)). For all of the above, see RR?, RDF?, etc. for (lots!) more documentation. - Robert On Wed, Jan 23, 2013 at 8:59 AM, LFS lfahlb...@gmail.com wrote: Hi - I would appreciate if someone could point me to a link explaining the difference (if there is a difference) between: type 'sage.rings.real_mpfr.RealLiteral' (Here I input x=3.) type 'float' (Here I input xx=float(3)) type 'sage.rings.real_mpfr.RealNumber' (Here I input 1/x) . My page: http://sage.math.canterbury.ac.nz/home/pub/247 Thanks so much, Linda -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] algebraic number to integer conversion?
When you say plot these values, do you mean as real or complex values? To do so you need to choose an embedding, e.g. sage: K.a = QQ[sqrt(5)]; K Number Field in sqrt5 with defining polynomial x^2 - 5 sage: K.embeddings(CC) [ Ring morphism: From: Number Field in sqrt5 with defining polynomial x^2 - 5 To: Complex Field with 53 bits of precision Defn: sqrt5 |-- -2.23606797749979, Ring morphism: From: Number Field in sqrt5 with defining polynomial x^2 - 5 To: Complex Field with 53 bits of precision Defn: sqrt5 |-- 2.23606797749979 ] sage: f = K.embeddings(CC)[1] sage: f(a) 2.23606797749979 sage: f(1 + a) 3.23606797749979 sage: f(a^2) 5.00 If they are actually integral, you can do sage: ZZ(a^2) 5 sage: ZZ(a) Traceback (most recent call last): File ipython console, line 1, in module File parent.pyx, line 804, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7228) File coerce_maps.pyx, line 156, in sage.structure.coerce_maps.NamedConvertMap._call_ (sage/structure/coerce_maps.c:4557) File number_field_element_quadratic.pyx, line 956, in sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic._integer_ (sage/rings/number_field/number_field_element_quadratic.cpp:8718) TypeError: Unable to coerce sqrt5 to an integer On Wed, Oct 17, 2012 at 10:45 AM, Eric Kangas eric.c.kan...@gmail.com wrote: Hi, I am working with eigenvalues, and want to figure out a way to plot these values as a return map. I am using sage 4.7.2 on a ubuntu 10.10 on a Toshiba M200 tablet. Do I need to convert the algrbraic number to integers, or is there a way to plot these values? Eric -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] algebraic number to integer conversion?
On Wed, Oct 17, 2012 at 9:37 PM, Eric Kangas eric.c.kan...@gmail.com wrote: code: b = 11^2 a = b^2 pri = [int(is_prime(i)) for i in range(a)] j = [i for i in range(a)][b+1:a:b] k = [i for i in range(a)][(b*2)+1:a:b] j.insert(0,0) k.insert(0,b) m = [matrix(QQ,sqrt(a)/(b/sqrt(b)),pri[j[i]:k[i]]) for i in range(len(j)-1)] eval = [m[i].eigenvalues() for i in range(len(m))] sage: eval[0] [0, 0, -2.689488289890632?, -1.629922151366316?, 0.9326384408005977?, 1.659378497883232?, 2.806129601401341?, -0.7002097052983131? - 0.1908799082669581?*I, -0.7002097052983131? + 0.1908799082669581?*I, 0.1608416558842022? - 0.4166325370716392?*I, 0.1608416558842022? + 0.4166325370716392?*I] sage: parent(eval[0][0]) Algebraic Field sage: [CC(x) for x in eval[0]] [0, 0, -2.68948828989063, -1.62992215136632, 0.932638440800598, 1.65937849788323, 2.80612960140134, -0.700209705298313 - 0.190879908266958*I, -0.700209705298313 + 0.190879908266958*I, 0.160841655884202 - 0.416632537071639*I, 0.160841655884202 + 0.416632537071639*I] sage: sum([plot(CC(x)) for x in eval[0]]) [pretty picture] -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] GPL and code generation using sage
On Wed, Sep 26, 2012 at 10:56 PM, Geoffrey Irving irv...@naml.us wrote: On Wed, Sep 26, 2012 at 10:42 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Wed, Sep 26, 2012 at 8:54 PM, Geoffrey Irving irv...@naml.us wrote: On Wed, Sep 26, 2012 at 6:03 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Wed, Sep 26, 2012 at 4:28 PM, Geoffrey Irving irv...@naml.us wrote: Hello, I recently used sage to write a code generation script for exact geometric predicates: https://github.com/otherlab/simplicity Since it's a python script that imports sage, the simplicity script is GPL. Not automatically; often Sage is used more as an interpreter than a library: http://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html#IfInterpreterIsGPL The opposite has been said in previous discussions on this mailing list: like most GPL python libraries, including sage is amount to linking against sage, which means the script doing the including must be GPL. I'm fine with this situation. The snippet you posted doesn't link against Sage anymore than Python. I don't hold with the philosophy that all Sage worksheets are automatically GPL. What about snippets of Sage code used as examples in published works? I'm not a lawyer, but as far as I know not even the lawyers have hashed this out. Here's an example of a thread with people voicing opinions in either direction (this one in favor of copyleft): http://www.mail-archive.com/sage-devel@googlegroups.com/msg23091.html Yes, I was an active participant in that thread, http://www.mail-archive.com/sage-devel@googlegroups.com/msg23126.html I don't think much has changed since then. Unfortunately, in this situation I have to assume the worst, especially if the lawyers haven't hashed it out. Well, it's a question of ascertaining the risk. I think the risk is low (that is the risk this being an actual violation as decided by the courts, let alone the risk of actually being taken to court on it). The more important factor is respecting the intent of the community, which you're clearly trying to do. As another data point, the GNU Bison project has an exception, but links in pure GPL libraries (iconv) that don't make mention of any exception. My hypothesis is that this is OK because the part of the source included in the output is part of Bison, not iconv. That's a good point, and would apply to my case as well (all the copied snippets are bits of C++ code unrelated to Sage). Not sure if I get it by the lawyers, but definitely worth a try. Thanks! (To go to one extreem, I suppose one could put all the C++ code strings in a separate file and call them a second input to your program, after all they're more data than code.) That being said, a runtime exemption could make a lot of sense, e.g. if we want to augment our fast_callable classes to spit out chunks of code in various languages. Okay. For now, it looks like the easiest way may be to port my code to sympy. That may be a fine thing to do, but it's sad when legal fluff does nothing but add busywork... Agreed! Sage is a wonderful system, and it's a shame to not be able to use it. On the other hand, copyleft certainly isn't legal fluff, and people's choices should be respected. Oh, I agree. I'm talking about the corner cases like what line one needs to cross for a simple script to be considered a derived work and how that impacts re-distributing its output. I would be extremely surprised if any Sage developer morally objects to you licensing this output as you wish (though opinions may vary widely as to its legality). - Robert -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] Re: Notebook server very slow. What are typical bottlenecks? I have ver5.2 and 1Gb RAM
I'd go for several 100M of RAM each, likely 0.5G to be comfortable, plus some memory for the OS and server itself. Throw 4G at it and it should behave much better, 8G and you should be good to go. Something like https://github.com/jasongrout/sage-forker would likely greatly reduce this requirement. On Wed, Sep 26, 2012 at 9:54 AM, Chris Seberino cseber...@gmail.com wrote: I have a Xen Ubuntu Linux 1 Gb RAM virtual machine from a provider called Linode. I am running a notebook server on that virtual machine for my classes... even with only a handful of students hitting it at the same time it slows to a crawl. Is getting more RAM the only solution? How much do you need for 10 people to be able to hit the server all at the same time comfortably? cs On Monday, September 24, 2012 8:31:16 PM UTC-5, kcrisman wrote: On Monday, September 24, 2012 8:32:23 PM UTC-4, Chris Seberino wrote: Notebook server very slow. What are typical bottlenecks? I have ver5.2 and 1Gb RAM cs This is a little vague. Do you mean on your own personal computer, or are you trying to run a notebook server for others (e.g., students)? It's pretty likely that with more than a couple users, this would be too little RAM. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] GPL and code generation using sage
On Wed, Sep 26, 2012 at 4:28 PM, Geoffrey Irving irv...@naml.us wrote: Hello, I recently used sage to write a code generation script for exact geometric predicates: https://github.com/otherlab/simplicity Since it's a python script that imports sage, the simplicity script is GPL. Not automatically; often Sage is used more as an interpreter than a library: http://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html#IfInterpreterIsGPL That being said, the GPL only covers *distribution*. If indeed you built on Sage and wanted to release the resulting work, you would have to do so under the GPL (or a compatible license, and you could release it under other licences or public domain in addition to that). If you just want to use it on your own machine(s), or share it internally, there's no requirement to so license it. You can then do whatever you want with the output. (If the output contained significant portions of Sage itself, that would be a different story.) That being said, a runtime exemption could make a lot of sense, e.g. if we want to augment our fast_callable classes to spit out chunks of code in various languages. However, I want the C++ *output* of this script to be license unencumbered, so that I can incorporate into either BSD licensed software (https://github.com/otherlab/core) or commercial software. As discussed in http://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html#GPLOutput doing this safely appears to require a special exception in the license, since the simplicity script copies a bunch of tiny portions of itself into the output. Examples include ... warning = '// Exact geometric predicates\n// Autogenerated by simplicity.py: DO NOT EDIT\n' ... body.append(' for (int i=starts[permutation];;i++) {') body.append('const bool f = terms[i]1;') body.append('switch (terms[i]1) {') Has anyone done anything similar before with sage? It seems questionable to add the runtime exemption to my license when it isn't in sage's, so I thought I'd ask here first. Thanks, Geoffrey -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] GPL and code generation using sage
On Wed, Sep 26, 2012 at 8:54 PM, Geoffrey Irving irv...@naml.us wrote: On Wed, Sep 26, 2012 at 6:03 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Wed, Sep 26, 2012 at 4:28 PM, Geoffrey Irving irv...@naml.us wrote: Hello, I recently used sage to write a code generation script for exact geometric predicates: https://github.com/otherlab/simplicity Since it's a python script that imports sage, the simplicity script is GPL. Not automatically; often Sage is used more as an interpreter than a library: http://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html#IfInterpreterIsGPL The opposite has been said in previous discussions on this mailing list: like most GPL python libraries, including sage is amount to linking against sage, which means the script doing the including must be GPL. I'm fine with this situation. The snippet you posted doesn't link against Sage anymore than Python. I don't hold with the philosophy that all Sage worksheets are automatically GPL. What about snippets of Sage code used as examples in published works? I'm not a lawyer, but as far as I know not even the lawyers have hashed this out. That being said, the GPL only covers *distribution*. If indeed you built on Sage and wanted to release the resulting work, you would have to do so under the GPL (or a compatible license, and you could release it under other licences or public domain in addition to that). If you just want to use it on your own machine(s), or share it internally, there's no requirement to so license it. You can then do whatever you want with the output. (If the output contained significant portions of Sage itself, that would be a different story.) Code that can't be distributed essentially doesn't exist for my purposes. I didn't say you couldn't distribute it. Essentially, you have Sage (GPL) + script (no licence) - output. As long as the output doesn't contain portions of Sage, it's your creation to distribute under whatever licence you want. As another data point, the GNU Bison project has an exception, but links in pure GPL libraries (iconv) that don't make mention of any exception. My hypothesis is that this is OK because the part of the source included in the output is part of Bison, not iconv. That being said, a runtime exemption could make a lot of sense, e.g. if we want to augment our fast_callable classes to spit out chunks of code in various languages. Okay. For now, it looks like the easiest way may be to port my code to sympy. That may be a fine thing to do, but it's sad when legal fluff does nothing but add busywork... - Robert -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] randint - Maybe one bug !
I agree that this is a surprising and unfortunate wart in the was Sage is built. I would explain it like this: Python has an integer type int that has several surprising behaviors (from a mathematicians perspective, e.g. division). For this reason we created our own time, Integer, that behaves better (and has a whole lot more functionality, e.g. factoring). It's not the division that's different, but the types (the same way integers and floating point numbers and polynomials, etc. are all different types and do their own kind of division). These are We do some magic so that any integer you type becomes the Sage Integer, but builtin Python functions still return Python integers so beware. At this level, it's probably safe to wrap anything your unsure of in ZZ(...) or Integer(...). Changing internal Python functions to return Sage integers would be technically difficult and very backwards incompatible (considering the number of Python packages, including internally in our own libraryies, that understand and expect Python ints). - Robert On Wed, Sep 19, 2012 at 9:42 AM, Christophe BAL projet...@gmail.com wrote: What I think very confusing is that 1/4 is the Sage division and not the Python standard one, so why it would be different for randint ? I'm a teacher and the problem is not from my point of view but it will be a tricky thing to explain to my students which are in french lycée (sorry, I don't know the english equivalent level). There are only 18 years old and the programmation is only a tool... Christophe 2012/9/19 D. S. McNeil dsm...@gmail.com I really think that this is illogical. Don't you ? No, because it's perfectly consistent. I can see why it's not obvious, though -- and for related reasons, in Python 3 the division of two ints produces a float (or in Python 2 if you `from __future__ import division`). That won't help us much though because we need to preprocess ints into Integers anyway. I guess that here there are some Sage-type conversions coming from ``+/- 1*...``. Yep. You're multiplying a Sage Integer by a Python integer, which produces a Sage Integer. From my point of view, using in Sage, ``randint`` should produce Sage integers and not Python integer. Not an unreasonable expectation, although I would probably suggest using a different name for the function instead to prevent confusion with random.randint. But in the case of integers, you could also get a random integer right from ZZ instead (with randrange behaviour instead of randint): sage: ZZ.random_element(10, 20) 13 So I could take or leave adding another function. Doug -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] Calling up pi to nth decimal place.
BBP won't help you compute the decimal digits of pi. On Fri, Aug 17, 2012 at 9:28 AM, Eric Kangas eric.c.kan...@gmail.com wrote: So it looks like I will have to setup a super computer to calculate pi out to graham's digit. With the string-list idea I could be able to get up to 24 million before my computer crashes due to out of memory. Also I will look into the Bailey-Borwein-Plouffe formula, and hope to convert each digit from binary to base 10. On Wednesday, August 15, 2012 11:39:12 PM UTC-7, Robert Bradshaw wrote: On Wed, Aug 15, 2012 at 5:55 PM, Eric Kangas eric.c...@gmail.com wrote: Yea crashing due to being out of memory. You could go a bit further by doing the string - list of ints part piecemeal. The memory usage of 1000 digits is 1000 + epsilon bytes, but a list of 1000 ints is something like 24000+ bytes. So I will have to convert from binary just to recall from mth to nth decimal place? The only (known) way to get the mth to nth decimal place is to compute the whole thing to the nth decimal place, as a decimal number, then ignore everything up to the mth. - Robert -- -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Calling up pi to nth decimal place.
On Wed, Aug 15, 2012 at 5:55 PM, Eric Kangas eric.c.kan...@gmail.com wrote: Yea crashing due to being out of memory. You could go a bit further by doing the string - list of ints part piecemeal. The memory usage of 1000 digits is 1000 + epsilon bytes, but a list of 1000 ints is something like 24000+ bytes. So I will have to convert from binary just to recall from mth to nth decimal place? The only (known) way to get the mth to nth decimal place is to compute the whole thing to the nth decimal place, as a decimal number, then ignore everything up to the mth. - Robert -- -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Calling up pi to nth decimal place.
On Wed, Aug 15, 2012 at 5:10 PM, Eric Kangas eric.c.kan...@gmail.com wrote: Hi, I am trying to figure out a way to call up the sequence for pi to a very large number ie. centillion, googleplex, even Graham's number. However sage crashes around 10 million decimal places. Crashing how? Out of memory? So I am wanting to figure out a way to call up this sequence in sections (mth to nth decimal place) rather then having to start the sequence from the beginning. As far as I know, there's no way to do that in base 10. (For base 2^n, of course, there's the Bailey-Borwein-Plouffe formula.) Here is the coding I am working on right now. a = 1000 p = list(str(n(pi, digits = a))) p.remove('.') p = [int(i) for i in p] -- -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Fraction Fields coefficients
Perhaps your looking for something like sage: R.x = QQ[] sage: f = 2 * x^2 / (x^3 + 5); f 2*x^2/(x^3 + 5) sage: f.numerator().list() [0, 0, 2] sage: f.denominator().list() [5, 0, 0, 1] On Sat, Jun 30, 2012 at 8:26 PM, juaninf juan...@gmail.com wrote: Dears members, How I will can get the coefficients list in Fraction Field. When I write p.lis() i obtained this message: 'FractionFieldElement_1poly_field' object has no attribute 'list' -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Comparison of approximate real numbers
On Tue, Jun 12, 2012 at 4:11 PM, William Stein wst...@gmail.com wrote: On Tue, Jun 12, 2012 at 3:54 PM, rych rych...@gmail.com wrote: Interval arithmetics also gives False, sage: from mpmath import iv sage: # iv.prec = 24 sage: # iv.prec = 53 # for double precision sage: x = 0.1 sage: iv.prec = x.prec() # precision of Sage Real numbers, 53 sage: iv.pretty = True sage: iv.mpf('10.44') [10.439503, 10.441279] sage: iv.mpf('10.44')-iv.mpf('10.30') [0.13879208, 0.14234479] sage: iv.mpf('0.14') [0.13998557, 0.14001332] sage: iv.mpf('10.44')-iv.mpf('10.30') == iv.mpf('0.14') False sage: iv.mpf('10.44')==iv.mpf('10.44') True Another approach to interval arithmetic: sage: RIF Real Interval Field with 53 bits of precision sage: RIF('10.44') - RIF('10.30') 0.14? sage: RIF('10.44') - RIF('10.30') == RIF('0.14') False sage: a = RIF('10.44') - RIF('10.30'); b = RIF('0.14') sage: a in b False sage: b in a True sage: a.intersection(b) 0.1400? sage: 0 in (a-b) True -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] MathML
There are two parts to this, sage - MathML (which is what the rudimentary _mathml_ methods are for) and MathML - sage (which it seems you've written, and might be more useful). To include this into Sage, I would probably create a file sage/interfaces/mathml.py with a single parse_mathml(...) function in it. Follow the developer guide to create a patch, write doctests, etc.. This would return a newly constructed Sage object from a mathml string. Even just attaching your code to http://trac.sagemath.org/sage_trac/ticket/13086 would be useful as a first step (and probably allow for more specific advice). - Robert On Mon, Jun 4, 2012 at 1:46 PM, kcrisman kcris...@gmail.com wrote: BTW, we have built a MathML - Sage input translator. This allows us to take simple expressions produced from, say, the MathDox formula editor and pass them to Sage for processing. How do I submit this for inclusion in Sage? I have never felt sufficiently confident to want to submit any of my efforts heretofore, but this works fairly well. John A. Velling Hi John, I think we spoke at the Joint Meetings about some of your projects, a conversation I wasn't able to follow up on due to time constraints (though I still have your email on a Sage business card). Here are some things you may want to do with this; this sounds quite valuable. First, look at http://trac.sagemath.org/sage_trac/browser/sage/misc/mathml.py which is a (very old) implementation of some kind of MathML output from Sage thing. I have no idea if it is any good or works, given that there are no docstrings :) and there is also sage: search_def('mathml') misc/mathml.py:57:def mathml(x): rings/integer.pyx:1035: def _mathml_(self): rings/rational.pyx:705: def _mathml_(self): symbolic/constants.py:239:def unpickle_Constant(class_name, name, conversions, latex, mathml, domain): symbolic/constants.py:268: def __init__(self, name, conversions=None, latex=None, mathml=, symbolic/constants.py:414: def _mathml_(self): symbolic/expression.pyx:669: def _mathml_(self): so at least a tiny bit of support, but it's very rudimentary. Here's one doctest: sage: mathml(pi+2) MATHML version of the string pi + 2 For some history, some comments William made a few years ago. http://www.mail-archive.com/sage-edu@googlegroups.com/msg00234.html I suppose that when we switch to MathJax we could potentially do a Sage - MathJax - MathML conversion trip. Does jsmath support MathML? I don't think so. Also, unless this was you, which I don't think, others have asked about this. See for example http://ask.sagemath.org/question/527/parse-and-evaluate-mathml - so this is a great project. Finally, where to contribute? Amazingly, there isn't an open Trac ticket for this. I've opened http://trac.sagemath.org/sage_trac/ticket/13086 for this. All you have to do is acquire a Trac account (see http://trac.sagemath.org/sage_trac/ for instructions, this is not hard) and post code. Ideally, of course, this would be something created using our standard developer workflow (see http://www.sagemath.org/doc/developer/index.html) but I'm not sure exactly how you've put it there. I feel like this should go in sage/interfaces/mathml.py, and maybe the old stuff should too. See http://trac.sagemath.org/sage_trac/browser/sage/interfaces/r.py or other files in sage/interfaces, especially the def _sage_(self): methods. If some students helped, so much the better - we love having new contributors and helping students see that computation and math go together. Good luck! - kcrisman -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: How to fix the path generated by tmp_filename() ?
os.path.normpath is handy for cleaning stuff like this up too (including removing /../ and /./). Doesn't really matter here, but is nice when one wants to compare paths or prefixes. - Robert On Mon, Jun 4, 2012 at 8:17 AM, Volker Braun vbraun.n...@gmail.com wrote: Posix stipulates that multiple successive slashes are considered to be the same as one slash. Its still ugly and not portable beyond posix, though. On 6/4/12 8:50 AM, Ruslan Kiianchuk wrote: However it was a surprise for me that extra slashes in the path are alright. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Discrete logarithm
sage: var('x,y') (x, y) sage: E = EllipticCurve(y^2 == x^3 - 36*x) sage: P=E(-3,9) sage: Q=E(12,36) sage: discrete_log(Q, P, operation='+', bounds=(0,100)) --- ValueErrorTraceback (most recent call last) ... ValueError: No discrete log of (12 : 36 : 1) found to base (-3 : 9 : 1) There is no such n, despite P being a generator. Maybe there's some torsion? sage: E.torsion_order() 4 sage: discrete_log(4*Q, P, operation='+', bounds=(0,100)) 4 sage: (P - Q) (0 : 0 : 1) sage: (P - Q).height() 0 sage: discrete_log?? Totally generic discrete log function. INPUT: - ``a``- group element - ``base`` - group element (the base) - ``ord`` - integer (multiple of order of base, or ``None``) - ``bounds`` - a priori bounds on the log - ``operation`` - string: '*', '+', 'other' - ``identity`` - the group's identity - ``inverse()`` - function of 1 argument ``x`` returning inverse of ``x`` - ``op()`` - function of 2 arguments ``x``, ``y`` returning ``x*y`` in group ... On Sat, May 26, 2012 at 2:14 PM, raman kurdi raman.kurdi2...@gmail.com wrote: Hi Dears, I have the elliptic curve Y^2=X^3-36X and P=(-3,9) as the its generator. Q=(12,36) is the other point on this curve. I would like to solve Discrete Logarithm but I do not know. Please tell me how I can find the n which nQ=p. Best, Raman -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: error in comparison of pi
Yes, I consider sage: bool(piInfinity) False to be a silent, incorrect result. stopgap is a reference to a ticket that makes the error non-silent. On Sat, May 12, 2012 at 1:02 AM, P Purkayastha ppu...@gmail.com wrote: I think the stopgap was introduced for the case where Sage silently gives incorrect results. On Saturday, May 12, 2012 4:06:50 AM UTC+8, kcrisman wrote: On Friday, May 11, 2012 3:34:26 PM UTC-4, Robert Bradshaw wrote: Did we ever decide on a standard label for mathematically incorrect results? This shouldn't drop under the radar. There is the stopgap terminology, but that's not what we called the incorrect result, that's for the stopgap ticket itself. On Fri, May 11, 2012 at 8:37 AM, P Purkayastha ppu...@gmail.com wrote: On Friday, May 11, 2012 4:58:53 PM UTC+8, Robert Samal wrote: Hi! By some random experiments I discovered the following weirdness: sage: bool(piInfinity) False sage: bool(piInfinity) True This looks like a bad bug. I think you can open tickets for things like this without announcing first. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: error in comparison of pi
Did we ever decide on a standard label for mathematically incorrect results? This shouldn't drop under the radar. On Fri, May 11, 2012 at 8:37 AM, P Purkayastha ppu...@gmail.com wrote: On Friday, May 11, 2012 4:58:53 PM UTC+8, Robert Samal wrote: Hi! By some random experiments I discovered the following weirdness: sage: bool(piInfinity) False sage: bool(piInfinity) True This looks like a bad bug. I think you can open tickets for things like this without announcing first. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: error in comparison of pi
Yeah, stopgap refers to the other ticket in case the bug is hard to fix. How about bogus or badmath? On Fri, May 11, 2012 at 1:06 PM, kcrisman kcris...@gmail.com wrote: On Friday, May 11, 2012 3:34:26 PM UTC-4, Robert Bradshaw wrote: Did we ever decide on a standard label for mathematically incorrect results? This shouldn't drop under the radar. There is the stopgap terminology, but that's not what we called the incorrect result, that's for the stopgap ticket itself. On Fri, May 11, 2012 at 8:37 AM, P Purkayastha ppu...@gmail.com wrote: On Friday, May 11, 2012 4:58:53 PM UTC+8, Robert Samal wrote: Hi! By some random experiments I discovered the following weirdness: sage: bool(piInfinity) False sage: bool(piInfinity) True This looks like a bad bug. I think you can open tickets for things like this without announcing first. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: error in comparison of pi
It's no longer (necessarily) a blocker once a stopgap has been assigned. On Fri, May 11, 2012 at 5:01 PM, John H Palmieri jhpalmier...@gmail.com wrote: On Friday, May 11, 2012 2:55:19 PM UTC-7, Robert Bradshaw wrote: Yeah, stopgap refers to the other ticket in case the bug is hard to fix. How about bogus or badmath? How about blocker? :) -- John -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Importing Cython .so module
On Thu, Apr 19, 2012 at 12:48 PM, Emil emi...@gmail.com wrote: On 19 April 2012 07:20, Robert Bradshaw rober...@math.washington.edu wrote: It might be distutils. It might be Cython. It might even be Sage or Python. But without knowing exactly how you're trying to compile/install your package, it's hard if not impossible to give any specific recommendations on what to change to get the result you want. Thanks Robert, but I've actually just managed to accidentally fix the problem! That's good to hear. I added an ext_package='...' declaration to the setup.py file, which broke things, but when I removed it and reinstalled, everything worked! I don't know what to make of all this. I'd really like to see more documentation on how to distribute packages for Sage that are not intended to part of Sage proper. I can't volunteer for this myself (at present) as I barely understand how things work and have only managed to get something working by accident. There should be little, if any, difference from how you would write a Python package outside of the Sage context. (In fact, I can't think of anything sage-specific to add...) While it's widely acknowledge that the Python packaging ecosystem is far from ideal, looking at more generic resources (e.g. distutils, setuptools, or in the Python documentation itself) should help. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Importing Cython .so module
On Sat, Apr 7, 2012 at 4:06 AM, Emil emi...@gmail.com wrote: On 7 April 2012 01:14, Maarten Derickx m.derickx.stud...@gmail.com wrote: Does executing: import foo give what you want or is your problem different? import foo doesn't do much, as foo/__init__.py is empty. I have adopted the Sage-like behaviour of having an all.py file which has from bar import * statements. The issue is that all.py contains lines like: from bazz import * from bar import * For some reason, the line corresponding to the bar.so file imports things into the top-level of the name space, rather than as foo.bar.. I can't find anything in the Cython docs or anywhere else about how to stop this. The Sage Cython modules seem to be imported into the correct places in the namespace hierarchy, so it must be possible... Just a guess, does placing an __init__.pxd file at that level help? Are you compiling the .so file and then moving it into place? (The fully qualified name of the pyx file is determined at compile time.) Otherwise, could you try posting a tarball/repo that illustrates the problem for someone to play around with? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Random Polynomials with restricted coefficients and homogeneous.
Doing sage: ZZ.random_element? tells you that ZZ takes x and y arguments for min/max. Polynomial rings' random_element pass extra keywords down to the basrings, so one can do sage: P.random_element(degree=10, terms=10, x=-9, y=9) -9*x^8*y^2 + x^8 + x^7*y + 8*x^6*y^2 - 7*x^2*y^6 - 2*x^6*y + 4*x*y^2 - 5*y^3 sage: P.random_element(degree=10, terms=10, x=100, y=200) 113*x^2*y^8 + 107*x^6*y^3 + 104*x^2*y^7 + 102*x*y^8 + 194*x*y^6 + 196*x^3*y^3 + 192*x^5 + 133*x^4*y + 179*x^3*y^2 + 152*x*y^2 To make a homogeneous polynomial, you could do sage: S.random_element(x=-9,y=0, degree=10)(x/y) * y^10 -7*x^10 - 5*x^9*y - 6*x^8*y^2 - 3*x^7*y^3 - 8*x^6*y^4 - 2*x^5*y^5 - 3*x^4*y^6 - 4*x^3*y^7 - 9*x^2*y^8 - 9*x*y^9 - 3*y^10 though this is unfortunately in the fraction field, so you'd have to cast it. sage: f = S.random_element(x=-9,y=0, degree=10)(x/y) * y^10 sage: f.parent() Fraction Field of Multivariate Polynomial Ring in x, y over Integer Ring sage: P(f) -9*x^10 - 5*x^9*y - 6*x^8*y^2 - 3*x^7*y^3 - 9*x^6*y^4 - 9*x^5*y^5 - x^4*y^6 - x^3*y^7 - 8*x^2*y^8 - 3*x*y^9 - 5*y^10 sage: P(f).parent() Multivariate Polynomial Ring in x, y over Integer Ring You could also construct it directly (which may be faster for large degree): sage: dict(((k, 10-k), ZZ.random_element(-9, 9)) for k in range(10)) {(6, 4): -7, (5, 5): -5, (7, 3): 8, (2, 8): -1, (8, 2): 3, (0, 10): -4, (1, 9): -8, (9, 1): -5, (3, 7): -8, (4, 6): 7} sage: P(dict(((k, 10-k), ZZ.random_element(-9, 9)) for k in range(10))) -8*x^9*y + 4*x^8*y^2 - 6*x^7*y^3 - 4*x^5*y^5 - 5*x^4*y^6 + 4*x^3*y^7 - 3*x^2*y^8 + 2*x*y^9 - 3*y^10 - Robert On Fri, Apr 13, 2012 at 8:51 AM, PavelY yartsevpa...@gmail.com wrote: Hi. I've been working on making random polynomials with sage and I cant seem to find a way to create them with restricted coefficients (or make a homogeneous polynomial). I've been constructing my polynomials with the help of the random_element(degree, term) function on PolynomialRings(ZZ). However I cant seem to find a way to restrict the coefficients (ex: coefficients from -9 to 9) Here is a segment of my code: x,y = var('x,y') P.x,y=PolynomialRing(ZZ) fcn = P.random_element(degree=3,terms=4) This produces very large coefficients (at times). I would like to restrict them to -9..9 and make the random polynomial homogeneous. Please let me know if there are functions which take care of this, or if this polynomial needs to be created manually without the random function. Thank You. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
On Sat, Mar 31, 2012 at 3:42 PM, Emil emi...@gmail.com wrote: On 31 March 2012 12:47, Volker Braun vbraun.n...@gmail.com wrote: If it is of interest to an academic community then it probably should be part of Sage ;-) I'm not against it being incorporated into Sage at some point, but right now I'd rather keep it as a separate package that people can install, and import if they want to use it; but if they don't it will not pollute the name space (It contains classes with quite generic names like Problem and Construction.) From what I can tell, I can use Python distutils, and I can get the SAGE_ROOT from environment variables, so that I can set the include_dirs for the Cython compilation. Then I just give people a tar ball and tell them to run sage -python setup.py. That would work fine, or even a pointer to a repository that then can clone/contribute to. Does this sound a good strategy? Or would it be best to distribute an .spkg ? Can .spkg's install stuff into the site-packages directory outside the sage folder? Spks would work fine. IIRC, the default is to run setup.py if there's a setup.py in the sources (though note that all the code lives under a scr directory, and one needs a couple of metadata files. They're just bzipped tarballs, so the easiest way is to understand them unpack some and take a look. That being said, I would suggest contribute to the main library unless there's a strong reason not to. Also, is there any documentation on sage -pkg? Emil -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] infinite dictionary
You should take a look at Python's defaultdict. One of the design decisions was to cache all the values computed for a given key; if you want to do differently you could implement your own using __getitem__ and __setitme__. - Robert On Wed, Mar 21, 2012 at 1:28 PM, Daniel Krenn kr...@aon.at wrote: Is there something like an infinite dictionary in Sage/Python? More precisely, is there something where - i can put in values like in a dictionary, - but maybe also a function which tells me how to map a key to a value, - and maybe also something that maps a key to a (finite) set of keys and then gives the corresponding value? Formulated in another way, what I want to have is the following thing: I initialize it in a way (give values, functions, whatever) and then it just gives me for each key a value (on request). Daniel -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: How to test if something is integer ?
On Thu, Mar 15, 2012 at 8:48 AM, Laurent moky.m...@gmail.com wrote: and it would not make very much sense to provide a method for this class to test for integrality, since every such element is an Integer by definition. I suspect that in your intended application, A will be the result of come computation resulting in a real number, and you want to test whether it is (at least approximately) integral. Here are some ideas: You are guessing almost right. In my case A is an user-given angle value that will be passed to trigonometric functions. I want to guess if the user gave radiant or degree. My first test if if pi in repr(A) I cannot believe that someone will provide an angle with pi in degree. In that case, I deal with A as radian. Then my second test is to see if A is integer. One almost never deal with integer radian. So if the A is integer, I will deal with it as degree. I'm expecting some problems with degree values given as pi/2 * 180/pi (result of a conversion) But well, up to now my function works :) You'd want to make sure this behavior is well documented, otherwise it could have unexpected behavior (e.g. what happens if you try to plot it? Is 10.5 treated as a degree or radian?) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: CSV file
On Sun, Mar 4, 2012 at 10:34 AM, Nils Bruin nbr...@sfu.ca wrote: On Mar 4, 1:14 am, Robert Bradshaw rober...@math.washington.edu wrote: I think it's fair to test for strings first, trying to parse, before testing if it's an iterator. This is consistant with many other objects that try to parse their string representations. sage: ZZ['x']([1,2,3]) 3*x^2 + 2*x + 1 sage: ZZ['x'](123) 123 sage: ZZ['x'](x^2 + 5) x^2 + 5 Indeed. It's not quit consistent with duck typing, but well ... I guess matrix(S) would do: if isinstance(S,basestring): do our best to parse S as a string rep of a matrix else: try: V=iter(S) #figure out how to interpret the elements of V #(are they rows or elements?) #should we accept strings at this point? #the CSV example above indicates that with a known base ring, #allowing elements of V to be iterables of strings representing elements #seems a good idea. except TypeError: #do whatever we do with non-iterable matrix initializers Yep, that's the basic idea, though I might test for the non-iterable matrix initializers first, so something like matrix(QQ['x'], 2, x^2) becomes [x^2, 0] [0, x^2] rather than using list(x^2), and an iterable of strings is always considered an iterator of elements, not an iterator of rows. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: CSV file
The difficulty with accepting an iterator (of strings) is that it is unclear if each item corresponds to a row or an element. But I would be in favor of rather liberal string parsing, so one could do matrix(open(test.csv).read()) just like matrix( 1,2,3 4,5,5 ) On Mon, Feb 27, 2012 at 6:26 AM, Jason Grout jason-s...@creativetrax.com wrote: On 2/24/12 1:32 PM, Volker Braun wrote: We do get questions about how to read matrix from csv quite regularly. Of course its just a few lines of code, but I think it would be nice to have a matrix_from_file('fname.csv') function that imports csv and perhaps others (gnumeric/ooffice/excel). Any volunteers? ;-) How about the matrix constructor reads from an iterator and recognizes csv? We could even use the numpy savetxt and loadtxt functions to more sophisticated parsing. So: with open('mymatrix.csv','r') as f: m=matrix(f) or m.save('test.csv') # or m.save('test.csv', format='csv') I'm not volunteering in these suggestions... Thanks, Jason -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: patch buildbot help
On Wed, Feb 29, 2012 at 11:29 AM, Kelvin Li ltwis...@gmail.com wrote: On Feb 29, 12:24 pm, Niles nil...@gmail.com wrote: So this means that you should write Apply trac_10229-2.patch in a new comment on the ticket. Unfortunately writing this in the ticket description is useless for the patchbot (although still helpful for human readers). Ah, so a comment is not the description. Another question: what if there are multiple comments with apply ...? Does the patchbot simply look at the most recent comment with such a string, so that older comments can be completely overridden? Yep. The problem with the ticket description is that it doesn't have an associated (easily visible) chronology, so if one posts trac_10229.patch and puts in the description Apply trac_10229.patch then someone comes along and posts trac_10229-referee.patch fixing a typo and adding a doctest, it's unclear if the description was specifically excluding the referee patch or just not updated. An enhancement could be that if the description has an apply section (?) then we should strictly obey it, forcing everyone to do the busywork of keeping it up to date. Even better would be checkboxes and a way to re-order the list of actual attached patches. (Even better than that would be specifying a commit/branch in a revision control system, where the selection and order of patches to apply doesn't have to be specified externally.) - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Evaluate quickly a complex expression
FYI, http://trac.sagemath.org/sage_trac/ticket/12513 On Mon, Feb 6, 2012 at 1:53 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Mon, Feb 6, 2012 at 1:01 PM, Jason Grout jason-s...@creativetrax.com wrote: On 2/6/12 1:33 PM, Oscar Lazo wrote: That is very nice! Unfortunately I need to evaluate many different expressions quickly, so the copy-paste aproach is not an option. That's why I wrote the fast_complex function. I'll be working in such a general implementation, do you think it's worth getting it into sage, or should fast_float be modified to accept complex expressions? fast_callable is the answer to getting fast_float to accept complex expressions. Seeing how fortran just stomps on fast_callable and even copy-paste of Cython (i.e., it's *way* faster), I think it would be really cool to get a fast_callable backend that uses fortran. A step towards that would be your fortran-generating fast_complex. It could be called as fast_callable(expr, domain=CDF, compiler=fortran) or something. Note that fast_callable (and fast_float) before it use an interpreter because actually invoking the compiler can be literally millions of times slower than a sub-optimal evaluation (with domain=RDF or domain=CDF). That can mean that if you're actually evaluating the function less then a million (or thousand, or whatever depending on the ratio) times then you're not gaining anything even if the compiled code runs in no time at all. That being said, fast_callable construction could stand to be faster, and even more there's *lots* of low-hanging for fast_callable over the complex field here: sage: z_fast_callable=fast_callable(z,vars=[K1,K2],domain=CC) sage: z_fast_callable.python_calls() [exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp] sage: z_fast_callable=fast_callable(z,vars=[K1,K2],domain=CDF) sage: z_fast_callable.python_calls() [(^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2)] Common sub-expression elimination (and constant folding) would be really handy here for this particular example as well, I wonder if that's the trick that the Fortran compiler is able to pull. I don't have time to play with it now, but it may also be worth trying cdef extern from complex.h: pass to use c99 complex numbers in the Cython version. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: speed question, numpy vs CDF
On Sun, Feb 12, 2012 at 4:30 PM, Nils Bruin nbr...@sfu.ca wrote: On Feb 12, 1:39 pm, Pierre pierre.guil...@gmail.com wrote: i think zz above might still be considered as a 1 x 1 matrix instead of a complex number, somehow, and this may be slowing things down. No, that's not the problem. It's simply that numpy's default complex number type is apparently a bit slower for individual element arithmetic. It may well be that you're mainly measuring overhead, though, so you should really test in a more representative situation before committing to a particular implementation choice. numpy does allow arbitrary types in its arrays. I doubt they're as optimized as its own types, but you can try: sage: A= MatrixSpace(CDF, 2).random_element() sage: B= MatrixSpace(CDF, 2).random_element() sage: %timeit A*B 625 loops, best of 3: 11.8 µs per loop sage: import numpy sage: AA= numpy.array(A); BB= numpy.array(B) sage: %timeit AA.dot(BB) 625 loops, best of 3: 1.28 µs per loop sage: AAA= numpy.array(A,dtype=type(A[0,0])); BBB= numpy.array(B,dtype=type(B[0,0])) sage: %timeit AAA.dot(BBB) 625 loops, best of 3: 2.33 µs per loop sage: z=A[0,0] sage: %timeit z*z 625 loops, best of 3: 101 ns per loop sage: zz=AA[0,0] sage: %timeit zz*zz 625 loops, best of 3: 253 ns per loop sage: zzz=AAA[0,0] sage: %timeit zzz*zzz 625 loops, best of 3: 107 ns per loop sage: type(z); type(zz); type(zzz) type 'sage.rings.complex_double.ComplexDoubleElement' type 'numpy.complex128' type 'sage.rings.complex_double.ComplexDoubleElement' With such small matrices (and elements), you're essentially measuring overhead rather than arithmetic here. Of course if you have lots of small matrices, that may be a relavant thing to measure. As the matrix size grows, they should be the same, as multiplying CDF matrices simply defers to multiplying numpy matrices. sage: A= MatrixSpace(CDF, 200).random_element() sage: B= MatrixSpace(CDF, 200).random_element() sage: %timeit A*B 125 loops, best of 3: 7.31 ms per loop sage: AA= numpy.array(A); BB= numpy.array(B) sage: %timeit AA.dot(BB) 125 loops, best of 3: 7.34 ms per loop - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: speed question, numpy vs CDF
On Mon, Feb 13, 2012 at 10:06 AM, William Stein wst...@gmail.com wrote: On Mon, Feb 13, 2012 at 9:59 AM, Pierre pierre.guil...@gmail.com wrote: I see. Well I *do* have hundreds of 2x2 matrices to multiply out so i'm better off storing them as numpy matrices throughout... thanks for your explanations though. Pierre You might consider using Cython and writing a custom 2x2 matrix class. It wouldn't be difficult... so I'll write one right now and respond with the benchmarks. +1, exactly what I was going to consider. Depending on how naturally it fits your problem, you could also consider packing your 2x2 matrices into larger arrays (e.g. representing n 2x2 matrices by a 4 x n matrix and manually doing the multiplication) so you can your computations in a vectorized form. On 13 fév, 18:32, Robert Bradshaw rober...@math.washington.edu wrote: On Sun, Feb 12, 2012 at 4:30 PM, Nils Bruin nbr...@sfu.ca wrote: On Feb 12, 1:39 pm, Pierre pierre.guil...@gmail.com wrote: i think zz above might still be considered as a 1 x 1 matrix instead of a complex number, somehow, and this may be slowing things down. No, that's not the problem. It's simply that numpy's default complex number type is apparently a bit slower for individual element arithmetic. It may well be that you're mainly measuring overhead, though, so you should really test in a more representative situation before committing to a particular implementation choice. numpy does allow arbitrary types in its arrays. I doubt they're as optimized as its own types, but you can try: sage: A= MatrixSpace(CDF, 2).random_element() sage: B= MatrixSpace(CDF, 2).random_element() sage: %timeit A*B 625 loops, best of 3: 11.8 µs per loop sage: import numpy sage: AA= numpy.array(A); BB= numpy.array(B) sage: %timeit AA.dot(BB) 625 loops, best of 3: 1.28 µs per loop sage: AAA= numpy.array(A,dtype=type(A[0,0])); BBB= numpy.array(B,dtype=type(B[0,0])) sage: %timeit AAA.dot(BBB) 625 loops, best of 3: 2.33 µs per loop sage: z=A[0,0] sage: %timeit z*z 625 loops, best of 3: 101 ns per loop sage: zz=AA[0,0] sage: %timeit zz*zz 625 loops, best of 3: 253 ns per loop sage: zzz=AAA[0,0] sage: %timeit zzz*zzz 625 loops, best of 3: 107 ns per loop sage: type(z); type(zz); type(zzz) type 'sage.rings.complex_double.ComplexDoubleElement' type 'numpy.complex128' type 'sage.rings.complex_double.ComplexDoubleElement' With such small matrices (and elements), you're essentially measuring overhead rather than arithmetic here. Of course if you have lots of small matrices, that may be a relavant thing to measure. As the matrix size grows, they should be the same, as multiplying CDF matrices simply defers to multiplying numpy matrices. sage: A= MatrixSpace(CDF, 200).random_element() sage: B= MatrixSpace(CDF, 200).random_element() sage: %timeit A*B 125 loops, best of 3: 7.31 ms per loop sage: AA= numpy.array(A); BB= numpy.array(B) sage: %timeit AA.dot(BB) 125 loops, best of 3: 7.34 ms per loop - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: functions
It sounds like what you're saying is I want a function, but I don't want a function. Perhaps I could offer some better suggestions if I understood why def f(...) isn't acceptable. On Wed, Feb 8, 2012 at 1:16 AM, Chappman chappman@gmail.com wrote: Yes I do want a function of some sort here, but I do not want a def chaps(u,v) like what anton has done for now, both for my simplified and larger problem. Is there a solution/method to this? Kind Regards Chappman On Feb 7, 9:35 pm, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Feb 7, 2012 at 1:07 PM, Chappman chappman@gmail.com wrote: Hi Rob, I am pretty new to Sage and am not used to the syntex, so even though I write [y1,y2] , i do not mean it as a list. Basically what I am trying to do is try and get the folllowing code to work, if the summation does come out correct ly x would be equal to 5 , i.e. x=5. Sage will interpret [y1, y2] as a list (as will others reading your code). I would not need to specify when y1y2 because I have made a rule in my summation that y2 in [1..y1], so y2 can never be bigger than y1. So the way I want my code to work is basically, when doing the summation, the first one would be [y1,y2] = [1,1], then using my previously set criteries if y1=y2: [y1,y2]=2 elif y1y2: [y1,y2]=1 this would make [y1,y2] = [1,1]=2 my second summation would be [y1,y2] = [2,1]=1 my last summation would be [y1,y2] = [2,2]=2 so then x += [y1,y2] = 5 - if y1=y2: [y1,y2]=2 elif y1y2: [y1,y2]=1 x=0 for y1 in [1..2]: for y2 in [1..y1]: x += [y1,y2] print x - Is there a method of not using a function like def chap(u,v) for this right now, because this is just a simplified problem, of my larger problem. Thank you for taking your time looking at this. If I understand your intent correctly, you do want a function here, both for the simplified and larger problem. Is there a reason that this doesn't work for you? On Feb 7, 8:07 pm, Anton Sherwood bro...@pobox.com wrote: On 2012-2-07 01:18, Chappman wrote: Hi Rob, with this syntex: x=0 for y_1 in [1..2]: for y_2 in [1..y_1]: x += [y_1,y_2] print x what I am trying to do is, trying to use the two numbers y_1 and y_2 in x +=[y_1,y_2] to assign it a number from previously set conditions if y_1 = y_2: y_1 = y_2 = 2 elif y_1y_2: y_1 = y_2 = 1 but currently my code is having trouble doing that. Is there a way to do this please? Are you trying to define [u,v] as a function whose value is 2 if the arguments are equal and 1 if uv? (What if vu?) Among other syntactic problems, you can't do that with [], because that symbol is reserved for lists. Here's how I'd do what I think you're trying to do: # define a function of two inputs def chap(u,v): if u==v: return 2 # no 'else' needed, because 'return' breaks out of the function if uv: return 1 return None # ought to be a numeric value x=0 for y1 in range(1,3): for y2 in range(1,y1+1): x += chap(y1,y2) print x -- Anton Sherwood *\\*www.bendwavy.org*\\*www.zazzle.com/tamfang -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/sage-support URL:http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: functions
On Tue, Feb 7, 2012 at 1:07 PM, Chappman chappman@gmail.com wrote: Hi Rob, I am pretty new to Sage and am not used to the syntex, so even though I write [y1,y2] , i do not mean it as a list. Basically what I am trying to do is try and get the folllowing code to work, if the summation does come out correct ly x would be equal to 5 , i.e. x=5. Sage will interpret [y1, y2] as a list (as will others reading your code). I would not need to specify when y1y2 because I have made a rule in my summation that y2 in [1..y1], so y2 can never be bigger than y1. So the way I want my code to work is basically, when doing the summation, the first one would be [y1,y2] = [1,1], then using my previously set criteries if y1=y2: [y1,y2]=2 elif y1y2: [y1,y2]=1 this would make [y1,y2] = [1,1]=2 my second summation would be [y1,y2] = [2,1]=1 my last summation would be [y1,y2] = [2,2]=2 so then x += [y1,y2] = 5 - if y1=y2: [y1,y2]=2 elif y1y2: [y1,y2]=1 x=0 for y1 in [1..2]: for y2 in [1..y1]: x += [y1,y2] print x - Is there a method of not using a function like def chap(u,v) for this right now, because this is just a simplified problem, of my larger problem. Thank you for taking your time looking at this. If I understand your intent correctly, you do want a function here, both for the simplified and larger problem. Is there a reason that this doesn't work for you? On Feb 7, 8:07 pm, Anton Sherwood bro...@pobox.com wrote: On 2012-2-07 01:18, Chappman wrote: Hi Rob, with this syntex: x=0 for y_1 in [1..2]: for y_2 in [1..y_1]: x += [y_1,y_2] print x what I am trying to do is, trying to use the two numbers y_1 and y_2 in x +=[y_1,y_2] to assign it a number from previously set conditions if y_1 = y_2: y_1 = y_2 = 2 elif y_1y_2: y_1 = y_2 = 1 but currently my code is having trouble doing that. Is there a way to do this please? Are you trying to define [u,v] as a function whose value is 2 if the arguments are equal and 1 if uv? (What if vu?) Among other syntactic problems, you can't do that with [], because that symbol is reserved for lists. Here's how I'd do what I think you're trying to do: # define a function of two inputs def chap(u,v): if u==v: return 2 # no 'else' needed, because 'return' breaks out of the function if uv: return 1 return None # ought to be a numeric value x=0 for y1 in range(1,3): for y2 in range(1,y1+1): x += chap(y1,y2) print x -- Anton Sherwood *\\*www.bendwavy.org*\\*www.zazzle.com/tamfang -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Evaluate quickly a complex expression
On Mon, Feb 6, 2012 at 1:01 PM, Jason Grout jason-s...@creativetrax.com wrote: On 2/6/12 1:33 PM, Oscar Lazo wrote: That is very nice! Unfortunately I need to evaluate many different expressions quickly, so the copy-paste aproach is not an option. That's why I wrote the fast_complex function. I'll be working in such a general implementation, do you think it's worth getting it into sage, or should fast_float be modified to accept complex expressions? fast_callable is the answer to getting fast_float to accept complex expressions. Seeing how fortran just stomps on fast_callable and even copy-paste of Cython (i.e., it's *way* faster), I think it would be really cool to get a fast_callable backend that uses fortran. A step towards that would be your fortran-generating fast_complex. It could be called as fast_callable(expr, domain=CDF, compiler=fortran) or something. Note that fast_callable (and fast_float) before it use an interpreter because actually invoking the compiler can be literally millions of times slower than a sub-optimal evaluation (with domain=RDF or domain=CDF). That can mean that if you're actually evaluating the function less then a million (or thousand, or whatever depending on the ratio) times then you're not gaining anything even if the compiled code runs in no time at all. That being said, fast_callable construction could stand to be faster, and even more there's *lots* of low-hanging for fast_callable over the complex field here: sage: z_fast_callable=fast_callable(z,vars=[K1,K2],domain=CC) sage: z_fast_callable.python_calls() [exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp, exp] sage: z_fast_callable=fast_callable(z,vars=[K1,K2],domain=CDF) sage: z_fast_callable.python_calls() [(^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2), (^3), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^3), (^2), (^3), (^3), (^2), (^2), (^3), (^2), (^2)] Common sub-expression elimination (and constant folding) would be really handy here for this particular example as well, I wonder if that's the trick that the Fortran compiler is able to pull. I don't have time to play with it now, but it may also be worth trying cdef extern from complex.h: pass to use c99 complex numbers in the Cython version. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] functions
On Mon, Feb 6, 2012 at 3:12 PM, Chappman chappman@gmail.com wrote: Hi, I am currently trying to write a program for my project and am trying to make the following syntax work: if y_1=y_2: [y_1,y_2]=2 elif y_1y_2: [y_1,y_2]=1 I think you want is if y_1 = y_2: y_1 = y_2 = 2 elif y_1y_2: y_1 = y_2 = 1 [a,b] = x essentially means tmp = list(x); a = tmp[0]; b = tmp[1] x=0 for y_1 in [1..2]: for y_2 in [1..y_1]: x += [y_1,y_2] print x What are you trying to do here? x is an integer, [y_1, y_2] is a list of integers. It doesn't really make sense to add an integer to a list. The error messages I am getting is TypeError: 'sage.rings.integer.Integer' object is not iterable . When this code is fixed and does work, the answer would be x=5. Can anybody see where my code is going wrong please? Kind Regards Chappman -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Power series expansion
If you create an actual power series element, you can easily write the coefficients to a file: sage: f = taylor(sin(x), x, 0, 10); f 1/362880*x^9 - 1/5040*x^7 + 1/120*x^5 - 1/6*x^3 + x sage: power_series = RR[['x']](f); power_series 0.000 + 1.00*x + 0.000*x^2 - 0.167*x^3 + 0.000*x^4 + 0.00833*x^5 + 0.000*x^6 - 0.000198412698412698*x^7 + 0.000*x^8 + 2.75573192239859e-6*x^9 sage: list(power_series) [0.000, 1.00, 0.000, -0.167, 0.000, 0.00833, 0.000, -0.000198412698412698, 0.000, 2.75573192239859e-6] sage: ,.join(str(a) for a in list(power_series)) '0.000,1.00,0.000,-0.167,0.000,0.00833,0.000,-0.000198412698412698,0.000,2.75573192239859e-6' sage: open(file.txt, w).write(\n.join(str(a) for a in list(power_series))) sage: open(file.txt, w).write(\n.join(str(a) for a in list(power_series))) sage: !cat file.txt 0.000 1.00 0.000 -0.167 0.000 0.00833 0.000 -0.000198412698412698 0.000 2.75573192239859e-6 Note that ZZ[[x]], QQ[[x]], RR[[x]] are *much* faster to compute with as well sage: R.t = PowerSeriesRing(ZZ, 't', 1000) sage: f = 1/(t+1) sage: f + O(t^10) # this is really O(t^1000), don't want to print it all 1 - t + t^2 - t^3 + t^4 - t^5 + t^6 - t^7 + t^8 - t^9 + O(t^10) sage: timeit(f^100) 25 loops, best of 3: 28.2 ms per loop - Robert On Tue, Dec 6, 2011 at 3:33 AM, Julie juliewilliams...@googlemail.com wrote: Thank you very much to everyone for all your help. I've now solved the issue I was having trouble with - the reason finding the coefficients of the y terms didn't give me the required results was because the generating function was really in terms of one variable (p), not two, and required values to be substituted in for y's rather than finding the various coefficients. Now I have completed this work, wondered if you knew the best way to export the outputted coefficients by the internet version of sage to another package such as Excel? Or indeed, if this is even possible? Many thanks, Julie On Dec 3, 8:57 pm, Anton Sherwood bro...@pobox.com wrote: On 2011-12-02 08:17, Julie wrote: Unfortunately, having the Tayorseriesapproach out, don't think it's really appropriate for my problem afterall, as what I esentially need to do is find the coefficientsof p^0*y^0, p, y, p^2*y etc in the formula (0.030*0.248244^y)y+0.05721*(0.248244^y)p +0.08838*(0.248244^y) [...] Since this is not a polynomial in p and y, what does it mean to obtain thecoefficientsof p^j y^k *if not* those of something very similar to a Taylorseries? -- Anton Sherwood *\\*www.bendwavy.org*\\*www.zazzle.com/tamfang -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: How to pop a list item in Cython?
On Wed, Oct 19, 2011 at 11:52 PM, Simon King simon.k...@uni-jena.de wrote: Hi Robert, On 20 Okt., 06:59, Robert Bradshaw rober...@math.washington.edu wrote: I have no idea why L.pop(0) is not optimized, but L.pop(int0) is (and the latter should be very fast). Clearly a bug in Cython, but user the latter. Surprise: Even though the annotated code for L.pop(int0) is less yellow than for L.pop(0), it is *slower* by about 30%! In flask.sagenb, I get: {{{ %cython def f(list L): L.append(1) return L.pop(0),L def g(list L): L.append(1) return L.pop(int0),L def h(list L): L.append(1) return L.pop(),L }}} {{{ L = range(1000) }}} timeit(f(L)) -- 625 loops, best of 3: 701 ns per loop timeit(g(L)) -- 625 loops, best of 3: 971 ns per loop timeit(h(L)) -- 625 loops, best of 3: 131 ns per loop Very interesting--looks like the crossover point is around 200 elements. Looks like Python's native pop uses memmove rather than doing a loop shift the array which could account for the difference. Since L.pop() (popping the last item) is so much faster than L.pop(0), I could perhaps just revert my lists. Inserting into the 0th element will have the same issues as popping it. Nevertheless, I'd still appreciate to learn a Cython replacement for pop(0) that is fast on long lists as well. There isn't one as pop(0) on a list requires re-copying the entire contents of the list. Really? I'm surprised that an in-place change requires copying. It's an array, not a linked list. The k-th item of a list occupies a fixed location in memory relative to the head of the object, so removing an item requires shifting everything. (Not the data, just the pointers.) You could use numpy arrays, where slices such as L[1:] are views. A cython-implemented linked list may perform well here as well. I've never used numpy before, but I'll give it a try. Some tests in pure Python seem to indicate that numpy arrays are slower than lists. In particular, I need containment test and pop (or slices), and the items are types: sage: import numpy sage: from numpy import array sage: A = CommutativeAlgebras(QQ); B = HopfAlgebras(QQ); C = Fields(); D = FiniteEnumeratedSets() sage: L1=A.parent_class.mro() sage: L2=B.parent_class.mro() sage: L3=C.parent_class.mro() sage: L4=D.parent_class.mro() sage: A1 = array(L1) sage: A2 = array(L2) sage: A3 = array(L3) sage: A4 = array(L4) sage: c = Algebras(QQ).parent_class sage: timeit(c in L2) 625 loops, best of 3: 344 ns per loop sage: timeit(c in A2) 625 loops, best of 3: 14 µs per loop sage: timeit(c in L4) 625 loops, best of 3: 555 ns per loop sage: timeit(c in A4) 625 loops, best of 3: 12.9 µs per loop sage: timeit(L4[1:]) 625 loops, best of 3: 835 ns per loop sage: timeit(A4[1:]) 625 loops, best of 3: 1.07 µs per loop As numpy slices are views, they are a bit more expensive but require O(1) time, whereas slicing a list is O(n) time. sage: from numpy import array sage: for k in [2..5]: ... L = range(10^k) ... N = array(L) ... timeit(L[1:]) ... timeit(N[1:]) 625 loops, best of 3: 656 ns per loop 625 loops, best of 3: 576 ns per loop 625 loops, best of 3: 3.42 µs per loop 625 loops, best of 3: 627 ns per loop 625 loops, best of 3: 45.5 µs per loop 625 loops, best of 3: 578 ns per loop 625 loops, best of 3: 959 µs per loop 625 loops, best of 3: 630 ns per loop Looks like your arrays are pretty small though. Will the picture be different when cimporting numpy.ndarray in Cython? Likely not. The primary benefits (100x or more speedups) are when indexing and using native C types. Why not write your own simple queue? cdef class Queue: cdef list elements cdef int start cdef int end cdef int capacity def __init__(self, initial_capacity=5): self.elements = [None] * initial_capacity self.start = 0 self.end = 0 self.capacity = initial_capacity cpdef push(self, o): self.elements[self.end] = o self.end = (self.end + 1) % self.capacity if self.end == self.start: self.elements = self.elements[self.start:] + self.elements[:self.end] + [None] * self.capacity self.start = 0 self.end = self.capacity self.capacity *= 2 cpdef pop(self): if self.start == self.end: raise ValueError, Empty queue try: return self.elements[self.start] finally: self.elements[self.start] = None self.start = (self.start + 1) % self.capacity def f(Queue q): q.push(1) return q.pop(), q q = Queue() for k in range(1000): q.push(k) timeit(f(q)) 625 loops, best of 3: 147 ns per loop - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support
Re: [sage-support] Re: How to pop a list item in Cython?
On Thu, Oct 20, 2011 at 4:55 AM, Simon King simon.k...@uni-jena.de wrote: Hi Robert, On 20 Okt., 13:38, Robert Bradshaw rober...@math.washington.edu wrote: Since L.pop() (popping the last item) is so much faster than L.pop(0), I could perhaps just revert my lists. Inserting into the 0th element will have the same issues as popping it. Yes. But the point is that I am popping from (several) input lists, while I am only appending to the list that will eventually be returned. I can revert the input lists (profiting from fast L.pop()) and don't need to revert the output list. Ah, in that case it would make total sense. Your example feels a lot like the category pushout stuff :). It's an array, not a linked list. The k-th item of a list occupies a fixed location in memory relative to the head of the object, so removing an item requires shifting everything... ... except when removing the last item (which explains why L.pop() is fast), OR THE FIRST. Because, when removing the first item, you don't need to shift the other items towards the head, because you could more easily move the head towards the other items. That depends on how easily you can shift the head; it's an implementation detail in Python (and most other languages that I'm aware of) that you can't. Of course C lets you do this, but that's because it doesn't really have arrays, just pointers (and you still usually have to keep the original head around to free it). Of course being able to shift the head as well as the tail is what I implemented. Likely not. The primary benefits (100x or more speedups) are when indexing and using native C types. Why not write your own simple queue? Would be worth a try. Thank you for the code! Best regards, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: How to pop a list item in Cython?
On Wed, Oct 19, 2011 at 12:42 PM, Simon King simon.k...@uni-jena.de wrote: Hi Alexander and all, First of all, sorry that I posted twice the same - google groups reported an error when I first tried to post. On 19 Okt., 19:58, Alexander Juarez coua...@gmail.com wrote: I think I found the collections.deque() to be faster that than the list.pop() which makes sense if the list is implemented as a linked list object. And the collections uses a array implementation. In contrast to my first tests, it meanwhile seems to me that the L[0], PyList_GetSlice(L,1,PyList_GET_SIZE(L)) idiom is faster than deque in my applications. Recall that this was the fastest replacement for pop(0), if the lists are not too long (which will probably be the case in my applications). I have no idea why L.pop(0) is not optimized, but L.pop(int0) is (and the latter should be very fast). Clearly a bug in Cython, but user the latter. After all, collections is Python, not Cython. Nevertheless, I'd still appreciate to learn a Cython replacement for pop(0) that is fast on long lists as well. There isn't one as pop(0) on a list requires re-copying the entire contents of the list. You could use numpy arrays, where slices such as L[1:] are views. A cython-implemented linked list may perform well here as well. I found this: http://www.mail-archive.com/cython-dev@codespeak.net/msg07518.html but Sturla Molden's trick didn't work for me: Cython complained about an incomplete type. Best regards, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: sagemath.org down
On Thu, Aug 25, 2011 at 2:24 PM, William Stein wst...@gmail.com wrote: On Thu, Aug 25, 2011 at 12:19 PM, Jason Grout jason-s...@creativetrax.com wrote: On 8/25/11 12:52 PM, William Stein wrote: On Thu, Aug 25, 2011 at 10:36 AM, Jason Grout jason-s...@creativetrax.com wrote: On 8/25/11 12:32 PM, William Stein wrote: On Thu, Aug 25, 2011 at 9:34 AM, jernejjernej.makov...@gmail.com wrote: Can't reach www.sagemath.org or www.sagenb.org. Has anybody else same problems? Was that somewhere announced? Hi, There was a new firewall installed in the mathematics building, and they forgot to punch a whole through for me. It should be fixed now. sagemath.org:5467, the single-cell server test page, is not accessible. Does a hole need to be punched through for every port? Yes, it would. And moreover, I'm not sure they will allow it. I'm currently in discussions with them about our options. Okay; thanks for working on this! Would it be simple to add an apache redirect to the port on the box, so that, say, singlecell.sagenb.org was internally redirected to port 5467? They punched a hole in the firewall so it should work now. Any word on other ports? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Sage sgn to Sympy sign
We'd welcome a patch. How to do so is written up in detail at http://www.sagemath.org/doc/developer/walk_through.html#creating-a-change . Essentially, you create the change, uploaded it to trac, someone referees it, and then it gets merged into the next release. On Thu, Oct 13, 2011 at 9:30 AM, CDSousa cris...@gmail.com wrote: Hi, Sage uses a dictionary to translate Sage function names to SymPy ones when they are different. Signal function is called sgn in Sage and sign in Sympy but the respective translation is not in the dictionary, and a error is issued if one tries to do something like: x = var('x'); sgn(x)._sympy_() To fix it, it is just a matter of adding sgn: sign, to the dictionary. Such dictionary is called translation_table and it is inside function composition from class SympyConverter of file sage/ symbolic/expression_conversions.py. I would like to know how can I submit a patch, or ask someone to do it, and if it is necessary to include something in a unit test (like I did for Sympy for the inverse translation). ? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Question about sagenb.org
No. Also note that sagenb.org is on a single computer shared among tens of thousands of users, so if you want to do something computationally expensive you're better of installing Sage on your own hardware. On Tue, Oct 11, 2011 at 8:38 AM, juaninf juan...@gmail.com wrote: Exist sagenb.org with openmpi module? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: no math module!
On Mon, Sep 19, 2011 at 10:45 PM, kod da kod...@gmail.com wrote: Thanks for your response. I found the same error when not setting SAGE64=yes. I noticed I got this message higher in the install log: Failed to find the necessary bits to build these modules: bsddb185 dl gdbm imageop linuxaudiodev ossaudiodev spwd sunaudiodev would it be related to python not finding the math module? Are these modules necessary? No, but the math one is. This is indicative of no extension modules compiling, probably something messed up with distutils or compiler flags. Presumably there are earlier errors as part of the build? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] gsl in sage outside of notebook
On Wed, Sep 14, 2011 at 2:31 AM, Rajeev Singh rajs2...@gmail.com wrote: Hi, The following examples compiles from the notebook %cython cimport sage.gsl.ode import sage.gsl.ode include 'gsl.pxi' cdef class van_der_pol(sage.gsl.ode.ode_system): cdef double beta def __cinit__(self, double beta=1.0): self.beta = beta cdef int c_f(self,double t, double *y,double *dydt): dydt[0]=y[1] dydt[1]=-y[0]-self.beta*y[1]*(y[0]*y[0]-1) return GSL_SUCCESS cdef int c_j(self, double t,double *y,double *dfdy,double *dfdt): dfdy[0]=0 dfdy[1]=1.0 dfdy[2]=-2.0*10*y[0]*y[1]-1.0 dfdy[3]=-10*(y[0]*y[0]-1.0) dfdt[0]=0 dfdt[1]=0 return GSL_SUCCESS However if I put it in a file vander.pyx (say) and use the following setup.py - from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext ext = Extension(vander, [vander.pyx], include_dirs = ['/home/rajeev/bin/sage/devel/sage-main/sage/gsl/']) setup(ext_modules=[ext], cmdclass = {'build_ext': build_ext}) I get the following error - cdef class van_der_pol(sage.gsl.ode.ode_system): ^ vander.pyx:10:5: 'ode_system' is not declared I guess the problem is with the setup.py. Can someone tell me how to do this? IIRC, the notebook %cython creates a setup.py--you could just look at that. Chances are your Extension object is missing include dirs and libraries. -Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Obtaining Size of a List and of elements of a List
On Fri, Sep 2, 2011 at 3:44 AM, Vince vincent.kni...@gmail.com wrote: Dear all, If I have a list, how do I obtain the cardinality of the list, the command Cardinality() doesn't seem to always work. For example, the following code produces a set ComSet of sets of combinations. Rows=3 RowVector=[2,3,2] ComSet=[] for j in range(Columns): C=Combinations(range(Rows),RowVector[j]) ComSet.append(C.list()) show(ComSet) What's Columns? However using Cardinality() on ComSet does not seem to work: ComSet.Cardinality() Basically I am looking for the mathematica command Length. FYI, most Python and Sage commands start with a lower case. In this case, however, what you're looking for is len(ComSet). If you have an object x, type x-dot-tab to see what methods it supports. Furthermore how would I be able to map that command on to the elements of ComSet? Use list comprehensions (it's a Python thing). sage: L = [[1, 2, 3], [4, 5]] sage: [len(a) for a in L] [3, 2] -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Can't build sage library
On Tue, Aug 30, 2011 at 3:08 PM, dkrumm dkr...@uga.edu wrote: I just made a new installation of Sage 4.7.1 and I tried to build the library (although I haven't made any changes to it). I get this error message: Building Sage on OS X in 64-bit mode Creating SAGE_LOCAL/lib/sage-64.txt since it does not exist Detected SAGE64 flag Building Sage on OS X in 64-bit mode -- sage: Building and installing modified Sage library files. Installing c_lib 64 bit mode gcc -o src/convert.os -c -O2 -g -m64 -fPIC -I/Applications/sage.app/ Contents/Resources/sage/local/include -I/Applications/sage.app/ Contents/Resources/sage/local/include/python2.6 -I/Applications/ sage.app/Contents/Resources/sage/local/include/NTL -Iinclude src/ convert.c sh: gcc: command not found scons: *** [src/convert.os] Error 127 ERROR: There was an error building c_lib. I've tried this on two different machines, with the same result. Any ideas of what I'm doing wrong? gcc: command not found means that you need to install the C compiler gcc. See http://www.sagemath.org/doc/faq/faq-usage.html#what-are-sage-s-prerequisites - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Is x (x) impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Mon, Aug 22, 2011 at 6:06 AM, Simon King simon.k...@uni-jena.de wrote: Hi Vladimir, On 22 Aug., 12:05, v...@ukr.net wrote: Hello guys! Could you please explain me (and perhaps some of the other readers) the reasons (or advantages) of using implicit multiplication at all? I mean in what situations it could be useful? I don't know any advantage of implicit multiplication, and that's why I wouldn't like to drop Python syntax for implicit multiplication's sake. But apparently other people find it practical to be able to write 2x instead of 2*x. Or paste. Personally, I found this handy when writing a lot of polynomials/power series. When my brain was in math mode I kept getting interrupted by syntax errors :). As far as this proposal, we try to be very cautious when adding anything to the preparser, and double cautious when changing the meaning of valid Python syntax. With the exception of leading whitespace for code blocks, Sage/Python is not whitespace sensitive. Also, to throw my 2 cents in, f (x) looks like a function call to me. As for the OP's original deprecation warning, this was to fix the ambiguity of sage: f = x^2 sage: g = t + 1 sage: h = f + g sage: h(2, 3) take a guess sage: z = f - x^2 sage: z(3) BOOM - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Bug: Finding kernel of a matrix over GF(2) seems to be broken.
I can't seem to download your test matrix, but are you sure you're not confusing left kernel and right kernel? What's M * M.kernel().basis()[0]? On Fri, Aug 19, 2011 at 10:57 AM, Sucharit sucharit.sar...@gmail.com wrote: I am using Sage to compute homologies of large chain complexes. For this, I need to compute kernels of matrices over GF(2). The attached file testmatrix.sage contains the 128 X 120 matrix that I started with. The first command loads the file. The second command should output a zero vector, but it does not. sage: load testmatrix.sage sage: M.kernel().basis()[0]*M (0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) I have tried this with Sage versions 4.6, 4.6.2, 4.7 and the latest 4.7.1. I tried this on two computers: one runs Ubuntu 10.04 and one runs a generic Linux with everything compiled from source. I would be extremely grateful if someone figures this out. Thanks in advance, Sucharit -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: how to a copy of a nested list?
On Thu, Aug 18, 2011 at 12:48 AM, v...@ukr.net wrote: Hello! On Thu, 18 Aug 2011 00:35:21 -0700 (PDT) Stan Schymanski schym...@gmail.com wrote: Dear Robert, Thanks a lot for your help, this is exactly what I wanted. I still don't get why it is necessary to import a special function to perform such a standard thing. import copy has the affect that suddenly I cannot do copy(L) any more, but I have to do copy.copy(L) instead. Since copy(L) does not do what I would expect anyway, I will avoid it. Frankly, as intuitive as Python is in other respects, this behaviour blows my mind. Isn't a list of lists just a list of _pointers_ to the lists? If so, the regular copy operation would just copy that list of pointers to a new list. Am I right? Yep, that's one way of thinking about it. Python has reference semantics, i.e. everything is just a reference to the actual objects. sage: a = [1,2,3] sage: b = a sage: c = [1,2,3] sage: a.append(x) sage: a [1, 2, 3, x] sage: b [1, 2, 3, x] sage: c [1, 2, 3] sage: L = range(10) sage: def foo(x): x.append(100) : sage: L [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] sage: foo(L) sage: L [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100] A copy of a list is a new list with exactly the same contents, not a new list with copies of the original contents. It makes more senes if you consider other usecases such as list of (GUI) windows or a list of network connections or a list of files, I wouldn't want it to make new windows or new connections or new files when I create a copy of that list, rather I want a new list that also references the same set of objects. And, as noted, deepcopy is a lot more expensive. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] how to a copy of a nested list?
On Wed, Aug 17, 2011 at 9:09 AM, Stan Schymanski schym...@gmail.com wrote: Dear all, This has been driving me mad. According to the python documentation, you can modify a copy of a list without modifying the original using the following code: sage: L = [] sage: M = L[:] # create a copy sage: # modify L only sage: L.append(1) sage: M [] Now, I want to do the same with a nested list, but I do not manage to unlink the two. See the example below, where I also tried copy(L) to no avail. I hope that someone can help. Thanks already! A copy of a list is a new list containing exactly the same elements as the original list. It sounds like what you want here is sage: import copy sage: L = [range(k) for k in range(5)] sage: M = copy.deepcopy(L) sage: M[0].append('something') sage: M [['something'], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]] sage: L [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]] - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Tracking down a bug(?) in Cython
On Wed, Aug 3, 2011 at 2:52 PM, Victor Miller victorsmil...@gmail.com wrote: Good news (so far) -- I tracked down the source of the bug. I had a long calculation (the details of which are irrelevant) which produced a pair of points on an elliptic curve, say P1 and P2, over a finite field of the form GF(2^n). In order to check the calculation I needed to check Q1 == 2**(1+m)*P1 and Q2 == 2**(1+m)*P2 where Q1,Q2 were another pair of points, and m was some integer (actually calculated as len(x) where x was some list). I put in tracing in both the .py and .pyx version and saw that P1,P2, Q1,Q2 were the same in each version, but the comparisons weren't! Interesting. To clarify, the string representations that were printed out were identical, but the == operator returned False? Could you pickle these points and send them? I should say that in this case n was 251 and m 200. So far I can't get an isolated case like this where I choose P1 to be a random point, but according to the traces everything computed up to that point was the same. Victor On Aug 3, 8:38 am, VictorMiller victorsmil...@gmail.com wrote: Robert, I'll see what I can do. As you suspected, the files are not disclosable :-(. Victor On Aug 3, 3:03 am, Robert Bradshaw rober...@math.washington.edu wrote: This is exactly the kind if thing we try to avoid. I'd like to see the files (if they're disclosable of course), or perhaps you could come up with a whittled-down example. On Tue, Aug 2, 2011 at 7:22 PM, VictorMiller victorsmil...@gmail.com wrote: Robert, The .py and .pyx files are identical. I copied one to the other, and just in case I checked with diff. It's very puzzling. Victor On Aug 2, 8:19 pm, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Aug 2, 2011 at 11:29 AM, William Stein wst...@gmail.com wrote: On Tue, Aug 2, 2011 at 11:09 AM, VictorMiller victorsmil...@gmail.com wrote: I've written a bunch of functions (some organized in classes) to do some large computations in a particular finite field (always GF(2^n) for some odd n). This seems to work fine. I'd like the computation to be as fast as possible, so the first thing I did was to copy the .py file to a .pyx file. The good news is that the compiled cython is at least 30% faster (sometimes more) than the interpreted .py version. The bad news is that it gives different results! In trying to track down where things go awry, I made the following declaration in each from sage.misc.decorators import sage_wrap from string import join def logged(func): @sage_wrap(func) def with_logging(*args, **kwds): print func.__name__ + '(' + join([str(_) for _ in args],',') + ')' return func(*args,**kwds) return with_logging I then put @logged in from of the defs of a bunch of functions. This works as expected with .py version, but when I try to compile the .pyx version I get the message: in update_wrapper setattr(wrapper, attr, getattr(wrapped, attr)) AttributeError: attribute '__doc__' of 'builtin_function_or_method' objects not writable I think that I understand what's going on here, but are there any You often can't use decorators with Cython code, yet... since it is compiled (not dynamic). suggestions as to how to get to the bottom of the differences between the cython compiled version and the interpreted version? Put in print statements? You could also write your own with_logging that doesn't try to access __name__ or __doc__ and decorate with that. I'm very curious what goes awry. Did you make any changes other than changing the file from .py to .pyx and compiling it? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/sage-support URL:http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Tracking down a bug(?) in Cython
On Thu, Aug 4, 2011 at 10:49 AM, Victor Miller victorsmil...@gmail.com wrote: There's a real bug in Cython. It looks like it's some sort of parsing bug. Consider the following program: def Check(P,x): Q = 2**(1+len(x))*P R = P for _ in range(1+len(x)): R = 2*R if Q != R: print Check: Got it!, Q=,Q, R=,R else: print Ok def Check0(P,x): Q = 2**x*P R = P for _ in range(x): R = 2*R if Q != R: print Check0: Check: Got it!, Q=,Q, R=,R else: print Ok def Testit(n,m): x = m*[0] Check(1,x) Check0(1,1+len(x)) Testit(201,100) when run as a .py program it prints Ok Ok when run as a .pyx program it prints Check: Got it!, Q=0, R= 2535301200456458802993406410752 Ok Ah hah. It's an overflow bug. 2**(1+len(x)) is computed as a (32- or 64-bit) C value, as the base and exponents are C ints. I'm not sure what the best solution is, short of automatic integer overflow checking and unboxing. Pow is especially tricky. Do we want to force cdef int a; a**2 to be a Python operation? What about len(a) * len(b) or even len(L) + 1? An intermediate solution might be to have overflow-checking int types, which would be appropriate for implicitly-inferred values (including buildtin return types like len). These would raise a runtime Overflow exception rather than silently giving bad values. A directive could specify that they should be Python objects rather than overflow-raising C values. Correctly and efficiently handling integer arithmetic is just such a pain... - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Tracking down a bug(?) in Cython
This is exactly the kind if thing we try to avoid. I'd like to see the files (if they're disclosable of course), or perhaps you could come up with a whittled-down example. On Tue, Aug 2, 2011 at 7:22 PM, VictorMiller victorsmil...@gmail.com wrote: Robert, The .py and .pyx files are identical. I copied one to the other, and just in case I checked with diff. It's very puzzling. Victor On Aug 2, 8:19 pm, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Aug 2, 2011 at 11:29 AM, William Stein wst...@gmail.com wrote: On Tue, Aug 2, 2011 at 11:09 AM, VictorMiller victorsmil...@gmail.com wrote: I've written a bunch of functions (some organized in classes) to do some large computations in a particular finite field (always GF(2^n) for some odd n). This seems to work fine. I'd like the computation to be as fast as possible, so the first thing I did was to copy the .py file to a .pyx file. The good news is that the compiled cython is at least 30% faster (sometimes more) than the interpreted .py version. The bad news is that it gives different results! In trying to track down where things go awry, I made the following declaration in each from sage.misc.decorators import sage_wrap from string import join def logged(func): @sage_wrap(func) def with_logging(*args, **kwds): print func.__name__ + '(' + join([str(_) for _ in args],',') + ')' return func(*args,**kwds) return with_logging I then put @logged in from of the defs of a bunch of functions. This works as expected with .py version, but when I try to compile the .pyx version I get the message: in update_wrapper setattr(wrapper, attr, getattr(wrapped, attr)) AttributeError: attribute '__doc__' of 'builtin_function_or_method' objects not writable I think that I understand what's going on here, but are there any You often can't use decorators with Cython code, yet... since it is compiled (not dynamic). suggestions as to how to get to the bottom of the differences between the cython compiled version and the interpreted version? Put in print statements? You could also write your own with_logging that doesn't try to access __name__ or __doc__ and decorate with that. I'm very curious what goes awry. Did you make any changes other than changing the file from .py to .pyx and compiling it? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Tracking down a bug(?) in Cython
On Tue, Aug 2, 2011 at 11:29 AM, William Stein wst...@gmail.com wrote: On Tue, Aug 2, 2011 at 11:09 AM, VictorMiller victorsmil...@gmail.com wrote: I've written a bunch of functions (some organized in classes) to do some large computations in a particular finite field (always GF(2^n) for some odd n). This seems to work fine. I'd like the computation to be as fast as possible, so the first thing I did was to copy the .py file to a .pyx file. The good news is that the compiled cython is at least 30% faster (sometimes more) than the interpreted .py version. The bad news is that it gives different results! In trying to track down where things go awry, I made the following declaration in each from sage.misc.decorators import sage_wrap from string import join def logged(func): @sage_wrap(func) def with_logging(*args, **kwds): print func.__name__ + '(' + join([str(_) for _ in args],',') + ')' return func(*args,**kwds) return with_logging I then put @logged in from of the defs of a bunch of functions. This works as expected with .py version, but when I try to compile the .pyx version I get the message: in update_wrapper setattr(wrapper, attr, getattr(wrapped, attr)) AttributeError: attribute '__doc__' of 'builtin_function_or_method' objects not writable I think that I understand what's going on here, but are there any You often can't use decorators with Cython code, yet... since it is compiled (not dynamic). suggestions as to how to get to the bottom of the differences between the cython compiled version and the interpreted version? Put in print statements? You could also write your own with_logging that doesn't try to access __name__ or __doc__ and decorate with that. I'm very curious what goes awry. Did you make any changes other than changing the file from .py to .pyx and compiling it? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] how to import locally defined extension types?
On Fri, Jul 29, 2011 at 5:00 PM, john_perry_usm john.pe...@usm.edu wrote: Hi I have a file type1.pyx that defines an extension type Type1, and a file type2.pyx that defines an extension type Type2. Some attributes of Type2 are of type Type1. If I have the types in one file, everything runs fine; I'd like to separate them into different files. I placed these files in a local working directory. I can attach type1.pyx with no problem. I cannot attach type2.pyx; this gives me: ImportError: No module named _atlas_perry_..._pyx.type1 even though I just attached the file containing extension type Type1, and I can create objects of type Type1. Can someone indicate the correct way to import this type, and/or point me to the relevant documentation on this? I did do some searching, but I'm pretty sure that what I found is for extending Sage's functionality, and not for temporary working files. You might have better luck with load, as attach re-compiles the file each time and Python can't handle re-loading extension modules very well (hence the re-naming). That failing, if it's growing to the point that you need multiple files, you may have to write (a.k.a. copy and modify) your own setup.py file. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] extending the Expression class
On Thu, Jul 21, 2011 at 3:37 AM, Burcin Erocal bur...@erocal.org wrote: Hi, On Wed, 20 Jul 2011 17:02:49 -0700 (PDT) Steven Pollack stevenlawrencepoll...@gmail.com wrote: I noticed that a thread was developed for this sort of thing (http:// groups.google.com/group/sage-support/browse_thread/thread/ d50dc3bc2bdbeab0/34798c0585fc034f?lnk=gstq=nicolasfwc=1#), but I'm a newbie, and a lot of it went over my head. Is there a simple to create a subclass of sage.symbolic.expression.Expression? Note that many of the low-level classes, such as Integers and perhaps Expressions, were not designed with sublcassing in mind. YMMV, but this is often a problem of OOP in general. The main problem with subclassing Expression is that the result returned from arithmetic is hardcoded to be an Expression again. I quickly did a search and replace in the sage/symbolics directory to pass the new class as an argument to the fast expression constructor new_Expression_from_GEx. Here is the patch: http://sage.math.washington.edu/home/burcin/subclass_expression.patch After applying the patch the following works: sage: class new_exp(Expression): : pass : sage: t = new_exp(SR, x) sage: t x sage: type(t) class '__main__.new_exp' sage: u = t*t sage: type(u) class '__main__.new_exp' sage: u x^2 Any performance cost? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] including a python module built with autotools in Sage
On Wed, Jul 20, 2011 at 4:09 PM, Jose Guzman sjm.guz...@googlemail.com wrote: Hi everybody, I am trying to install a Python module in Sage that uses autotools as its build system. I would like to install it in my local Sage, so I type: ./configure --prefix=$HOME/sage-4.7/local PYTHON=$HOME/sage-4.7/local/bin/python make make install which returns: /bin/bash $HOME/dev/stfio/./shave-libtool '/bin/bash ./libtool' --mode=install /usr/bin/install -c libstfio.la '$HOME/sage-4.7/local/lib/python2.6/dist-packages/stfio' libtool: install: warning: remember to run `libtool --finish /usr/local/lib/python2.6/dist-packages/stfio' However, when executing Sage, the package is not recognized. Is this the correct subdirectory to install the package? Should I configure any Sage variable? I would recommend running sage -sh to set up all your paths and environment variables, then doing an install like you normally would (with the --prefix still being sage-N.n/local/. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Possible to make implicit multiplication allow (1 + 2) (3 + 4) ?
On Mon, Jun 27, 2011 at 8:23 AM, Chris Seberino cseber...@gmail.com wrote: On Jun 24, 11:59 pm, Jason Grout jason-s...@creativetrax.com wrote: sage: implicit_mul('diff(f,x)(3)', level=10) 'diff(f,x)*(3)' which is definitely not what I intended. Jason Would you agree a good robust solution to your issue would be for an implicit_mul level that *ONLY* converted spaces to multiplication? In other words This should work... (1 + 2) (3 + 4) # Notice space between parens. This should/would give an error... (1 + 2)(3 + 4) # Notice no space between parens. That doesn't solve the call mangling issue: sage: f(x) = x+1 sage: g(x) = x^2 sage: var('a,b') (a, b) sage: (f) (a) a + 1 sage: f + g x |-- x^2 + x + 1 sage: (f + g) (a + b) (a + b)^2 + a + b + 1 I reread the implicit_mul docs at http://www.sagemath.org/doc/reference/sage/misc/preparser.html and I cannot find a level between 3 and 10 that does this. The levels aren't tight so that we can add levels if needed, however I think it's a bad idea for the default level to make syntactically valid Python into something that has a totally different meaning. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] unanticipated divison by zero
On Wed, Jun 22, 2011 at 12:35 PM, Ken Levasseur klevass...@mac.com wrote: Hello. I'm trying to implement the algorithm for representing primes congruent to 1 mod 4 as a sum of squares and I know the logic of the algebra is right (identical equations work in Mathematica). However, I get a ZeroDivisionError: Inverse does not exist. error when I evaluate the expression sum_of_squares(73). where the definition of sum_of_squares is def sum_of_squares(p): if p.mod(4)==1: A=startingA(p) print A B=1 M=(A**2+B**2)/p while M1: [a,b,r]=iterate(A,B,M,p) [A,B,M]=[a,b,r] return [A,B] else: print 'no' The error appears to be when M is computed just before the while loop. I know that A is computed correctly because the correct values come out randomly when I print A, but then I never get to the loop. I evaluate the following before the definition of the function. p=var('p') A=var('A') B=var('B') r=var('r') a=var('a') b=var('b') Anyone know what's going on? What is startingA ? What is the parent of A? The full error message from evaluating sum_of_squares(73) is ]Traceback (most recent call last): File stdin, line 1, in module File _sage_input_36.py, line 10, in module exec compile(u'open(___code___.py,w).write(# -*- coding: utf-8 -*-\\n + _support_.preparse_worksheet_cell(base64.b64decode(c3VtX29mX3NxdWFyZXMoNzMp),globals()) +\\n); execfile(os.path.abspath(___code___.py)) File , line 1, in module File /private/var/folders/dV/dVqvhWPV2RWo0U+8ZQR1kTM/-Tmp-/ tmpGm6sIU/___code___.py, line 3, in module exec compile(u'sum_of_squares(_sage_const_73 ) File , line 1, in module File /private/var/folders/dV/dVqvhWPV2RWo0U+8ZQR1kTM/-Tmp-/ tmpXtNmdU/___code___.py, line 8, in sum_of_squares M=(A**_sage_const_2 +B**_sage_const_2 )/p File element.pyx, line 1551, in sage.structure.element.RingElement.__div__ (sage/structure/element.c: 12000) File coerce.pyx, line 713, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/ coerce.c:6153) File element.pyx, line 1549, in sage.structure.element.RingElement.__div__ (sage/structure/element.c: 11981) File integer_mod.pyx, line 2223, in sage.rings.finite_rings.integer_mod.IntegerMod_int._div_ (sage/rings/ finite_rings/integer_mod.c:19173) ZeroDivisionError: Inverse does not exist. Ken Levasseur UMass Lowell -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] How can I tell if an algebraic number is rational?
On Wed, Jun 1, 2011 at 7:30 AM, zsharon zacherysha...@gmail.com wrote: Hi, I need to determine if a given algebraic number is rational. Here is the setup: PolynomialRing(ZZ, 'x') A=-2 B=5 f=x^3 + A*x +B D=-4*A^3-27*B^2 L.c = NumberField(f) Then I need to know if a given number beta=b0+b1*c+b2*c^2 is rational or not. It tried using K.s=QQ.extension(beta.minpoly()) K==QQ but I'm not sure if this is reliable. To test membership, just do sage: beta in QQ - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Python and Sage
On Sat, May 28, 2011 at 4:17 AM, Vahid v.mojta...@gmail.com wrote: Hi, I would like to know that if I write my Sage codes in IDLE of Python, will it be faster when it runs? I highly doubt it. Someone told me that in this case the codes are translated to machine language faster and it is better. Looks like it's just a GUI. Given that there are already libraries of sage written in python for different functions like set partitions, can I call them in python? shall I just copy and paste it? In some sense, Sage is just a huge Python library + a small bit of preparsing. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: How set up new accounts in a Python script? (instead of the notebook web form?)
On Fri, May 27, 2011 at 3:35 PM, Chris Seberino cseber...@gmail.com wrote: On May 27, 3:34 pm, Berkin Malkoc malk...@gmail.com wrote: It is in the reference:http://www.sagemath.org/doc/reference/sagenb/notebook/notebook.html Thank you. Those docs appear to be for a Sage session. I actually need it to work from a Django web application unrelated to Sage!?!? In other words, my question pertains to a Python script instead of a Sage session! Is this possible? A sage script is just a pre-parsed python script. The majority of the pre-parsing is math-specific so it would probably work as is (once you've imported the used functions from sage.all). - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Slow serialization of sparse array
Are you suer that savetxt has sparse representations? I bet it's saving a whole bunch or 0's (though the numpy list would be the place to ask for sure, and for a replacement). On Mon, May 16, 2011 at 10:29 AM, akm andrew.mussel...@gmail.com wrote: Would it be expected behavior for a 26k x 26k sparse array to take more than two hours to serialize using numpy.savetxt on a modern Apple laptop? Thanks Andrew -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: degree of poly
On Tue, May 10, 2011 at 11:40 AM, MathLynx mathl...@gmail.com wrote: Is it safe to say that R = PolynomialRing(QQ, 'X,Y') defines a ring over Q in two variables, in which x,y = R.gens() sets x y to be the generators? If this is so, then what exactly is the role of 'X,Y' ? Just to list the number of generators or what? It gives the names of the generators. Could we just as well have said R = PolynomialRing(QQ, 'A,B') x,y = R.gens() Yes, but that gets confusing, 'cause the last line assigns the (Python) variables x and y to the generators A and B respectively. Perhaps this will clarify things sage: x, y = (3, hi) sage: x 3 sage: y 'hi' sage: R = PolynomialRing(QQ, 'A,B') sage: R.gens() (A, B) sage: x,y = R.gens() sage: x A sage: y B sage: x+y A + B sage: A, B = R.gens() sage: z = A + B^2; z B^2 + A The shorthand sage: R.x,y = PolynomialRing(QQ) # or R.x,y = QQ[] both creates a polynomial ring with generators named x and y, and assigns the local variables x and y to those generators. On the other hand, just because two things have the same name doesn't mean that they're the same thing: sage: QQ['x'] Univariate Polynomial Ring in x over Rational Field sage: QQ['x'].gen() x sage: 5 * QQ['x'].gen() 5*x sage: GF(5)['x'] Univariate Polynomial Ring in x over Finite Field of size 5 sage: GF(5)['x'].gen() x sage: 5 * GF(5)['x'].gen() 0 - Robert On May 10, 2:22 pm, Sebastian Ramacher s.ramac...@gmx.at wrote: On 05/10/2011 07:59 PM, MathLynx wrote: How do I detect the degree of a polynomial (say over Q) in one or several variables? x = var('x'); B = x^2; B.deg() gives an error. How about x,y = var('x , y'); B = x^2 + y^3; and we want degree of B with respect to x? (presuming wrt y is the same) Are you looking for something like that? R = PolynomialRing(QQ, 'X,Y') x,y = R.gens() (x**2).degree() 2 (x**2+y**3).degree(x) 2 Kind regards, -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Root finding
On Tue, May 10, 2011 at 10:02 PM, Santanu Sarkar sarkar.santanu@gmail.com wrote: If I want to find the roots of x^2-2 in reals, I use the following approach. R.x=RR[] f=x^2-2 f.roots() But, it gives the rational approximation. Is it possible to find the exact root (irrational form)? Depending on exactly what you want sage: x = var('x') sage: f = x^2-2 sage: f.roots() [(-sqrt(2), 1), (sqrt(2), 1)] or sage: R.x = QQ[] sage: f = x^2-2 sage: f.roots(f.root_field('a')) [(a, 1), (-a, 1)] sage: z = f.roots(f.root_field('a'))[0][0]; z a sage: parent(z) Number Field in a with defining polynomial x^2 - 2 sage: z^2 2 or sage: f.roots(QQbar) [(-1.414213562373095?, 1), (1.414213562373095?, 1)] # these are exact sage: z = f.roots(QQbar)[0][0] sage: z^2 2.000? sage: z^2 == 2 True -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: efficient way to convert str to rational
On Tue, May 10, 2011 at 12:53 PM, tvn nguyenthanh...@gmail.com wrote: sorry my question wasn't so clear -- but yes the main bottleneck is applying the conversion function from string to rational . Thanks for the sage_eval function If the sage_eval function is faster, then string - Rational needs to be fixed. sage: %timeit sage_eval(101/389) 625 loops, best of 3: 96.9 µs per loop sage: %timeit QQ(101/389) 625 loops, best of 3: 4.08 µs per loop sage: sage: %timeit sage_eval('101.9') 625 loops, best of 3: 87.5 µs per loop sage: sage: %timeit RealNumber('101.9') 625 loops, best of 3: 2.18 µs per loop sage: def parse(s): : if '.' in s or 'e' in s or 'E' in s: : return QQ(RealNumber(s)) : else: : return QQ(s) : sage: %timeit parse(101/389) 625 loops, best of 3: 4.98 µs per loop sage: %timeit parse(101.9) 625 loops, best of 3: 794 µs per loop sage: %timeit sage_eval(101.9) 625 loops, best of 3: 94 µs per loop Hmm... looks like there's a bottleneck there. sage: a = RealNumber(1.2) sage: %timeit QQ(a) 625 loops, best of 3: 759 µs per loop That could be way faster, at least for literals. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Modular Exponentiation
Yep, looking at Integer.__pow__ def __pow__(self, n, modulus): if modulus is not None: from sage.rings.finite_rings.integer_mod import Mod return Mod(self, modulus) ** n so that should be exactly the same thing. On Thu, Mar 17, 2011 at 10:26 AM, Graham Enos graham.e...@gmail.com wrote: Another option is to use the pow() function, as in pow(a, b, c). On Mar 17, 1:58 am, Robert Bradshaw rober...@math.washington.edu wrote: mod(a, c)^b On Wed, Mar 16, 2011 at 10:44 PM, Santanu Sarkar sarkar.santanu@gmail.com wrote: How one can calculate a^b mod c in Sage for large b? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/sage-support URL:http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Modular Exponentiation
mod(a, c)^b On Wed, Mar 16, 2011 at 10:44 PM, Santanu Sarkar sarkar.santanu@gmail.com wrote: How one can calculate a^b mod c in Sage for large b? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Server connection problems - which are likely linked to enclosed code.
Looks like you downloaded a 10.6 binary and are trying to use it on your 10.5.8 machine. You (probably) want the first item in this list: http://boxen.math.washington.edu/sage/osx/intel/index.html On Thu, Feb 24, 2011 at 10:14 PM, amandachan2...@yahoo.com amandachan2...@yahoo.com wrote: Essentially, I'm having problems understanding this unknown required load command code. I'm unable to connect to the server, or even access sage through terminal. I'm confused, and would really appreciate some enlightment? I'm running a Mac OSX, version 10.5.8, duo intel processor, after downloading, I dragged the file into my applications and ran it from there. -- | Sage Version 4.6.1, Release Date: 2011-01-11 | | Type notebook() for the GUI, and license() for information. | -- dyld: unknown required load command 0x8022 /Volumes/sage-4.6.1-OSX-64bit-10.6-i386-Darwin/sage/local/bin/sage- sage: line 253: 40748 Trace/BPT trap $SAGE_ROOT/local/ bin/sage-location logout [Process completed] There were some complications with the installation, but I can't figure it out. After dragging it in, I double clicked the sage icon(as indicated), then it started running with terminal anyways, step number 4(below) was ignored because of this. Could this be a reason? If so, how would I go about fixing it? 4) Select to run it with Terminal: Choose Applications, then select All Applications in the Enable: drop down. Change the Applications drop down to Utilities. On the left, scroll and select Terminal. Click Open, then in the next dialog select Update. Whenever I try to start sage server, this shows up in my terminal: Last login: Fri Feb 25 01:12:03 on ttys000 STUDENT-achan:~ achan$ '/Volumes/sage-4.6.1-OSX-64bit-10.6-i386-Darwin/ sage/'/sage --notebook Detected SAGE64 flag Building Sage on OS X in 64-bit mode dyld: unknown required load command 0x8022 /Volumes/sage-4.6.1-OSX-64bit-10.6-i386-Darwin/sage/local/bin/sage- sage: line 608: 78729 Trace/BPT trap sage-cleaner /dev/null /Volumes/sage-4.6.1-OSX-64bit-10.6-i386-Darwin/sage/local/bin/sage- sage: line 608: 78730 Trace/BPT trap sage-notebook $@ Thank you! -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Memory problem
What basering is your system over? This could make a huge difference in terms of memory requirements. On Wed, Feb 23, 2011 at 6:57 AM, Guillermo Oviedo oviedo...@gmail.com wrote: In trying to solve a linear equation system of 4096 variables (with matrix.solve_right()) , there occurs a memory allocation error python (359) malloc *** mmap (size = 2097152) failed (error code = 12)*** error: can not allocate region. . Someone could tell me how to increase memory capacity for use in SAGE. I own 4GB of physical memory. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: help needed with cube
On Sun, Jan 30, 2011 at 6:42 AM, Loïc xl...@free.fr wrote: Do you think it's better to report it as a bug? Yes. http://trac.sagemath.org/sage_trac/ticket/10796 -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: sagenb.org server(s)
On Mon, Feb 7, 2011 at 10:21 AM, Jason Grout jason-s...@creativetrax.com wrote: On 2/7/11 11:59 AM, Thomas Scofield wrote: I've spent the last couple of hours frustrated at trying to log in and use notebooks at sagenb.org. I was attempting to do this while teaching a class, and had little to no success between 10:30 and 12:20 EST (U.S.). I had this same experience about a month ago when teaching a different class---probably can write off 75 students or thereabouts as having seen enough frustration in an hour to never want to use Sage again. Nevertheless, I've found remarkably few (given my 2-for-2 batting average) messages like this in the list archives over the last year. Is this not a problem for others, just me doing something wrong? If so, can someone help me diagnose the problem? If it's a consistent problem that everyone else has become so accustomed to that we just don't speak of it anymore, then how can it be addressed? I'd suggest to my students that they should all download a copy if it weren't that so many of them are Windows users, and that looks to be oppressively hard. If I could convince the IT people at my institution to run a notebook server, what could I tell them about numbers and power? Just what are the specs on existing sagenb servers, and how many users before you notice poor performance? I too have noticed sagenb.org being slow or down quite a bit recently. My personal work-around has been to use demo.sagenb.org or our school Sage server for my classes. We have a Dell PowerEdge 2900 server (i.e., probably 5-6 years old) with 16 gig of RAM, and I have noticed no problems serving my classes (3 classes, probably 80 students total). We probably don't need that much RAM to serve just these students, but we also use the server for research work. You can see instructions from our setup here: http://wiki.sagemath.org/SageServer. My guess is that about 50-60 simultaneous users (not accounts, but simultaneous users) is enough to cause a severe slowdown to sagenb.org. That's a guess, though; I'm not sure what the actual number is. As for the future: In January, we held a Sage conference in which many people worked on designing a much more scalable notebook. I am working with a group of students on the first steps of this rewrite. There are other people also working on this rewrite or other projects which restructure the notebook and make it more scalable. There is funding from an NSF grant to work on making the notebook more scalable, so it will get done (i.e., there's funding and committed developer time). One project (the rewrite to use flask) is at the testing stage, so hopefully we will see it go into Sage soon. Sage is a victim of its own success! In response to the original poster, this is a big pain point and something several people are working on. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] I need some help configuring my sage notebook
On Sun, Feb 6, 2011 at 11:29 AM, Daniel M. danielmeji...@gmail.com wrote: Hi everyone, i need some help configuring my notebook: When i start the notebook server typing notebook() on the sage prompt it always login as 'admin' so i have to log out and enter as my user defined account. I've tried to reconfigure my notebook server settings as follows: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') nb.add_user('user','password','','admin',True) so there is not default user to log in when notebook starts nb.default_user() '' but when i type notebook() notebook() it always stars as admin i dont know what kind of problems would i have if a work on the sage nb as admin, i hope anyone can help Note that the notebook admin user is completely distinct from any admin account on your computer, so if you start the notebook by typing notebook() it's still doing everything in your name (as are any other notebook accounts you create). If you're just using it as a personal notebook server (i.e. not giving out accounts and sharing it with other people) then that's probably the behavior you want. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: sagenb.org server(s)
On Mon, Feb 7, 2011 at 3:59 PM, Harald Schilly harald.schi...@gmail.com wrote: On Monday, February 7, 2011 7:52:52 PM UTC+1, robertwb wrote: Sage is a victim of its own success! I think it's really great that there is an online notebook to try sage, but we should post a warning that this is not intended for serious work and we are working on it. Related to that, I added this notebook to the chrome webstore. I stopped promoting it on the sage website, but it still goes up the ranks rather fast. You can see it here: https://chrome.google.com/webstore/detail/dckejpjjnjaagdahkdgighlejbckajak Over 700 users ... and when you look into the listing of the most popular apps for education, it is in one of the top pages. I think this is an excellent promotion for sage and nearly 90% of those who visited that chrome webstore page were completely new to sage, so, my $5 really payed off ;) Should we point this to one of the other servers, given the less than ideal user experience when the main one? - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] edges in graphs
On Fri, Feb 4, 2011 at 3:26 PM, Mike Hansen mhan...@gmail.com wrote: On Fri, Feb 4, 2011 at 11:56 PM, Johannes dajo.m...@web.de wrote: Hi list how can i add a new edge (a-b) to a given graph G (n.n. connected), just in the case that there is no path (a - ... - b) before? You should use shortest_path which uses Dijkstra's algorithm under the hood. if g.shortest_path('a', 'b') == []: g.add_edge('a', 'b') Of course finding the shortest path may be (almost) as expensive as finding all of them... If you're doing this for a lot of edges you might want to break it up into components, then the test would be easy. It would be cool if all_paths were an iterator and you could just ask for the first one. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: help needed with cube
On Sun, Jan 30, 2011 at 2:55 AM, Loïc xl...@free.fr wrote: Thanks you very much for your reply You're right, size affects the center too. Not very intuituive but now, I know it. I think this behaviour is quite surprising. For example, with sphere, size doesn't affect center I might go so far to call it a bug... On 29 jan, 20:04, Francois Maltey fmal...@nerim.fr wrote: Hello, I was making some tries with 3D. I don't succeed to make cube correctly: Here is my code: c=cube((0,0,0),size=2,opacity=0.1,color='red') c+=point((2/3,2/3,0),color='green',size=10) c+=cube(center=(2/3,2/3,0),size=1/3,opacity=0.8) show(c) I draw a point with coord (2/3,2/3,0) Then I draw a cube centered on this point with size 1/3 When I display with JMol, the point is outside the cube... Is it a bug ? Perhaps I've missed something with the instruction cube() It seems that sage multiplies by size all the coordinates of the cube, even the center, not only the length. Try size=1, size=10 and size=0.1. The center of the cube changes. F. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] sage binaries
On Tue, Jan 25, 2011 at 4:17 PM, calcp...@aol.com calcp...@aol.com wrote: Hello All! First of all, thanx for all the great work you do making SAGE such a great resource. My students and I love it! I've used online SAGE servers and SAGE live Linux CDs over the years in class and at conferences. I recently started using the 32bit SAGE binary for Ubuntu 10.04 Desktop and love it. My question is, can I use such a binary to set up a dedicated SAGE server for my students? Yes, that binary should have everything in it to run a server. (In fact, if you're using the notebook interface, you're already doing it, though setting it up for more than local access requires a bit more work.) - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: [sage-devel] simplify_full on matrices.
On Sat, Jan 22, 2011 at 8:19 PM, ancienthart joalheag...@gmail.com wrote: This tip, which seems the most effective and least likely to blow up, has made it to the following blog. http://doxdrum.wordpress.com/2011/01/22/sage-tip-simplifying-a-matrix/ So is it possible that this could become an approach to matrices, either automagically, or by a smarter map function? Proposal one: All method calls to matrices first try to find a method that is native to the matrix. Then if this fails, sage attempts to map the method to all the matrix elements. Proposal two: matrix.map accepts either a function OR a method name. If the function call fails, tries to apply as a method of each element. E.g. D.map(simplify_full) currently gives NameError: name 'simplify_full' is not defined Instead D.map(simplify_full) fails on the function call, but instead of returning NameError, it then tries Simon's approach, by doing an invisible call to self.map(lambda x: x.simplify_full) If that fails, then let the errors propagate back up. (Have to make sure that this semi-recursive approach doesn't result in an infinite recursion of course.) Sound good? How would this second method be implemented? The NameError is raised before map even gets called. I'm +1 to the first option. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Problem: X11 dialogs and plots are used instead of Native Mac OS X GUI items
On Fri, Jan 21, 2011 at 12:28 PM, LouP pec...@anvil.nrl.navy.mil wrote: I have more information. I ran my script using the pre-installed python 2.6 framework on my Mac and the Mac version of the dialogs was used (which is what I want), Just out of curiosity, what script are you running and how is it opening dialog boxes? Is it just a standard Python script? but when I use the sage installed python I still get the X11 dialogs. More interesting is that I replaced all the files in the lib-tk folder in sage with the preinstalled lib-tk from the Mac (in /System/Library/Frameworks.../python/.../lib-tk). I still get the X11 behavior when I run the script with the sage python. This suggests that something else in the sage package is setting the X11 interface to be used rather than the native Mac GUI dialogs, etc. I have no idea where that might be set, though. What is probably going on is that some special settings/code have to be used to get the native OS X dialogs instead of the (default) X-11 ones, and there's very little platform-specific code in Sage. This is probably something that needs to be set at compile time--probably by changing how Sage's Python is compiled. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Problem: X11 dialogs and plots are used instead of Native Mac OS X GUI items
On Fri, Jan 21, 2011 at 1:09 PM, LouP pec...@anvil.nrl.navy.mil wrote: On Jan 21, 3:46 pm, Robert Bradshaw rober...@math.washington.edu wrote: On Fri, Jan 21, 2011 at 12:28 PM, LouP pec...@anvil.nrl.navy.mil wrote: I have more information. I ran my script using the pre-installed python 2.6 framework on my Mac and the Mac version of the dialogs was used (which is what I want), Just out of curiosity, what script are you running and how is it opening dialog boxes? Is it just a standard Python script? Hi, Robert, Here's the whole thing: #!/usr/bin/env sage -python def open_files(starting_dir): Returns list of filenames+paths given starting dir import Tkinter import tkFileDialog root = Tkinter.Tk() root.withdraw() # Hide root window filenames = tkFileDialog.askopenfilenames(parent=root,initialdir=starting_dir) return list(filenames) stdir= '/Users/louispecora/Desktop/' fl= open_files(stdir) print fl I'm just testing getting a file name from the dialog. Running the above in sage brings up the X11 dialog. Running it with the Mac python (changing the she-bang command) gives me the Mac dialog. I think you're right that something is set somewhere in the sage directory, but I have no idea what or where. I don't think it's something that's set, rather it's something that's not set, though I'm not sure and have no idea what. If I plot with matplotlib using TKAgg I get the X11 plot window as you might guess. I wouldn't mind recompiling sage if I could get the Mac dialogs and windows. Who would know the answer to this? I'd ask on the (Mac)Python lists to see if anyone knows how to compile Python to get the native tk dialogs instead of X11. - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org