DADiSP® SPL vs. MATLAB®
A brief comparison for those of you who aren't afraid to
explore alternatives...
If you have found this web page, you
might be familiar with the
MATLAB (1) software from the MathWorks
or one of the free clones. While the rest of this website is
devoted to
DSP Development Corporation
and its flagship
DADiSP product, this
particular page focuses on the similarities and differences between
MATLAB and our alternative, DADiSP.
Emerging Academic Powerhouse
The introduction of the
Student Edition of
DADiSP (a free download for all academic users, by the way) has
caused quite a stir at universities and academic institutions
around the world. Over the last few years, DSP Development has
licensed DADiSP formally to dozens of top universities and training
institutes, but the Student Edition program has put DADiSP into the
hands of tens of thousands of students and academics to use for research or
teaching.
Check this
brief description of what DADiSP
is and what it can do for you. You can also watch our introductory
Flash Demo
and
Executive Summary for a quick overview
of DADiSP and the concept of an engineering spreadsheet.
Technical Computing Tools
For MATLAB users, one of the more interesting features of DADiSP is
a comprehensive data series processing language called
SPL.
Many students and instructors who are familiar with MATLAB and
similar products have asked us what makes SPL different. Here's
the scoop...
Although DADiSP and MATLAB are both software tools designed for a
technical audience, the products differ considerably in how they
meet the demanding data analysis needs of scientists and
engineers.
Matrix Based M Files
MATLAB is a matrix-based programming language. In fact, MATLAB
stands for "MATrix LABoratory" and was originally developed to
provide easier programming access to specialized matrix processing
routines. MATLAB consists primarily of a command interpreter and a
variety of sub-routines that reside in ASCII files known as M
files. Typically, the MATLAB user types out expressions or writes
small M files to analyze data and generate graphics.
Engineering Spreadsheet
DADiSP, on the other hand, is a full-featured data analysis and
visualization environment designed around a more generalized data
construct called a
data series. A DADiSP series can
represent anything -- from a time domain radar signal to a medical
image -- and includes important attributes about the data. The
product's highly graphical user interface features
interrelated "live" graphical windows, manipulated by simple
pull-down menus, dialog boxes and point-and-click operation.
Graphs are automatic and dynamic. By working in this powerful and
familiar environment, the DADiSP user avoids the many perils of
programming.
DADiSP - Language Included
In short, MATLAB is essentially an interpreted programming
environment, somewhat analogous to Visual Basic with technical data
analysis capability. DADiSP is more like a spreadsheet, a
non-programming core methodology that includes a programming
language, similar to the combination of Excel and Visual Basic.
SPL
The ultimate design goal of DADiSP is to allow the user to focus on
the problem at hand and not the code in the debugger. However, for
those who wish to customize DADiSP or add special processing
capability, DADiSP provides a robust series processing language
called SPL. SPL is based on the very popular C/C++ language and
sports a C/C++ like syntax.
"For anyone with
some experience in C, C++, C# or Java, SPL routines have a clean
and familiar style about them. Because MATLAB was originally
developed in FORTRAN and later rewritten in C, some feel MATLAB programs
exhibit a less consistent, 'mixed breed' feel by combining
FORTRAN and C coding styles" says Randy Race, DSP's Chief Technical Officer
and designer of SPL.
Like many contemporary programming languages, SPL is implemented as
an interpreted language where each statement is incrementally
compiled once to low level bytecode. The bytecode is then executed on
a virtual machine. This approach often results in quicker turn
around time by eliminating the tedious
compile-link-test
cycle required by traditional compiled languages. However, because
many of the core numeric processing algorithms are implemented as built-in C/C++
routines, SPL functions can execute at speeds approaching purely compiled
languages.
A Comparison
Although MATLAB and SPL have there own approach and advantages, it is
fairly easy to convert routines from one to the other. For
example, here are two routines that perform numerical quadrature
based on the trapezoidal rule -- one written in MATLAB and the
other in DADiSP SPL:
Yet Different
Both SPL and MATLAB are free-form and the examples above show the
typical formatting styles of each language. The comment block
after the function declaration in a M file is displayed when the
user types
help detrend
. SPL displays the free-form
text between the
#if @HELP_DETREND
and
#endif
block
. This block can be placed anywhere within the SPL
file.
detrend
removes the least squares line from a series
or table. The function also has an optional argument to specify
that only the mean value should be removed. This optional argument
is detected in MATLAB by counting the number of input arguments
with
nargin
. SPL uses the C/C++ like
argc
to indicate the number of input
parameters.
Matrix vs Series Based Solution
Because MATLAB is matrix-based and series are stored in row form,
row vectors must be transposed into columns. In fact, operators
such as * and / actually perform matrix multiplication and
inversion. Because SPL is
series-based, row transpositions
are not required and mathematical operators work in the way you
would expect. SPL includes the explicit operators
*^ and
\^ to multiply and solve matrices.
If the optional argument is set to 1, the mean value of each column
is removed by forming a table of the mean values and subtracting it
from the data. MATLAB forms the table by creating a matrix of all
ones and performing a matrix multiply. SPL simply subtracts the
mean value of each column from the corresponding column.
The linear trend is removed by forming a least squares line.
Again, MATLAB resorts to matrix operations where SPL uses the
linreg function.
Although both routines accomplish the same goal, MATLAB approaches
the problem from a matrix point of view, where SPL offers a
series-based solution. Each approach has its advantages, but for
problems that involve single or multi-column data series, SPL can
result in clearer, more direct code.
M File Memory Limitations
All arrays in MATLAB are limited by the amount of physical memory.
Because MATLAB relies on the operating system's general purpose
implementation of virtual memory, if an array size exceeds the
available memory, calculations produce errors or grind to a halt if
a memory page is swapped to disk.
Virtual Series Management
SPL employs a optimized method called virtual series management.
Each series and each column of an array is limited only by
available disk space. If the series size exceeds available memory,
SPL automatically uses hard disk storage. Because virtual series
management is optimized for series processing, this method is much
faster and more robust than general purpose operating system page
swapping. The size of a series kept in memory is adjustable,
allowing users to optimize processing based on system memory. With
SPL, the memory footprint of large data series is small enough to
bypass slow operating system page swapping, but computation is fast
due to virtual data handling designed specifically for series
processing. Thus, SPL is ideally suited for manipulating any
number of very large data series.
More M File Issues
Because of the mixed heritage of the MATLAB language, several potentially
confusing ambiguities persist.
For example, the MATLAB * operator actually performs a matrix
multiply. A common expression like:
would perform matrix multiplication if a and b are arrays or
a standard multiply if either variable is a scalar. A careful
reading of the code is required to establish the specific
meaning of this simple expression.
SPL preserves the standard meaning of
*
and introduces the
*^
operator for explicit matrix multiplication. Thus,
is always a standard multiplication whereas
is always a matrix multiplication. The intent of either expression
is immediately obvious.
Further, the MATLAB expression:
could refer to element
x of array
f or function
f called with argument
x. Again, a careful reading of the
code is required to disambiguate the two possible meanings.
In SPL as well as C/C++,
is always a function call and
is always an array reference. The intent is immediately clear and consistent
with the C/C++ family of modern programming languages.
C/C++ Style Syntax
In fact, SPL borrows so much of its syntax from C/C++ that many
C/C++ programs can be loaded directly as SPL routines! For example,
SPL supports C/C++ operators such as ++, --, +=, -=, /=, *= %=, ==,
!=, >>, <<, >>=, <<=, ||, && and scalar
pointers. Looping and iteration constructs such as
for,
while, do while, if, else, switch, goto
work exactly as they
do in C/C++. Array construction also mimics the C/C++ syntax. SPL
also includes a full C/C++ like preprocessor:
#if, #ifdef,
#elif, #endif, #include, #define, #undef
.
Useful Constructs
But SPL also borrows some good ideas from MATLAB. Matrix operators
such as matrix multiply
*^,
\^ to multiply and solve matrices
and transpose
' are
supported. Powerful array addressing constructs such range
specifiers
1..10, array assignments
A[1..10] = 5,
multiple return
values
(a, b) = f(x)
, automatic loading of SPL routines and
built-in help syntax are provided.
A simple table gives
a brief summary of the
operators and syntax supported by MATLAB, C/C++ and
SPL.
Execute M Files Directly in DADiSP
The
MATLINK Module, included with DADiSP, provides a
simple interface for executing MATLAB code directly from
DADiSP. Any MATLAB function or script can be processed just as if
it were a native DADiSP function.
No need to rewrite code or manipulate temporary data files.
MATLINK combines the functionality of existing MATLAB programs with
the ease and power of the DADiSP Worksheet environment.
Series, arrays, scalars and strings are exchanged seamlessly.
Series and array results returned from MATLAB plot automatically in
DADiSP. MATLAB code embedded into a Worksheet Window formula is
hot linked and automatically re-executes when the Window updates.
Convert M Files to SPL
For those who desire a native SPL implementation of an M file, The
MathWorks offers a MATLAB-to-C conversion utility. Because SPL
is so similar to C/C++, you can also use this utility as a great
shortcut for converting M files into SPL functions for use in
DADiSP.
MAT File Support
Finally, if your data is saved in MATLAB's binary MAT file format, the
DADiSP/MAT File Module reads and loads all
MAT Files of Version 4 and higher.
(1) MATLAB is a registered trademark of The MathWorks, Inc.