FNLStat : Utilities : RORDM
RORDM
Reorders rows and columns of a symmetric matrix.
Required Arguments
AANAA by NAA symmetric matrix to be reordered. (Input)
Only elements in the upper triangle of AA are referenced.
INDAA — Index vector of length NA containing the indices of the rows/columns of AA that are being selected for inclusion into A. (Input)
INDAA(I) = J means the J‑th row and column of AA will be the I‑th row and column of A.
ANAA by NAA matrix containing the reordered AA. (Output)
The first NA rows and columns of A are those specified by INDAA. The remaining elements of A contain the rows and columns not specified in INDAA
Optional Arguments
NAA — Order of the matrix AA. (Input)
Default: NAA = size (AA,2).
LDAA — Leading dimension of AA exactly as specified in the dimension statement in the calling program. (Input)
Default: LDAA = size (AA,1).
NA — Order of the reordered matrix A. (Input)
NA must be less than or equal to NAA.
Default: NA = size (INDAA,1).
LDA — Leading dimension of A exactly as specified in the dimension statement in the calling program. (Input)
Default: LDA = size (A,1).
FORTRAN 90 Interface
Generic: CALL RORDM (AA, INDAA, A [])
Specific: The specific interface names are S_RORDM and D_RORDM.
FORTRAN 77 Interface
Single: CALL RORDM (NAA, AA, LDAA, NA, INDAA, A, LDA)
Double: The double precision name is DRORDM.
Description
Routine RORDM reorders the rows and columns of a symmetric matrix. Frequently in practice a sum of squares and crossproducts matrix is first computed for all variables in a data set. Then, a sum of squares and crossproducts matrix is needed for some subset of the data set variables. Alternatively, a specific order for the selected variables may be required for input into an analysis routine. For example, in regression, IMSL routine RCOV requires the sum of squares and crossproducts matrix for the independent variables and the dependent variables. Sums of squares and crossproducts for the independent variables must appear first, followed by entries for the dependent variables. Variables not in the regression analysis, but in the data set, can appear last. RORDM can be used to reorder the sum of squares and crossproducts matrix for input to RCOV.
Comments
Workspace may be explicitly provided, if desired, by use of R2RDM/DR2RDM. The reference is:
CALL R2RDM (NAA, AA, LDAA, NA, INDAA, A, LDA, IWK)
The additional argument is
IWK — Work vector of length NAA indicating how the entire AA matrix has been reordered and returned in A. IWK(I) = J means the J‑th row and column of AA are returned as the I‑th row and column of A.
Example
A 4 x 4 symmetric matrix AA is reordered so that row/column 4, 3, and 1 of AA correspond to row/column 1, 2, and 3 of A, respectively.
 
USE RORDM_INT
USE WRRRN_INT
 
IMPLICIT NONE
INTEGER LDA, LDAA, NA, NAA, J
PARAMETER (NA=3, NAA=4, LDA=NAA, LDAA=NAA)
!
INTEGER INDAA(NA)
REAL A(LDA,NAA), AA(LDAA,NAA)
!
DATA (AA(1,J),J=1,NAA)/10., 20., 40., 70./
DATA (AA(2,J),J=1,NAA)/20., 30., 50., 80./
DATA (AA(3,J),J=1,NAA)/40., 50., 60., 90./
DATA (AA(4,J),J=1,NAA)/70., 80., 90., 100./
DATA INDAA/4, 3, 1/
!
CALL RORDM (AA, INDAA, A)
CALL WRRRN ('A', A)
END
Output
 
A
1 2 3 4
1 100.0 90.0 70.0 80.0
2 90.0 60.0 40.0 50.0
3 70.0 40.0 10.0 20.0
4 80.0 50.0 20.0 30.0