Matlab MEX

Matlab is a great programming language and environment because of its ease of use, great visualization, and rapid prototyping abilities. Matlab has a feature called MEX, Matlab Executables.   See:  Matlab MEX Introduction MEX files allow Matlab scripts to call user-supplied functions written in C/C++ and… Read more

MPI

Introduction Message Passing Interface (MPI) is a portable library of subprograms which can be used to facilitate parallel computing. The MPI subprograms can be called from C and Fortran programs. Parallel Computing Parallel computing enables large scale numerical problems to be solved in a timely… Read more

Matrix Inversion in LAPACK

Here is a Fortran program which performs matrix inversion using the LU decomposition method:  INVERSE_MATRIX.F It is compiled via: gfortran -o INVERSE_MATRIX INVERSE_MATRIX.F -llapack It compiles & runs under both Ubuntu & Cygwin. See also: http://www.nag.com/numeric/fl/nagdoc_fl23/examples/source/f07ajfe.f90 * * * The INVERSE_MATRIX.F program uses the subroutines:… Read more

C/C++ Tips

Passing 1D array as function argument Example… // prototype function declaration void calc(double *x); double a[1000]; int main() { // call calc calc(a); } void calc(double *x) { // do some calculations } *************************************************************** Dynamic Memory Allocation for 1D Array int* a = NULL;     //… Read more

Mixed C++ Fortran Programming

This is another matrix multiplication project using the BLAS function dgemm. It is complied and run in an Ubuntu system. The set consists of two programs:  (right mouse click.  save target or link as) matrix_mult_cf.cpp fort_matmul_main.f The set calculates: C = A*B The C++ program… Read more

MinGW Windows Installation

MinGW stands for Minimalist GNU for Windows. MinGW is a native software port of the GNU Compiler Collection (GCC) and GNU Binutils for use in the development of native Microsoft Windows applications. MinGW can be downloaded with Code::Blocks. Or it can be downloaded via  soureforge.… Read more

C/C++ Read 2D Array

The following program reads a 2D array of numbers.  The array may have an arbitrary or unknown number of rows and columns up to a certain cell limit. The program counts the number of columns and rows as it reads the data. The program souce… Read more

Lapack in Ubunutu

Blas and Lapack may be installed on an Ubuntu system using the instructions at: Generalized Eigenvalue Problem * * * C++ programs that use Lapack can be compiled in Terminal or Bash shell mode via: g++ file_in -o file_out -lgfortran -llapack -lm where file_in is… Read more