User`s manual

3 Creating Fortran MEX-Files
3-28
For an input 2-by-3 matrix
x = [1 2 3; 4 5 6];
typing
y = dblmat(x)
yields
y =
2 4 6
8 10 12
Note The dblmat.f example, as well as fulltosparse.f and sincall.f, are
split into two parts, the gateway and the computational subroutine, because of
restrictions in some compilers.
Handling Sparse Matrices
The MATLAB API provides a set of functions that allow you to create and
manipulate sparse matrices from within your MEX-files. There are special
parameters associated with sparse matrices, namely
ir, jc, and nzmax. For
information on how to use these parameters and how MATLAB stores sparse
matrices in general, refer to the section on “The MATLAB Array” on page 1-6.
Note Sparse array indexing is zero-based, not one-based.
This example illustrates how to populate a sparse matrix.
C $Revision: 1.6 $
C===============================================================
C
C fulltosparse.f
C Example for illustrating how to populate a sparse matrix.
C For the purpose of this example, you must pass in a
C non-sparse 2-dimensional argument of type real double.