Compatibility
LME is mostly compatible with the language of MATLAB(R) 4.x. It includes many features of
MATLAB 5 to 7, such as integer data types, structures, and switch and
try control structure. Other
functions are enhanced; e.g. functions which manipulate polynomials (such as
addpol and roots) also accept matrices containing
multiple polynomials. Because of these extensions, it would be a bad idea to
attempt to learn the language of MATLAB by reading this material. However, with a
background in MATLAB, you will learn LME much quicker.
Except for a number of advanced mathematic functions such as qz,
and eigs (some of them are provided in the
LAPACK extension), and a few minor differences described
in the list of functions as "Caveat", here is the list of the main
differences. Knowing them, it is very easy to write code compatible
with both Matlab and LME.
- Functions are stored in libraries, not in separate files. Except for Palm
devices which do not have a file system, libraries are files with the suffix
.lml. They contain a sequence of related functions. They are
made known to LME with the
use instruction.
use instructions define a network of dependencies which permit to
avoid name clashes. Inside libraries, functions can be public or private.
Functions can also be stored directly in SQ files (Sysquake applications)
and typed at the command prompt.
- Constants can be defined with
define.
- Inline functions are not restricted to simple
expressions; they can be created with the normal function syntax too.
- Methods (functions overloaded for objects) are recognized as such
with the syntax classname::methodname in the function definition
instead of their location in the file system.
- Looping construct
repeat/until
for loops which are executed at least once.
- Access to the fields of a structure with the dot syntax (a.b), or to the elements
of a matrix or a list with parenthesis or braces (A(i,j) or L{k}) is possible not only
with variables, but also with any expression (odeset.RelTol calls function odeset
which returns a structure, then gets its field RelTol).
- Conditional evaluation in expression with operator
? : (same behavior as in C).
- In strings, control sequences beginning with a backslash are converted during
compilation.
- if, elseif,
while, and
until
take the imaginary part of complex numbers into account for consistency with boolean
operators and functions.
- Matrices are stored row by row, which has an impact on M(:),
reshape, M(index), and the order of the indices when
they are matrices (for instance, with a=1:4, b=[1,2;3,4], a(b) ->
[1;2;3;4] in LME and [1;3;2;4] in MATLAB).
- The preferred syntax for a list of output arguments is to enclose them
in parenthesis, not in square brackets. Square brackets should be reserved for
arrays. They can also be used for output arguments, to preserve compatibility.
- eval has a single argument
(the catch part is not supported), and it cannot create a new variable; however, it can change the
value of an existing variable.
- Empty matrices always have the size 0 x 0 (i.e. sum(zeros(0,2)) =
[] instead of [0,0]).
- In addition to cell arrays, lists are cell arrays with one row.
Structures have a single element.
- rand and
randn
have (currently) a 64-bit seed, and consequently a lower quality.
- Sparse matrices are not supported.
- LME is much faster than MATLAB for loops with scalar operations (e.g. two orders
of magnitude faster than Matlab 5 for finding the 669 prime numbers smaller than 5000 with the
(admittedly inefficient) code
p = [];
for i = 2:5000
for j = 2:i
if j*j > i
p(end+1) = i;
break;
end
if mod(i,j) == 0
break;
end
end
end
on a PowerPC G3 with 1 MB of L2 cache; Matlab 6.5 has improved a lot, but still takes about 150%
more time than LME). LME is slower for some operations on large matrices.
Copyright 1998-2007, Calerga.
All rights reserved.