lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I am pleased at how complete your port is.  You've overloaded arithmetic
operators and have even included support for N-d arrays. It is almost as
easy to use as Matlab!  However there is still a performance issue which
surprised me.  On my windows xp box  (amd x2 3800) I ran a simple benchmark
that inverts some matrices and performs some other calculations.  I then ran
the equivalent code in Matlab 6.5.

The results are
NumLua 24 sec.s
Matlab. 15.2 sec.s

here's the code for each


u0 = os.time()
x = matrix(100,100)
I = matrix.eye(100)
for i,j in x:entries() do
		x[i][j] = math.random()
for q=1,1000 do
	x = I + matrix.inv(x)
u1 = os.time()

tic ;
x = rand(100,100) ;
I = eye(100) ;
for q=1:1000
    x = I + inv(x) ;

Now since I used your binary distribution I'm not using tuned BLAS
libraries, but then again neither is Matlab.  (I think 6.5 uses Atlas but
I'm not sure).  Your code does a lot of type checking, but then again so
does Matlabs.  I would have expected Matlab to incur more overhead and
therefore the LUA code to be more competitive.  

One of the big attractions for using LUA for numerical applications is it's
easy interface to C, (with the help of maybe tolua or SWIG).  With C doing
the heavy number crunching, one can get a factor of 5 or 6 improvment in
speed over Matlab.  (Contrary to the claims of some speed is still of huge
importance for numerical applications.  I have Matlab scripts that take 2
days to run, even on my overclocked dual core athlon)

LUA is great for configuration and high level logic.  I have used it this
way before with great success.  The problem now with the NumLua approach, 
with all the syntactic sugar, is that an overhead penalty is being paid that
defeats the purpose of using LUA.  If we want free numerical software, 
SciPy is a lot more mature and also has a nice C interface.  

View this message in context:
Sent from the Lua - General forum at