Information Technology Reference
In-Depth Information
in numerical libraries. Algorithms to be implemented in Maple, Matlab, and Python
should utilize the languages' high-performance built-in functionality to as high a
degree as possible. Hence, programmers using these languages need to be familiar
with the libraries, otherwise they will both reinvent the wheel (by re-implementing
basic algorithms) and decrease performance. While loops play an important role
in compiled languages, loops are very slow in interpreted languages and should
hence be avoided. Instead, one needs to express the algorithms in terms of built-
in basic vector operations, where all loops are solely executed in libraries written
in compiled languages. The process of rewriting an algorithm in terms of basic
vector operations is usually referred to as vectorization and constitutes the subject
of Sect. 6.3.7 .
We should mention that Matlab has a just-in-time compiler that can automatically
turn loops over arrays into as efficient code as vectorization can offer. However,
the just-in-time compilation strategy works only in certain situations, and in par-
ticular not if there are function calls inside the loops, as we have in the numerical
integration algorithms.
6.2.4
Support for User-Defined Objects
Fortran 77 has only a few different types of variables: integer, real, array, complex,
and character string. One can build any code with these types of variables, but as
soon as the complexity of the program grows, one may want to group a collection
of primitive variables into a new, more advanced variable type. Many languages
therefore allow the programmer to define new variable types. In C, one can define a
struct to be a collection of basic C variables and previously defined struct s. This
construction acts as a method for creating user-defined variable types.
When people start to create their own types with struct s and similar construc-
tions in other languages, it becomes apparent that a user-defined variable should not
only store information, but also be able to manipulate and process that information.
This results in more intelligent variable types, but requires the struct to contain
functions as well as data. C CC is an extension of C that offers user-defined vari-
able types containing both functions and data. Such a user-defined type is normally
referred to as a class . Fortran 90 and Fortran 95 are extensions of Fortran 77 (and
earlier versions known as Fortran IV and Fortran 66) where the programmer can
collect data and functions in modules . Modules can do many of the same things as
classes, but classes in C CC are much more advanced than the modules in Fortran
90/95. The Fortran 2000 initiative aims at equipping Fortran with modules having
the functionality of classes that programmers expect today.
Java supports classes, but the flexibility of the classes is less than in C CC .On
the other hand, Java has functionality that makes the language much more user-
friendly and easier to program with than C CC . Python has classes that are more
advanced than those in C CC . Matlab originally had only matrices and strings, but
recent extensions to Matlab allow the definition of classes. Maple has many variable
Search WWH ::




Custom Search