RANK more...
Computes the mathematical rank of a matrix.
Function Return Value
Integer rank of A. The output function value is an integer with a value equal to the number of singular values that are greater than a tolerance. (Output)
Required Argument
A — Matrix for which the rank is to be computed. The argument must be rank-2 or rank-3 (box) array of type single, double, complex, or double complex. (Input)
Optional Arguments, Packaged Options
This function uses LIN_SOL_SVD to compute the singular values of the argument. The singular values are then compared with the value of the tolerance to compute the rank.
The option and derived type names are given in the following tables:
Option Names for RANK
Option Value
?_rank_set_small
1
?_rank_for_lin_sol_svd
2
Name of Unallocated Option Array to Use for Setting Options
Use
Derived Type
?_rank_options(:)
Use when setting options for calls hereafter.
?_options
?_rank_options_once(:)
Use when setting options for next call only.
?_options
For a description on how to use these options, see Matrix Optional Data Changes. See LIN_SOL_SVD in Chapter 1, “Linear Systems” for the specific options for these routines.
FORTRAN 90 Interface
RANK (A)
Description
Computes the mathematical rank of a rank-2 or rank-3 array. The output function value is an integer with a value equal to the number of singular values that are greater than a tolerance. The default value for this tolerance is ɛ1/2s1, where ɛ is machine precision and s1 is the largest singular value of the matrix.
Examples
Example 1

use linear_operators
real (kind(1e0)) A(5,5)
A = rand (A)
write (*,*) rank(A)
A=1.0
write (*,*) rank(A)
end
Output
5
1
Parallel Example

use linear_operators
use mpi_setup_int

integer, parameter :: N=3, nr=4
integer r(nr)
real (kind(1.e0)) s_mat(N,N), s_box(N,N,nr)
! Setup for MPI
mp_nprocs = mp_setup()

if (mp_rank == 0) then
s_mat = reshape((/1.,0.,0.,epsilon(1.0e0)/),(/n,n/))