NAG FL Interface
f01ckf (real_​gen_​matmul)

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

Fortran Interface
Subroutine f01ckf ( a, b, c, n, p, m, z, iz, opt, ifail)
Integer, Intent (In) :: n, p, m, iz, opt
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (Inout) :: b(n,m), c(m,p)
Real (Kind=nag_wp), Intent (Out) :: a(n,p), z(iz)
C Header Interface
#include <nag.h>
void  f01ckf_ (double a[], double b[], double c[], const Integer *n, const Integer *p, const Integer *m, double z[], const Integer *iz, const Integer *opt, Integer *ifail)
The routine may be called by the names f01ckf or nagf_matop_real_gen_matmul.

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 Arguments

1: anp Real (Kind=nag_wp) array Output
On exit: if opt=1, a contains the result of the matrix multiplication.
2: bnm Real (Kind=nag_wp) array Input/Output
On entry: the n by m matrix B.
On exit: if opt=2, b contains the result of the multiplication.
3: cmp Real (Kind=nag_wp) array Input/Output
On entry: the m by p matrix C.
On exit: if opt=3, c contains the result of the multiplication.
4: n Integer Input
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 Integer Input
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 Integer Input
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: ziz Real (Kind=nag_wp) array Workspace
8: iz Integer Input
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 Integer Input
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 Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface 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 argument, 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=value.
Constraint: m1.
On entry, n=value.
Constraint: n1.
On entry, p=value.
Constraint: p1.
ifail=2
On entry, m=value and p=value.
Constraint: if opt=2, m=p.
ifail=3
On entry, n=value and m=value.
Constraint: if opt=3, n=m.
ifail=4
On entry, opt=value, iz=value and m=value.
Constraint: if opt1, izm.
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

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

8 Parallelism and Performance

f01ckf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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 by f01ckf is approximately proportional to mnp.

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

10.1 Program Text

Program Text (f01ckfe.f90)

10.2 Program Data

Program Data (f01ckfe.d)

10.3 Program Results

Program Results (f01ckfe.r)