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:
LINPAC and EISPACK,

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:
* http://en.wikipedia.org/w/index.php?title=Clapack&action=edit&redlink=1 [Broken] for C (especially useful if there is no Fortran Compiler available, as it is already preprocessed with f2c)
* LAPACK++ for C++
* http://en.wikipedia.org/w/index.php?title=Jlapack&action=edit&redlink=1 [Broken] for Java
* http://en.wikipedia.org/w/index.php?title=HBlas&action=edit&redlink=1 [Broken] for Haskell
* http://www.ocaml.info/home/ocaml_sources.html#LACAML [Broken] for OCaml
* Boost uBLAS numerics bindings (http://svn.boost.org/svn/boost/sandbox/boost/numeric/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.
http://www.physics.oregonstate.edu/~rubin/nacphy/lapack/cprogp.html

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.
http://people.sc.fsu.edu/~burkardt/f_src/lapack/lapack.html [Broken]
http://people.sc.fsu.edu/~burkardt/f_src/linpack/linpack.html
http://people.sc.fsu.edu/~burkardt/m_src/linpack/linpack.html
http://people.sc.fsu.edu/~burkardt/f_src/linpack/linpack.html

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#.
http://www.microsoft.com/downloads/...9b4f-904b0a973174&displaylang=en#Instructions
http://www.developer.com/net/csharp/article.php/2235411

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:
http://www.netlib.org/java/f2j/

And here is a language comparison between JAVA and C#:
http://www.javacamp.org/javavscsharp/
 
Last edited by a moderator:

Answers and Replies

Related Threads on Math Libraries

Replies
6
Views
1K
  • Last Post
Replies
7
Views
2K
  • Last Post
Replies
3
Views
2K
Replies
4
Views
2K
Top