NAG FL Interface
f01ctf (real_​addsub)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

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

2 Specification

Fortran Interface
Subroutine f01ctf ( transa, transb, m, n, alpha, a, lda, beta, b, ldb, c, ldc, ifail)
Integer, Intent (In) :: m, n, lda, ldb, ldc
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: alpha, a(lda,*), beta, b(ldb,*)
Real (Kind=nag_wp), Intent (Inout) :: c(ldc,*)
Character (1), Intent (In) :: transa, transb
C Header Interface
#include <nag.h>
void  f01ctf_ (const char *transa, const char *transb, const Integer *m, const Integer *n, const double *alpha, const double a[], const Integer *lda, const double *beta, const double b[], const Integer *ldb, double c[], const Integer *ldc, Integer *ifail, const Charlen length_transa, const Charlen length_transb)
The routine may be called by the names f01ctf or nagf_matop_real_addsub.

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×n or n×m matrices, depending on whether they are to be transposed before addition. C is an m×n matrix.

4 References

None.

5 Arguments

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 Integer Input
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 Integer Input
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: a(lda,*) Real (Kind=nag_wp) array Input
Note: the second dimension of the array a must be at least max(1,n) if transa='N', and at least max(1,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×n part of a must contain the matrix A, otherwise the leading n×m part of a must contain the matrix A.
7: lda Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f01ctf is called.
Constraints:
  • if transa='N', ldamax(1,m);
  • otherwise ldamax(1,n).
8: beta Real (Kind=nag_wp) Input
On entry: the scalar β, by which matrix B is multiplied before addition.
9: b(ldb,*) Real (Kind=nag_wp) array Input
Note: the second dimension of the array b must be at least max(1,n) if transb='N', and at least max(1,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×n part of b must contain the matrix B, otherwise the leading n×m part of b must contain the matrix B.
10: ldb Integer Input
On entry: the first dimension of the array b as declared in the (sub)program from which f01ctf is called.
Constraints:
  • if transb='N', ldbmax(1,m);
  • otherwise ldbmax(1,n).
11: c(ldc,*) Real (Kind=nag_wp) array Output
Note: the second dimension of the array c must be at least max(1,n).
On exit: the elements of the m×n matrix C.
12: ldc Integer Input
On entry: the first dimension of the array c as declared in the (sub)program from which f01ctf is called.
Constraint: ldcmax(1,m).
13: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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, transa=value.
Constraint: transa='N', 'T' or 'C'.
On entry, transb=value.
Constraint: transb='N', 'T' or 'C'.
ifail=2
On entry, m=value and n=value.
Constraint: m0 and n0.
ifail=3
On entry, lda=value and m=value.
Constraint: if transa=value, ldamax(1,m).
On entry, lda=value and n=value.
Constraint: if transa=value, ldamax(1,n).
ifail=4
On entry, ldb=value and m=value.
Constraint: if transb=value, ldbmax(1,m).
On entry, ldb=value and n=value.
Constraint: if transb=value, ldbmax(1,n).
ifail=5
On entry, ldc=value and m=value.
Constraint: ldcmax(1,m).
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface 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)