Compatibility
LME is mostly compatible with the language of MATLAB(R) 4.x. Many features of
MATLAB 5.x are included, such as 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 qr,
null, and logm (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.
- 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.
- Empty matrices always have the size 0 x 0 (i.e. sum(zeros(0,2)) =
[] instead of [0,0]).
- if, elseif and while
take the imaginary part of complex numbers into account for consistency with boolean
operators and functions.
- rand and randn
have (currently) a 64-bit seed, and consequently a relatively poor quality.
- eval has only one argument (the catch part is
not supported), and it cannot create a new variable; however, it can change the
value of an existing variable.
- Global variables are not supported.
- 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).
- Sparse matrices are not supported.
- Cell arrays are replaced with lists, which are restricted to one dimension.
Structures are special kinds of lists where elements have tags.
- Methods (functions overloaded for objects) are recognized as such
by the syntax classname::methodname in the function definition
instead of their location in the file system.
- Conditional evaluation in expression with operators &&, || and ? : (same
behavior as in C).
- In strings, control sequences beginning with a backslash are converted during
compilation.
- LME is much faster than MATLAB for loops with scalar operations (e.g. two orders
of magnitude faster 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), and slightly slower for some matricial
operations.
Copyright 1998-2001, Calerga.
All rights reserved.