FNLMath : Utilities : WRCRL
WRCRL
Prints a complex 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.
A — Complex NRA 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. Because a complex number consists of two parts (a real and an imaginary part), two edit descriptors are used for printing a single complex number. FMT = ’(E10.3, F10.3)’ specifies an E format for the real part and an F format for the imaginary part. FMT = ’(F10.3)’ uses an F format for both the real and imaginary parts. If the end of FMT is encountered and if all columns of the matrix have not been printed, format control continues with the first format in FMT. Even though the matrix A is complex, an I format can be used to print the integer parts of the real and imaginary components of each complex number. 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 automatially 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 WRCRL (TITLE, A, RLABEL, CLABEL [])
Specific: The specific interface names are S_WRCRL and D_WRCRL for two dimensional arrays, and S_WRCRL1D and D_WRCRL1D for one dimensional arrays.
FORTRAN 77 Interface
Single: CALL WRCRL (TITLE, NRA, NCA, A, LDA, ITRING, FMT, RLABEL, CLABEL)
Double: The double precision name is DWRCRL.
Description
Routine WRCRL prints a complex rectangular matrix (stored in A) with row and column labels (specified by RLABEL and CLABEL, respectively) according to a given format (stored in FMT). Routine WRCRL can restrict printing to the elements of upper or lower triangles of matrices via the ITRING option. Generally, the ITRING  0 is used with Hermitian 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 W2CRL/DW2CRL. The reference is:
CALL W2CRL (TITLE, NRA, NCA, A, LDA, ITRING, FMT, RLABEL, CLABEL, CHWK)
The additional argument is:
CHWKCHARACTER * 10 work vector of length 2 * 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,xxxxx)
(xxxxx,xxxxx)
RLABEL(2)
(xxxxx,xxxxx)
(xxxxx,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, a method for printing large matrices, paging, method for printing NaN (not a number), printing a title on each page, and may other options can be selected by invoking WROPT.
7. Output is written to the unit specified by UMACH (see the Reference Material).
Example
The following example prints all of a 3 × 4 matrix A with elements
USE WRCRL_INT
 
IMPLICIT NONE
 
INTEGER ITRING, LDA, NCA, NRA
PARAMETER (ITRING=0, LDA=10, NCA=4, NRA=3)
!
INTEGER I, J
COMPLEX A(LDA,NCA), CMPLX
CHARACTER CLABEL(5)*5, FMT*8, RLABEL(3)*5
INTRINSIC CMPLX
!
DATA FMT/'(W12.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) = CMPLX(I,J) + 0.123456
10 CONTINUE
20 CONTINUE
! Write A matrix.
CALL WRCRL ('A', A, RLABEL, CLABEL, NRA=NRA, FMT=FMT)
END
Output
A
Col 1 Col 2
Row 1 ( 1.12346, 1.00000) ( 1.12346, 2.00000)
Row 2 ( 2.12346, 1.00000) ( 2.12346, 2.00000)
Row 3 ( 3.12346, 1.00000) ( 3.12346, 2.00000)
Col 3 Col 4
Row 1 ( 1.12346, 3.00000) ( 1.12346, 4.00000)
Row 2 ( 2.12346, 3.00000) ( 2.12346, 4.00000)
Row 3 ( 3.12346, 3.00000) ( 3.12346, 4.00000)