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

NAG Library Routine Document

F01CTF

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

F01CTF adds two real matrices, each one optionally transposed and multiplied by a scalar.

2  Specification

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

3  Description

F01CTF performs one of the operations where A, B and C are matrices, and α and β are scalars. 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' or 'C'
The matrix will be transposed.
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 – REAL (KIND=nag_wp)Input
On entry: the scalar α, by which matrix A is multiplied before addition.
6:     ALDA* – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array A must be at least max1,N if TRANSA='N', and at least max1,M otherwise.
On entry: if α=0.0, the elements of array A need not be assigned. If α0.0, then if TRANSA='N', the leading m by n part of A must contain the matrix A, otherwise the leading n by m part of A must contain the matrix A.
7:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F01CTF is called.
Constraints:
  • if TRANSA='N', LDAmax1,M;
  • otherwise LDAmax1,N.
8:     BETA – REAL (KIND=nag_wp)Input
On entry: the scalar β, by which matrix B is multiplied before addition.
9:     BLDB* – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array B must be at least max1,N if TRANSB='N', and at least max1,M otherwise.
On entry: if β=0.0, the elements of array B need not be assigned. If β0.0, then if TRANSA='N', the leading m by n part of B must contain the matrix B, otherwise the leading n by m part of B must contain the matrix B.
10:   LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F01CTF is called.
Constraints:
  • if TRANSB='N', LDBmax1,M;
  • otherwise LDBmax1,N.
11:   CLDC* – REAL (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 F01CTF 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.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

The results returned by F01CTF are accurate to machine precision.

8  Parallelism and Performance

F01CTF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

The time taken for a call of F01CTF 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.

10  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.

10.1  Program Text

Program Text (f01ctfe.f90)

10.2  Program Data

Program Data (f01ctfe.d)

10.3  Program Results

Program Results (f01ctfe.r)


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

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