Seppo Mustonen : Programming Survo in C

Functions in library SURVO.LIB

matrix_load
Summary

int matrix_load(matr,A,rdim,cdim,rlab,clab,lr,lc,type,expr)
char *matr;   /* name of matrix file */
double **A;   /* pointer to matrix space */
int *rdim;    /* pointer to number of rows */
int *cdim;    /* pointer to number of columns */
char **rlab;  /* pointer to row labels space */
char **clab;  /* pointer to column labels space */
int *lr;      /* pointer to length of row label */
int *lc;      /* pointer to length of column label */
int *type;    /* pointer to type of matrix */
char *expr;   /* matrix expression (internal name) */
Description

The matrix_load function reads a matrix saved in a matrix file. It also allocates space (by malloc) for the matrix elements (of type double) and for the row and column labels. matrix_load does not allocate space for scalar parameters or for the matrix expression.

The elements of the matrix are read by columns in a one-dimensional double array pointed by *A and having the size (*rdim)*(*cdim)*sizeof(double). Each row label has the length *lr and they are read in a one-dimensional character array pointed by *rlab and having the size (*lr)*(*rdim). If rlab is NULL, no space is allocated and no row labels are read. Each column label has length of *lc bytes and they are read in an one-dimensional character array pointed by *clab and having the size (*lc)*(*cdim). If clab is NULL, no space is allocated and no column labels are read. *type will be the type of the matrix with possible values of

*type=20
diagonal matrix,
*type=10
symmetric matrix,
*type=0
general matrix
and *expr will be the internal name of the matrix (as a matrix expression) of length 128 characters at most. Space is not allocated to *expr in matrix_load; it is the responsibility of the calling function to have 129 bytes at least for *expr. Similarly space must be allocated for rdim,cdim,lr,lc and type before the matrix_load call.
Return Value

matrix_load returns -1 if matrix matr is not found or if space cannot be allocated for it. Upon successful completion of the function 1 is returned.

See Also

matrix_save, matrix_print, library SURVOMAT.LIB

Example

double *A;
int m,n;
char *rlab,*clab;
int lr,lc;
int type;
char expr[129];

matrix_load("MEANS",&A,&m,&n,&rlab,&clab,&lr,&lc,&type,expr);
reads an m*n matrix A from a matrix file MEANS.MAT on the current data disk. The labels of rows are read in character array clab and each label has length lr. The labels of columns are read in character array rlab and each of them has length lc. In most cases lr=lc=8. The type of matrix is type and its internal name is expr.


Front page of Survo C libraries