F01CWF (PDF version)
F01 Chapter Contents
F01 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

F01CWF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

F01CWF adds two complex matrices, each one optionally transposed and multiplied by a scalar.

2  Specification

SUBROUTINE F01CWF ( TRANSA, TRANSB, M, N, ALPHA, A, LDA, BETA, B, LDB, C, LDC, IFAIL)
INTEGER  M, N, LDA, LDB, LDC, IFAIL
COMPLEX (KIND=nag_wp)  ALPHA, A(LDA,*), BETA, B(LDB,*), C(LDC,*)
CHARACTER(1)  TRANSA, TRANSB

3  Description

F01CWF performs one of the operations where A, B and C are matrices, α and β are scalars, T denotes transposition and H denotes conjugate transposition. For efficiency, the routine contains special code for the cases when one or both of α, β is equal to zero, unity or minus unity. The matrices, or their transposes, must be compatible for addition. A and B are either m by n or n by m matrices, depending on whether they are to be transposed before addition. C is an m by n matrix.

4  References

None.

5  Parameters

1:     TRANSA – CHARACTER(1)Input
2:     TRANSB – CHARACTER(1)Input
On entry: TRANSA and TRANSB must specify whether or not the matrix A and the matrix B, respectively, are to be transposed before addition.
TRANSA or TRANSB='N'
The matrix will not be transposed.
TRANSA or TRANSB='T'
The matrix will be transposed.
TRANSA or TRANSB='C'
The matrix will be transposed and conjugated.
Constraint: TRANSA​ or ​TRANSB='N', 'T' or 'C'.
3:     M – INTEGERInput
On entry: m, the number of rows of the matrices A and B or their transposes. Also the number of rows of the matrix C.
Constraint: M0.
4:     N – INTEGERInput
On entry: n, the number of columns of the matrices A and B or their transposes. Also the number of columns of the matrix C.
Constraint: N0.
5:     ALPHA – COMPLEX (KIND=nag_wp)Input
On entry: the scalar α, by which matrix A is multiplied before addition.
6:     A(LDA,*) – COMPLEX (KIND=nag_wp) arrayInput
Note: the second dimension of the array A must be at least max1,N if ALPHA0 and TRANSA='N', max1,M if ALPHA0 and TRANSA='T' or 'C' and at least 1 if ALPHA=0.
On entry: the matrix A. If α=0, the array A is not referenced.
7:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F01CWF is called.
Constraints:
  • if TRANSA='N', LDAmax1,M;
  • otherwise LDAmax1,N.
8:     BETA – COMPLEX (KIND=nag_wp)Input
On entry: the scalar β, by which matrix B is multiplied before addition.
9:     B(LDB,*) – COMPLEX (KIND=nag_wp) arrayInput
Note: the second dimension of the array B must be at least max1,N if BETA0 and TRANSB='N', max1,M if BETA0 and TRANSB='T' or 'C' and at least 1 if BETA=0.
On entry: the matrix B. If β=0, the array B is not referenced.
10:   LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F01CWF is called.
Constraints:
  • if TRANSB='N', LDBmax1,M;
  • otherwise LDBmax1,N.
11:   C(LDC,*) – COMPLEX (KIND=nag_wp) arrayOutput
Note: the second dimension of the array C must be at least max1,N.
On exit: the elements of the m by n matrix C.
12:   LDC – INTEGERInput
On entry: the first dimension of the array C as declared in the (sub)program from which F01CWF is called.
Constraint: LDCmax1,M.
13:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,one or both of TRANSA or TRANSB is not equal to 'N', 'T' or 'C'.
IFAIL=2
On entry,one or both of M or N is less than 0.
IFAIL=3
On entry,LDA<max1,P, where P=M if TRANSA='N', and P=N otherwise.
IFAIL=4
On entry,LDB<max1,P, where P=M if TRANSB='N', and P=N otherwise.
IFAIL=5
On entry,LDC<max1,M.

7  Accuracy

The results returned by F01CWF are accurate to machine precision.

8  Further Comments

The time taken for a call of F01CWF varies with M, N and the values of α and β. The routine is quickest if either or both of α and β are equal to zero, or plus or minus unity.

9  Example

The following program reads in a pair of matrices A and B, along with values for TRANSA, TRANSB, ALPHA and BETA, and adds them together, printing the result matrix C. The process is continued until the end of the input stream is reached.

9.1  Program Text

Program Text (f01cwfe.f90)

9.2  Program Data

Program Data (f01cwfe.d)

9.3  Program Results

Program Results (f01cwfe.r)


F01CWF (PDF version)
F01 Chapter Contents
F01 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012