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)

Purpose

nag_matop_real_gen_matmul (f01ck) returns with the result of the multiplication of two matrices BB and CC in the matrix AA, with the option to overwrite BB or CC.

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 nn by mm matrix BB is post-multiplied by the mm by pp matrix CC. If opt = 1opt=1 the result is formed in the nn by pp matrix AA. If opt = 2opt=2, mm must equal pp, and the result is written back to BB. If opt = 3opt=3, nn must equal mm, and the result is written back to CC.

References

None.

Parameters

Compulsory Input Parameters

1:     b(n,m) – double array
n, the first dimension of the array, must satisfy the constraint
  • if opt = 3opt=3, n = mn=m;
  • otherwise n1n1.
The nn by mm matrix BB.
2:     c(m,p) – double array
m, the first dimension of the array, must satisfy the constraint
  • if opt = 2opt=2, m = pm=p;
  • if opt = 3opt=3, m = nm=n;
  • if opt1opt1, mizmiz;
  • otherwise m1m1.
The mm by pp matrix CC.
3:     opt – int64int32nag_int scalar
The value of opt determines which array is to contain the final result.
opt = 1opt=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 = 2opt=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 = 3opt=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: 1opt31opt3.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array b.
nn, the number of rows of the array AA and of the array BB.
Constraints:
  • if opt = 3opt=3, n = mn=m;
  • otherwise n1n1.
2:     p – int64int32nag_int scalar
Default: The second dimension of the array c.
pp, the number of columns of the array AA and of the array CC.
Constraints:
  • if opt = 2opt=2, p = mp=m;
  • otherwise p1p1.
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.)
mm, the number of columns of the array BB and rows of the array CC.
Constraints:
  • if opt = 2opt=2, m = pm=p;
  • if opt = 3opt=3, m = nm=n;
  • if opt1opt1, mizmiz;
  • otherwise m1m1.

Input Parameters Omitted from the MATLAB Interface

z iz

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry, m or p or n0n0.
  ifail = 2ifail=2
opt = 2opt=2 and mpmp.
  ifail = 3ifail=3
opt = 3opt=3 and nmnm.
  ifail = 4ifail=4
opt1opt1 and iz < miz<m.

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

Example

function nag_matop_real_gen_matmul_example
b = [0, 1, 2];
c = [0, 1;
     1, 2;
     2, 3];
opt = int64(1);
[a, bOut, cOut, ifail] = nag_matop_real_gen_matmul(b, c, opt)
 

a =

     5     8


bOut =

     0     1     2


cOut =

     0     1
     1     2
     2     3


ifail =

                    0


function f01ck_example
b = [0, 1, 2];
c = [0, 1;
     1, 2;
     2, 3];
opt = int64(1);
[a, bOut, cOut, ifail] = f01ck(b, c, opt)
 

a =

     5     8


bOut =

     0     1     2


cOut =

     0     1
     1     2
     2     3


ifail =

                    0



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–2013