hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_matop_real_gen_matmul (f01ck)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_matop_real_gen_matmul (f01ck) 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.

Syntax

[a, b, c, ifail] = f01ck(b, c, opt, 'n', n, 'p', p, 'm', m)
[a, b, c, ifail] = nag_matop_real_gen_matmul(b, c, opt, 'n', n, 'p', p, 'm', m)

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.

References

None.

Parameters

Compulsory Input Parameters

1:     bnm – double array
The n by m matrix B.
2:     cmp – double array
The m by p matrix C.
3:     opt int64int32nag_int scalar
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.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the array b.
n, the number of rows of the array A and of the array B.
Constraints:
  • if opt=3, n=m;
  • otherwise n1.
2:     p int64int32nag_int scalar
Default: the second dimension of the array c.
p, the number of columns of the array A and of the array C.
Constraints:
  • if opt=2, p=m;
  • otherwise p1.
3:     m int64int32nag_int scalar
Default: the first dimension of the array c and the second dimension of the array b. (An error is raised if these dimensions are not equal.)
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.

Output Parameters

1:     anp – double array
If opt=1, a contains the result of the matrix multiplication.
2:     bnm – double array
If opt=2, b contains the result of the multiplication.
3:     cmp – double array
If opt=3, c contains the result of the multiplication.
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   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.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

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

Further Comments

The time taken by nag_matop_real_gen_matmul (f01ck) is approximately proportional to mnp.

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.
function f01ck_example


fprintf('f01ck example results\n\n');

% Matrices B and C
b = [0, 1, 2;
     1, 2, 3];
c = [0, 1;
     1, 2;
     2, 3];

% Calculate A = BC
opt = int64(1);
[a, b, c, ifail] = f01ck(b, c, opt);

disp('Martix A');
disp(a);


f01ck example results

Martix A
     5     8
     8    14


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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