Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_blast_zwaxpby (f16gh)

## Purpose

nag_blast_zwaxpby (f16gh) computes the sum of two scaled vectors, preserving input, for complex scalars and vectors.

## Syntax

[w] = f16gh(n, alpha, x, incx, beta, y, incy, incw)
[w] = nag_blast_zwaxpby(n, alpha, x, incx, beta, y, incy, incw)

## Description

nag_blast_zwaxpby (f16gh) performs the operation
 $w ← αx+βy,$
where $x$ and $y$ are $n$-element complex vectors, and $\alpha$ and $\beta$ are complex scalars.

## References

Basic Linear Algebra Subprograms Technical (BLAST) Forum (2001) Basic Linear Algebra Subprograms Technical (BLAST) Forum Standard University of Tennessee, Knoxville, Tennessee http://www.netlib.org/blas/blast-forum/blas-report.pdf

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
$n$, the number of elements in $x$, $y$ and $w$.
2:     $\mathrm{alpha}$ – complex scalar
The scalar $\alpha$.
3:     $\mathrm{x}\left(1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incx}}\right|\right)$ – complex array
The $n$-element vector $x$.
If ${\mathbf{incx}}>0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(\left(\mathit{i}-1\right)×\left|{\mathbf{incx}}\right|+1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incx}}<0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(\left({\mathbf{n}}-\mathit{i}\right)×\left|{\mathbf{incx}}\right|-1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of x are not referenced.
4:     $\mathrm{incx}$int64int32nag_int scalar
The increment in the subscripts of x between successive elements of $x$.
Constraint: ${\mathbf{incx}}\ne 0$.
5:     $\mathrm{beta}$ – complex scalar
The scalar $\beta$.
6:     $\mathrm{y}\left(1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incy}}\right|\right)$ – complex array
The $n$-element vector $y$.
If ${\mathbf{incy}}>0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(1+\left(\mathit{i}-1\right)×{\mathbf{incy}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incy}}<0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(1-\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{incy}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of y are not referenced.
7:     $\mathrm{incy}$int64int32nag_int scalar
The increment in the subscripts of y between successive elements of $y$.
Constraint: ${\mathbf{incy}}\ne 0$.
8:     $\mathrm{incw}$int64int32nag_int scalar
The increment in the subscripts of w between successive elements of $w$.
Constraint: ${\mathbf{incw}}\ne 0$.

None.

### Output Parameters

1:     $\mathrm{w}\left(1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incw}}\right|\right)$ – complex array
The $n$-element vector $w$.
If ${\mathbf{incw}}>0$, ${w}_{i}$ is in ${\mathbf{w}}\left(1+\left(\mathit{i}-1\right)×{\mathbf{incw}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incw}}<0$, ${w}_{i}$ is in ${\mathbf{w}}\left(1+\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{incw}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of w are not referenced.

## Error Indicators and Warnings

If ${\mathbf{incx}}=0$ or ${\mathbf{incy}}=0$ or ${\mathbf{incw}}=0$, an error message is printed and program execution is terminated.

## Accuracy

The BLAS standard requires accurate implementations which avoid unnecessary over/underflow (see Section 2.7 of Basic Linear Algebra Subprograms Technical (BLAST) Forum (2001)).

None.

## Example

This example computes the result of a scaled vector accumulation for
 $α=3+2i, x = -6+1.2i,3.7+4.5i,-4+2.1iT , β=-i, y = -5.1,6.4-5i,-3-2.4iT .$
$x$ and $y$, and also the sum vector $w$, are stored in reverse order.
```function f16gh_example

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

n = int64(3);
x = [ -4 + 2.1i    3.7 + 4.5i     -6   + 1.2i];
y = [ -3 - 2.4i    6.4 - 5.0i     -5.1 + 0.0i];

% z = alpha*x +beta*y;
alpha =  3 + 2i;
beta  =  0 - 1i;

fprintf('w = alpha*x + beta*y\n');
fprintf('alpha = %5.1f%+5.1fi      beta = %5.1f%+5.1fi\n', ...
real(alpha), imag(alpha), real(beta), imag(beta));

incx = int64(1);
incy = int64(1);
incw = int64(1);
[w] = f16gh( ...
n, alpha, x, incx, beta, y, incy, incw);

disp('          x                  y                  w');
disp([x; y; w']');

```
```f16gh example results

w = alpha*x + beta*y
alpha =   3.0 +2.0i      beta =   0.0 -1.0i
x                  y                  w
-4.0000 - 2.1000i  -3.0000 + 2.4000i -18.6000 + 1.3000i
3.7000 - 4.5000i   6.4000 + 5.0000i  -2.9000 +14.5000i
-6.0000 - 1.2000i  -5.1000 + 0.0000i -20.4000 - 3.3000i

```