Maxima: compiling with cmucl, sbcl and gcl.



Hi Robert,

Thanks for constructing and running the test example.

In this regard note the following:

(1) In Maxima 5.10 and 5.12 I am loading the following lisp function (defined 
in the file lengths.lisp) which you supplied some time ago:

(let ((save-$length (symbol-function '$length)))
  (defun $length (x) 
    (if (mstringp x) 
      (- (length (string x)) 1) 
      (funcall save-$length x))))

(The function slength() does not seem to be defined in Maxima 5.10.  I could 
not trace this in the Maxima 5.12 installation.)

(2) I ran my complete representative program with  Maxima 5.12 using 
slength() in mysimprec() and the results are better (but still quite a bit 
slower than Maxima 5.10 using lengths.lisp). 

(Results are obtained using time nohup...., on amd64 (2.2GHz), suse 10.1, 64 
bit, cmucl)

mysimprec() using lengths.lisp:
Maxima 5.10: 14.7 sec
Maxima 5.12: 170.5 sec

mysimprec() using slength():
Maxima 5.12: 28.2 sec

The manner in which lengths.lisp seems to be influencing the running times is 
not clear to me.

(3) I ran your test program below with Maxima 5.12. The run times are quite 
short and might be inaccurate ??

mysimprec() using lengths.lisp: 0.59 sec.
mysimprec() using slength(): 0.67 sec.

(4) I am unable to run your test program with Maxima 5.10 as it does not have 
the function elapsed_run_time (). I could not find this function in the 
Maxima 5.12 installation.


Regards,

C. Frangos.


On Wednesday 11 July 2007 06:59, you wrote:
> Hello,
>
> After looking at the example posted recently, I still can't tell what
> is going on. With the matrix dAconndt as posted, the function
> mysimprec seems to run in a timely fashion. Maybe someone
> else can try this.
>
> I get mysimprec run times from 1.5 s (for GCL) to about 4 s
> (SBCL) to about 5 s (for Clisp). These are all using current
> CVS Maxima (i.e. 5.12 + changes) on a Linux system w/ 450 MHz cpu.
>
> I changed length(string(...)) to slength(string(...)) in mysimprec.
> It triggers an error otherwise; I don't see how it could have
> succeeded before. I also threw in calls to elapsed_run_time
> which is a recently added function (because showtime:true
> didn't show the time when I ran load("mysimprec.mac")).
>
> By the way when I run the program, it loops one more time and
> produces a different (and slightly shorter) result.
>
> I'll be interested to hear what are the run times on other systems.
>
> Robert Dodier
>
> PS. Here is my script in extenso. I ran it with load("/tmp/mysimprec.mac").
>
> $ cat /tmp/mysimprec.mac
> mysimprec(s):=block(
>           [indexlist,sx,nf,listsimpf,nsx,nmin,simpf,sxnew],
>           listsimpf:[fullratsimp,trigsimp,factor,trigreduce,
>                      dividethru],nf:length(listsimpf),sx:s,
>           nmin:slength(string(sx)),indexlist:[],
>           print ("mysimprec: initial length of string(sx) =", nmin),
>           for i1 thru nf do
>               (simpf:listsimpf[i1],sxnew:apply(simpf,[sx]),
>                nsx:slength(string(sxnew)),
>                print ("mysimprec: after applying", simpf, "length of
> string(sxnew) =", nsx),
>                if nsx < nmin
>                    then (indexlist:endcons(simpf,indexlist),
>                          sx:sxnew,nmin:nsx)),display(indexlist),
>           return(sx))$
>
> dividethru(a):=block([num,den,quo,result],
>            if not atom(a) and op(a) = "//"
>                then (num:part(a,1),den:part(a,2),
>                      quo:divide(num,den),
>                      result:quo[2]/den+quo[1]) else result:a,
>            return(result))$
>
> dAconndt : matrix([0,a*dphi*kon*cos(phi)/2],[0,a*dphi*kon*sin(phi)/2],
>                  [0,
>                   a*sin(delta3)*kon
>                    *(ddelta3*cos(delta3)*Lo1-ddelta3*sin(delta3)*Lc)
>                    /(2*(sin(delta3)*Lo1+cos(delta3)*Lc)^2)
>                    -a*ddelta3*cos(delta3)*kon
>                     /(2*(sin(delta3)*Lo1+cos(delta3)*Lc))],
>                  [0,
>                   -ddelta3*sin(delta3)*kon*Lc
>                    /(2*(sin(delta3)*Lo1+cos(delta3)*Lc))
>                    -cos(delta3)*kon*Lc
>                                *(ddelta3*cos(delta3)*Lo1
>                                 -ddelta3*sin(delta3)*Lc)
>                     /(2*(sin(delta3)*Lo1+cos(delta3)*Lc)^2)],
>                  [0,
>                   kon*(2*ddelta3*cos(delta3)*Lo1-ddelta3*sin(delta3)*Lc)
>                    /(2*(sin(delta3)*Lo1+cos(delta3)*Lc))
>                    -kon*(ddelta3*cos(delta3)*Lo1-ddelta3*sin(delta3)*Lc)
>                        *(2*sin(delta3)*Lo1+cos(delta3)*Lc)
>                     /(2*(sin(delta3)*Lo1+cos(delta3)*Lc)^2)],
>                  [0,
>                   kon*(8*ddelta3*cos(delta3)*sin(delta3)*Lo1^2
>                       -4*ddelta3*sin(delta3)^2*Lc*Lo1
>                       +4*ddelta3*cos(delta3)^2*Lc*Lo1)
>                    /(4*(sin(delta3)*Lo1+cos(delta3)*Lc)
>                       *sqrt(4*sin(delta3)^2*Lo1^2
>                              +4*cos(delta3)*sin(delta3)*Lc*Lo1+Lc^2))
>                    -kon*(ddelta3*cos(delta3)*Lo1-ddelta3*sin(delta3)*Lc)
>                        *sqrt(4*sin(delta3)^2*Lo1^2
>                               +4*cos(delta3)*sin(delta3)*Lc*Lo1+Lc^2)
>                     /(2*(sin(delta3)*Lo1+cos(delta3)*Lc)^2)],
>                  [0,
>                   -kon*Lc*(ddelta3*cos(delta3)*Lo1-ddelta3*sin(delta3)*Lc)
>                    /(2*(sin(delta3)*Lo1+cos(delta3)*Lc)^2)],[0,0],[0,0])$
>
> t0 : elapsed_run_time ()$
> dAconndt_result : mysimprec (dAconndt)$
> t1 : elapsed_run_time ()$
> print ("time to compute mysimprec = ", t1 - t0)$
>
> grind (dAconndt_result)$
>
> dAconndt_expected :
> matrix([0,a*dphi*kon*cos(phi)/2],[0,a*dphi*kon*sin(phi)/2], [0,
>                   -a*ddelta3*kon*Lc/(2*(sin(delta3)^2*Lo1^2
>                                        +2*cos(delta3)*sin(delta3)*Lc*Lo1
>                                        -sin(delta3)^2*Lc^2+Lc^2))],
>                  [0,
>                   -ddelta3*kon*Lc*Lo1/(2
>                                       *(sin(delta3)^2*Lo1^2
>                                        +2*cos(delta3)*sin(delta3)*Lc*Lo1
>                                        -sin(delta3)^2*Lc^2+Lc^2))],
>                  [0,
>                   ddelta3*kon*Lc*Lo1/(2
>                                      *(sin(delta3)^2*Lo1^2
>                                       +2*cos(delta3)*sin(delta3)*Lc*Lo1
>                                       -sin(delta3)^2*Lc^2+Lc^2))],
>                  [0,
>                   ddelta3*kon*Lc
>                          *(2*sin(delta3)*Lo1^2+cos(delta3)*Lc*Lo1
>                                               +sin(delta3)*Lc^2)
>                   
> /(2*(sin(delta3)^2*Lo1^2+2*cos(delta3)*sin(delta3)*Lc*Lo1
> -sin(delta3)^2*Lc^2+Lc^2) *sqrt(4*sin(delta3)^2*Lo1^2
>                              +4*cos(delta3)*sin(delta3)*Lc*Lo1+Lc^2))],
>                  [0,
>                   -ddelta3*kon*Lc*(cos(delta3)*Lo1-sin(delta3)*Lc)
>                   
> /(2*(sin(delta3)^2*Lo1^2+2*cos(delta3)*sin(delta3)*Lc*Lo1
> -sin(delta3)^2*Lc^2+Lc^2))],[0,0], [0,0])$
>
> print ("length of string(dAconndt_result) = ", slength (string
> (dAconndt_result)))$
> print ("length of string(dAconndt_expected) = ", slength (string
> (dAconndt_expected)))$
>
>
> Here is an example output (SBCL).
>
> (%i1) load ("/tmp/mysimprec.mac");
> mysimprec: initial length of string(sx) = 1116
> mysimprec: after applying fullratsimp length of string(sxnew) =
>                                                              986
> mysimprec: after applying trigsimp length of string(sxnew) = 788
> mysimprec: after applying factor length of string(sxnew) = 751
> mysimprec: after applying trigreduce length of string(sxnew) =
>                                                              747
> mysimprec: after applying dividethru length of string(sxnew) =
>                                                              747
>      indexlist = [fullratsimp, trigsimp, factor, trigreduce]
>
> time to compute mysimprec =  4.66
> matrix([0,a*dphi*kon*cos(phi)/2],[0,a*dphi*kon*sin(phi)/2],
>        [0,
>         a*ddelta3*kon*Lc/(cos(2*delta3)*Lo1^2
>                          -Lo1^2-2*sin(2*delta3)*Lc*Lo1
>                          -cos(2*delta3)*Lc^2-Lc^2)],
>        [0,
>         ddelta3*kon*Lc*Lo1/(cos(2*delta3)*Lo1^2
>                            -Lo1^2-2*sin(2*delta3)*Lc*Lo1
>                            -cos(2*delta3)*Lc^2-Lc^2)],
>        [0,
>         -ddelta3*kon*Lc*Lo1/(cos(2*delta3)*Lo1^2
>                             -Lo1^2-2*sin(2*delta3)*Lc*Lo1
>                             -cos(2*delta3)*Lc^2-Lc^2)],
>        [0,
>         (-2*ddelta3*sin(delta3)*kon*Lc*Lo1^2
>          -ddelta3*cos(delta3)*kon*Lc^2*Lo1
>          -ddelta3*sin(delta3)*kon*Lc^3)
>          /(((cos(2*delta3)-1)*Lo1^2-2*sin(2*delta3)*Lc*Lo1
>                                    +(-cos(2*delta3)-1)*Lc^2)
>           *sqrt(-2*cos(2*delta3)*Lo1^2+2*Lo1^2
>                                       +2*sin(2*delta3)*Lc*Lo1
>                                       +Lc^2))],
>        [0,
>         (ddelta3*cos(delta3)*kon*Lc*Lo1
>          -ddelta3*sin(delta3)*kon*Lc^2)
>          /((cos(2*delta3)-1)*Lo1^2-2*sin(2*delta3)*Lc*Lo1
>                                   +(-cos(2*delta3)-1)*Lc^2)],
>        [0,0],[0,0])$
> length of string(dAconndt_result) =  747
> length of string(dAconndt_expected) =  751
> (%o1)                  /tmp/mysimprec.mac
> (%i2) build_info();
>
> Maxima version: 5.12.0cvs
> Maxima build date: 19:57 7/9/2007
> host type: i686-pc-linux-gnu
> lisp-implementation-type: SBCL
> lisp-implementation-version: 1.0

-- 
Constantine Frangos, Pr.Eng.
Professor
Dept. of Mathematics and Statistics
University of Johannesburg
Auckland Park Kingsway Campus
P O Box 524
Auckland Park 2006
South Africa

Tel: +27-11-559-2452
Fax: +27-11-559-2832
e-mail: cfrangos at uj.ac.za , cfrangos at telkomsa.net