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

NAG Library Routine Document

F01CKF

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

F01CKF returns with the result of the multiplication of two matrices B and C in the matrix A, with the option to overwrite B or C.

2  Specification

SUBROUTINE F01CKF ( A, B, C, N, P, M, Z, IZ, OPT, IFAIL)
INTEGER  N, P, M, IZ, OPT, IFAIL
REAL (KIND=nag_wp)  A(N,P), B(N,M), C(M,P), Z(IZ)

3  Description

The n by m matrix B is post-multiplied by the m by p matrix C. If OPT=1 the result is formed in the n by p matrix A. If OPT=2, m must equal p, and the result is written back to B. If OPT=3, n must equal m, and the result is written back to C.

4  References

None.

5  Parameters

1:     A(N,P) – REAL (KIND=nag_wp) arrayOutput
On exit: if OPT=1, A contains the result of the matrix multiplication.
2:     B(N,M) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the n by m matrix B.
On exit: if OPT=2, B contains the result of the multiplication.
3:     C(M,P) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the m by p matrix C.
On exit: if OPT=3, C contains the result of the multiplication.
4:     N – INTEGERInput
On entry: n, the number of rows of the array A and of the array B.
Constraints:
  • if OPT=3, N=M;
  • otherwise N1.
5:     P – INTEGERInput
On entry: p, the number of columns of the array A and of the array C.
Constraints:
  • if OPT=2, P=M;
  • otherwise P1.
6:     M – INTEGERInput
On entry: m, the number of columns of the array B and rows of the array C.
Constraints:
  • if OPT=2, M=P;
  • if OPT=3, M=N;
  • if OPT1, MIZ;
  • otherwise M1.
7:     Z(IZ) – REAL (KIND=nag_wp) arrayWorkspace
8:     IZ – INTEGERInput
On entry: the dimension of the array Z as declared in the (sub)program from which F01CKF is called.
Constraints:
  • if OPT=1, IZ1;
  • if OPT1, IZM.
9:     OPT – INTEGERInput
On entry: the value of OPT determines which array is to contain the final result.
OPT=1
A must be distinct from B and C and, on exit, contains the result. B and C need not be distinct in this case.
OPT=2
B must be distinct from C and on exit, contains the result. A is not used in this case and need not be distinct from B or C.
OPT=3
C must be distinct from B and on exit, contains the result. A is not used in this case and need not be distinct from B or C.
Constraint: 1OPT3.
10:   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, M or P or N0.
IFAIL=2
OPT=2 and MP.
IFAIL=3
OPT=3 and NM.
IFAIL=4
OPT1 and IZ<M.

7  Accuracy

Each element of the result is effectively computed as an inner product using basic precision.

8  Further Comments

The time taken by F01CKF is approximately proportional to mnp.

9  Example

This example multiplies the 2 by 3 matrix B and the 3 by 2 matrix C together and places the result in the 2 by 2 matrix A.

9.1  Program Text

Program Text (f01ckfe.f90)

9.2  Program Data

Program Data (f01ckfe.d)

9.3  Program Results

Program Results (f01ckfe.r)


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

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