[sage-support] sagenb.org timeout
I'd been running some computations on sagenb.org which involved (implicitly) asking Singular to make some groebner basis calculations. I was never able to complete it because it would eventually appear to finish, but at that point it acted as though the worksheet was restarted (and silently -- at least if it were going to do this it would be nice to have a message). Upon reading some posts today I realized that this was happening because of a timeout parameter in the notebook. However, if I'm in the middle of a calculation I'm not idle! I understand that because the calculation is being farmed out to Singular it might look like SAGE is idle, but it isn't. Should there be a trac ticket for this? Victor -- 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
[sage-support] Magma on a mac (yet again)
I'm running sage-4.7 64 bit on my macbook pro. I have a copy of magma 2.15 installed also. In the past I've been able to use the magma interface from Sage, but today when I try something like sage: Im = magma(I) I get the error "unable to start magma" I have the magma script in /usr/local/bin and it points correctly to where the .magmapass file is. I can run magma from the command line without problem. Any suggestions as to how to resolve this? Victor -- 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
[sage-support] Re: Tracking down a bug(?) in Cython
My vote is for an Overflow exception. Certainly doing nothing is not good. Victor On Aug 4, 3:05 pm, Robert Bradshaw wrote: > On Thu, Aug 4, 2011 at 10:49 AM, Victor Miller > 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
[sage-support] Re: Tracking down a bug(?) in Cython
I'll see what I can do about getting that. To give a little more detail, I then wrote the following function: def manydouble(P,n): for _ in range(n): P = 2*P return P and changed the statement if Q1 = 2**(1+len(z))*P1: print "Hooray" to if Q = manydouble(P1,1+len(z)): print "Hooray" and then everything started working ok in the .pyx version. On Aug 4, 3:41 am, Robert Bradshaw wrote: > On Wed, Aug 3, 2011 at 2:52 PM, Victor Miller 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 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 > >> 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 > >> > 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 > >> > > wrote: > >> > >> On Tue, Aug 2, 2011 at 11:29 AM, William Stein > >> > >> wrote: > >> > >> > On Tue, Aug 2, 2011 at 11:09 AM, VictorMiller > >> > >> > 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_w
[sage-support] ntl_GF2E
I'm doing a lot of finite field computations in finite fields of the form GF(2^n). Since I'd like to speed it up I want to use cython. When I copy over the .py file to a .pyx and compile (after excising a particular bug) it works fine. Since I want more speed, I decided to use ntl_GF2E. So I put various cdef and cimport's in compiled it with cython, but now the compilation with gcc fails because the cython tranlated C is making declarations like: GF2E x; Now GF2E is declared the ntl .h files. I suspect that somehow they're not getting included. The only cimport that I have is from sage.lib.ntl.ntl_GF2E cimport GF2E Is there anything else that I should include? Victor -- 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
[sage-support] Re: Tracking down a bug(?) in Cython
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 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 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 > > wrote: > >> On Tue, Aug 2, 2011 at 11:29 AM, William Stein wrote: > >> > On Tue, Aug 2, 2011 at 11:09 AM, VictorMiller > >> > 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
[sage-support] Re: magma interface problems
More bugs: sage: a = [ [[1,1],[0,1]], [[0,-1],[1,0]] ] sage: G = MatrixGroup([Matrix(_) for _ in a]) sage: Gm = magma(G) TypeError: Error evaluating Magma code. IN:_sage_[2]:=Matrix group over Integer Ring with 2 generators: [[[1, 1], [0, 1]], [[0, -1], [1, 0]]]; OUT: In file "/Users/victorsmiller/.sage//temp/ victor_millers_macbook_pro.local/9860//interface//tmp9882", line 1, column 19: >> _sage_[2]:=Matrix group over Integer Ring with 2 generators: ^ User error: bad syntax [I did the above from the command line interface. Read on to see why] Also, I just tried to use the magma interface on my macbook. This is a weird problem. I first started the notebook and typed sage: magma('1+1') Traceback (most recent call last): File "", line 1, in File "_sage_input_6.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("bWFnbWEoJzErMScp"),globals()) +"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc644gn/T/ tmpsQGH8V/___code___.py", line 2, in exec compile(u"magma('1+1')" + '\n', '', 'single') File "", line 1, in File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/sage/ interfaces/magma.py", line 736, in __call__ A = Expect.__call__(self, x) File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/sage/ interfaces/expect.py", line 1105, in __call__ return cls(self, x, name=name) File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/sage/ interfaces/expect.py", line 1538, in __init__ raise TypeError, x TypeError: Unable to start magma I realized that I didn't have the magma executable in my default path. So, I made a symbolic link from /usr/local/bin/magma to where the magma executable is. Tried again -- no dice. I stopped the server and exited sage (I'm using the Sage.app), and started again -- still no change. Now here's the weird thing -- if I just start up sage from the command line, and I type sage: magma('1+1') everything works ok. I just can't do it from the notebook. Since I had installed 10.7 Lion the other day I thought that possibly sage needed rebuilding (even though it had been running ok). I did a sage - b . It recompiled a lot of things, but the behavior hasn't changed. Any suggestions? Victor -- 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
[sage-support] Re: Tracking down a bug(?) in Cython
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 wrote: > On Tue, Aug 2, 2011 at 11:29 AM, William Stein wrote: > > On Tue, Aug 2, 2011 at 11:09 AM, VictorMiller > > 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
[sage-support] Re: magma interface problems
Whoops, I was copying the lines manually. The line should have been sage: x = G.InvariantsOfDegree(GF(2),2) Victor On Aug 2, 5:32 pm, William Stein wrote: > On Tue, Aug 2, 2011 at 1:29 PM, VictorMiller wrote: > > I'm unable to get some magma output converted back into sage. This > > has to do with group invariants. Here's a script that produces the > > error > > > sage: G =magma(SymmetricGroup(5)) > > sage: x = G.InvariantsOfDegree(2) > > What version of Magma are you using? With Magma V2.17-4 I get > > >> _sage_[7]:=InvariantsOfDegree(_sage_[5],_sage_[6]); > > ^ > Runtime error in 'InvariantsOfDegree': Bad argument types > Argument types given: GrpPerm, RngIntElt > > > > > > > > > > > sage: print x > > [ > > x1^2 + x2^2 + x3^2 + x4^2 + x5^2, > > x1*x2 + x1*x3 + x2*x3 + x1*x4 + x2*x4 + x3*x4 + x1*x5 + x2*x5 + x3*x5 > > + > > x4*x5 > > ] > > sage: print x.sage() > > NameError: name 'x1' is not defined > > > -- > > 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 > > -- > William Stein > Professor of Mathematics > University of Washingtonhttp://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
[sage-support] magma interface problems
I'm unable to get some magma output converted back into sage. This has to do with group invariants. Here's a script that produces the error sage: G =magma(SymmetricGroup(5)) sage: x = G.InvariantsOfDegree(2) sage: print x [ x1^2 + x2^2 + x3^2 + x4^2 + x5^2, x1*x2 + x1*x3 + x2*x3 + x1*x4 + x2*x4 + x3*x4 + x1*x5 + x2*x5 + x3*x5 + x4*x5 ] sage: print x.sage() NameError: name 'x1' is not defined -- 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
[sage-support] Tracking down a bug(?) in Cython
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 suggestions as to how to get to the bottom of the differences between the cython compiled version and the interpreted version? -- 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
[sage-support] decorators
Is there any documentation for the decorators that are available in Sage? I couldn't find anything about them in the reference manual? -- 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
[sage-support] Sage launching a lot of processes
Yesterday I started up sage 4.6.2 on one of our compute servers, started the notebook interface, and connected to from firefox on my workstation. I started up a notebook session, where I constructed a particular elliptic curve over GF(2^351), and a point on it. I (unwisely) tried P1.order() When it didn't come back after 30 seconds or so, I realized that I was implicitly asking Sage to compute the order of the curve and then factor that order, so I tried to kill it by using Interrupt, which didn't work, so I restarted the worksheet. However, at that point things became non-responsive. I eventually ended up logging onto the server and stopping sage. About an hour later the computer administrator came into my office saying that I had nearly brought the compute server to its knees because I had started 1300 processes (all running something in the sage directory)! Has anybody seen anything like this before? Victor -- 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
[sage-support] Cython programming with finite field computations
I want to do a lot of finite field computations, and want to use Cython to speed things up. It's not clear to me what the details are that I need to adhere to. I noticed from the comments in element_givaro.pyx that the givaro library is fastest from fields of size < 2^16. However, some of the fields that I want to calculate in are bigger than that. So the particular question is -- what declarations to I need to import, and most importantly can I do this use formulae in my program (e.g like a*b + c^2) or will I need to labaoriously write out all the individual function calls? Victor PS. If someone has a .pyx/.pxd program that does such a thing as an example, that would probably be most of what I need. -- 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
[sage-support] Generating extension fields
Suppose that I have field (it's actually a finite field, but it would be nice to know if this works in more generality) F, and an extension field K. If a[0], ..., a[k] are elements of K, I'd like to generate the field F obtained by adjoining these elements to F as a sage object. Is there a method to do this? Victor -- 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
[sage-support] sagenb.org
Is sagenb.org having problems? I tried to log on yesterday (and today, just now), and it said that my username was unknown! Victor -- 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
[sage-support] Error Messages from cached functions
If you give the wrong number of arguments to a cached function you get a rather mystifying error message: sage: @cached_function sage: def A(i,j): sage:return i+j sage: def B(i,j): sage:return i+j sage: A(3) Traceback (click to the left of this block for traceback) ... KeyError: 'j' But sage: B(3) Traceback (click to the left of this block for traceback) ... TypeError: B() takes exactly 2 arguments (1 given) -- 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
[sage-support] dual abelian group
There are some defects in dual abelian group: 1) The base ring is currently CC. It would be nice if it were CyclotomicField of the exponent of the of group. There's an old (2006) from David Joyner about this on sage-support, and Kiran asked for it. I'd like to pop that request to the top of the stack 2) The dual group is not an instance of AbelianGroup. 3) If (2) is fixed, the dual of the dual should be the original group. 4) It would be good if there were a fourier transform method, though I'm not sure of the right place for it to live. For example if f is a map from an AbelianGroup A to some ring R, then you might have the method A.fourier_transform(f) which would produce a map from A.dual_group() to R (more specifically R tensor A.dual_group().base_ring()). -- 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
[sage-support] Re: Bug in genus of an ideal
Thanks! Then perhaps Sage should raise an exception when it gets back genus -1 from singular. Victor On Nov 22, 3:12 am, luisfe wrote: > On Nov 21, 6:22 am, VictorMiller wrote: > > > sage: T. = QQ[] > > sage: TJ = Ideal([t1^2 + u1^2 - 1,t2^2 + u2^2 - 1, (t1-t2)^2 + (u1- > > u2)^2 -1]) > > sage: TJ.genus() > > 4294967295 > > sage: TJ.dimension() > > 1 > > Yes, there is a bug in the code. If I try Sage 32 bits, the answer to > TJ.genus() is -1. Is I use Sage 64 bits I get your result. > > The genus -1 looks like the ideal is not (absolutely) prime. This > looks odd at first sight since the ideal is prime over the rationals > and the projection onto [t1,t2] or [u1,u2] gives rational curves. > But, after a little research the answer looks right. > > sage: T.=QQ[sqrt(3)][] > sage: TJ = Ideal([t1^2 + u1^2 - 1,t2^2 + u2^2 - 1, (t1-t2)^2 + (u1- > u2)^2 -1]) > sage: TJ.is_prime() > False > sage: TJ.primary_decomposition() > [Ideal (3*t2 + (-2*sqrt3)*u1 + (sqrt3)*u2, 3*t1 + (-sqrt3)*u1 + > (2*sqrt3)*u2, 4*u1^2 - 4*u1*u2 + 4*u2^2 - 3) of Multivariate > Polynomial Ring in t1, t2, u1, u2, t over Number Field in sqrt3 with > defining polynomial x^2 - 3, Ideal (3*t2 + (2*sqrt3)*u1 + (-sqrt3)*u2, > 3*t1 + (sqrt3)*u1 + (-2*sqrt3)*u2, 4*u1^2 - 4*u1*u2 + 4*u2^2 - 3) of > Multivariate Polynomial Ring in t1, t2, u1, u2, t over Number Field in > sqrt3 with defining polynomial x^2 - 3] > > The ideal is the union of two rational conjugate curves. -- 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
[sage-support] Bug in genus of an ideal
sage: T. = QQ[] sage: TJ = Ideal([t1^2 + u1^2 - 1,t2^2 + u2^2 - 1, (t1-t2)^2 + (u1- u2)^2 -1]) sage: TJ.genus() 4294967295 sage: TJ.dimension() 1 I'm very skeptical about that answer (I realize that Singular is doing the calculation) especially since (for example). Even if it's calculating arithmetic genus I can't imagine that that curve could have that many singularities. sage: TK = Ideal([t1^2/4 + u1^2 - 1,t2^2/4 + u2^2 - 1, (t1-t2)^2 + (u1- u2)^2 -1]) sage: TK.genus() 3 sage: TK.dimension() 1 -- 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
[sage-support] Specializing a base ring
I have the following: sage: R. = QQ[] sage: K = FractionField(R) sage: S. = K[] I then create an ideal, J, in S. I'd like to take various specializations of the base. That is I have a homomorphism which maps a and b to specific values in Q, and I'd like to form the ideal in a bivariate polynomial ring QQ[] which is the specialization of this ideal. I almost had it by first using J.subs({a:value,b:value}) but that doesn't change the base, and Sage complains when I try to do a change_ring on the specialized version of J since the base field is still K and not QQ. It would be nice if change_ring could be supplemented by allowing a morphism instead of a ring. If that were specified then the source should be the original ring and the new ideal (or other things that have a change_ring method) would be obtained by applying that morphism. In some sense that's what's done now, but the morphism used is the implicit coercion. Victor -- 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
[sage-support] Newton Polygons
Are there any Sage functions and/or classes for computing Newton Polygons? -- 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
[sage-support] Bug in Group Algebra
Using sagenb.org: sage: G = SymmetricGroup(5) sage GA = G.algebra(QQ) sage: GA.gens() Traceback (click to the left of this block for traceback) ... RuntimeError: Free module generated by SymmetricGroup(5) over Rational Field still using old coercion framework Traceback (most recent call last): File "", line 1, in File "_sage_input_6.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("R0EuZ2Vucygp"),globals()) +"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/tmp/tmpRs8c10/___code___.py", line 2, in exec compile(u'GA.gens() File "", line 1, in File "parent_gens.pyx", line 294, in sage.structure.parent_gens.ParentWithGens.gens (sage/structure/ parent_gens.c:2674) -- 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
[sage-support] Bug in norm of sparse matrix
Observe (using sagenb.org) sage: M = matrix(ZZ,4,4,sparse=True) sage: M.norm() Traceback (click to the left of this block for traceback) ... AttributeError: 'sage.matrix.matrix_generic_sparse.Matrix_generic_sparse' object has no attribute 'SVD' sage: M.norm(1) Traceback (click to the left of this block for traceback) ... TypeError: base_ring (=Category of objects) must be a ring and similarly for any other argument to norm. When I do sage: M.base_ring() Integer Ring But if I do sage: M = matrix(ZZ,4,4) # without sparse=True everything works ok -- 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
[sage-support] bug in vector
Observe (using sage 4.5.2 on my mac): sage: import numpy sage: a = numpy.array([1,2,3]) sage: v = vector(a) Traceback (click to the left of this block for traceback) ... TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'int' The error message is particularly weird. Victor -- 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
[sage-support] Re: sagenb.org problem
Here's a followup question, which might be considered a firefox question: At work I used firefox. The form filling for the log in page for sagenb.org has one of my ids VictorSMiller filled in. If I try to erase it and put in victorsmiller (all lower case), as soon as I hit the log in button, it reverts back to VictorSMiller, so I can't log into the other account. Any suggestions as to how to deal with this? Victor On Jul 29, 8:54 am, VictorMiller wrote: > I'm a bit embarrassed (but only a small bit). It turns out that I > have two ids at sagenb.org: victorsmiller and VictorSMiller. I never > realized that they are different! > > Victor > > On Jul 29, 7:47 am, VictorMiller wrote: > > > Last night I logged into sagenb.org and created a new worksheet. At > > the end I pressed "Save and Quit". However, when I logged in this > > morning there was no trace of the worksheet. Can it be recovered? > > > Victor > > -- 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
[sage-support] Re: sagenb.org problem
I'm a bit embarrassed (but only a small bit). It turns out that I have two ids at sagenb.org: victorsmiller and VictorSMiller. I never realized that they are different! Victor On Jul 29, 7:47 am, VictorMiller wrote: > Last night I logged into sagenb.org and created a new worksheet. At > the end I pressed "Save and Quit". However, when I logged in this > morning there was no trace of the worksheet. Can it be recovered? > > Victor -- 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
[sage-support] sagenb.org problem
Last night I logged into sagenb.org and created a new worksheet. At the end I pressed "Save and Quit". However, when I logged in this morning there was no trace of the worksheet. Can it be recovered? Victor -- 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
[sage-support] Weird matrix bug
There's a bug in assigning 1 x 1 submatrices. assigning any submatrices with dimensions bigger than 1 seems to work as expected: sage: A = matrix(GF(2),100,100) sage: C1 = matrix(GF(2),[[1]]) sage: C2 = matrix(GF(2),[[0,1],[1,0]]) sage: A[88:90,88:90] = C2 # this is ok however sage: A[90:91,90:91] = C1 TypeError: unable to coerce to an integer Traceback (most recent call last): File "", line 1, in File "_sage_input_5.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("QVs5MDo5MSw5MDo5MV0gPSBDMQ=="),globals()) +"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/tmp/tmpo1FHLb/___code___.py", line 3, in exec compile(u'A[_sage_const_90 :_sage_const_91 ,_sage_const_90 :_sage_const_91 ] = C1 File "", line 1, in File "matrix0.pyx", line 1367, in sage.matrix.matrix0.Matrix.__setitem__ (sage/matrix/matrix0.c:5964) File "matrix0.pyx", line 1472, in sage.matrix.matrix0.Matrix._coerce_element (sage/matrix/matrix0.c: 7082) File "/usr/local/sage2/local/lib/python2.6/site-packages/sage/rings/ finite_rings/integer_mod_ring.py", line 763, in __call__ return integer_mod.IntegerMod(self, x) File "integer_mod.pyx", line 167, in sage.rings.finite_rings.integer_mod.IntegerMod (sage/rings/ finite_rings/integer_mod.c:2951) File "integer_mod.pyx", line 1672, in sage.rings.finite_rings.integer_mod.IntegerMod_int.__init__ (sage/ rings/finite_rings/integer_mod.c:14001) File "parent.pyx", line 859, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:6407) File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/ structure/coerce_maps.c:3108) File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/ structure/coerce_maps.c:3010) File "integer.pyx", line 644, in sage.rings.integer.Integer.__init__ (sage/rings/integer.c:6714) File "parent.pyx", line 859, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:6407) File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/ structure/coerce_maps.c:3108) File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/ structure/coerce_maps.c:3010) -- 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
[sage-support] repr of dense matrices
I had thought that repr(A) (where A is some object) was supposed to be a string with property that eval(repr(A)) == A. However, if A is a dense matrix (whose size is above some threshold) what I get instead is something like: '212 x 212 dense matrix over Finite Field of size 2' I could understand is str produces this, but not repr. So if I wanted to write out a string representing this matrix to a file (say) what function or method should I use? Victor -- 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
[sage-support] Sparse Vector Bug?
I'd like to construct a sparse vector (say a unit vector in 100 dimensional space) by saying a = vector(GF(2),100,dict([(22,1)]),sparse=True) However, this gives the error message below. This seems like a bug to me. Victor ValueError: incompatible degrees in vector constructor Traceback (most recent call last): File "", line 1, in File "_sage_input_4.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("YSA9IHZlY3RvcihHRigyKSwxMDAsZGljdChbKDIyLDEpXSksc3BhcnNlPVRydWUp"),globals()) +"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/tmp/tmpubMoJH/___code___.py", line 3, in exec compile(u'a = vector(GF(_sage_const_2 ),_sage_const_100 ,dict([(_sage_const_22 ,_sage_const_1 )]),sparse=True) File "", line 1, in File "free_module_element.pyx", line 277, in sage.modules.free_module_element.vector (sage/modules/ free_module_element.c:2312) ValueError: incompatible degrees in vector constructor -- 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
[sage-support] Re: Weird error message from random_element
John, Thanks for the explanation. It would have never occurred to me that polynomial rings would have gotten involved here. Victor On May 29, 7:24 am, John Cremona wrote: > This is now being tracked athttp://trac.sagemath.org/sage_trac/ticket/9085 -- 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
[sage-support] Re: Testing if something is an instance of FreeModule
Alex, Thanks. I had discovered is_FreeModule after I posted my query, but didn't know how to get rid of the deprecation warnings. Victor On May 29, 7:37 am, Alex Ghitza wrote: > On Sat, 29 May 2010 04:26:31 -0700 (PDT), John Cremona > wrote: > > Does the function is_FreeModule() do what you want by any chance? > > And if it does and you don't want to see the deprecation warnings all > the time: > > sage: from sage.modules.all import is_FreeModule > sage: is_FreeModule(x) > False > > Best, > Alex > > -- > Alex Ghitza --http://aghitza.org/ > Lecturer in Mathematics -- The University of Melbourne -- Australia -- 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
[sage-support] Re: Magma on a mac
Aha! I did some further investigation and found that I had the following line in my ~/.bash_profile file MAGMAPASSFILE=.magmapass However, it should have been MAGMAPASSFILE=~/.magmapass so that's why it couldn't find it because it was running in a directory not my home directory. Victor On May 28, 9:24 pm, VictorMiller wrote: > Ah, that's it. I had put the .magmapass file in my home directory, > but never set up MAGMAPASSFILE as an environment variable. For some > reason when I started magma from the command line, or with !magma this > didn't bother it, but from the notebook it did. I added something to > set MAGMAPASSFILE in the magma script and now everything works ok. > > Victor > > On May 28, 9:09 pm, William Stein wrote: > > > > > On Fri, May 28, 2010 at 5:46 PM, Jason Grout > > > wrote: > > > On 5/28/10 7:10 PM, William Stein wrote: > > > >> On Fri, May 28, 2010 at 5:07 PM, VictorMiller > > >> wrote: > > > >>> After 1/2 hour (!) I decided to interrupt the worksheet, quite the > > >>> notebook, quite sage, and then restart sage. Now when I try > > > >>> os.system('mamga') it comes back right away with > > > >>> Can't open Magma password file > > >>> .magmapass > > > >>> 256 > > > > I wonder if it just can't find the magma password file. After skimming > > > >http://magma.maths.usyd.edu.au/magma/prot/prot.html > > > > it looks like you can (must?) set the MAGMAPASSFILE environment variable. > > > Can you try: > > > > os.system('export MAGMAPASSFILE= && magma') > > > No, do > > > os.system('export MAGMAPASSFILE= && magma < /dev/null') > > > so you don't just hang things. > > > > or > > > > import os > > > os.environ['MAGMAPASSFILE'] > > > > 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 > > > -- > > William Stein > > Professor of Mathematics > > University of Washingtonhttp://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
[sage-support] Re: Magma on a mac
Ah, that's it. I had put the .magmapass file in my home directory, but never set up MAGMAPASSFILE as an environment variable. For some reason when I started magma from the command line, or with !magma this didn't bother it, but from the notebook it did. I added something to set MAGMAPASSFILE in the magma script and now everything works ok. Victor On May 28, 9:09 pm, William Stein wrote: > On Fri, May 28, 2010 at 5:46 PM, Jason Grout > > > > > > wrote: > > On 5/28/10 7:10 PM, William Stein wrote: > > >> On Fri, May 28, 2010 at 5:07 PM, VictorMiller > >> wrote: > > >>> After 1/2 hour (!) I decided to interrupt the worksheet, quite the > >>> notebook, quite sage, and then restart sage. Now when I try > > >>> os.system('mamga') it comes back right away with > > >>> Can't open Magma password file > >>> .magmapass > > >>> 256 > > > I wonder if it just can't find the magma password file. After skimming > > >http://magma.maths.usyd.edu.au/magma/prot/prot.html > > > it looks like you can (must?) set the MAGMAPASSFILE environment variable. > > Can you try: > > > os.system('export MAGMAPASSFILE= && magma') > > No, do > > os.system('export MAGMAPASSFILE= && magma < /dev/null') > > so you don't just hang things. > > > > > > > > > or > > > import os > > os.environ['MAGMAPASSFILE'] > > > 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 > > -- > William Stein > Professor of Mathematics > University of Washingtonhttp://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
[sage-support] Re: Magma on a mac
After 1/2 hour (!) I decided to interrupt the worksheet, quite the notebook, quite sage, and then restart sage. Now when I try os.system('mamga') it comes back right away with Can't open Magma password file .magmapass 256 However, I have no trouble starting magma from a terminal or from sage in command line mode. Victor On May 28, 7:27 pm, William Stein wrote: > On Fri, May 28, 2010 at 4:15 PM, VictorMiller wrote: > > I'm in the notebook and I typed > > > os.system('magma') > > > It's now over 5 minutes, and it still hasn't come back! While I was > > waiting I went a terminal and typed magma and it started within less > > than a second. > > Something weird. > > What about > > os.system('magma < /dev/null') > > William > > > > > > > > > Victor > > > On May 28, 6:55 pm, William Stein wrote: > >> On Fri, May 28, 2010 at 3:33 PM, VictorMiller > >> wrote: > >> > More data: If I start sage and then type > > >> > !magma > > >> > it starts up Magma. I then exit from it (by typing "exit;") and start > >> > the notebook. > > >> > However, if I try to run magma from the notebook, I get the message > > >> > "Type Error: unable to start magma" > > >> > What's going on? > > >> What happens if you do this on the command line: > > >> sage: magma.eval('2+2') > > >> What happens if you type this in a notebook cell: > > >> sage: os.system('magma') > > >> William > > >> > Victor > > >> > On May 28, 2:11 pm, William Stein wrote: > >> >> On Fri, May 28, 2010 at 11:03 AM, VictorMiller > >> >> wrote: > >> >> > I have magma and sage 4.4.1 installed on my macbook pro. I've made > >> >> > sure that the magma command is on my PATH. Yet when I run sage, and I > >> >> > try and call to magma.eval, it says that it can't find magma. This > >> >> > has worked without problem on my linux workstation at work. So what > >> >> > needs to be done to have sage find my installation of magma? The page > >> >> >http://www.sagemath.org/doc/reference/sage/interfaces/magma.html > >> >> > doesn't say anything about this. > > >> >> > Victor > > >> >> Start sage and type > > >> >> sage: !magma > > >> >> What happens? > > >> >> > -- > >> >> > 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 > > >> >> -- > >> >> William Stein > >> >> Professor of Mathematics > >> >> University of Washingtonhttp://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 > >> > athttp://groups.google.com/group/sage-support > >> > URL:http://www.sagemath.org > > >> -- > >> William Stein > >> Professor of Mathematics > >> University of Washingtonhttp://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 > > athttp://groups.google.com/group/sage-support > > URL:http://www.sagemath.org > > -- > William Stein > Professor of Mathematics > University of Washingtonhttp://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
[sage-support] Re: Magma on a mac
I'm in the notebook and I typed os.system('magma') It's now over 5 minutes, and it still hasn't come back! While I was waiting I went a terminal and typed magma and it started within less than a second. Something weird. Victor On May 28, 6:55 pm, William Stein wrote: > On Fri, May 28, 2010 at 3:33 PM, VictorMiller wrote: > > More data: If I start sage and then type > > > !magma > > > it starts up Magma. I then exit from it (by typing "exit;") and start > > the notebook. > > > However, if I try to run magma from the notebook, I get the message > > > "Type Error: unable to start magma" > > > What's going on? > > What happens if you do this on the command line: > > sage: magma.eval('2+2') > > What happens if you type this in a notebook cell: > > sage: os.system('magma') > > William > > > > > > > > > Victor > > > On May 28, 2:11 pm, William Stein wrote: > >> On Fri, May 28, 2010 at 11:03 AM, VictorMiller > >> wrote: > >> > I have magma and sage 4.4.1 installed on my macbook pro. I've made > >> > sure that the magma command is on my PATH. Yet when I run sage, and I > >> > try and call to magma.eval, it says that it can't find magma. This > >> > has worked without problem on my linux workstation at work. So what > >> > needs to be done to have sage find my installation of magma? The page > >> >http://www.sagemath.org/doc/reference/sage/interfaces/magma.html > >> > doesn't say anything about this. > > >> > Victor > > >> Start sage and type > > >> sage: !magma > > >> What happens? > > >> > -- > >> > 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 > > >> -- > >> William Stein > >> Professor of Mathematics > >> University of Washingtonhttp://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 > > athttp://groups.google.com/group/sage-support > > URL:http://www.sagemath.org > > -- > William Stein > Professor of Mathematics > University of Washingtonhttp://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
[sage-support] Re: Magma on a mac
More data: If I start sage and then type !magma it starts up Magma. I then exit from it (by typing "exit;") and start the notebook. However, if I try to run magma from the notebook, I get the message "Type Error: unable to start magma" What's going on? Victor On May 28, 2:11 pm, William Stein wrote: > On Fri, May 28, 2010 at 11:03 AM, VictorMiller > wrote: > > I have magma and sage 4.4.1 installed on my macbook pro. I've made > > sure that the magma command is on my PATH. Yet when I run sage, and I > > try and call to magma.eval, it says that it can't find magma. This > > has worked without problem on my linux workstation at work. So what > > needs to be done to have sage find my installation of magma? The page > >http://www.sagemath.org/doc/reference/sage/interfaces/magma.html > > doesn't say anything about this. > > > Victor > > Start sage and type > > sage: !magma > > What happens? > > > > > -- > > 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 > > -- > William Stein > Professor of Mathematics > University of Washingtonhttp://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
[sage-support] Weird error message from random_element
Here's something a bit odd: sage: F = GF(2) sage: A = CartesianProduct(F,F) sage: print A.random_element() This gets a trace back and the message TypeError: You must specify the names of the variables Victor -- 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
[sage-support] Testing if something is an instance of FreeModule
I'm writing some code, and I'd like to test if a the value of a variable, say M, is an instance of an element of a FreeModule(F,n) for some F and n. If this weren't a parametrized class I could write if isinstance(M,C): # do stuff here However doing if isinstance(M,FreeModule): # do stuff here doesn't work because FreeModule isn't a class or a type. So how do I do this? And, then if it passes that test, how do I extract the F and n (the two arguments to FreeModule)? Victor -- 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
[sage-support] Magma on a mac
I have magma and sage 4.4.1 installed on my macbook pro. I've made sure that the magma command is on my PATH. Yet when I run sage, and I try and call to magma.eval, it says that it can't find magma. This has worked without problem on my linux workstation at work. So what needs to be done to have sage find my installation of magma? The page http://www.sagemath.org/doc/reference/sage/interfaces/magma.html doesn't say anything about this. Victor -- 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
[sage-support] Re: solving linear systems
It's possible. Probably a better test would be to write a loop in Magma which would modify the matrix in each iteration (say by adding something to one location). This came about because one of my colleagues had a large search program written in Magma in which almost all the computation was done in calls to IsConsistent in the inner loop. Each call was with a different matrix A. I rewrote the program in Sage, and found, much to my chagrin, that it was about a factor of 30 slower. So in that program no caching could have helped. Victor On May 26, 6:23 pm, Simon King wrote: > On 26 Mai, 22:09, VictorMiller wrote: > > > A = Matrix([[1,0,1,0],[1,1,0,1],[0,1,0,1],[1,1,0,0],[1,0,0,0]]) > > b=vector([13,1,7,5,14]) > > timeit('A.solve_right(b,check=False)') > > B = A.change_ring(QQ) > > timeit('B.solve_right(b,check=False)') > > bm = magma(v) > > Am = magma(A.transpose()) # magma uses solve_left > > magma.eval('t :=Cputime();for i in [1..1] do a,b,c := > > IsConsistent(%s,%s); end for; Cputime()-t;'%(Am.name(),bm.name())) > > Might there be some caching of useful information on Am in Magma? -- 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
[sage-support] Re: solving linear systems
A = Matrix([[1,0,1,0],[1,1,0,1],[0,1,0,1],[1,1,0,0],[1,0,0,0]]) b=vector([13,1,7,5,14]) timeit('A.solve_right(b,check=False)') B = A.change_ring(QQ) timeit('B.solve_right(b,check=False)') bm = magma(v) Am = magma(A.transpose()) # magma uses solve_left magma.eval('t :=Cputime();for i in [1..1] do a,b,c := IsConsistent(%s,%s); end for; Cputime()-t;'%(Am.name(),bm.name())) Victor On May 26, 3:58 pm, William Stein wrote: > On Wed, May 26, 2010 at 12:55 PM, VictorMiller > wrote: > > It was even slower than A.solve_right(check=False). The results from > > timeit (on my workstation) were > > > 767 microseconds for b in A.column_space() > > Can you post the actual problem? Or something equivalent? > > -- William > > > > > and > > > 481 microseconds for A.solve_right(b,check=False) > > > but 1 iterations of IsConsistent(A,b) in Magma (on the same > > computer -- called from SAGE) > > yielded > > 14 microseconds per iteration > > > This was all with solving over the rationals. > > > By contrast, (implicitly using Hermite normal form) > > > it was 625 microseconds for A.solve_right(b), where now A was a matrix > > over Z (and not over Q as above). > > > I was just glancing at the appropriate code and it is all written in > > cython. On first glance it appears to be doing the correct thing and > > not to be obviously wasting any time, but the huge discrepancy between > > it and Magma points to an important thing to be worked on. > > > Victor > > > On May 26, 1:46 pm, John Cremona wrote: > >> Victor, > > >> How fast is it to do > > >> b in A.column_space() > > >> ? > > >> John > > >> On May 25, 7:48 pm, VictorMiller wrote: > > >> > I have a sage program which involves a lot of calculations of the > >> > form: > > >> > solve for x, Ax = b, where A is an integral matrix and x and b are > >> > column vectors. A is an integer matrix, but the solution (if it > >> > exists) for x might be rational. Actually I want more than this: > > >> > I want to also determine the kernel of A. It turns out that magma has > >> > a function which does this: > > >> > IsConsistent(A,b) which returns a boolean (saying if it's solvable), a > >> > value for x, and the kernel of A. > > >> > I know that I can get the same functionality in Sage by doing > >> > something like: > > >> > try: > >> > x = A.change_ring(QQ).solve_right(b) > >> > K = A.right_kernel() > >> > # process x and K > >> > except: > >> > print "no solution" > > >> > This appears to be wasteful because, whatever elimination algorithm is > >> > being used by solve_right, would almost immediately yield the kernel, > >> > so that it's wasteful to redo the calculation. So, perhaps > >> > solve_right could have an optional argument like kernel=True, etc. > > >> > By the way, I've tried using hermite_form instead, but that's much > >> > much slower. > > >> > I've found however, that magma's IsConsistent function is MUCH faster > >> > than this (by over a factor of 30). > >> > As usual, it's impossible to figure out what algorithm Magma is > >> > using, but this indicates that some work should be done on the sage > >> > functions. To be specific, the matrices that I'm processing are > >> > fairly small (say 5 by 4) 0/1 matrices. > > >> > Victor > > > -- > > 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 > > -- > William Stein > Professor of Mathematics > University of Washingtonhttp://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
[sage-support] Re: solving linear systems
It was even slower than A.solve_right(check=False). The results from timeit (on my workstation) were 767 microseconds for b in A.column_space() and 481 microseconds for A.solve_right(b,check=False) but 1 iterations of IsConsistent(A,b) in Magma (on the same computer -- called from SAGE) yielded 14 microseconds per iteration This was all with solving over the rationals. By contrast, (implicitly using Hermite normal form) it was 625 microseconds for A.solve_right(b), where now A was a matrix over Z (and not over Q as above). I was just glancing at the appropriate code and it is all written in cython. On first glance it appears to be doing the correct thing and not to be obviously wasting any time, but the huge discrepancy between it and Magma points to an important thing to be worked on. Victor On May 26, 1:46 pm, John Cremona wrote: > Victor, > > How fast is it to do > > b in A.column_space() > > ? > > John > > On May 25, 7:48 pm, VictorMiller wrote: > > > I have a sage program which involves a lot of calculations of the > > form: > > > solve for x, Ax = b, where A is an integral matrix and x and b are > > column vectors. A is an integer matrix, but the solution (if it > > exists) for x might be rational. Actually I want more than this: > > > I want to also determine the kernel of A. It turns out that magma has > > a function which does this: > > > IsConsistent(A,b) which returns a boolean (saying if it's solvable), a > > value for x, and the kernel of A. > > > I know that I can get the same functionality in Sage by doing > > something like: > > > try: > > x = A.change_ring(QQ).solve_right(b) > > K = A.right_kernel() > > # process x and K > > except: > > print "no solution" > > > This appears to be wasteful because, whatever elimination algorithm is > > being used by solve_right, would almost immediately yield the kernel, > > so that it's wasteful to redo the calculation. So, perhaps > > solve_right could have an optional argument like kernel=True, etc. > > > By the way, I've tried using hermite_form instead, but that's much > > much slower. > > > I've found however, that magma's IsConsistent function is MUCH faster > > than this (by over a factor of 30). > > As usual, it's impossible to figure out what algorithm Magma is > > using, but this indicates that some work should be done on the sage > > functions. To be specific, the matrices that I'm processing are > > fairly small (say 5 by 4) 0/1 matrices. > > > Victor > > -- 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
[sage-support] Re: solving linear systems
I just did a small test comparing Sage with Magma on my workstation (sort of a generic intel box). I generated a random 5 x 4 0/1 matrix, and a random 5-vector v with coefficients in range(0,16). I ran timeit('xx= A.solve_right(v,check=False)') and then passed v and A to magma and had magma eval to a 1 long loop of a,c,d := IsConsistent(A,v) I found that Magma was faster than sage by a factor of 44. I haven't looked at the sage code yet, but I hope that most of the difference comes from the fact that it's not written in Cython. Victor On May 25, 2:48 pm, VictorMiller wrote: > I have a sage program which involves a lot of calculations of the > form: > > solve for x, Ax = b, where A is an integral matrix and x and b are > column vectors. A is an integer matrix, but the solution (if it > exists) for x might be rational. Actually I want more than this: > > I want to also determine the kernel of A. It turns out that magma has > a function which does this: > > IsConsistent(A,b) which returns a boolean (saying if it's solvable), a > value for x, and the kernel of A. > > I know that I can get the same functionality in Sage by doing > something like: > > try: > x = A.change_ring(QQ).solve_right(b) > K = A.right_kernel() > # process x and K > except: > print "no solution" > > This appears to be wasteful because, whatever elimination algorithm is > being used by solve_right, would almost immediately yield the kernel, > so that it's wasteful to redo the calculation. So, perhaps > solve_right could have an optional argument like kernel=True, etc. > > By the way, I've tried using hermite_form instead, but that's much > much slower. > > I've found however, that magma's IsConsistent function is MUCH faster > than this (by over a factor of 30). > As usual, it's impossible to figure out what algorithm Magma is > using, but this indicates that some work should be done on the sage > functions. To be specific, the matrices that I'm processing are > fairly small (say 5 by 4) 0/1 matrices. > > Victor -- 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
[sage-support] solving linear systems
I have a sage program which involves a lot of calculations of the form: solve for x, Ax = b, where A is an integral matrix and x and b are column vectors. A is an integer matrix, but the solution (if it exists) for x might be rational. Actually I want more than this: I want to also determine the kernel of A. It turns out that magma has a function which does this: IsConsistent(A,b) which returns a boolean (saying if it's solvable), a value for x, and the kernel of A. I know that I can get the same functionality in Sage by doing something like: try: x = A.change_ring(QQ).solve_right(b) K = A.right_kernel() # process x and K except: print "no solution" This appears to be wasteful because, whatever elimination algorithm is being used by solve_right, would almost immediately yield the kernel, so that it's wasteful to redo the calculation. So, perhaps solve_right could have an optional argument like kernel=True, etc. By the way, I've tried using hermite_form instead, but that's much much slower. I've found however, that magma's IsConsistent function is MUCH faster than this (by over a factor of 30). As usual, it's impossible to figure out what algorithm Magma is using, but this indicates that some work should be done on the sage functions. To be specific, the matrices that I'm processing are fairly small (say 5 by 4) 0/1 matrices. Victor -- 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
[sage-support] Re: Vertical and Horizontal join of matrices
Thanks! On May 20, 6:19 pm, Robert Bradshaw wrote: > On May 20, 2010, at 3:15 PM, VictorMiller wrote: > > > Does the Matrix class have methods for vertical and horizontal joins > > of matrices (as in Magma)? That is > > > if A is an m by n matrix and B is an r by n matrix then > > VerticalJoin(A,B) would by the (m+r) by n matrix with A "on top" and B > > "on the bottom". Similarly, if A is m by n and B is m by r then > > HorizontalJoin(A,B) would be an m by (n+r) matrix with A "on the left" > > and B "on the right". I though that Numeric Python used to have > > something like this with a method called concatenate, but I can't find > > that in numpy. > > You're probably looking for stack and augment. > > sage: M = random_matrix(ZZ, 3, 3) > sage: M.stack(M) > [ -1 1 -5] > [ 72 -2 1] > [ -2 2 -20] > [ -1 1 -5] > [ 72 -2 1] > [ -2 2 -20] > sage: M.augment(M) > [ -1 1 -5 -1 1 -5] > [ 72 -2 1 72 -2 1] > [ -2 2 -20 -2 2 -20] > > - 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
[sage-support] Vertical and Horizontal join of matrices
Does the Matrix class have methods for vertical and horizontal joins of matrices (as in Magma)? That is if A is an m by n matrix and B is an r by n matrix then VerticalJoin(A,B) would by the (m+r) by n matrix with A "on top" and B "on the bottom". Similarly, if A is m by n and B is m by r then HorizontalJoin(A,B) would be an m by (n+r) matrix with A "on the left" and B "on the right". I though that Numeric Python used to have something like this with a method called concatenate, but I can't find that in numpy. Victor -- 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
[sage-support] New sage version?
I just downloaded, what I thought, was SAGE 4.4 (I went to sagemath.org, download, and clicked on the server from Boston) for Mac OS X 64 bit intel. After installing it, and running it the banner says version 4.3.5. Has the new version not made it out to all the servers? Victor -- 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
[sage-support] exceptions in @interact
If I write a function in a cell of a notebook like: @interact def foo(a = input_box(default=0, type=Integer)): # do something here pass And the user enters something that cannot be coerced to Integer, then I get a verbose (and rather unhelpful) exception, which, as far as I can see, can't be caught inside of foo. So, I would suggest that if a type is specified in input_box, and the coercion fails that a nicer looking message be given (perhaps next to the box that a specifies). Victor -- 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
[sage-support] A server that only runs a particular worksheet
Is it possible to do the following: have SAGE be a server so that when someone goes to a particular URL that they'll attach to SAGE only running a particular worksheet (which would probably have @interactive stuff)? If so, how would I do it? Victor PS. What I'd like to do is to have a server which is customized to doing a specific class of calculations. People would attach, log in, do whatever calculations are offered, with the ability to save results between sessions, etc. -- 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
[sage-support] Re: subprocess in SAGE
Thanks for the suggestion. It turned out (for a rather convoluted reason) that the program that I thought I'd be running didn't exist. My bad :-). Victor On Apr 22, 2:58 pm, Jason Grout wrote: > On 04/22/2010 12:18 PM, VictorMiller wrote: > > > > > I tried using sage -python > > > It still bombs out, but slightly differently: it now does a > > > raise child_exception in the _execute_child method of subprocess, and > > gets the error string > > > OSError: [Errno 2] No such file or directory > > > On Apr 22, 12:58 pm, Jason Grout wrote: > >> On 04/22/2010 11:38 AM, VictorMiller wrote: > > >>> I have some old Python programs that I've been using, and would like > >>> to use them as part of SAGE. One particular function I have uses the > >>> standard python module subprocess to call an external program, and > >>> then process the output from that. This has worked fine in python for > >>> a number of years (through various python version changes). However, > >>> when I try to use it from within SAGE, when subprocess is finished > >>> with the process and it tries to close the process handle it gets an > >>> error > > >>> OSError: [Errno 2] No such file or directory. > > >>> [Actually I'm not sure if it's even able to spawn the process at all] > > My guess is that your process can't find your executable. Try doing > this (which will check that subprocess works and also check that your > executable is found: > > import subprocess > p=subprocess.Popen("/bin/sh",stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) > output=p.communicate('which ls\n') > print output[0], output[1] > > Replace the "which ls" command with "which " to just > double-check that the spawned shell can see your program. > > The above works for me in Sage, so I think subprocess works just fine in > Sage. > > Thanks, > > Jason > > -- > Jason Grout > > -- > 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
[sage-support] Re: subprocess in SAGE
Also, I'm running on Redhat Linux On Apr 22, 1:18 pm, VictorMiller wrote: > I tried using sage -python > > It still bombs out, but slightly differently: it now does a > > raise child_exception in the _execute_child method of subprocess, and > gets the error string > > OSError: [Errno 2] No such file or directory > > On Apr 22, 12:58 pm, Jason Grout wrote: > > > > > On 04/22/2010 11:38 AM, VictorMiller wrote: > > > > I have some old Python programs that I've been using, and would like > > > to use them as part of SAGE. One particular function I have uses the > > > standard python module subprocess to call an external program, and > > > then process the output from that. This has worked fine in python for > > > a number of years (through various python version changes). However, > > > when I try to use it from within SAGE, when subprocess is finished > > > with the process and it tries to close the process handle it gets an > > > error > > > > OSError: [Errno 2] No such file or directory. > > > > [Actually I'm not sure if it's even able to spawn the process at all] > > > > Is there a known issue with using subprocess from within SAGE? > > > What if you invoke them using sage -python? That will just launch the > > Sage's version of python, and will narrow down the problem to being > > (possibly) just a problem with python 2.6.4 (the version that comes with > > Sage). > > > Thanks, > > > Jason > > > -- > > Jason Grout > > > -- > > 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 > 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
[sage-support] Re: subprocess in SAGE
I should say that my call is subprocess.Popen(myargs,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) where myargs is the usual list of tokens in the command On Apr 22, 12:58 pm, Jason Grout wrote: > On 04/22/2010 11:38 AM, VictorMiller wrote: > > > I have some old Python programs that I've been using, and would like > > to use them as part of SAGE. One particular function I have uses the > > standard python module subprocess to call an external program, and > > then process the output from that. This has worked fine in python for > > a number of years (through various python version changes). However, > > when I try to use it from within SAGE, when subprocess is finished > > with the process and it tries to close the process handle it gets an > > error > > > OSError: [Errno 2] No such file or directory. > > > [Actually I'm not sure if it's even able to spawn the process at all] > > > Is there a known issue with using subprocess from within SAGE? > > What if you invoke them using sage -python? That will just launch the > Sage's version of python, and will narrow down the problem to being > (possibly) just a problem with python 2.6.4 (the version that comes with > Sage). > > Thanks, > > Jason > > -- > Jason Grout > > -- > 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
[sage-support] Re: subprocess in SAGE
I tried using sage -python It still bombs out, but slightly differently: it now does a raise child_exception in the _execute_child method of subprocess, and gets the error string OSError: [Errno 2] No such file or directory On Apr 22, 12:58 pm, Jason Grout wrote: > On 04/22/2010 11:38 AM, VictorMiller wrote: > > > I have some old Python programs that I've been using, and would like > > to use them as part of SAGE. One particular function I have uses the > > standard python module subprocess to call an external program, and > > then process the output from that. This has worked fine in python for > > a number of years (through various python version changes). However, > > when I try to use it from within SAGE, when subprocess is finished > > with the process and it tries to close the process handle it gets an > > error > > > OSError: [Errno 2] No such file or directory. > > > [Actually I'm not sure if it's even able to spawn the process at all] > > > Is there a known issue with using subprocess from within SAGE? > > What if you invoke them using sage -python? That will just launch the > Sage's version of python, and will narrow down the problem to being > (possibly) just a problem with python 2.6.4 (the version that comes with > Sage). > > Thanks, > > Jason > > -- > Jason Grout > > -- > 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
[sage-support] subprocess in SAGE
I have some old Python programs that I've been using, and would like to use them as part of SAGE. One particular function I have uses the standard python module subprocess to call an external program, and then process the output from that. This has worked fine in python for a number of years (through various python version changes). However, when I try to use it from within SAGE, when subprocess is finished with the process and it tries to close the process handle it gets an error OSError: [Errno 2] No such file or directory. [Actually I'm not sure if it's even able to spawn the process at all] Is there a known issue with using subprocess from within SAGE? Victor -- 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
[sage-support] Finite Dimensional non-commutative algebras
Are there any classes for computing with finite dimensional non- commutative algebras? I know (but don't know the details) that GAP has some support for that, to compute things like ideals, and the Jacobson radical. And, I think that SAGE has some support for group rings, but I was looking for things in more generality. Victor -- 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
[sage-support] Re: Sage 4.3.1 notebook server exceptions
I was using Safari. What I mean by the "server stopped responding" was that if I would type something into the notebook, it would just hang up. When I tried to refresh the page I got an error message saying that it couldn't reach that URL (I didn't save the exact message). Victor On Feb 11, 12:36 am, William Stein wrote: > On Wed, Feb 10, 2010 at 9:34 PM, VictorMiller wrote: > > I've been running Sage 4.3.1 on my macbook pro. Today, the following > > happened twice: > > > The notebook server stopped responding. When I looked at the console > > I had the following error on it: > > > 2010-02-10 23:02:21-0500 [HTTPChannel,86,127.0.0.1] /Applications/sage/ > > local/lib/python2.6/site-packages/twisted/internet/defer.py:267: > > exceptions.DeprecationWarning: Don't pass strings (like 'Bad token') > > to failure.Failure (replacing with a DefaultException). > > 2010-02-10 23:02:21-0500 [HTTPChannel,86,127.0.0.1] Exception > > rendering: > > 2010-02-10 23:02:21-0500 [HTTPChannel,86,127.0.0.1] Unhandled Error > > Traceback (most recent call last): > > Failure: twisted.python.failure.DefaultException: Bad token > > > At that point I had to stop the notebook server and restart it, but > > after an hour or so, it happened again. Has anybody seen anything > > like that? Is this a known bug? > > It doesn't look familiar to me. Did you try refreshing your web > browser, and did it then still not work? > Did you try using a different web browser (e.g., Safari) to see if > that made any difference. Were there any additional log messages when > you clicked around? When you said the server stopped responding, what > do you mean exactly? > > William -- 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
[sage-support] Re: Solving a^2+n*b^2
I'm pretty sure that Cornacchia's algorithm is part of Pari (though I don't remember what the function is called). Victor On Feb 9, 5:54 am, Alasdair wrote: > Do a google search on "Cornacchia's algorithm". Shouldn't be too hard > to program in Sage (if it isn't there already). > > Alasdair > > On Feb 8, 4:07 pm, Rolandb wrote: > > > > > Thanks William, > > > Actually I try to solve it for different x and n. A typical example of > > (x,n) is: > > > %time > > bruteforce(7^10*29^5,973) > > [(3899224, 2437015)] > > CPU time: 25.88 s, Wall time: 26.12 s > > > Roland > > > On 7 feb, 22:29, William Stein wrote: > > > > On Sun, Feb 7, 2010 at 12:35 PM, Rolandb wrote: > > > > Hi, > > > > Consider Euler’s famous expression x=a^2+n*b^2. I want to solve a and > > > > b, given x and n. Because solve_mod is totally broken, I tried to > > > > develop a clever method myself. Counterintuitively, I found that the > > > > most simple brute force method in SAGE is relatively fast. > > > > > def bruteforce(number,n): > > > > out=[] > > > > for b in xrange(isqrt(number/n)): > > > > (bool,a)=is_square(number-n*b^2,True) > > > > if bool: out.append((a,b)) > > > > return out > > > > > My questions are: > > > > - Why is the brute force method relatively fast? > > > > - Is there a clever approach (not dependent on solve_mod)? > > > > > Thanks in advance! Roland > > > > We have > > > > x=a^2+n*b^2 = (a-sqrt(n)*b)*(a+sqrt(n)*b) = Norm(a+sqrt(n)*b), > > > > where the norm is in the quadratic field Q(sqrt(n)). Thus a solution > > > corresponds to a factorization of the ideal generated by x in the ring > > > of integers of Q(sqrt(n)). So here is some code related to your > > > question above, which you may or may not find relevant, depending on > > > whether you're making n big or x: > > > > def eqn(x, n): > > > """ > > > Solve x = a^2+n*b^2 when x is prime, n is not a square, and there > > > is a solution. > > > > EXAMPLES: > > > > sage: a,b = eqn(13, -3); a,b > > > (4, 1) > > > sage: a^2 + -3*b^2 > > > 13 > > > sage: a,b = eqn(113, 97); a,b > > > (-4, 1) > > > sage: a^2 + 97*b^2 > > > 113 > > > """ > > > proof.number_field(False) > > > assert is_prime(x), "x must be prime" > > > assert not is_square(n), "n must not be a square" > > > R. = QQ[] > > > K. = NumberField(X^2 + n) > > > F = K.factor(x) > > > if len(F) == 1 and F[0][1] == 1: > > > raise ValueError, "no solution (x is inert)" > > > A = F[0][0].gens_reduced() > > > if len(A) > 1: > > > raise ValueError, "no solution (ideal isn't principal)" > > > return A[0][0], A[0][1] -- 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
[sage-support] Sage 4.3.1 notebook server exceptions
I've been running Sage 4.3.1 on my macbook pro. Today, the following happened twice: The notebook server stopped responding. When I looked at the console I had the following error on it: 2010-02-10 23:02:21-0500 [HTTPChannel,86,127.0.0.1] /Applications/sage/ local/lib/python2.6/site-packages/twisted/internet/defer.py:267: exceptions.DeprecationWarning: Don't pass strings (like 'Bad token') to failure.Failure (replacing with a DefaultException). 2010-02-10 23:02:21-0500 [HTTPChannel,86,127.0.0.1] Exception rendering: 2010-02-10 23:02:21-0500 [HTTPChannel,86,127.0.0.1] Unhandled Error Traceback (most recent call last): Failure: twisted.python.failure.DefaultException: Bad token At that point I had to stop the notebook server and restart it, but after an hour or so, it happened again. Has anybody seen anything like that? Is this a known bug? Victor -- 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
[sage-support] orthogonal subspace?
I can't find a method for a vector space (or perhaps a subspace of a vector space) for "orthogonal subspace". Since vector space seem to be equipped with an inner product this seems like a natural function to have. Am I missing something? If not, I vote that it should be added. Victor -- 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
[sage-support] Re: A ring of exponentials
Burcin, Thanks. That sounds a lot like what I'm looking for. I'd be interested in it. And, I'm sure that I'm not alone in saying that even if it's inefficient it might be worthwhile making an optional spkg for it. Victor On Dec 31, 3:42 pm, Burcin Erocal wrote: > Hi, > > On Thu, 31 Dec 2009 08:37:55 -0800 (PST) > > VictorMiller wrote: > > Is there any easy way of building up what I'd call a ring of > > exponentials (maybe there's a better word)? For example I'd like to > > work in the ring QQ[[2^j for j in Integers()]]: the ring with > > coefficients in Q and elements 2^j where j is an integer (or possibly > > just a non-negative integer). Such things arise naturally when > > considering difference equations. Such a ring should also have a > > difference operator Delta(f)(x) := f(x+1)-f(x). In fact the ring that > > I mentioned might also be embedded in an even bigger ring -- of all > > functions > > > f: Integers() --> QQ > > > Has anybody built such a thing? > > I have implemented special difference fields, so called PiSigma > Fields [1], which can be used to model sums and products. > > [1]http://doi.acm.org/10.1145/322248.322255 > > I work with the shift operator \sigma, which is the mapping x |-> x+1, > and not Delta as you describe. > > Since 2^j is a product, namely \prod_{i=1}^j 2, this can be modeled in > a PiSigmaField: > > sage: from karr.pi_sigma_field import PiSigmaField > sage: K. = PiSigmaField(QQ, 1, 1) > sage: E. = PiSigmaField(K, 2, 0) > > Here the arguments to the PiSigmaField constructor specify the base > field and a,b in the base field such that \sigma(j) = aj + b where j > is the generator of the extension. Michael Karr shows that most first > order equations of interest create transcendental extensions of the > base field which have the same constant field. An interesting > object which doesn't lead to a transcendental extension is (-1)^n. > > In the construction above, we have > > sage: sigma = E.sigma() > sage: sigma > Ring endomorphism of PiSigmaField with constant field Rational Field > and tower: [('j', 1, 1), ('e', 2, 0)] > Defn: e |--> 2*e > j |--> j + 1 > sage: sigma(j) > j + 1 > > Solving first order difference equations in such an object is > equivalent to simplifying indefinite symbolic sums or products. I have > an implementation of a modified version of Karr's algorithm for this. > > It is also possible to solve higher order equations, once we have > degree bounds for the solutions. > > The code is for experimentation only and far from being efficient. > This is the main reason I didn't try to submit it for inclusion in Sage > so far. I can make it available if you're interested though. > > Cheers, > Burcin -- 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
[sage-support] A ring of exponentials
Is there any easy way of building up what I'd call a ring of exponentials (maybe there's a better word)? For example I'd like to work in the ring QQ[[2^j for j in Integers()]]: the ring with coefficients in Q and elements 2^j where j is an integer (or possibly just a non-negative integer). Such things arise naturally when considering difference equations. Such a ring should also have a difference operator Delta(f)(x) := f(x+1)-f(x). In fact the ring that I mentioned might also be embedded in an even bigger ring -- of all functions f: Integers() --> QQ Has anybody built such a thing? Victor -- 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
[sage-support] Graph plotting and labels
I'm in the middle of implementing SAGE classes for binary decision diagrams using the library called CUDD (which is included in Polybori). Each BDD is actually a labeled DiGraph. It's standard in the BDD literature to draw pictures of the digraph as follows: the vertex label of a non-leaf is a decision node, and it's standard to label it with the variable name. Note that the same variable may appear in more than one node, so this is not the same as the vertex labeling convention for DiGraph in sage. Each decision node also always has two outgoing directed edges -- the true edge which is drawn with a solid line, and the false edge with a dotted line. Is there a way in the plotting package from graph to have different edge rendering depending on some criterion? It would also be nice if the graph package could be supplemented to allow extra labels to be associated with each vertex (besides its unique label), and to have an option for plot of just printing the extra information. It's also traditional in the BDD literature to print the leaves (terminal nodes) with boxes around them instead of circles. What do people think about some way of enriching the graph package to allow such things? Victor -- 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
[sage-support] Re: irreducible_components
I just ran the following on sagenb.org (so the latest release): PP. = ProjectiveSpace(3,QQ) f = x^3 + y^3 + z^3 + w^3 R = f.parent() I = [f] + [f.derivative(zz) for zz in PP.gens()] V = PP.subscheme(I) V.irreducible_components() The output is: [ Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w z y x ] [ Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w z y x ] I think that the problem is that normally Proj(R) is defined to be all prime ideals that do not contain sum_{d > 0} S_d where R is a graded ring graded by non-negative integers, and S_d is the ideal generated by homogeneous elements of degree d. I glanced at irreducible_components and it just returns all of the prime ideals coming from the primary decomposition. In the case that the ambient scheme is projective, it should exclude some. Victor On Sep 8, 7:56 pm, Kwankyu wrote: > Hi, > > What was f? What is the version of your Sage and what is the platform? > > Kwankyu --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] irreducible_components
I was looking at a hypersurface in projective 3 space, so I did sage: PP. = ProjectiveSpace(3,QQ) and then defined a homogeneous polynomial f in x,y,z,w. I wanted to find the singularities, so I did sage: I = [f] + [f.derivative(zz) for zz in PP.gens()] sage: V = PP.subscheme(I) and then asked for the irreducible components of V. However, one of them was listed as Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: x, y, z, w This seems wrong -- after all we're working in projective space. Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] divisor_of_function
divisor_of_function appears to be badly broken: E = EllipticCurve(j=1) xx,yy,zz = E.coordinate_ring().gens() E.divisor_of_function(yy) gives the output Type Error: "A positive bound (=0) must be specified. If I then do E0 = E.change_ring(GF(144169)) xxx,yyy,zzz = E0.coordinate_ring().gens() E0.divisor_of_function(yyy) just hangs up. Looking at projective_curve.py starting at line 74, shows a rather bad algorithm: It has a loop that tries all rational points on the curve (which is certainly disastrous for curves over the rationals -- this appears to be the source of the first error -- since bound=0 is the default when calling E.rational_points()) and checks each one to see if it's a 0 of the function which is the input. This is terrible on two counts: (1) It's just not correct, since the function might have 0's or poles which are not at points defined over the field of definition. (2) It's either very inefficient (over finite fields), or might never end over infinite fields. It would seem much better for it to reduce the problem to one of the zeros of a zero- dimensional ideal (using Groebner in the most general case), which essentially reduces to factorization of univariate polynomials. Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Division by zero in calculation of Weil Pairing
Hmm, In looking at ell_point.py at line 1181 it looks like it does the right thing. Somehow the pari error of division by 0 (perhaps in non- prime finite fields?) doesn't get raised as a ZeroDivisionError. This is a problem with the interface with pari: p = 100019 K. = GF(p) L. = GF(p^2) K(1)/K(0) L(1)/L(0) Note that the errors given by K and L and different. And, if we work over small characteristic, say p=7, we get a different set of errors. Victor On Aug 6, 1:13 pm, VictorMiller wrote: > Slight change. The code I gave works, but the following fails. I > really don't know what there is about a non-prime finite field that > causes this. > > Victor > > p=100019 > E = EllipticCurve(j=GF(p^2,'r')(1728)) > M = (p+1)//3 > # find an element of order 3 > while True: > P = M*E.random_element() > if P != 0: > break > P.weil_pairing(2*P,3) > > On Aug 6, 1:05 pm, VictorMiller wrote: > > > In calculating the Weil Pairing of two points I get a pari division by > > zero error. Needless to say this shouldn't happen. I think that the > > solution is that if either of the miller_functions that are calculated > > yield a 0 then the value of the Weil Pairing must be 1. > > > Here's some code that provokes the error > > > p=100019 > > E = EllipticCurve(j=GF(p)(1728)) > > M = (p+1)//3 > > # find an element of order 3 > > while True: > > P = M*E.random_element() > > if P != 0: > > break > > P.weil_pairing(2*P,3) > > --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Division by zero in calculation of Weil Pairing
Slight change. The code I gave works, but the following fails. I really don't know what there is about a non-prime finite field that causes this. Victor p=100019 E = EllipticCurve(j=GF(p^2,'r')(1728)) M = (p+1)//3 # find an element of order 3 while True: P = M*E.random_element() if P != 0: break P.weil_pairing(2*P,3) On Aug 6, 1:05 pm, VictorMiller wrote: > In calculating the Weil Pairing of two points I get a pari division by > zero error. Needless to say this shouldn't happen. I think that the > solution is that if either of the miller_functions that are calculated > yield a 0 then the value of the Weil Pairing must be 1. > > Here's some code that provokes the error > > p=100019 > E = EllipticCurve(j=GF(p)(1728)) > M = (p+1)//3 > # find an element of order 3 > while True: > P = M*E.random_element() > if P != 0: > break > P.weil_pairing(2*P,3) --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Division by zero in calculation of Weil Pairing
In calculating the Weil Pairing of two points I get a pari division by zero error. Needless to say this shouldn't happen. I think that the solution is that if either of the miller_functions that are calculated yield a 0 then the value of the Weil Pairing must be 1. Here's some code that provokes the error p=100019 E = EllipticCurve(j=GF(p)(1728)) M = (p+1)//3 # find an element of order 3 while True: P = M*E.random_element() if P != 0: break P.weil_pairing(2*P,3) --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Singular timeout?
It seems that what I posted about must have been caused by some other error (memory leak?). When I tried to do the same calculation again in the same worksheet, I got a different error about recursion depth being exceeded. So I quit the worksheet and started it over again. This time the calculation completed. Victor On Aug 5, 5:02 pm, VictorMiller wrote: > I had a small typo in the last code. The line that said > > F = FractionField(K) > > should have read > > F = FractionField(R) > > also after the line that starts with "vars = " should be the line > > R = PolynomialRing(Rationals(),k,vars) > > On Aug 5, 4:59 pm, VictorMiller wrote: > > > Okay, Here's some code (in case anyone is interested, this was related > > to a problem that appeared on the math-fun mailing list): > > > def ECurve(n,k): > > vars = ['a%d_%d'%(n,i) for i in range(k)] > > v = R.gens() > > F = FractionField(K) > > S. = F[] > > f = (x^n-1)//(x-1) > > g = x^k + sum([v[i]*x^i for i in range(k)]) > > c = (f%g).coefficients() > > return R.ideal([z.numerator() for z in c[1:]).groebner_basis() > > def Curve1(n,k) > > I = ECurve(n,k) > > if len(I) == 0: > > return I > > R = I[0].parent() > > II = R.ideal(I) > > J = II.elimination_ideal(R.gen()[:-2]) > > S. = QQ[] > > phi = R.hom((k-2)*[S(0)] + [b1,b2]) > > return Curve(phi(J.gens()[0])) > > > C = Curve1(9,3) > > > print C.genus() > > > On Aug 5, 4:12 pm, William Stein wrote: > > > > On Wed, Aug 5, 2009 at 1:09 PM, VictorMiller > > > wrote: > > > > > I was asking SAGE to do a calculation that I knew was probably > > > > laborious -- I had a plane curve (over Q) and I wanted its genus. I > > > > defined it with C=Curve(equation_in_two_variables) and then typed > > > > > C.genus() > > > > > after a while (I was in the notebook) I just got the mysterious error > > > > message: > > > > > delaybeforesend: 0 > > > > > when I expanded it, at the end there was a lot of stuff, but the > > > > relevant line was > > > > > pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). > > > > > > > > command: /u/victor/sage/local/bin/Singular > > > > > So, there are two questions: > > > > > a) is it possible to give a more informative error message. It seems > > > > obvious that singular just took > > > > too long in getting back to sage. > > > > This is not obvious to me. That is really weird. Sage should wait > > > forever > > > for any subprocess to return. The time limit on reading is purposely > > > disabled. Weird. Maybe the subprocess really crashed and the error > > > message is just wrong? Or maybe something is screwy with pexpect. Can > > > you post code? Has anybody else seen anything similar? > > > > William > > > > > b) is it possible to give a longer timeout (if I really want the > > > > answer)? > > > > > Victor > > > > -- > > > William Stein > > > Associate Professor of Mathematics > > > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Singular timeout?
Another small oops. The offending example should be C = Curve1(9,4) On Aug 5, 5:02 pm, VictorMiller wrote: > I had a small typo in the last code. The line that said > > F = FractionField(K) > > should have read > > F = FractionField(R) > > also after the line that starts with "vars = " should be the line > > R = PolynomialRing(Rationals(),k,vars) > > On Aug 5, 4:59 pm, VictorMiller wrote: > > > Okay, Here's some code (in case anyone is interested, this was related > > to a problem that appeared on the math-fun mailing list): > > > def ECurve(n,k): > > vars = ['a%d_%d'%(n,i) for i in range(k)] > > v = R.gens() > > F = FractionField(K) > > S. = F[] > > f = (x^n-1)//(x-1) > > g = x^k + sum([v[i]*x^i for i in range(k)]) > > c = (f%g).coefficients() > > return R.ideal([z.numerator() for z in c[1:]).groebner_basis() > > def Curve1(n,k) > > I = ECurve(n,k) > > if len(I) == 0: > > return I > > R = I[0].parent() > > II = R.ideal(I) > > J = II.elimination_ideal(R.gen()[:-2]) > > S. = QQ[] > > phi = R.hom((k-2)*[S(0)] + [b1,b2]) > > return Curve(phi(J.gens()[0])) > > > C = Curve1(9,3) > > > print C.genus() > > > On Aug 5, 4:12 pm, William Stein wrote: > > > > On Wed, Aug 5, 2009 at 1:09 PM, VictorMiller > > > wrote: > > > > > I was asking SAGE to do a calculation that I knew was probably > > > > laborious -- I had a plane curve (over Q) and I wanted its genus. I > > > > defined it with C=Curve(equation_in_two_variables) and then typed > > > > > C.genus() > > > > > after a while (I was in the notebook) I just got the mysterious error > > > > message: > > > > > delaybeforesend: 0 > > > > > when I expanded it, at the end there was a lot of stuff, but the > > > > relevant line was > > > > > pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). > > > > > > > > command: /u/victor/sage/local/bin/Singular > > > > > So, there are two questions: > > > > > a) is it possible to give a more informative error message. It seems > > > > obvious that singular just took > > > > too long in getting back to sage. > > > > This is not obvious to me. That is really weird. Sage should wait > > > forever > > > for any subprocess to return. The time limit on reading is purposely > > > disabled. Weird. Maybe the subprocess really crashed and the error > > > message is just wrong? Or maybe something is screwy with pexpect. Can > > > you post code? Has anybody else seen anything similar? > > > > William > > > > > b) is it possible to give a longer timeout (if I really want the > > > > answer)? > > > > > Victor > > > > -- > > > William Stein > > > Associate Professor of Mathematics > > > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Singular timeout?
I had a small typo in the last code. The line that said F = FractionField(K) should have read F = FractionField(R) also after the line that starts with "vars = " should be the line R = PolynomialRing(Rationals(),k,vars) On Aug 5, 4:59 pm, VictorMiller wrote: > Okay, Here's some code (in case anyone is interested, this was related > to a problem that appeared on the math-fun mailing list): > > def ECurve(n,k): > vars = ['a%d_%d'%(n,i) for i in range(k)] > v = R.gens() > F = FractionField(K) > S. = F[] > f = (x^n-1)//(x-1) > g = x^k + sum([v[i]*x^i for i in range(k)]) > c = (f%g).coefficients() > return R.ideal([z.numerator() for z in c[1:]).groebner_basis() > def Curve1(n,k) > I = ECurve(n,k) > if len(I) == 0: > return I > R = I[0].parent() > II = R.ideal(I) > J = II.elimination_ideal(R.gen()[:-2]) > S. = QQ[] > phi = R.hom((k-2)*[S(0)] + [b1,b2]) > return Curve(phi(J.gens()[0])) > > C = Curve1(9,3) > > print C.genus() > > On Aug 5, 4:12 pm, William Stein wrote: > > > On Wed, Aug 5, 2009 at 1:09 PM, VictorMiller wrote: > > > > I was asking SAGE to do a calculation that I knew was probably > > > laborious -- I had a plane curve (over Q) and I wanted its genus. I > > > defined it with C=Curve(equation_in_two_variables) and then typed > > > > C.genus() > > > > after a while (I was in the notebook) I just got the mysterious error > > > message: > > > > delaybeforesend: 0 > > > > when I expanded it, at the end there was a lot of stuff, but the > > > relevant line was > > > > pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). > > > > > > command: /u/victor/sage/local/bin/Singular > > > > So, there are two questions: > > > > a) is it possible to give a more informative error message. It seems > > > obvious that singular just took > > > too long in getting back to sage. > > > This is not obvious to me. That is really weird. Sage should wait forever > > for any subprocess to return. The time limit on reading is purposely > > disabled. Weird. Maybe the subprocess really crashed and the error > > message is just wrong? Or maybe something is screwy with pexpect. Can > > you post code? Has anybody else seen anything similar? > > > William > > > > b) is it possible to give a longer timeout (if I really want the > > > answer)? > > > > Victor > > > -- > > William Stein > > Associate Professor of Mathematics > > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Singular timeout?
Okay, Here's some code (in case anyone is interested, this was related to a problem that appeared on the math-fun mailing list): def ECurve(n,k): vars = ['a%d_%d'%(n,i) for i in range(k)] v = R.gens() F = FractionField(K) S. = F[] f = (x^n-1)//(x-1) g = x^k + sum([v[i]*x^i for i in range(k)]) c = (f%g).coefficients() return R.ideal([z.numerator() for z in c[1:]).groebner_basis() def Curve1(n,k) I = ECurve(n,k) if len(I) == 0: return I R = I[0].parent() II = R.ideal(I) J = II.elimination_ideal(R.gen()[:-2]) S. = QQ[] phi = R.hom((k-2)*[S(0)] + [b1,b2]) return Curve(phi(J.gens()[0])) C = Curve1(9,3) print C.genus() On Aug 5, 4:12 pm, William Stein wrote: > On Wed, Aug 5, 2009 at 1:09 PM, VictorMiller wrote: > > > > > > > I was asking SAGE to do a calculation that I knew was probably > > laborious -- I had a plane curve (over Q) and I wanted its genus. I > > defined it with C=Curve(equation_in_two_variables) and then typed > > > C.genus() > > > after a while (I was in the notebook) I just got the mysterious error > > message: > > > delaybeforesend: 0 > > > when I expanded it, at the end there was a lot of stuff, but the > > relevant line was > > > pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). > > > > command: /u/victor/sage/local/bin/Singular > > > So, there are two questions: > > > a) is it possible to give a more informative error message. It seems > > obvious that singular just took > > too long in getting back to sage. > > This is not obvious to me. That is really weird. Sage should wait forever > for any subprocess to return. The time limit on reading is purposely > disabled. Weird. Maybe the subprocess really crashed and the error > message is just wrong? Or maybe something is screwy with pexpect. Can > you post code? Has anybody else seen anything similar? > > William > > > b) is it possible to give a longer timeout (if I really want the > > answer)? > > > Victor > > -- > William Stein > Associate Professor of Mathematics > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Singular timeout?
I was asking SAGE to do a calculation that I knew was probably laborious -- I had a plane curve (over Q) and I wanted its genus. I defined it with C=Curve(equation_in_two_variables) and then typed C.genus() after a while (I was in the notebook) I just got the mysterious error message: delaybeforesend: 0 when I expanded it, at the end there was a lot of stuff, but the relevant line was pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). command: /u/victor/sage/local/bin/Singular So, there are two questions: a) is it possible to give a more informative error message. It seems obvious that singular just took too long in getting back to sage. b) is it possible to give a longer timeout (if I really want the answer)? Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Strange behavior in timeit
Sorry, here's the definition of Q: Q = E.random_element() Victor On Aug 3, 8:45 pm, Simon King wrote: > Hi! > > On 4 Aug., 02:31, VictorMiller wrote: > > > Here are the commands I used: > > > qq = [z for z in primes(10,10+100) if (z%12) == 11] > > E = EllipticCurve(j=GF(qq[0])(1728)) > > # E has qq[0]+1 points over GF(qq[0]) > > factor(qq[0]+1) > > P = ((qq[0]+1)//3)*E.random_element() > > K = [E(0),P,-P] > > phi = E.isogeny(K) > > No Maxima up to here (tested by quitting Sage)... > > > for i in xrange(20): timeit('phi(Q)') > > But also no Q. How is Q defined? > > 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Strange behavior in timeit
Here are the commands I used: qq = [z for z in primes(10,10+100) if (z%12) == 11] E = EllipticCurve(j=GF(qq[0])(1728)) # E has qq[0]+1 points over GF(qq[0]) factor(qq[0]+1) P = ((qq[0]+1)//3)*E.random_element() K = [E(0),P,-P] phi = E.isogeny(K) for i in xrange(20): timeit('phi(Q)') On Aug 3, 7:41 pm, Minh Nguyen wrote: > Hi Victor, > > On Tue, Aug 4, 2009 at 8:29 AM, VictorMiller wrote: > > > I was trying to find out how fast a calculation was (applying an > > isogeny of degree on an elliptic curve over > > a finite field). At first I noticed that when I repeated a timeit > > call with the same expression I was getting monotonically increasing > > numbers, so I decided to try something more systematic. I got the > > following peculiar results on sagenb.org (just now). The average > > times keep getting longer and longer. Could this be some bug in the > > way that the calls to internal timer routines are used? > > > phi = E.isogeny([E(0),P,-P]) > > Just out of curiosity: How did you define E? I assume it's an elliptic > curve. But what were the commands you used to define it? > > -- > Regards > Minh Van Nguyen --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Strange behavior in timeit
As far as I know Maxima isn't involved -- I don't think that isogenies uses Maxima. Victor On Aug 3, 6:58 pm, Simon King wrote: > On 4 Aug., 00:29, VictorMiller wrote: > ... > > > > > > > phi = E.isogeny([E(0),P,-P]) > > for i in xrange(20): timeit('phi(Q)') > > > 625 loops, best of 3: 1.17 ms per loop > > 625 loops, best of 3: 1.75 ms per loop > > 125 loops, best of 3: 2.1 ms per loop > > 125 loops, best of 3: 2.22 ms per loop > > 125 loops, best of 3: 2.3 ms per loop > > 125 loops, best of 3: 2.4 ms per loop > > 125 loops, best of 3: 2.52 ms per loop > > 125 loops, best of 3: 2.73 ms per loop > > 125 loops, best of 3: 3.02 ms per loop > > 125 loops, best of 3: 3.32 ms per loop > > 125 loops, best of 3: 3.48 ms per loop > > 125 loops, best of 3: 3.73 ms per loop > > 125 loops, best of 3: 3.79 ms per loop > > 125 loops, best of 3: 4.21 ms per loop > > 125 loops, best of 3: 4.56 ms per loop > > 125 loops, best of 3: 5.09 ms per loop > > 125 loops, best of 3: 5.63 ms per loop > > 125 loops, best of 3: 6.23 ms per loop > > 125 loops, best of 3: 6.86 ms per loop > > 125 loops, best of 3: 7.52 ms per loop > > This reminds me the > threadshttp://groups.google.com/group/sage-devel/browse_thread/thread/863e59... > orhttp://groups.google.com/group/sage-support/browse_thread/thread/abb4... > > In other words: > Is Maxima involved in this computation? > If yes, then it might be related with > tickethttp://trac.sagemath.org/sage_trac/ticket/4731 > Is someone working on this ticket? > > Cheers, > 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Strange behavior in timeit
I was trying to find out how fast a calculation was (applying an isogeny of degree on an elliptic curve over a finite field). At first I noticed that when I repeated a timeit call with the same expression I was getting monotonically increasing numbers, so I decided to try something more systematic. I got the following peculiar results on sagenb.org (just now). The average times keep getting longer and longer. Could this be some bug in the way that the calls to internal timer routines are used? phi = E.isogeny([E(0),P,-P]) for i in xrange(20): timeit('phi(Q)') 625 loops, best of 3: 1.17 ms per loop 625 loops, best of 3: 1.75 ms per loop 125 loops, best of 3: 2.1 ms per loop 125 loops, best of 3: 2.22 ms per loop 125 loops, best of 3: 2.3 ms per loop 125 loops, best of 3: 2.4 ms per loop 125 loops, best of 3: 2.52 ms per loop 125 loops, best of 3: 2.73 ms per loop 125 loops, best of 3: 3.02 ms per loop 125 loops, best of 3: 3.32 ms per loop 125 loops, best of 3: 3.48 ms per loop 125 loops, best of 3: 3.73 ms per loop 125 loops, best of 3: 3.79 ms per loop 125 loops, best of 3: 4.21 ms per loop 125 loops, best of 3: 4.56 ms per loop 125 loops, best of 3: 5.09 ms per loop 125 loops, best of 3: 5.63 ms per loop 125 loops, best of 3: 6.23 ms per loop 125 loops, best of 3: 6.86 ms per loop 125 loops, best of 3: 7.52 ms per loop Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: The speed of random_element in finite fields versus Magma
Thanks, I found that it even gets much worse with a bigger finite field. For example if p = next_prime(100) and I try the same experiment in GF(p^2), Magma is over 100 times faster! Victor On Jul 30, 6:07 pm, Robert Bradshaw wrote: > On Jul 30, 2009, at 2:50 PM, VictorMiller wrote: > > > I just did a test of SAGE versus Magma on the same computer. > > > I had a finite field GF(19991^2), and timed generating a random > > element in SAGE and in Magma. > > I found, much to my surprise, that Magma was a factor of 7 times > > faster. Does anyone know what > > method they use? > > No, but for this size field we're using a wrapper around pari, so I'm > sure there's lots of needless overhead converting and copying in our > implementation. > > - 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] The speed of random_element in finite fields versus Magma
I just did a test of SAGE versus Magma on the same computer. I had a finite field GF(19991^2), and timed generating a random element in SAGE and in Magma. I found, much to my surprise, that Magma was a factor of 7 times faster. Does anyone know what method they use? Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Finding the containing elliptic curve
Suppose that q is a prime power, and I have an elliptic curve E over GF (q) (say created by E = EllipticCurve(coefficient_list)) and P,Q = E.gens() How can I find E just given P (say if I pass just P to a function)? If I say print P.parent() I get something like Abelian group of point on Elliptic Curve defined by blah blah So the information must be there, but I can't figure out which method to call. Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Elliptic Curve with j invariant
I found the following to be rather unexpected: EllipticCurve(GF(144169),j=1728) Elliptic Curve defined by y^2 = x^3 - x over Rational Field Victor [I understand that 1728 is considered an Integer, yet the first argument seems to be ignored] --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Symmetric Algebras
I have a finite dimensional vector space V/k, and various automorphisms (i.e. members of GL(V)). I would like to construct the field k(X), where the variables in X correspond to a basis of V, along with the operation of GL(V) on k(X). Is there some existing way to do this in SAGE, or do I need to write new classes? In addition I have a map, h, from the basis of V to another field L, so that h is extended in the obvious way k(X) --> L. Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Where does import look?
I know that you can modify sys.path which is where python looks to find where to use import. The question that I should have asked is how does one develop new sage functions. It makes sense for each project to have its own directory to contain the pieces of stuff. What I'd like is to have some sort of function and/or command for a SAGE notebook which would give a list of directories to look in when I do attach or load, so instead of saying attach somelongpathstring/foo.sage I could just say adddirectory somelongpathstring attach foo.sage and foo.sage could have lines like from bar import baz where bar.py is in the directory somelongpathstring Victor On Jul 23, 1:56 pm, John Cremona wrote: > Hi Victor. Although I don't know the answer to your question, I'm > sure that it actually a python question (rather than a sage one) so I > expect that the answer lies somewhere in the wealth of online python > documentation! > > Of course someone else might give a more helpful answer... > > John Cremona > > On Jul 23, 5:16 pm, VictorMiller wrote: > > > I have a sage program in a file in one of my directories called > > calc.sage. It uses a class that I wrote called Table, which I've put > > in a file called Table.py in the same directory. In the sage notebook > > I load calc.sage (by explicitly giving the path to the directory), and > > calc.sage has a line > > > from Table import Table > > > However, when I try to run it it can't find Table.py. So, the > > question is, what is the path that sage uses for import, and how do I > > change it? Is there a way to do this without having to include > > explicit path qualification in the files? > > > Victor > > --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Where does import look?
I have a sage program in a file in one of my directories called calc.sage. It uses a class that I wrote called Table, which I've put in a file called Table.py in the same directory. In the sage notebook I load calc.sage (by explicitly giving the path to the directory), and calc.sage has a line from Table import Table However, when I try to run it it can't find Table.py. So, the question is, what is the path that sage uses for import, and how do I change it? Is there a way to do this without having to include explicit path qualification in the files? Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Rendering latex
Ok, I've absorbed all of that. This morning it occured to me that it would be nice if one could define a class method called _html_. If present, it would try to render an htmlized (is that a word?) version of the class (just as __str__ renders a printable version or _latex_ renders a latex version). What do people think? Victor On Jul 21, 2:27 pm, William Stein wrote: > On Tue, Jul 21, 2009 at 10:34 AM, VictorMiller wrote: > > > William, Thanks. That works ok -- except, for example if I do > > > latex.eval('$N_0$',{}) > > > I get what I expect plus a line with two single quotes before what I > > wanted. This seems to happen with any latex string. Do you know > > what's happening? > > Try > > _ = latex.eval('$N_0$',{}) > > > > > > > Victor > > > On Jul 20, 6:58 pm, William Stein wrote: > >> On Mon, Jul 20, 2009 at 3:30 PM, VictorMiller > >> wrote: > > >> > I have a program which calculates a table of values, and I'd like to > >> > display it nicely formatted. I've written a function to produce latex > >> > for it (using tabular), but I can't figure out how to get SAGE to > >> > display this in a notebook. I've tried the html command but that > >> > doesn't work. Here's a small example. I can put the following in a > >> > cell: > > >> > %latex > >> > \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > >> > {tabular} > > >> > and it renders as I expect. however, if I put the above latex in a > >> > string and try html or view it just spits out the latex (minus the > >> > first two characters!). > > >> Try this: > > >> latex.eval(r""" > >> \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > >> {tabular} > >> """,{}) > > >> In most cases, you can simulate any "%foo" environment in the notebook > >> by just typing foo.eval(, globals()). > > >> William > > >> > And incidentally, I can't figure out the following part of the latex > >> > documenation since something seems to be missing. Exactly what does > >> > the Latex function do? > > >> > class sage.misc.latex.Latex(debug=False, slide=False, density=150, > >> > pdflatex=None)¶ > > >> > Enter, e.g., > > >> > %latex > >> > The equation $y^2 = x^3 + x$ defines an elliptic curve. > >> > We have $2006 = \sage{factor(2006)}$. > > >> > in an input cell in the notebook to get a typeset version. Use > >> > %latex_debug to get debugging output. > > >> -- > >> William Stein > >> Associate Professor of Mathematics > >> University of Washingtonhttp://wstein.org > > -- > William Stein > Associate Professor of Mathematics > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Rendering latex
Ok, I've absorbed all of that. This morning it occured to me that it would be nice if one could define a class method called _html_. If present, it would try to render an htmlized (is that a word?) version of the class (just as __str__ renders a printable version or _latex_ renders a latex version). What do people think? Victor On Jul 21, 2:27 pm, William Stein wrote: > On Tue, Jul 21, 2009 at 10:34 AM, VictorMiller wrote: > > > William, Thanks. That works ok -- except, for example if I do > > > latex.eval('$N_0$',{}) > > > I get what I expect plus a line with two single quotes before what I > > wanted. This seems to happen with any latex string. Do you know > > what's happening? > > Try > > _ = latex.eval('$N_0$',{}) > > > > > > > Victor > > > On Jul 20, 6:58 pm, William Stein wrote: > >> On Mon, Jul 20, 2009 at 3:30 PM, VictorMiller > >> wrote: > > >> > I have a program which calculates a table of values, and I'd like to > >> > display it nicely formatted. I've written a function to produce latex > >> > for it (using tabular), but I can't figure out how to get SAGE to > >> > display this in a notebook. I've tried the html command but that > >> > doesn't work. Here's a small example. I can put the following in a > >> > cell: > > >> > %latex > >> > \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > >> > {tabular} > > >> > and it renders as I expect. however, if I put the above latex in a > >> > string and try html or view it just spits out the latex (minus the > >> > first two characters!). > > >> Try this: > > >> latex.eval(r""" > >> \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > >> {tabular} > >> """,{}) > > >> In most cases, you can simulate any "%foo" environment in the notebook > >> by just typing foo.eval(, globals()). > > >> William > > >> > And incidentally, I can't figure out the following part of the latex > >> > documenation since something seems to be missing. Exactly what does > >> > the Latex function do? > > >> > class sage.misc.latex.Latex(debug=False, slide=False, density=150, > >> > pdflatex=None)¶ > > >> > Enter, e.g., > > >> > %latex > >> > The equation $y^2 = x^3 + x$ defines an elliptic curve. > >> > We have $2006 = \sage{factor(2006)}$. > > >> > in an input cell in the notebook to get a typeset version. Use > >> > %latex_debug to get debugging output. > > >> -- > >> William Stein > >> Associate Professor of Mathematics > >> University of Washingtonhttp://wstein.org > > -- > William Stein > Associate Professor of Mathematics > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Rendering latex
Ok, I've absorbed all of that. This morning it occured to me that it would be nice if one could define a class method called _html_. If present, it would try to render an htmlized (is that a word?) version of the class (just as __str__ renders a printable version or _latex_ renders a latex version). What do people think? Victor On Jul 21, 2:27 pm, William Stein wrote: > On Tue, Jul 21, 2009 at 10:34 AM, VictorMiller wrote: > > > William, Thanks. That works ok -- except, for example if I do > > > latex.eval('$N_0$',{}) > > > I get what I expect plus a line with two single quotes before what I > > wanted. This seems to happen with any latex string. Do you know > > what's happening? > > Try > > _ = latex.eval('$N_0$',{}) > > > > > > > Victor > > > On Jul 20, 6:58 pm, William Stein wrote: > >> On Mon, Jul 20, 2009 at 3:30 PM, VictorMiller > >> wrote: > > >> > I have a program which calculates a table of values, and I'd like to > >> > display it nicely formatted. I've written a function to produce latex > >> > for it (using tabular), but I can't figure out how to get SAGE to > >> > display this in a notebook. I've tried the html command but that > >> > doesn't work. Here's a small example. I can put the following in a > >> > cell: > > >> > %latex > >> > \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > >> > {tabular} > > >> > and it renders as I expect. however, if I put the above latex in a > >> > string and try html or view it just spits out the latex (minus the > >> > first two characters!). > > >> Try this: > > >> latex.eval(r""" > >> \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > >> {tabular} > >> """,{}) > > >> In most cases, you can simulate any "%foo" environment in the notebook > >> by just typing foo.eval(, globals()). > > >> William > > >> > And incidentally, I can't figure out the following part of the latex > >> > documenation since something seems to be missing. Exactly what does > >> > the Latex function do? > > >> > class sage.misc.latex.Latex(debug=False, slide=False, density=150, > >> > pdflatex=None)¶ > > >> > Enter, e.g., > > >> > %latex > >> > The equation $y^2 = x^3 + x$ defines an elliptic curve. > >> > We have $2006 = \sage{factor(2006)}$. > > >> > in an input cell in the notebook to get a typeset version. Use > >> > %latex_debug to get debugging output. > > >> -- > >> William Stein > >> Associate Professor of Mathematics > >> University of Washingtonhttp://wstein.org > > -- > William Stein > Associate Professor of Mathematics > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Rendering latex
Is there a way to get tex formulas as cells in the table? Victor On Jul 21, 4:02 am, Jason Grout wrote: > VictorMiller wrote: > > I have a program which calculates a table of values, and I'd like to > > display it nicely formatted. I've written a function to produce latex > > for it (using tabular), but I can't figure out how to get SAGE to > > display this in a notebook. I've tried the html command but that > > doesn't work. Here's a small example. I can put the following in a > > cell: > > > %latex > > \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > > {tabular} > > > and it renders as I expect. however, if I put the above latex in a > > string and try html or view it just spits out the latex (minus the > > first two characters!). > > Did you try the html.table command? > > Seehttp://sagenb.org/home/pub/669/ > > or do > > html.table? > > in the notebook. > > 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Rendering latex
Jason, thanks for the suggestion. I didn't know about that function. Victor On Jul 21, 4:02 am, Jason Grout wrote: > VictorMiller wrote: > > I have a program which calculates a table of values, and I'd like to > > display it nicely formatted. I've written a function to produce latex > > for it (using tabular), but I can't figure out how to get SAGE to > > display this in a notebook. I've tried the html command but that > > doesn't work. Here's a small example. I can put the following in a > > cell: > > > %latex > > \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > > {tabular} > > > and it renders as I expect. however, if I put the above latex in a > > string and try html or view it just spits out the latex (minus the > > first two characters!). > > Did you try the html.table command? > > Seehttp://sagenb.org/home/pub/669/ > > or do > > html.table? > > in the notebook. > > 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Rendering latex
William, Thanks. That works ok -- except, for example if I do latex.eval('$N_0$',{}) I get what I expect plus a line with two single quotes before what I wanted. This seems to happen with any latex string. Do you know what's happening? Victor On Jul 20, 6:58 pm, William Stein wrote: > On Mon, Jul 20, 2009 at 3:30 PM, VictorMiller wrote: > > > I have a program which calculates a table of values, and I'd like to > > display it nicely formatted. I've written a function to produce latex > > for it (using tabular), but I can't figure out how to get SAGE to > > display this in a notebook. I've tried the html command but that > > doesn't work. Here's a small example. I can put the following in a > > cell: > > > %latex > > \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > > {tabular} > > > and it renders as I expect. however, if I put the above latex in a > > string and try html or view it just spits out the latex (minus the > > first two characters!). > > Try this: > > latex.eval(r""" > \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end > {tabular} > """,{}) > > In most cases, you can simulate any "%foo" environment in the notebook > by just typing foo.eval(, globals()). > > William > > > > > > > And incidentally, I can't figure out the following part of the latex > > documenation since something seems to be missing. Exactly what does > > the Latex function do? > > > class sage.misc.latex.Latex(debug=False, slide=False, density=150, > > pdflatex=None)¶ > > > Enter, e.g., > > > %latex > > The equation $y^2 = x^3 + x$ defines an elliptic curve. > > We have $2006 = \sage{factor(2006)}$. > > > in an input cell in the notebook to get a typeset version. Use > > %latex_debug to get debugging output. > > -- > William Stein > Associate Professor of Mathematics > University of Washingtonhttp://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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Rendering latex
I have a program which calculates a table of values, and I'd like to display it nicely formatted. I've written a function to produce latex for it (using tabular), but I can't figure out how to get SAGE to display this in a notebook. I've tried the html command but that doesn't work. Here's a small example. I can put the following in a cell: %latex \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end {tabular} and it renders as I expect. however, if I put the above latex in a string and try html or view it just spits out the latex (minus the first two characters!). And incidentally, I can't figure out the following part of the latex documenation since something seems to be missing. Exactly what does the Latex function do? class sage.misc.latex.Latex(debug=False, slide=False, density=150, pdflatex=None)¶ Enter, e.g., %latex The equation $y^2 = x^3 + x$ defines an elliptic curve. We have $2006 = \sage{factor(2006)}$. in an input cell in the notebook to get a typeset version. Use %latex_debug to get debugging output. --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] sage and numpy interactions
In converting some of my old python programs to run on SAGE I expressions like: 0.5**numpy.arange(10,1,-1) which works fine in python, but gives a type error in SAGE. I eventually figured out that I could get this to work by doing float(0.5)**numpy.arange(10,1,-1) but that's a pain. Any chance that this could be fixed so that I don't have to explicitly say float each time? Victor --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---