
240 Introduction to Computational Modeling
18.2.3 Matrix Manipulation in C and the GSL
Matrices are created and manipulated in C by calling the various library function
in the GSL. Before using a matrix, it needs to be created. Function gsl matrix alloc
creates a matrix of the specified length m rows and n columns, and returns a pointer
to the matrix. Matrices are stored in row-major order, the elements of each row form
a contiguous block in memory. This is the standard C-language ordering of two-
dimensional arrays.
When a matrix is no longer needed in the program, it can be destroyed by call-
ing the GSL function gsl matrix free. The first of the following ...