Math Libraries

  • #1

Main Question or Discussion Point

I used MATLAB a lot in school but it is very expensive and uses, a lot of resources and it isn't installed on most computers. MATLAB was originally built upon the math libraries:

The MATLAB libraries were MATLAB later upgraded to LAPAC

I believe the above libraries are available in both FORTRAN 90 and fortran 77. I swear I've looked at some FORTRAN90 which I swear has matrix operation syntax that has a very simmilar syntax to MATLAB.

As I understand LAPAC can run very fast in certain systems:

LAPACK, in contrast, depends upon the Basic Linear Algebra Subprograms (BLAS) in order to effectively exploit the caches on modern cache-based architectures, and thus can run orders of magnitude faster than LINPACK on such machines, given a well-tuned BLAS implementation. LAPACK has also been extended to run on distributed-memory systems in later packages such as ScaLAPACK and PLAPACK.

LAPAC has several versions:
* [Broken] for C (especially useful if there is no Fortran Compiler available, as it is already preprocessed with f2c)
* LAPACK++ for C++
* [Broken] for Java
* [Broken] for Haskell
* [Broken] for OCaml
* Boost uBLAS numerics bindings ( [Broken]) for C++.

If your are not running a system which takes advantages of these optimizations then I believe that their are several advantages to these alternative LAPAC alternatives. The first is that Microsoft products tend to be built from C and C++ libraries. It is possible to build a DLL from FORTRAN source could but it is less common. Therefor tools will be harder to get to integrate FORTRAN with C. Additionally there are some internal differences that must be considered when interfacing C with FORTRAN

One difference between C and Fortran lies in the way matrices are stored in memory, so that we have to transpose our matrices before we can pass them to a Fortran routine.
Another difference is the way arguments are passed to a subroutine in C and Fortran. In Fortran the argument is passed to the routine and the routine can read and change this value. This mechanism is called call by reference. In C a copy of the value of the argument is passed to the routine and not the argument itself, the subroutine can't change the value of the argument. This mechanism is called call by value. To use call by reference in C, we have to pass pointers to variables instead of the variables themself to the routine.

The C implementation of LAPAC should be useful for anyone who does low level microprocessor stuff since C is low level and is the most common language available for microprocessors. The C implementation was created by using the f2c language translator. However, for low level stuff a C version of LINPAC may be preferable to a C version of LAPAC.

LINPACK has officially been superseded by the LAPACK library. The LAPACK library uses more modern algorithms and code structure. However, the LAPACK library can be extraordinarily complex; what is done in a single LINPACK routine may correspond to 10 or 20 utility routines in LAPACK. This is fine if you treat LAPACK as a black box. But if you wish to learn how the algorithm works, or to adapt it, or to convert the code to another language, this is a real drawback. This is one reason I still keep a copy of LINPACK around. [Broken]

Not being in school I don't do any microprocessor programing. I tend to do most programing in Microsoft office application. Specifically I now write most code as macros for excel and Access. I do this much more frequently then I use MATLAB.

Macro's for Microsoft office applications are writen in visual basic. The reason I use visual basic more then MATLAB is most people have Microsoft Office while most people do not Have MATLAB. Even large engineering companies may be surprisingly limited on what software they have available.

Now none of the above libraries I mentioned contain visual basic versions of the library. However, there is a JAVA version of the libraries. JAVA is nice because it is multi platform and generally not considered a security risk as it can be run in a sandbox. Or at least it is considered less of a security risk then compiled files (e.g. .exe .dll)

Thus one clear alternative is to try and call JAVA from visual basic. The other is to convert the JAVA versions of the libraries to microsofts alternative to JAVA (AKA C#). Microsoft has the following tool available to convert JAVA to C#.

Both C# and java are multiplatform but I suspect that C# is better integrated with Microsoft products. It is not as restrictive as JAVA. For instance pointers are allowed. Additional A C# compiler comes with every version of windows from windows XP and up.

Given the availability of C# compiler and that it is well integrated with Microsoft products I'm learning towards converting the JAVA version of LAPAC to C# and using a C# version of the library for when I want to use math functionality that is beyond what is available in excel.

The JAVA version of the library is available here:

And here is a language comparison between JAVA and C#:
Last edited by a moderator:

Answers and Replies

Related Threads on Math Libraries

  • Last Post
  • Last Post