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_zamax_val (f16js)

## Purpose

nag_blast_zamax_val (f16js) computes, with respect to absolute value, the largest component of a complex vector, along with the index of that component.

## Syntax

[k, r] = f16js(n, x, incx)
[k, r] = nag_blast_zamax_val(n, x, incx)

## Description

nag_blast_zamax_val (f16js) computes, with respect to absolute value, the largest component, $r$, of an $n$-element complex vector $x$, and determines the smallest index, $k$, such that
 $r = Re⁡xk + Im⁡xk = maxj Re⁡xj + Im⁡xj .$

## 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$.
2:     $\mathrm{x}\left(1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incx}}\right|\right)$ – complex array
The vector $x$. Element ${x}_{\mathit{i}}$ is stored in ${\mathbf{x}}\left(\left(\mathit{i}-1\right)×\left|{\mathbf{incx}}\right|+1\right)$, for $\mathit{i}=1,2,\dots ,n$.
3:     $\mathrm{incx}$int64int32nag_int scalar
The increment in the subscripts of x between successive elements of $x$.
Constraint: ${\mathbf{incx}}\ne 0$.

None.

### Output Parameters

1:     $\mathrm{k}$int64int32nag_int scalar
$k$, the index, from the set $\left\{1,2,\dots ,{\mathbf{n}}\right\}$, of the largest component of $x$ with respect to absolute value. If ${\mathbf{n}}\le 0$ on input then k is returned as $0$.
2:     $\mathrm{r}$ – double scalar
$r$, the largest component of $x$ with respect to absolute value. If ${\mathbf{n}}\le 0$ on input then r is returned as $0.0$.

None.

## 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 largest component with respect to absolute value and index of that component for the vector
 $x= -4+2.1i,3.7+4.5i,-6+1.2iT .$
```function f16js_example

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

% maxabs complex and location
n    = int64(3);
x    = [ -4 + 2.1i      3.7 + 4.5i      -6 + 1.2i];
incx = int64(1);

[xloc, xmax] = f16js(n, x, incx);

fprintf('maxabs(x) = |x(%4d)| = %5.1f\n', xloc, xmax);

```
```f16js example results

maxabs(x) = |x(   2)| =   8.2
```