On Dec 3, 2007 12:30 PM, Stephen Forrest <[EMAIL PROTECTED]> wrote: > > On Dec 3, 2007 11:16 AM, William Stein <[EMAIL PROTECTED]> wrote: > [snip] > > I want to time maple, but I just spent 10 minutes and couldn't > > even figure out how to raise a matrix to a power! > > I couldn't get the Sage interface to Maple to work properly with > matrices. When I tried the following in Sage, the generated Maple > input was not valid Maple syntax: > m = matrix(QQ,3,range(9)); m[0,0] =20; n=m^(-1) > b = maple(n) >
That won't work because nobody ever implement _maple_init_ as a method for Sage matrices. > In any case, there's nothing syntactically tricky about matrix > exponentation in Maple: just use ^. There was for me -- see below. But many many thanks for the clarification. > This is how you'd do it in Maple: > > > m := > > Matrix([[1/20,-1/10,1/20],[-1/10,-37/15,47/30],[1/20,67/30,-77/60]],shape=symmetric): The input matrix actually is *not* symmetric. > > a := time(): > > n := m^20000: > > time()-a; > 11.170 > > It's possible the powering could be further sped up with additional > options, and the time above can't be directly compared as the above is > actual time (as opposed to cpu time). But as it is, it appears that > Maple is not competitive with Sage here. Thanks for the clarification! According to the maple help, "The time command returns the total CPU time used since the start of the Maple session." Anyway, here is the same computation on sage.math using maple correctly and done from in Sage. It takes about 1.6 seconds, which seems reasonable -- slower than Sage by a factor of 10, but not so long. sage: m = maple('Matrix([[1/20,-1/10,1/20],[-1/10,-37/15,47/30],[1/20,67/30,-77/60]])')sage: t = maple.cputime() sage: time a=m^20000 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s Wall time: 1.70 sage: maple.cputime(t) 1.5880000000000001 sage: time a = n^20000 CPU times: user 0.16 s, sys: 0.00 s, total: 0.16 s Wall time: 0.16 Here's what I tried in Maple (see below). I tried lowercase "matrix" since, that's what I found when googling for how to create a matrix in Maple: > a := matrix([[1,2],[3,4]]); [1 2] a := [ ] [3 4] > a^2; 2 a WTF? But you're writing, using upper case works: > a := Matrix([[1,2],[3,4]]); [1 2] a := [ ] [3 4] > a^2; [ 7 10] [ ] [15 22] I guess that surprises me. Anyway many many thanks for contributing your Maple (or maple?) expertise on this list, which I greatly appreciate. -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---