The Complete SPRLIB & ANNLIB

matrix

- a Numerical Recipes in C datatype

SYNOPSIS

int **imatrix (min_row, max_row, min_col, max_col)

double **matrix (min_row, max_row, min_col, max_col)

void *free_imatrix (im, min, max)

void free_matrix (m, min, max)

ARGUMENTS

int min_row The minimum row index.
int max_row The maximum row index.
int min_col The minimum column index.
int max_col The maximum column index.
int **im A matrix of integers.
double **m A matrix of doubles.

DESCRIPTION

In SPRANNLIB, the datatype used for matrices (and vectors) is the same as the type used in the Numerical Recipes in C functions. The only difference with a normal C array is that the first element is thought to have index 1; i.e., to fill a matrix with m by n units, the code is something like:
int *v, i, j;

v = matrix (1, m, n);

for (i = 1; i <= n; i++)
{
  for (j = 1; j <= m; j++);
  {
    v[j][i] = j + i*m;
  }
}

The imatrix function can be used to allocate an integer matrix, matrix to allocate a matrix of doubles. The free_... function speak for themselves.

SEE ALSO

All the Numerical Recipe functions are described in, "Numerical Recipes in C, the Art of Scientific Computing", Second Edition, 1992, Cambridge University Press. vector

This document was generated using api2html on Thu Mar 5 09:00:00 MET DST 1998