[sage-support] Fwd: Speeding up Python Again
On Wed, Aug 10, 2011 at 6:48 PM, Rajeev Singh rajs2...@gmail.com wrote: Hi, I was trying out the codes discussed at http://technicaldiscovery.blogspot.com/2011/07/speeding-up-python-again.html Here is a summary of my results - Computer: Desktopimsc9aravali annapurna NumPy: 7.651419 4.219105 5.576453 4.858640 Cython: 4.259419 3.477259 3.204909 2.357819 Weave: 4.302778 * 3.298551 2.40 Looped Fortran: 4.199148 3.414484 3.202963 2.315644 Vectorized Fortran: 3.118410 2.131966 1.512303 1.460251 pure fortran update1: 1.205727 1.964857 2.034688 1.336086 pure fortran update2: 0.600848 0.604649 0.573593 0.721339 imsc9, aravali and annapurna are HPC machines at my institute * for some reason Weave didn't compile on imsc9 Indeed there is about a factor of 7 to 12 difference between pure fortran with update2 (vectorized) and the numpy version. I should mention that I changed N to 150 in laplace_for.f90 Rajeev Hi, Continuing the comparison of various ways of implementing solving laplace equation, following result might interest you - Desktop imsc9 aravali annapurna Octave (0): 20.7866 *21.6179 * Vectorized Fortran (pure) (1): 0.7487 0.6501 0.7507 1.1619 Vectorized Fortran (f2py) (2): 0.7190 0.6089 0.6243 1.0312 NumPy (3): 4.1343 2.5844 2.6565 3.7445 Cython (4): 1.7273 1.9927 2.0471 1.3525 Cython with C (5): 1.7248 1.9665 2.0354 1.3367 Weave (6): 1.9818 * 2.1326 1.4003 Looped Fortran (f2py) (7): 1.6996 1.9657 2.0429 1.3354 Looped Fortran (pure) (8): 1.7189 2.0145 2.0917 1.5086 C (pure) (9): 1.2820 1.9948 2.0527 1.4259 imsc9, aravali and annapurna are HPC machines at my institute * for some reason Weave didn't compile on imsc9 * octave isn't installed on imsc9 and annapurna The difference between numpy and fortran performance seems significant. However f2py does as well as pure fortran now. The difference from earlier case is that earlier there was a division inside the loop which I have replaced by multiplication by reciprocal. This does not affect the result but makes the execution faster in all cases except pure fortran (I guess fortran compiler was already doing it). I would be happy to give all the codes if someone is interested. Should we update the performance python page at scipy with these codes? This might be of interest to people doing numerical computation using Sage. Should we put all these examples in Numerical Sage along with the above table? Rajeev -- To 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 Graph.is_chordal
Hi, The Graph.is_chordal function can be used to return a chordless cycle on non-chordal graphs, but the implementation seems to be wrong. Example (ran on the sagenb.org server): sage: g = Graph({3:[2,1,4],2:[1],4:[1],5:[2,1,4]}) sage: g.is_chordal() = False sage: _, g1 = g.is_chordal(certificate=True); g1.is_chordal() = True Currently, the function proceeds as follows: 1. run algorithm LexBFS to find a vertex ordering which would be a perfect-elimination-order (PEO) if G is chordal. 2. check if this ordering satisfies the PEO-property w.r.t. G, and if not, remember the last vertex (i) in the PEO which violates it. (assume G is not chordal) 3. let G' be the vertex induced subgraph of G corresponding to all vertices occuring after (i) in the PEO. 4. find two non-adj. vertices (j), (k) in G', which were both adj. to (i) in G. 5. find a shortest path between them in G', and return the vertex induced subgraph consisting of this path plus (i). The resulting cycle is not necessarily chordless, since the shortest path can contain another neighbour (x) of (i), resulting in the chord {x,i}. One linear-time solution is given in [1]. I think it is not hard to modify the code to use this. [1] Addendum: Simple Linear-Time Algorithms to Test Chordality of Graphs, Test Acyclicity of Hypergraphs, and Selectively Reduce Acyclic Hypergraphs. http://dx.doi.org/10.1137/0214020 Regards, Jan -- To 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] Binary array to integer
Let A=(1,1,0,0,0,1) be an binary array. How efficiently can we calculate the corresponding integer? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Binary array to integer
Treat it as a binary number: s = ''.join(str(i) for i in A) ZZ(s, base=2) On Tue, Aug 23, 2011 at 12:08 PM, Santanu Sarkar sarkar.santanu@gmail.com wrote: Let A=(1,1,0,0,0,1) be an binary array. How efficiently can we calculate the corresponding integer? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: Re: [sage-support] Binary array to integer
On Tuesday 23 August 2011, Tom Boothby wrote: Treat it as a binary number: s = ''.join(str(i) for i in A) ZZ(s, base=2) sage: Z((1,0),2) 1 sage: Z((1,1),2) 3 On Tue, Aug 23, 2011 at 12:08 PM, Santanu Sarkar sarkar.santanu@gmail.com wrote: Let A=(1,1,0,0,0,1) be an binary array. How efficiently can we calculate the corresponding integer? -- To 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 Cheers, Martin -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x8EF0DC99 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF _www: http://martinralbrecht.wordpress.com/ _jab: martinralbre...@jabber.ccc.de -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Binary array to integer
Martin Albrecht points out that my stringification is a waste: ZZ(A,2) works fine. On Tue, Aug 23, 2011 at 12:29 PM, Tom Boothby tomas.boot...@gmail.com wrote: Treat it as a binary number: s = ''.join(str(i) for i in A) ZZ(s, base=2) On Tue, Aug 23, 2011 at 12:08 PM, Santanu Sarkar sarkar.santanu@gmail.com wrote: Let A=(1,1,0,0,0,1) be an binary array. How efficiently can we calculate the corresponding integer? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Binary array to integer
Thanks. Is there more efficient than this? On 24 August 2011 00:59, Tom Boothby tomas.boot...@gmail.com wrote: Treat it as a binary number: s = ''.join(str(i) for i in A) ZZ(s, base=2) On Tue, Aug 23, 2011 at 12:08 PM, Santanu Sarkar sarkar.santanu@gmail.com wrote: Let A=(1,1,0,0,0,1) be an binary array. How efficiently can we calculate the corresponding integer? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Sage Account
I registered an account on http://www.sagenb.org/. It seems to work for a day, but then when I go back the next day I get a message that Username is not in the system. Strangely enough if I recreate the account, the worksheet that I saved the day before is still there so the account seems to remain, it's just the login. I'm using Firefox on Windows NT. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Sage Account
On Tue, Aug 23, 2011 at 1:07 PM, pblelloch paul.blell...@gmail.com wrote: I registered an account on http://www.sagenb.org/. It seems to work for a day, but then when I go back the next day I get a message that Username is not in the system. Strangely enough if I recreate the account, the worksheet that I saved the day before is still there so the account seems to remain, it's just the login. I'm using Firefox on Windows NT. I had to kill -9 the servers due to some mysterious out of memory errors on the computer, which may have resulted in exactly the sort of bug you describe above (this is because of us not using a separate database... yet!). 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 -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Sage Account
THANKS. It seems to be working now. On Aug 23, 1:30 pm, William Stein wst...@gmail.com wrote: On Tue, Aug 23, 2011 at 1:07 PM, pblelloch paul.blell...@gmail.com wrote: I registered an account onhttp://www.sagenb.org/. It seems to work for a day, but then when I go back the next day I get a message that Username is not in the system. Strangely enough if I recreate the account, the worksheet that I saved the day before is still there so the account seems to remain, it's just the login. I'm using Firefox on Windows NT. I had to kill -9 the servers due to some mysterious out of memory errors on the computer, which may have resulted in exactly the sort of bug you describe above (this is because of us not using a separate database... yet!). 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 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