Maxima Lapack is very slow: 7 seconds versus 0.002 seconds in Julia.



Hello:

?Thanks for the information about cffi, and for your work in matlisp. 
?
?There are some projects to improve the? port of? sbcl to windows. Since gcl lacks ffi, sbcl seems a good candidate once the port is mature.? (good speed and cffi).

? Perhaps the efforts in linear algebra of Rosseti, Tamas, Raymond, Liliam (gsl), Luis Oliveira. (cffi) and others could be ported to maxima or some interface via cffi between Julia and maxima could be very interesting.? There also some Lispers that use Lisp and R (for example C. Rhodes) .? Improving the numeric capabilities of maxima could appeal to more people and communities. 

?Today ECL develoopers announce improving? multithreading in ECL (see planet.lisp)

?My wish is that maxima becomes both in Symbolics and Numeric capabilities,

also there is ceres solver (google project), maxima also has a least square solver by Robert. Perhaps? some of those advances could be ported to maxima? 

(ceres is in C++ so problem with cffi, Julia is also thinking about this).

Best


?Recently other people are trying to link Julia with gnuplot, (like Mario Riotorto work in the draw packages), also perhaps some work in solving ODE and plotting like 
plotvectorfield are things that could be improved numeracally. 



?
?

Raymond said:

What kind of machine did you run this on?? On my machine, this took
    .04 sec (using cmucl).


    In any case, this could be faster but it is not because lapack is a
    (machine) translation from the original Fortran to Lisp.? Maxima
    does not have an ffi so this is the only reasonably simple and
    portable approach available. [1]


    If all you care about is computing a huge number of
    eigenvalues/vectors, then maxima is the wrong tool.? Use a different
    tool.


    Ray


    [1] Matlisp has recently been updated to use cffi, suddenly making
    matlisp basically available on any lisp supported by cffi, which
    includes all lisps supported by maxima, except gcl.? But based on my
    experience with building lapack in matlisp, this is not that easy to
    do because there are many fortran compilers out there and that all
    do different things which the ffi needs to take into account. While
    adding support for cffi to maxima is straighforward making it useful
    with the existing code that we have is not as easy, but it's not
    rocket science either.


--- El s?b, 5/5/12, Manuel Pedrinero rossetil <pdx7l1 at yahoo.es> escribi?:

De: Manuel Pedrinero rossetil <pdx7l1 at yahoo.es>
Asunto: Maxima Lapack is very slow: 7 seconds versus 0.002 seconds in Julia.
Para: maxima at math.utexas.edu
Fecha: s?bado, 5 de mayo, 2012 16:36

Recently Raimond Toy asked about what capabilities are lacking in maxima, numeric computations in linear algebra seems to be very slow 
?
?This is an example in gcl using lapack

(%i1) load(lapack);
/share/lapack/binary-gcl/dgemm.o
(%o1)????????? /usr/share/maxima/5.24.0/share/lapack/lapack.mac
(%i2) h[i,j]:= 1/(i+j);
?????????????????????????????????????????? 1
(%o2)?????????????????????????? h???? :=
 -----
???????????????????????????????? i, j??? i + j
(%i3) m : genmatrix(h,50,50)$

(%i4) showtime : true;
Evaluation took 0.0000 seconds (0.0000 elapsed)
(%o4)??????????????????????????????? true
(%i5) [one,two,three] : dgeev(m)$
Evaluation took 7.3200 seconds (7.4000 elapsed)

In Julia computing eigenvalues of a 50x50 matrix whose entries are random numbers from a normal distribution is about 0.007 seconds.

julia> @time v1,others = eig(randn(50,50));
elapsed time: 0.0070650577545166016 seconds



?The same computation takes 0.002 seconds in Julia. (first make some
 computation
with eig so that it loads the function in memory).

filewrite("path/file",m);

to convert m to Julia format one can use system and sed
replacing "," => "space" ? "]" by ";" and deleting "["? 
the final step is to put parenthesis around the numbers (that are separated by space inside rows and ";" separate rows.

Julia:

@time one,others = eig(m)
?

Maxima version: 5.24.0
Maxima build date: 9:11 2/29/2012
Host type: x86_64-unknown-linux-gnu
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.7

? I know that some efforts like matlisp are trying to improve this situation.