Documentation 
Numerical estimate of the rank of a matrix
This functionality does not run in MATLAB.
numeric::rank(A, <eps>, options)
numeric::rank(A) returns an integer indicating the rank of the matrix A.
All entries of the input matrix must be numerical, i.e., they must be floatingpoint numbers or expressions that can be converted to floatingpoint numbers.
The rank of a matrix coincides with the number of nonzero singular values.
A numerical estimate of the rank is computed by counting all singular values that are larger than eps s_{m}ax, where s_{m}ax is the largest singular value. (All smaller singular values are regarded as roundoff artifacts and treated as zero.)
The function is sensitive to the environment variable DIGITS, which determines the numerical working precision.
We consider a quadratic matrix of rank 2:
A := matrix([[1, 1, I], [1, 2, 3], [2, 4, 6]]): numeric::rank(A)
Hilbert matrices have full rank. However, they are extremely illconditioned and it is difficult to compute their rank numerically. The 10×10 Hilbert matrix has rank 10. Numerically, however, some of the singular values are so small that they may be regarded as zero resulting in a smaller numerical rank. In particular, with the default value eps = , two singular values are smaller than eps s_{m}ax where s_{m}ax = is the maximal singular value:
A := linalg::hilbert(10): numeric::singularvalues(A)
numeric::rank(A)
We specify a second argument eps = 10^{ 14} to allow smaller singular values to be regarded as nonzero. Now, the numerical rank is 10:
numeric::rank(A, 10^(14))
delete A:
We consider a nonsquare matrix of rank 1:
A := matrix([[0, 0], [I, 1], [I, 1]]): numeric::rank(A)
delete A:
We demonstrate the difference between hardware floats and software floats:
A := linalg::hilbert(15): numeric::rank(A, 10^(20), SoftwareFloats), numeric::rank(A, 10^(20), HardwareFloats)
delete A:
A 
An m×n matrix of domain type DOM_ARRAY, DOM_HFARRAY, or of category Cat::Matrix 
eps 
Relative tolerance: regard all singular values s of A as zero if they satisfy s ≤ eps s_{m}ax, where s_{m}ax is the largest singular value of A. The default value of eps is . 
Hard, HardwareFloats, Soft, SoftwareFloats 
With Hard (or HardwareFloats), computations are done using fast hardware float arithmetic from within a MuPAD^{®} session. Hard and HardwareFloats are equivalent. With this option, the input data are converted to hardware floats and processed by compiled C code. The result is reconverted to MuPAD floats and returned to the MuPAD session. With Soft (or SoftwareFloats) computations are dome using software float arithmetic provided by the MuPAD kernel. Soft and SoftwareFloats are equivalent. SoftwareFloats is used by default if the current value of DIGITS is larger than 15 and the input matrix A is not of domain type DOM_HFARRAY. Compared to the SoftwareFloats used by the MuPAD kernel, the computation with HardwareFloats may be many times faster. Note, however, that the precision of hardware arithmetic is limited to about 15 digits. Further, the size of floatingpoint numbers may not be larger than approximately 10^{308} and not smaller than approximately 10^{ 308}. If no HardwareFloats or SoftwareFloats are requested explicitly, the following strategy is used: If the current value of DIGITS is smaller than 16 or if the matrix A is a hardware float array of domain type DOM_HFARRAY, then hardware arithmetic is tried. If this is successful, the result is returned. If the result cannot be computed with hardware floats, software arithmetic by the MuPAD kernel is tried. If the current value of DIGITS is larger than 15 and the input matrix A is not of domain type DOM_HFARRAY, or if one of the options Soft, SoftwareFloats or Symbolic is specified, MuPAD computes the result with its software arithmetic without trying to use hardware floats first. There may be several reasons for hardware arithmetic to fail:
If neither HardwareFloats nor SoftwareFloats is specified, the user is not informed whether hardware floats or software floats are used. If HardwareFloats are specified but fail due to one of the reasons above, a warning is issued that the (much slower) software floatingpoint arithmetic of the MuPAD kernel is used. Note that HardwareFloats can only be used if all input data can be converted to floatingpoint numbers.
