FNLMath : Utilities : WRRRL
WRRRL
Print a real rectangular matrix with a given format and labels.
Required Arguments
TITLE — Character string specifying the title. (Input)
TITLE set equal to a blank character(s) suppresses printing of the title.
ANRA by NCA matrix to be printed. (Input)
RLABELCHARACTER * (*) vector of labels for rows of A. (Input)
If rows are to be numbered consecutively 1, 2, …, NRA, use RLABEL(1) = ’NUMBER’. If no row labels are desired, use RLABEL(1) = ’NONE’. Otherwise, RLABEL is a vector of length NRA containing the labels.
CLABELCHARACTER * (*) vector of labels for columns of A. (Input)
If columns are to be numbered consecutively 1, 2, …, NCA, use CLABEL(1) = ’NUMBER’. If no column labels are desired, use CLABEL(1) = ’NONE’. Otherwise, CLABEL(1) is the heading for the row labels, and either CLABEL(2) must be ’NUMBER’or ’NONE’, or CLABEL must be a vector of length NCA + 1 with CLABEL(1 + j) containing the column heading for the j-th column.
Optional Arguments
NRA — Number of rows. (Input)
Default: NRA = size (A,1).
NCA — Number of columns. (Input)
Default: NCA = size (A,2).
LDA — Leading dimension of A exactly as specified in the dimension statement in the calling program. (Input)
Default: LDA = size (A,1).
ITRING — Triangle option. (Input)
Default: ITRING = 0.
ITRING
Action
0
Full matrix is printed.
1
Upper triangle of A is printed, including the diagonal.
2
Upper triangle of A excluding the diagonal of A is printed.
-1
Lower triangle of A is printed, including the diagonal.
-2
Lower triangle of A excluding the diagonal of A is printed.
FMT — Character string containing formats. (Input)
If FMT is set to a blank character(s), the format used is specified by WROPT. Otherwise, FMT must contain exactly one set of parentheses and one or more edit descriptors. For example, FMT = (F10.3) specifies this F format for the entire matrix. FMT = (2E10.3, 3F10.3) specifies an E format for columns 1 and 2 and an F format for columns 3, 4 and 5. If the end of FMT is encountered and if some columns of the matrix remain, format control continues with the first format in FMT. Even though the matrix A is real, an I format can be used to print the integer part of matrix elements of A. The most useful formats are special formats, called the V and W formats, that can be used to specify pretty formats automatically. Set FMT = (V10.4) if you want a single D, E, or F format selected automatically with field width 10 and with 4 significant digits. Set FMT = (W10.4) if you want a single D, E, F, or I format selected automatically with field width 10 and with 4 significant digits. While the V format prints trailing zeroes and a trailing decimal point, the W format does not. See Comment 4 for general descriptions of the V and W formats. FMT may contain only D, E, F, G, I, V, or W edit descriptors, e.g., the X descriptor is not allowed.
Default: FMT = ‘ ‘.
FORTRAN 90 Interface
Generic: CALL WRRRL (TITLE, A, RLABEL, CLABEL [])
Specific: The specific interface names are S_WRRRL and D_WRRRL for two dimensional arrays, and S_WRRRL1D and D_WRRRL1D for one dimensional arrays.
FORTRAN 77 Interface
Single: CALL WRRRL (TITLE, NRA, NCA, A, LDA, ITRING, FMT, RLABEL, CLABEL)
Double: The double precision name is DWRRRL.
Description
Routine WRRRL prints a real rectangular matrix (stored in A) with row and column labels (specified by RLABEL and CLABEL, respectively) according to a given format (stored in FMT). WRRRL can restrict printing to the elements of upper or lower triangles of matrices via the ITRING option. Generally, ITRING  0 is used with symmetric matrices.
In addition, one-dimensional arrays can be printed as column or row vectors. For a column vector, set NRA to the length of the array and set NCA = 1. For a row vector, set NRA = 1 and set NCA to the length of the array. In both cases, set LDA = NRA, and set ITRING = 0.
Comments
1. Workspace may be explicitly provided, if desired, by use of W2RRL/DW2RRL. The reference is:
CALL W2RRL (TITLE, NRA, NCA, A, LDA, ITRING, FMT, RLABEL, CLABEL, CHWK)
The additional argument is:
CHWKCHARACTER * 10 work vector of length NCA. This workspace is referenced only if all three conditions indicated at the beginning of this comment are met. Otherwise, CHWK is not referenced and can be a CHARACTER * 10 vector of length one.
2. The output appears in the following form:
TITLE
CLABEL(1)
CLABEL(2)
CLABEL(3)
CLABEL(4)
RLABEL(1)
Xxxxx
Xxxxx
Xxxxx
RLABEL(2)
Xxxxx
Xxxxx
Xxxxx
3. Use “% /” within titles or labels to create a new line. Long titles or labels are automatically wrapped.
4. For printing numbers whose magnitudes are unknown, the G format in FORTRAN is useful; however, the decimal points will generally not be aligned when printing a column of numbers. The V and W formats are special formats used by this routine to select a D, E, F, or I format so that the decimal points will be aligned. The V and W formats are specified as Vn.d and Wn.d. Here, n is the field width and d is the number of significant digits generally printed. Valid values for n are 3, 4,, 40. Valid values for d are 1, 2, , n 2. If FMT specifies one format and that format is a V or W format, all elements of the matrix A are examined to determine one FORTRAN format for printing. If FMT specifies more than one format, FORTRAN formats are generated separately from each V or W format.
5. A page width of 78 characters is used. Page width and page length can be reset by invoking PGOPT .
6. Horizontal centering, method for printing large matrices, paging, method for printing NaN (not a number), printing a title on each page, and many other options can be selected by invoking WROPT .
7. Output is written to the unit specified by UMACH (see Reference Material).
Example
The following example prints all of a 3 × 4 matrix A where aij = (i + j/10)10j-3.
 
USE WRRRL_INT
 
IMPLICIT NONE
INTEGER ITRING, LDA, NCA, NRA
PARAMETER (ITRING=0, LDA=10, NCA=4, NRA=3)
!
INTEGER I, J
REAL A(LDA,NCA)
CHARACTER CLABEL(5)*5, FMT*8, RLABEL(3)*5
!
DATA FMT/'(W10.6)'/
DATA CLABEL/' ', 'Col 1', 'Col 2', 'Col 3', 'Col 4'/
DATA RLABEL/'Row 1', 'Row 2', 'Row 3'/
!
DO 20 I=1, NRA
DO 10 J=1, NCA
A(I,J) = (I+J*0.1)*10.0**(J-3)
10 CONTINUE
20 CONTINUE
! Write A matrix.
CALL WRRRL ('A', A, RLABEL, CLABEL, NRA=NRA, FMT=FMT)
END
Output
 
A
Col 1 Col 2 Col 3 Col 4
Row 1 0.011 0.120 1.300 14.000
Row 2 0.021 0.220 2.300 24.000
Row 3 0.031 0.320 3.300 34.000