# MatrixRank

Advanced Analysis Library Only

AnalysisLibErrType MatrixRank (void *inputMatrix, int numberOfRows, int numberOfColumns, double tolerance, int *rank);

## Purpose

Calculates the rank of the real input matrix. The input matrix can be square or rectangular.

The maximum number of linearly independent rows or columns of the matrix defines the rank of a matrix. The rank is always less than or equal to the minimum of the number of rows and columns of the matrix. If the rank equals this minimum value, the matrix is a full-rank matrix. Otherwise, it is a rank-deficient matrix.

The rank of a matrix can be calculated in a number of ways. MatrixRank first calculates the singular values of the input matrix and then calculates the rank as the number of singular values of the input matrix that are larger than the input tolerance.

You must specify the input tolerance as a positive number close to machine precision. If the matrix in your application is a full-rank matrix, any small value of tolerance gives the same rank. If the matrix in your application is a rank-deficient matrix, different values of tolerance can result in different values of rank.

## Parameters

Input
Name | Type | Description
inputMatrix | numeric array | Input matrix. This matrix must be an array of doubles.
numberOfRows | integer | Number of rows in inputMatrix.
numberOfColumns | integer | Number of columns in inputMatrix.
tolerance | double-precision | Tolerance value. Matrix rank is the number of singular values in the input matrix that are larger than the tolerance. Set tolerance close to eps, which is the smallest possible double-precision, floating-point number.
Output
Name | Type | Description
rank | integer | Rank of the input matrix.

## Return Value

Name | Type | Description
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.