[sage-support] Re: 3dplotting complex functions
Dear kcrisman, I think it would be enough to give an example in the tutorial or in the output of plot3d?. Even more, an example gives kind of a smooth lesson in how really to use the 3dplotting and the .imag() or the .real() command at the same time. Starting from Jason's examples I did all I wanted to and even more and I am beginning to understand plotting. Examples are better than new commands, because they are way more flexible and they make you play around. Perhaps it would be nice for the user to find an example how to plot graphs like these http://mathworld.wolfram.com/ModifiedBesselFunctionoftheSecondKind.html in the outputs of bessel_X?. In this case I succeded in generating some pictures, but they don't look like the ones in mathworld. (But I am not asking for support in this respect.) One thing I am missing (or simply not understanding) is 3dplotting without automatically scaled up range of the function value. Jmol and Sage seem to try to plot the whole graph even at singularities, then give up (at a level I don't know how to fix) but leave the picture with the scaled up value range. Use the link above to see what I mean would be useful sometimes. There the value range is simply cut at some point. In the german wikipedia article on the exponential funcion it is done in a similar way by Maple and the whole picture is scaled equal in all dimensions. But I am going to make a new support question out of that. Thanks a lot. Yours, littlemathteacher On 31 Mai, 04:01, kcrisman kcris...@gmail.com wrote: Ironically, I did something just like this at a talk this week. But I used something like lambda x,y: abs(zeta(x+i*y)) (actually not that, but I hope that will work). At least one of these should really be implemented as complexplot3d or something like that. Does that seem like a useful function to have around? - kcrisman On May 30, 9:13 pm, littlemathteacher relational...@gmail.com wrote: Thanks a lot. Much simpler than I thought it would be. Very fine instructive example. Yours, littlemathteacher. On 30 Mai, 17:49, Jason Grout jason-s...@creativetrax.com wrote: littlemathteacher wrote: Dear Supporters, first of all thanks to you all for doing such a great support job to me so far. Now I want to make complex analysis visible and to plot 3d-graphics either of real or imaginary parts of functions. The first step would be to plot the exponential function just like in the german or the us wikipedia article, later to show the branch cuts like in http://mathworld.wolfram.com/BranchCut.html or the gamma function like in http://mathworld.wolfram.com/GammaFunction.html. The reason why my attemps fail might lie somwhere in the defining of variables and in the picking out of the real or the imaginary part. I guess all I need is one working example of how to 3dplot let's say complexplane X real part of the function value. Starting from that example I could do the rest myself, but I didn't find one yet. Could you please post a link to an example? And here's the imaginary part: sage: plot3d(lambda x,y: arcsin(x+y*I).imag(), (-2,2), (-2,2)) 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 at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Limiting the function value range in 3dplots
Dear supporters, again thanks for the great support. One thing I am missing (or simply not understanding) is 3dplotting without automatically scaled up range of the function value. (This is just my first example at hand and surely not a good one: y, x = var ('x,y') plot3d(lambda x,y : (bessel_Y(y,x,scipy,53)).real(), (-0.002,0.002), (-1,1)) #Put some broader x-range in to see what I mean.) Please excuse this sloppy written description: Jmol and Sage seem to try to plot the whole graph even at singularities, then give up (at a level I don't know how to fix) but leave the picture with the scaled up value range. Use this link to see what I mean would be useful sometimes (and please do not blame me because my plot above is another thing as seen there - I am just playing around and I just took the first example at hand): http://mathworld.wolfram.com/ModifiedBesselFunctionoftheSecondKind.html There the value range is simply cut at some point. In the german wikipedia article on the exponential function it is done in a similar way by Maple and the whole picture is scaled equally in all dimensions: http://de.wikipedia.org/w/index.php?title=Datei:Exp_re.pngfiletimestamp=20050215210532 (Put the two lines together without intermedate space.) Is there a way to limit the value range in a 3dplot other than limiting the input range (I want to see, say, the region around the singularity)? Yours, littlemathteacher --~--~-~--~~~---~--~~ 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: Limiting the function value range in 3dplots
Sorry, me again. Maybe I was wrong to say Sage scales up. Maybe Sage scales down. Howto aviod this? Thanks On 2 Jun., 08:44, littlemathteacher relational...@gmail.com wrote: Dear supporters, again thanks for the great support. One thing I am missing (or simply not understanding) is 3dplotting without automatically scaled up range of the function value. (This is just my first example at hand and surely not a good one: y, x = var ('x,y') plot3d(lambda x,y : (bessel_Y(y,x,scipy,53)).real(), (-0.002,0.002), (-1,1)) #Put some broader x-range in to see what I mean.) Please excuse this sloppy written description: Jmol and Sage seem to try to plot the whole graph even at singularities, then give up (at a level I don't know how to fix) but leave the picture with the scaled up value range. Use this link to see what I mean would be useful sometimes (and please do not blame me because my plot above is another thing as seen there - I am just playing around and I just took the first example at hand): http://mathworld.wolfram.com/ModifiedBesselFunctionoftheSecondKind.html There the value range is simply cut at some point. In the german wikipedia article on the exponential function it is done in a similar way by Maple and the whole picture is scaled equally in all dimensions: http://de.wikipedia.org/w/index.php?title=Datei:Exp_re.pngfiletimest... (Put the two lines together without intermedate space.) Is there a way to limit the value range in a 3dplot other than limiting the input range (I want to see, say, the region around the singularity)? Yours, littlemathteacher --~--~-~--~~~---~--~~ 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: Limiting the function value range in 3dplots
Actually, Sage's 2d plotting has a similar problem, though for different reasons; see http://trac.sagemath.org/sage_trac/ticket/3985 . I believe that in both cases, though, there could be improvement of automatic detecting of the right values. That said, you may want to try something using the command show(), at least for your second question. E.g. sage: P=plot3d(lambda x,y : (bessel_Y(y,x,scipy,53)).real(), (-0.002,0.002), (-1,1)) sage: P.show(aspect_ratio=[200,1,1/2000]) yields something approximately like the original graph, though of course it still includes all values. For more info, you can look at sage: P.show? Unfortunately, something like xmax, xmin in the 2d show command seems to be missing in 3d plotting; at least, using them is ignored by Jmol. So if that is the main thing you are asking for, it is not yet implemented. - kcrisman On Jun 2, 6:16 am, littlemathteacher relational...@gmail.com wrote: Sorry, me again. Maybe I was wrong to say Sage scales up. Maybe Sage scales down. Howto aviod this? Thanks On 2 Jun., 08:44, littlemathteacher relational...@gmail.com wrote: Dear supporters, again thanks for the great support. One thing I am missing (or simply not understanding) is 3dplotting without automatically scaled up range of the function value. (This is just my first example at hand and surely not a good one: y, x = var ('x,y') plot3d(lambda x,y : (bessel_Y(y,x,scipy,53)).real(), (-0.002,0.002), (-1,1)) #Put some broader x-range in to see what I mean.) Please excuse this sloppy written description: Jmol and Sage seem to try to plot the whole graph even at singularities, then give up (at a level I don't know how to fix) but leave the picture with the scaled up value range. Use this link to see what I mean would be useful sometimes (and please do not blame me because my plot above is another thing as seen there - I am just playing around and I just took the first example at hand): http://mathworld.wolfram.com/ModifiedBesselFunctionoftheSecondKind.html There the value range is simply cut at some point. In the german wikipedia article on the exponential function it is done in a similar way by Maple and the whole picture is scaled equally in all dimensions: http://de.wikipedia.org/w/index.php?title=Datei:Exp_re.pngfiletimest... (Put the two lines together without intermedate space.) Is there a way to limit the value range in a 3dplot other than limiting the input range (I want to see, say, the region around the singularity)? Yours, littlemathteacher --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sage-support] Re: sage and numpy interactions
On Tue, Jun 2, 2009 at 10:15 AM, VictorMiller victorsmil...@gmail.com wrote: 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? This will be fixed eventually, probably by patches we will apply to numpy at build time. Nobody has even started doing this or surveyed how hard it will be. It'll happen eventually, though. See the FAQ: http://wiki.sagemath.org/faq#Typeissuesusingscipy.2CcvxoptornumpyfromSage --~--~-~--~~~---~--~~ 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: sage and numpy interactions
On Tue, Jun 2, 2009 at 11:26 AM, William Stein wst...@gmail.com wrote: On Tue, Jun 2, 2009 at 10:15 AM, VictorMiller victorsmil...@gmail.com wrote: 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? This will be fixed eventually, probably by patches we will apply to numpy at build time. Nobody has even started doing this or surveyed how hard it will be. It'll happen eventually, though. See the FAQ: http://wiki.sagemath.org/faq#Typeissuesusingscipy.2CcvxoptornumpyfromSage Even better fix would be to send patches to numpy itself, since I thought we agreed that this is a bug in numpy. Ondrej --~--~-~--~~~---~--~~ 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: Notebook server sluggish in 3.4
Thanks Kiran, I think snapshots were indeed part of the problem. I have been running that server since early 2007, with multiple grad students, and it had a ridiculous number of snapshot files. I think I've deleted about 1 GB so far. -Marshall On May 30, 3:24 pm, Kiran Kedlaya ksk...@gmail.com wrote: Followup: I think the underlying issue here was addressed in ticket #5880. My problem was that I had a lot of old snapshots created by pre-3.4.1 versions of sage, and they were tying the file system in knots. I'm now running the script Gonzalo posted to #5880 that deletes redundant snapshots; that should help. Marshall: might that help in your case too? Kiran On May 30, 2:47 pm, Kiran Kedlaya ksk...@gmail.com wrote: I just tried a test with 3.4.1, and I was seeing 100% CPU usage (and impressive memory usage) even when the notebook was idle. This is a Fedora 64 system, so I also tried using a patched 4.0.rc1 that upgraded python to 2.5.4 (since that fixed other memory issues); that way, I don't see any CPU usage on idle, but when I try to evaluate 2+2 I get 90+% CPU usage for 10+ seconds Does that happen *every* time, or just the first time? . Every time. It also takes much longer to start and stop the notebook on this system than, say, on sage.math (20+ seconds versus maybe 2 seconds), out of proportion to the CPU speeds of the machines. Maybe your filesystem is slow? Are you using nfs? The Sage install is on a local file system, but the sage_notebook directory is on nfs. If I force the notebook directory to be on the local file system, this doesn't seem to happen. I suppose that means that I can get around this by moving the notebook directory. But it might be nice if there were another alternative in case someone doesn't have that option (i.e., some way to run the notebook with fewer file accesses). Thanks! Kiran --~--~-~--~~~---~--~~ 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] Just to tell you I could make a wx render to work for matplotlib within ETS spkg
Hi all, I was a little dissappointed when I discover after accomplished to install the ETS spkg to work, in my Ubuntu 9.04 athlon x86_64 computer, that although it has mayavi2 and chaco working in all is beautifullness, it has not the render for pylab (matplotlib). Because all my 2-D graphs are of this kind I try to see how to do to get a render for it. I do not know traits and it take me too much time to convince myself to look for another possibility, until I found an example (attached) of Ken McIvor using wx and a library developed by him: wxmpl to render at full capacity matplotlib graphs. My first trial was with the 1.2.9 wxmpl version whithout success, asking him for help he adviced me to try with this last one: wxmpl-1.3.1, then I install it and it works very well, in such a way that it can be called also running the example inside the notebook. CHeers, Jorge _ Actualiza y gana con Windows Live http://www.actualizatuperfil.com.mx/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- #!/usr/bin/env python # Purpose: Demonstrates different plots from the matplotlib examples collection # Author: Ken McIvor mci...@iit.edu, deriving from the matplotlib examples # collection # # Copyright 2002-2004 John D. Hunter, 2005 Illinois Institute of Technology # # Distributed under the license agreement for matplotlib 0.72. # # For information on the usage and redistribution of this file, and for a # DISCLAIMER OF ALL WARRANTIES, see the file LICENSE that ships with the # matplotlib 0.72 or http://matplotlib.sourceforge.net/license.html __version__ = '1.0' import wx import wxmpl import matplotlib import matplotlib.cm as cm from pylab import array, arange, sin, cos, exp, pi, randn, normpdf, meshgrid, \ convolve def plot_simple(fig): t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) c = cos(2*pi*t) axes = fig.gca() axes.plot(t, s, linewidth=1.0) axes.plot(t, c, linewidth=1.0) axes.set_xlabel('time (s)') axes.set_ylabel('voltage (mV)') axes.set_title('About as simple as it gets, folks') axes.grid(True) def plot_subplot(fig): def f(t): return cos(2*pi*t) * exp(-t) t1 = arange(0.0, 5.0, 0.10) t2 = arange(0.0, 5.0, 0.02) a1 = fig.add_subplot(2, 1, 1) a1.plot(t1, f(t1), 'bo') a1.plot(t2, f(t2), 'k') a1.grid(True) a1.set_title('A Tale of 2 Subplots') a1.set_ylabel('Damped oscillation') a2 = fig.add_subplot(2, 1, 2) a2.plot(t2, cos(2*pi*t2), 'r') a2.grid(True) a2.set_xlabel('time (s)') a2.set_ylabel('Undamped') def plot_subplot_sharex(fig): def f(t): return cos(2*pi*t) * exp(-t) t1 = arange(0.0, 5.0, 0.10) t2 = arange(0.0, 5.0, 0.02) a1 = fig.add_subplot(2, 1, 1) a1.plot(t1, f(t1), 'bo') a1.plot(t2, f(t2), 'k') a1.grid(True) a1.set_title('Two Subplots Sharing an Axis') a1.set_ylabel('Damped oscillation') for ticklabel in a1.get_xticklabels(): ticklabel.set_visible(False) a2 = fig.add_subplot(2, 1, 2, sharex=a1) a2.plot(t2, cos(2*pi*t2), 'r') a2.grid(True) a2.set_xlabel('time (s)') a2.set_ylabel('Undamped') def plot_histogram(fig): mu, sigma = 100, 15 x = mu + sigma*randn(1) axes = fig.gca() # the histogram of the data n, bins, patches = axes.hist(x, 100, normed=1) # add a 'best fit' line y = normpdf( bins, mu, sigma) l = axes.plot(bins, y, 'r--', linewidth=2) axes.set_xlim((40, 160)) axes.set_xlabel('Smarts') axes.set_ylabel('P') axes.set_title('IQ: mu=100, sigma=15') #axes.set_title(r'$\rm{IQ:}\/ \mu=100,\/ \sigma=15$') def plot_fill(fig): t = arange(0.0, 1.01, 0.01) s = sin(2*2*pi*t) axes = fig.gca() axes.fill(t, s*exp(-5*t), 'r') axes.grid(True) def plot_log(fig): dt = 0.01 t = arange(dt, 20.0, dt) a1 = fig.add_subplot(2, 1, 1) a1.semilogx(t, sin(2*pi*t)) a1.set_ylabel('semilogx') a1.grid(True) a2 = fig.add_subplot(2, 1, 2) a2.loglog(t, 20*exp(-t/10.0), basey=4) a2.xaxis.grid(True, which='minor') # minor grid on too a2.set_xlabel('time (s)') a2.set_ylabel('loglog') a2.grid(True) def plot_polar(fig): import pylab r = arange(0,1,0.001) theta = 2*2*pi*r # radar green, solid grid lines matplotlib.rc('grid', color='#316931', linewidth=1, linestyle='-') ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') ax.plot(theta, r, color='#ee8d18', lw=3) ax.set_title(And there was much rejoicing!, fontsize=14) matplotlib.rcdefaults() def
[sage-support] Re: Just to tell you I could make a wx render to work for matplotlib within ETS spkg
Jorge E. ´Sanchez Sanchez wrote: Hi all, I was a little dissappointed when I discover after accomplished to install the ETS spkg to work, in my Ubuntu 9.04 athlon x86_64 computer, that although it has mayavi2 and chaco working in all is beautifullness, it has not the render for pylab (matplotlib). Because all my 2-D graphs are of this kind I try to see how to do to get a render for it. I do not know traits and it take me too much time to convince myself to look for another possibility, until I found an example (attached) of Ken McIvor using wx and a library developed by him: wxmpl to render at full capacity matplotlib graphs. My first trial was with the 1.2.9 wxmpl version whithout success, asking him for help he adviced me to try with this last one: wxmpl-1.3.1, then I install it and it works very well, in such a way that it can be called also running the example inside the notebook. Interesting. Can you elaborate? Jaap CHeers, Jorge _ Actualiza y gana con Windows Live http://www.actualizatuperfil.com.mx/ --~--~-~--~~~---~--~~ 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: Just to tell you I could make a wx render to work for matplotlib within ETS spkg
After installing ETS spkg, once someone knows what to do it seems very easily, 1) download from: agni.phys.iit.edu/~kmcivor/wxmpl/, Wxmpl version 1.3.1 which is completely compatible with the matplotlib library comming with the ETS-3.1.1 spkg, in your $SAGE_ROOT/local/lib/python2.5/site-packages directory. 2) untar the file: tar xvf wxmpl-1.3.1.tar.gz 3) cd to the wxmpl-1.3.1 directory 4) sage sage: python setup.py install installs the library. 5) sage: notebook() 6) load the example in the notebook: - Action (button), choose Evaluate all, and the corresponding buttons of the example code will appear at your display. Enjoy Jorge Date: Tue, 2 Jun 2009 22:33:22 +0200 From: j.sp...@hccnet.nl To: sage-support@googlegroups.com Subject: [sage-support] Re: Just to tell you I could make a wx render to work for matplotlib within ETS spkg Jorge E. ´Sanchez Sanchez wrote: Hi all, I was a little dissappointed when I discover after accomplished to install the ETS spkg to work, in my Ubuntu 9.04 athlon x86_64 computer, that although it has mayavi2 and chaco working in all is beautifullness, it has not the render for pylab (matplotlib). Because all my 2-D graphs are of this kind I try to see how to do to get a render for it. I do not know traits and it take me too much time to convince myself to look for another possibility, until I found an example (attached) of Ken McIvor using wx and a library developed by him: wxmpl to render at full capacity matplotlib graphs. My first trial was with the 1.2.9 wxmpl version whithout success, asking him for help he adviced me to try with this last one: wxmpl-1.3.1, then I install it and it works very well, in such a way that it can be called also running the example inside the notebook. Interesting. Can you elaborate? Jaap CHeers, Jorge _ Actualiza y gana con Windows Live http://www.actualizatuperfil.com.mx/ _ Comparte tu vida en Perfil de Windows Live. Actualízalo ya! http://www.actualizatuperfil.com.mx/ --~--~-~--~~~---~--~~ 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] Typesetting issue
I had installed sage 3.4.1 in my Ubuntu machine, and every time I did something like: f=function(f,x) integrate(f,x,0,1) in a notebook, sage showed me the equation using an integral symbol. I just installed sage 4.0, and when I do the same, I get: integrate(f(x), x, 0, 1) no matter if I check the Typeset Box. It happens also with derivatives. What am I doing wrong? Is there anything else I need to install? Regards Ricardo --~--~-~--~~~---~--~~ 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: Typesetting issue
I made a mistake in the example. The correct example is: f=function(f,x) a=integrate(f,x,0,1) show(a) I have been doing some other tests, and all math symbols seem to be gone, square roots for example. Regards Ricardo On 2 jun, 16:55, richi ramezqui...@gmail.com wrote: I had installed sage 3.4.1 in my Ubuntu machine, and every time I did something like: f=function(f,x) integrate(f,x,0,1) in a notebook, sage showed me the equation using an integral symbol. I just installed sage 4.0, and when I do the same, I get: integrate(f(x), x, 0, 1) no matter if I check the Typeset Box. It happens also with derivatives. What am I doing wrong? Is there anything else I need to install? Regards Ricardo --~--~-~--~~~---~--~~ 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: Limiting the function value range in 3dplots
littlemathteacher wrote: Dear supporters, again thanks for the great support. One thing I am missing (or simply not understanding) is 3dplotting without automatically scaled up range of the function value. (This is just my first example at hand and surely not a good one: y, x = var ('x,y') plot3d(lambda x,y : (bessel_Y(y,x,scipy,53)).real(), (-0.002,0.002), (-1,1)) #Put some broader x-range in to see what I mean.) Please excuse this sloppy written description: Jmol and Sage seem to try to plot the whole graph even at singularities, then give up (at a level I don't know how to fix) but leave the picture with the scaled up value range. Use this link to see what I mean would be useful sometimes (and please do not blame me because my plot above is another thing as seen there - I am just playing around and I just took the first example at hand): http://mathworld.wolfram.com/ModifiedBesselFunctionoftheSecondKind.html There the value range is simply cut at some point. In the german wikipedia article on the exponential function it is done in a similar way by Maple and the whole picture is scaled equally in all dimensions: http://de.wikipedia.org/w/index.php?title=Datei:Exp_re.pngfiletimestamp=20050215210532 (Put the two lines together without intermedate space.) Is there a way to limit the value range in a 3dplot other than limiting the input range (I want to see, say, the region around the singularity)? Here is a way to do what you want with a new very powerful feature in 4.0: implicit_plot3d(lambda x,y,z: z-(bessel_Y(y,x,scipy,53)).real(), ( -0.002,0.002),( -1,1), (-100,100)) See http://www.sagenb.org/home/pub/347/ Using implicit_plot3d is a lot slower than I expected to do this, though. When http://trac.sagemath.org/sage_trac/ticket/5514 is finished and merged, you should be able to do something like: y, x = var ('x,y') plot3d(lambda x,y : (bessel_Y(y,x,scipy,53)).real(), (-0.002,0.002), (-1,1), region=lambda x,y,z: z20 and z-20) or even y, x = var ('x,y') my_plot = plot3d(lambda x,y : (bessel_Y(y,x,scipy,53)).real(), (-0.002,0.002), (-1,1)) my_plot.clip(lambda x,y,z: z20 and z-20) I agree that there should also be an easy way to do this without the functionality in #5514 and without having to resort to implicit_plot3d. 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 at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: fast slicing of matrix
William Stein wrote: On Mon, Jun 1, 2009 at 5:16 PM, davidp dav...@reed.edu wrote: Is there a fast way to create a submatrix? - sage: version() 'Sage Version 4.0.alpha0, Release Date: 2009-05-15' sage: G = graphs.GridGraph([100,100]) sage: L = G.laplacian_matrix() sage: L 1 x 1 sparse matrix over Integer Ring sage: time M = L[1:,1:] CPU times: user 24.93 s, sys: 0.04 s, total: 24.97 s Wall time: 25.27 s I am just interested in deleting a single row and column of the matrix (not necessarily the first). Thanks, There is no fast way to do that right now. One could easily add code to SAGE_ROOT/devel/sage/sage/matrix/matrix_integer_sparse.pyx that would provide blazingly fast deletion of a row, and reasonably fast deletion of a column. Of course it would be better to implement arbitrary slicing in some optimized way in matrix_integer_sparse.pyx. I hope somebody does so. Just looking at the generic code, it seems that it goes through each and every index position in the slice, setting the new matrix entry to the old one. This is obviously the wrong thing to do for sparse matrices, and can likely trivially be made faster. I think all you may have to do is override the matrix_from_rows_and_columns for sparse matrices. 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: fast slicing of matrix
I tried adding a delete_row method to matrix_integer_sparse.pyx but stopped after getting the error message: + Error converting Pyrex file to C: ... add_mpz_vector_init(M._matrix[i], self._matrix[i], (Matrix_integer_sparseright)._matrix[i], mul) mpz_clear(mul) return M # added by David Perkinson cpdef ModuleElement _delete_row_(self, Py_ssize_t row_number): ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:216:10: C method '_delete_row_' not previously declared in definition part of extension type Error running command, failed with status 256. sage: There was an error installing modified sage library code. ++ I might have to actually read the Cython documentation! Dave On Jun 2, 5:43 pm, Jason Grout jason-s...@creativetrax.com wrote: William Stein wrote: On Mon, Jun 1, 2009 at 5:16 PM, davidp dav...@reed.edu wrote: Is there a fast way to create a submatrix? - sage: version() 'Sage Version 4.0.alpha0, Release Date: 2009-05-15' sage: G = graphs.GridGraph([100,100]) sage: L = G.laplacian_matrix() sage: L 1 x 1 sparse matrix over Integer Ring sage: time M = L[1:,1:] CPU times: user 24.93 s, sys: 0.04 s, total: 24.97 s Wall time: 25.27 s I am just interested in deleting a single row and column of the matrix (not necessarily the first). Thanks, There is no fast way to do that right now. One could easily add code to SAGE_ROOT/devel/sage/sage/matrix/matrix_integer_sparse.pyx that would provide blazingly fast deletion of a row, and reasonably fast deletion of a column. Of course it would be better to implement arbitrary slicing in some optimized way in matrix_integer_sparse.pyx. I hope somebody does so. Just looking at the generic code, it seems that it goes through each and every index position in the slice, setting the new matrix entry to the old one. This is obviously the wrong thing to do for sparse matrices, and can likely trivially be made faster. I think all you may have to do is override the matrix_from_rows_and_columns for sparse matrices. 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: fast slicing of matrix
On Tue, Jun 2, 2009 at 7:22 PM, davidp dav...@reed.edu wrote: I tried adding a delete_row method to matrix_integer_sparse.pyx but stopped after getting the error message: Just def your method -- do not cpdef it. You can still use Cython code in a cpdef's method and it will be just as fast. Make sure that your delete row method returns a *new* matrix by the way... William + Error converting Pyrex file to C: ... add_mpz_vector_init(M._matrix[i], self._matrix[i], (Matrix_integer_sparseright)._matrix[i], mul) mpz_clear(mul) return M # added by David Perkinson cpdef ModuleElement _delete_row_(self, Py_ssize_t row_number): ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:216:10: C method '_delete_row_' not previously declared in definition part of extension type Error running command, failed with status 256. sage: There was an error installing modified sage library code. ++ I might have to actually read the Cython documentation! Dave On Jun 2, 5:43 pm, Jason Grout jason-s...@creativetrax.com wrote: William Stein wrote: On Mon, Jun 1, 2009 at 5:16 PM, davidp dav...@reed.edu wrote: Is there a fast way to create a submatrix? - sage: version() 'Sage Version 4.0.alpha0, Release Date: 2009-05-15' sage: G = graphs.GridGraph([100,100]) sage: L = G.laplacian_matrix() sage: L 1 x 1 sparse matrix over Integer Ring sage: time M = L[1:,1:] CPU times: user 24.93 s, sys: 0.04 s, total: 24.97 s Wall time: 25.27 s I am just interested in deleting a single row and column of the matrix (not necessarily the first). Thanks, There is no fast way to do that right now. One could easily add code to SAGE_ROOT/devel/sage/sage/matrix/matrix_integer_sparse.pyx that would provide blazingly fast deletion of a row, and reasonably fast deletion of a column. Of course it would be better to implement arbitrary slicing in some optimized way in matrix_integer_sparse.pyx. I hope somebody does so. Just looking at the generic code, it seems that it goes through each and every index position in the slice, setting the new matrix entry to the old one. This is obviously the wrong thing to do for sparse matrices, and can likely trivially be made faster. I think all you may have to do is override the matrix_from_rows_and_columns for sparse matrices. Jason -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] problem running sage -t
I would like to run the doctests in my file, sandpile.sage, but get the following error message: ++=== xyzzy sage -t sandpile.sage sage -t sandpile.sage /usr/local/sage-devel/local/bin/sage-preparse: File file_name is missing Traceback (most recent call last): File ./sandpile.py, line 18, in module from sandpile import * File /home/davidp/math/sandpile/sage/sage-sandpile1.4/sandpile.py, line 167, in module class Sandpile(DiGraph): NameError: name 'DiGraph' is not defined [1.6 s] exit code: 1024 -- The following tests failed: sage -t sandpile.sage Total time for all tests: 1.6 seconds ++ I tried adding from sage.graphs.graph import DiGraph to the file but got the same error message. Any suggestions? Thanks, Dave --~--~-~--~~~---~--~~ 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: fast slicing of matrix
William Stein wrote: On Tue, Jun 2, 2009 at 7:22 PM, davidp dav...@reed.edu wrote: I tried adding a delete_row method to matrix_integer_sparse.pyx but stopped after getting the error message: Just def your method -- do not cpdef it. You can still use Cython code in a cpdef's method and it will be just as fast. Make sure that your delete row method returns a *new* matrix by the way... You might fold your functionality into matrix_from_rows_and_columns. That way slicing will automatically use it. Maybe you could intelligently guess from the rows and columns requested whether it is faster to just copy the matrix, then delete some rows/columns, or to build the new matrix up. For example, if I'm asking for every row and column in the matrix except one, almost surely it is faster to copy the dictionary and delete the appropriate row/column keys. Then again, I can see the advantage of just having a delete_rows or delete_columns method; it's definitely clear what you are doing. 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: fast slicing of matrix
I can't figure out how to create a new sparse matrix (see below). Sorry, Dave M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) --- ... def _delete_row_(self, Py_ssize_t row_number): cdef Py_ssize_t i cdef mpz_vector* self_row, *M_row cdef Matrix_integer_sparse M M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:221:101: Compiler crash in AnalyseExpressionsTransform ModuleNode.body = StatListNode(matrix_integer_sparse.pyx:23:0) StatListNode.stats[13] = StatListNode(matrix_integer_sparse.pyx:43:5) StatListNode.stats[0] = CClassDefNode(matrix_integer_sparse.pyx:43:5, as_name = u'Matrix_integer_sparse', base_class_module = u'matrix_sparse', base_class_name = u'Matrix_sparse', class_name = u'Matrix_integer_sparse', module_name = '', visibility = 'private') CClassDefNode.body = StatListNode(matrix_integer_sparse.pyx:55:4) StatListNode.stats[9] = DefNode(matrix_integer_sparse.pyx:216:4, name = u'_delete_row_', num_required_args = 2, reqd_kw_flags_cname = '0') File 'Nodes.py', line 360, in analyse_expressions: StatListNode (matrix_integer_sparse.pyx:217:8) File 'Nodes.py', line 2835, in analyse_expressions: SingleAssignmentNode(matrix_integer_sparse.pyx:221:41) File 'Nodes.py', line 2928, in analyse_types: SingleAssignmentNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 2281, in analyse_types: SimpleCallNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 3105, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2972, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2522, in analyse_types: GeneralCallNode (matrix_integer_sparse.pyx:221:101) Compiler crash traceback from this point on: File /usr/local/sage-devel/local/lib/python2.5/site-packages/Cython/ Compiler/ExprNodes.py, line 2532, in analyse_types if hasattr(self.function, 'entry') and not self.function.entry.as_variable: AttributeError: 'NoneType' object has no attribute 'as_variable' Error running command, failed with status 256. sage: There was an error installing modified sage library code. On Jun 2, 7:28 pm, William Stein wst...@gmail.com wrote: On Tue, Jun 2, 2009 at 7:22 PM, davidp dav...@reed.edu wrote: I tried adding a delete_row method to matrix_integer_sparse.pyx but stopped after getting the error message: Just def your method -- do not cpdef it. You can still use Cython code in a cpdef's method and it will be just as fast. Make sure that your delete row method returns a *new* matrix by the way... William + Error converting Pyrex file to C: ... add_mpz_vector_init(M._matrix[i], self._matrix[i], (Matrix_integer_sparseright)._matrix[i], mul) mpz_clear(mul) return M # added by David Perkinson cpdef ModuleElement _delete_row_(self, Py_ssize_t row_number): ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:216:10: C method '_delete_row_' not previously declared in definition part of extension type Error running command, failed with status 256. sage: There was an error installing modified sage library code. ++ I might have to actually read the Cython documentation! Dave On Jun 2, 5:43 pm, Jason Grout jason-s...@creativetrax.com wrote: William Stein wrote: On Mon, Jun 1, 2009 at 5:16 PM, davidp dav...@reed.edu wrote: Is there a fast way to create a submatrix? - sage: version() 'Sage Version 4.0.alpha0, Release Date: 2009-05-15' sage: G = graphs.GridGraph([100,100]) sage: L = G.laplacian_matrix() sage: L 1 x 1 sparse matrix over Integer Ring sage: time M = L[1:,1:] CPU times: user 24.93 s, sys: 0.04 s, total: 24.97 s Wall time: 25.27 s I am just interested in deleting a single row and column of the matrix (not necessarily the first). Thanks, There is no fast way to do that right now. One could easily add code to SAGE_ROOT/devel/sage/sage/matrix/matrix_integer_sparse.pyx that would provide blazingly fast deletion of a row, and reasonably fast deletion of a column. Of course
[sage-support] Re: fast slicing of matrix
On Tue, Jun 2, 2009 at 8:45 PM, davidp dav...@reed.edu wrote: I can't figure out how to create a new sparse matrix (see below). Sorry, Dave You can make a new matrix with the analogous parent but a different shape using the new_matrix method. sage: a = random_matrix(ZZ,3,4,sparse=True) sage: a.new_matrix(2,4) [0 0 0 0] [0 0 0 0] In your cython code you would write something like cdef Matrix_integer_sparse M = a.new_matrix(2,4) William M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) --- ... def _delete_row_(self, Py_ssize_t row_number): cdef Py_ssize_t i cdef mpz_vector* self_row, *M_row cdef Matrix_integer_sparse M M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:221:101: Compiler crash in AnalyseExpressionsTransform ModuleNode.body = StatListNode(matrix_integer_sparse.pyx:23:0) StatListNode.stats[13] = StatListNode(matrix_integer_sparse.pyx:43:5) StatListNode.stats[0] = CClassDefNode(matrix_integer_sparse.pyx:43:5, as_name = u'Matrix_integer_sparse', base_class_module = u'matrix_sparse', base_class_name = u'Matrix_sparse', class_name = u'Matrix_integer_sparse', module_name = '', visibility = 'private') CClassDefNode.body = StatListNode(matrix_integer_sparse.pyx:55:4) StatListNode.stats[9] = DefNode(matrix_integer_sparse.pyx:216:4, name = u'_delete_row_', num_required_args = 2, reqd_kw_flags_cname = '0') File 'Nodes.py', line 360, in analyse_expressions: StatListNode (matrix_integer_sparse.pyx:217:8) File 'Nodes.py', line 2835, in analyse_expressions: SingleAssignmentNode(matrix_integer_sparse.pyx:221:41) File 'Nodes.py', line 2928, in analyse_types: SingleAssignmentNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 2281, in analyse_types: SimpleCallNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 3105, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2972, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2522, in analyse_types: GeneralCallNode (matrix_integer_sparse.pyx:221:101) Compiler crash traceback from this point on: File /usr/local/sage-devel/local/lib/python2.5/site-packages/Cython/ Compiler/ExprNodes.py, line 2532, in analyse_types if hasattr(self.function, 'entry') and not self.function.entry.as_variable: AttributeError: 'NoneType' object has no attribute 'as_variable' Error running command, failed with status 256. sage: There was an error installing modified sage library code. On Jun 2, 7:28 pm, William Stein wst...@gmail.com wrote: On Tue, Jun 2, 2009 at 7:22 PM, davidp dav...@reed.edu wrote: I tried adding a delete_row method to matrix_integer_sparse.pyx but stopped after getting the error message: Just def your method -- do not cpdef it. You can still use Cython code in a cpdef's method and it will be just as fast. Make sure that your delete row method returns a *new* matrix by the way... William + Error converting Pyrex file to C: ... add_mpz_vector_init(M._matrix[i], self._matrix[i], (Matrix_integer_sparseright)._matrix[i], mul) mpz_clear(mul) return M # added by David Perkinson cpdef ModuleElement _delete_row_(self, Py_ssize_t row_number): ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:216:10: C method '_delete_row_' not previously declared in definition part of extension type Error running command, failed with status 256. sage: There was an error installing modified sage library code. ++ I might have to actually read the Cython documentation! Dave On Jun 2, 5:43 pm, Jason Grout jason-s...@creativetrax.com wrote: William Stein wrote: On Mon, Jun 1, 2009 at 5:16 PM, davidp dav...@reed.edu wrote: Is there a fast way to create a submatrix? - sage: version() 'Sage Version 4.0.alpha0, Release Date: 2009-05-15' sage: G = graphs.GridGraph([100,100]) sage: L = G.laplacian_matrix() sage: L 1 x 1 sparse matrix over Integer Ring sage: time M = L[1:,1:] CPU times: user 24.93 s, sys: 0.04 s, total: 24.97 s Wall time: 25.27 s
[sage-support] Re: fast slicing of matrix
I might be going down the wrong path, but is seems like I would want to add a copy_mpz_vector_init function to vector_integer_sparse_c.pxi that would make a copy of an mpz_vector. Is that overkill? My first idea was to use add_mpz_vector_init(sum, v, w, mul), which sets sum equal to v + mul*w, but let mul = 0. However add_mpz_vector_init returns the zero vector when mul = 0 ! Dave On Jun 2, 9:06 pm, William Stein wst...@gmail.com wrote: On Tue, Jun 2, 2009 at 8:45 PM, davidp dav...@reed.edu wrote: I can't figure out how to create a new sparse matrix (see below). Sorry, Dave You can make a new matrix with the analogous parent but a different shape using the new_matrix method. sage: a = random_matrix(ZZ,3,4,sparse=True) sage: a.new_matrix(2,4) [0 0 0 0] [0 0 0 0] In your cython code you would write something like cdef Matrix_integer_sparse M = a.new_matrix(2,4) William M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) --- ... def _delete_row_(self, Py_ssize_t row_number): cdef Py_ssize_t i cdef mpz_vector* self_row, *M_row cdef Matrix_integer_sparse M M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:221:101: Compiler crash in AnalyseExpressionsTransform ModuleNode.body = StatListNode(matrix_integer_sparse.pyx:23:0) StatListNode.stats[13] = StatListNode(matrix_integer_sparse.pyx:43:5) StatListNode.stats[0] = CClassDefNode(matrix_integer_sparse.pyx:43:5, as_name = u'Matrix_integer_sparse', base_class_module = u'matrix_sparse', base_class_name = u'Matrix_sparse', class_name = u'Matrix_integer_sparse', module_name = '', visibility = 'private') CClassDefNode.body = StatListNode(matrix_integer_sparse.pyx:55:4) StatListNode.stats[9] = DefNode(matrix_integer_sparse.pyx:216:4, name = u'_delete_row_', num_required_args = 2, reqd_kw_flags_cname = '0') File 'Nodes.py', line 360, in analyse_expressions: StatListNode (matrix_integer_sparse.pyx:217:8) File 'Nodes.py', line 2835, in analyse_expressions: SingleAssignmentNode(matrix_integer_sparse.pyx:221:41) File 'Nodes.py', line 2928, in analyse_types: SingleAssignmentNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 2281, in analyse_types: SimpleCallNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 3105, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2972, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2522, in analyse_types: GeneralCallNode (matrix_integer_sparse.pyx:221:101) Compiler crash traceback from this point on: File /usr/local/sage-devel/local/lib/python2.5/site-packages/Cython/ Compiler/ExprNodes.py, line 2532, in analyse_types if hasattr(self.function, 'entry') and not self.function.entry.as_variable: AttributeError: 'NoneType' object has no attribute 'as_variable' Error running command, failed with status 256. sage: There was an error installing modified sage library code. On Jun 2, 7:28 pm, William Stein wst...@gmail.com wrote: On Tue, Jun 2, 2009 at 7:22 PM, davidp dav...@reed.edu wrote: I tried adding a delete_row method to matrix_integer_sparse.pyx but stopped after getting the error message: Just def your method -- do not cpdef it. You can still use Cython code in a cpdef's method and it will be just as fast. Make sure that your delete row method returns a *new* matrix by the way... William + Error converting Pyrex file to C: ... add_mpz_vector_init(M._matrix[i], self._matrix[i], (Matrix_integer_sparseright)._matrix[i], mul) mpz_clear(mul) return M # added by David Perkinson cpdef ModuleElement _delete_row_(self, Py_ssize_t row_number): ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:216:10: C method '_delete_row_' not previously declared in definition part of extension type Error running command, failed with status 256. sage: There was an error installing modified sage library code. ++ I might have to actually read the Cython documentation! Dave On Jun 2, 5:43 pm, Jason Grout
[sage-support] Re: fast slicing of matrix
On Tue, Jun 2, 2009 at 10:10 PM, davidp dav...@reed.edu wrote: I might be going down the wrong path, but is seems like I would want to add a copy_mpz_vector_init function to vector_integer_sparse_c.pxi that would make a copy of an mpz_vector. Is that overkill? That sounds like a good idea to me. William My first idea was to use add_mpz_vector_init(sum, v, w, mul), which sets sum equal to v + mul*w, but let mul = 0. However add_mpz_vector_init returns the zero vector when mul = 0 ! Dave On Jun 2, 9:06 pm, William Stein wst...@gmail.com wrote: On Tue, Jun 2, 2009 at 8:45 PM, davidp dav...@reed.edu wrote: I can't figure out how to create a new sparse matrix (see below). Sorry, Dave You can make a new matrix with the analogous parent but a different shape using the new_matrix method. sage: a = random_matrix(ZZ,3,4,sparse=True) sage: a.new_matrix(2,4) [0 0 0 0] [0 0 0 0] In your cython code you would write something like cdef Matrix_integer_sparse M = a.new_matrix(2,4) William M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) --- ... def _delete_row_(self, Py_ssize_t row_number): cdef Py_ssize_t i cdef mpz_vector* self_row, *M_row cdef Matrix_integer_sparse M M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:221:101: Compiler crash in AnalyseExpressionsTransform ModuleNode.body = StatListNode(matrix_integer_sparse.pyx:23:0) StatListNode.stats[13] = StatListNode(matrix_integer_sparse.pyx:43:5) StatListNode.stats[0] = CClassDefNode(matrix_integer_sparse.pyx:43:5, as_name = u'Matrix_integer_sparse', base_class_module = u'matrix_sparse', base_class_name = u'Matrix_sparse', class_name = u'Matrix_integer_sparse', module_name = '', visibility = 'private') CClassDefNode.body = StatListNode(matrix_integer_sparse.pyx:55:4) StatListNode.stats[9] = DefNode(matrix_integer_sparse.pyx:216:4, name = u'_delete_row_', num_required_args = 2, reqd_kw_flags_cname = '0') File 'Nodes.py', line 360, in analyse_expressions: StatListNode (matrix_integer_sparse.pyx:217:8) File 'Nodes.py', line 2835, in analyse_expressions: SingleAssignmentNode(matrix_integer_sparse.pyx:221:41) File 'Nodes.py', line 2928, in analyse_types: SingleAssignmentNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 2281, in analyse_types: SimpleCallNode (matrix_integer_sparse.pyx:221:41) File 'ExprNodes.py', line 3105, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2972, in analyse_types: TupleNode (matrix_integer_sparse.pyx:221:41, is_sequence_constructor = 1) File 'ExprNodes.py', line 2522, in analyse_types: GeneralCallNode (matrix_integer_sparse.pyx:221:101) Compiler crash traceback from this point on: File /usr/local/sage-devel/local/lib/python2.5/site-packages/Cython/ Compiler/ExprNodes.py, line 2532, in analyse_types if hasattr(self.function, 'entry') and not self.function.entry.as_variable: AttributeError: 'NoneType' object has no attribute 'as_variable' Error running command, failed with status 256. sage: There was an error installing modified sage library code. On Jun 2, 7:28 pm, William Stein wst...@gmail.com wrote: On Tue, Jun 2, 2009 at 7:22 PM, davidp dav...@reed.edu wrote: I tried adding a delete_row method to matrix_integer_sparse.pyx but stopped after getting the error message: Just def your method -- do not cpdef it. You can still use Cython code in a cpdef's method and it will be just as fast. Make sure that your delete row method returns a *new* matrix by the way... William + Error converting Pyrex file to C: ... add_mpz_vector_init(M._matrix[i], self._matrix[i], (Matrix_integer_sparseright)._matrix[i], mul) mpz_clear(mul) return M # added by David Perkinson cpdef ModuleElement _delete_row_(self, Py_ssize_t row_number): ^ /usr/local/sage-devel/devel/sage-devel/sage/matrix/ matrix_integer_sparse.pyx:216:10: C method '_delete_row_' not previously declared in definition part of extension type Error running command, failed with status 256. sage: There was an error installing modified sage library code.