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 B$B$ and C$C$ in the matrix A$A$, with the option to overwrite B$B$ or C$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$n$ by m$m$ matrix B$B$ is post-multiplied by the m$m$ by p$p$ matrix C$C$. If opt = 1${\mathbf{opt}}=1$ the result is formed in the n$n$ by p$p$ matrix A$A$. If opt = 2${\mathbf{opt}}=2$, m$m$ must equal p$p$, and the result is written back to B$B$. If opt = 3${\mathbf{opt}}=3$, n$n$ must equal m$m$, and the result is written back to C$C$.

None.

Parameters

Compulsory Input Parameters

1:     b(n,m) – double array
n, the first dimension of the array, must satisfy the constraint
• if opt = 3${\mathbf{opt}}=3$, n = m${\mathbf{n}}={\mathbf{m}}$;
• otherwise n1${\mathbf{n}}\ge 1$.
The n$n$ by m$m$ matrix B$B$.
2:     c(m,p) – double array
m, the first dimension of the array, must satisfy the constraint
• if opt = 2${\mathbf{opt}}=2$, m = p${\mathbf{m}}={\mathbf{p}}$;
• if opt = 3${\mathbf{opt}}=3$, m = n${\mathbf{m}}={\mathbf{n}}$;
• if opt1${\mathbf{opt}}\ne 1$, miz${\mathbf{m}}\le \mathit{iz}$;
• otherwise m1${\mathbf{m}}\ge 1$.
The m$m$ by p$p$ matrix C$C$.
3:     opt – int64int32nag_int scalar
The value of opt determines which array is to contain the final result.
opt = 1${\mathbf{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${\mathbf{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${\mathbf{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$1\le {\mathbf{opt}}\le 3$.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array b.
n$n$, the number of rows of the array A$A$ and of the array B$B$.
Constraints:
• if opt = 3${\mathbf{opt}}=3$, n = m${\mathbf{n}}={\mathbf{m}}$;
• otherwise n1${\mathbf{n}}\ge 1$.
2:     p – int64int32nag_int scalar
Default: The second dimension of the array c.
p$p$, the number of columns of the array A$A$ and of the array C$C$.
Constraints:
• if opt = 2${\mathbf{opt}}=2$, p = m${\mathbf{p}}={\mathbf{m}}$;
• otherwise p1${\mathbf{p}}\ge 1$.
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$m$, the number of columns of the array B$B$ and rows of the array C$C$.
Constraints:
• if opt = 2${\mathbf{opt}}=2$, m = p${\mathbf{m}}={\mathbf{p}}$;
• if opt = 3${\mathbf{opt}}=3$, m = n${\mathbf{m}}={\mathbf{n}}$;
• if opt1${\mathbf{opt}}\ne 1$, miz${\mathbf{m}}\le \mathit{iz}$;
• otherwise m1${\mathbf{m}}\ge 1$.

z iz

Output Parameters

1:     a(n,p) – double array
If opt = 1${\mathbf{opt}}=1$, a contains the result of the matrix multiplication.
2:     b(n,m) – double array
If opt = 2${\mathbf{opt}}=2$, b contains the result of the multiplication.
3:     c(m,p) – double array
If opt = 3${\mathbf{opt}}=3$, c contains the result of the multiplication.
4:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{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${\mathbf{ifail}}=1$
On entry, m or p or n0${\mathbf{n}}\le 0$.
ifail = 2${\mathbf{ifail}}=2$
opt = 2${\mathbf{opt}}=2$ and mp${\mathbf{m}}\ne {\mathbf{p}}$.
ifail = 3${\mathbf{ifail}}=3$
opt = 3${\mathbf{opt}}=3$ and nm${\mathbf{n}}\ne {\mathbf{m}}$.
ifail = 4${\mathbf{ifail}}=4$
opt1${\mathbf{opt}}\ne 1$ and iz < m$\mathit{iz}<{\mathbf{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 mnp$mnp$.

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