NAG Library Routine Document

f01ckf  (real_gen_matmul)

 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

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 nagmk26.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)

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) arrayOutput
On exit: if opt=1, a contains the result of the matrix multiplication.
2:     bnm – 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:     cmp – 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:     ziz – 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 argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 or p or n0.
ifail=2
opt=2 and mp.
ifail=3
opt=3 and nm.
ifail=4
opt1 and iz<m.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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)

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