# NAG Library Routine Document

## 1Purpose

f06kjf updates the Euclidean norm of complex vector in scaled form.

## 2Specification

Fortran Interface
 Subroutine f06kjf ( n, x, incx, scal,
 Integer, Intent (In) :: n, incx Real (Kind=nag_wp), Intent (Inout) :: scal, sumsq Complex (Kind=nag_wp), Intent (In) :: x(*)
C Header Interface
#include nagmk26.h
 void f06kjf_ (const Integer *n, const Complex x[], const Integer *incx, double *scal, double *sumsq)

## 3Description

Given an $n$-element complex vector $x$, and real scalars $\alpha$ and $\xi$, f06kjf returns updated values $\stackrel{~}{\alpha }$ and $\stackrel{~}{\xi }$ such that
 $α~2ξ~=x12+x22+⋯+xn2+α2ξ.$
f06kjf is designed for use in the safe computation of the Euclidean norm of a complex vector, without unnecessary overflow or destructive underflow. An initial call to f06kjf (with $\xi =1$ and $\alpha =0$) may be followed by further calls to f06kjf and finally a call to f06bmf to complete the computation. Multiple calls of f06kjf may be needed if the elements of the vector cannot all be accessed in a single array x.
None.

## 5Arguments

1:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of elements in $x$.
2:     $\mathbf{x}\left(*\right)$ – Complex (Kind=nag_wp) arrayInput
Note: the dimension of the array x must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,1+\left({\mathbf{n}}-1\right)×{\mathbf{incx}}\right)$.
On entry: the $n$-element vector $x$. ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(1+\left(\mathit{i}-1\right)×{\mathbf{incx}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of x are not referenced.
3:     $\mathbf{incx}$ – IntegerInput
On entry: the increment in the subscripts of x between successive elements of $x$.
Constraint: ${\mathbf{incx}}>0$.
4:     $\mathbf{scal}$ – Real (Kind=nag_wp)Input/Output
On entry: the scaling factor $\alpha$. On the first call to f06kjf ${\mathbf{scal}}=0.0$.
Constraint: ${\mathbf{scal}}\ge 0$.
On exit: the updated scaling factor $\stackrel{~}{\alpha }=\underset{i}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left(\alpha ,\left|\mathrm{Re}\left({x}_{i}\right)\right|,\left|\mathrm{Im}\left({x}_{i}\right)\right|\right)$.
5:     $\mathbf{sumsq}$ – Real (Kind=nag_wp)Input/Output
On entry: the scaled sum of squares $\xi$. On the first call to f06kjf ${\mathbf{sumsq}}=1.0$.
Constraint: ${\mathbf{sumsq}}\ge 1$.
On exit: the updated scaled sum of squares $\stackrel{~}{\xi }$, satisfying: $1\le \stackrel{~}{\xi }\le \xi +2n$.

None.

Not applicable.

## 8Parallelism and Performance

f06kjf is not threaded in any implementation.

None.

## 10Example

None.
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017