# NAG Library Routine Document

## 1Purpose

f06fjf updates the Euclidean norm of real vector in scaled form.

## 2Specification

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

## 3Description

Given an $n$-element real vector $x$, and real scalars $\alpha$ and $\xi$, f06fjf returns updated values $\stackrel{~}{\alpha }$ and $\stackrel{~}{\xi }$ such that
 $α~2ξ~=x12+x22+⋯+xn2+α2ξ.$
f06fjf is designed for use in the safe computation of the Euclidean norm of a real vector, without unnecessary overflow or destructive underflow. An initial call to f06fjf (with $\xi =1$ and $\alpha =0$) may be followed by further calls to f06fjf and finally a call to f06bmf to complete the computation. Multiple calls of f06fjf 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)$ – Real (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 f06fjf ${\mathbf{scal}}=0.0$.
Constraint: ${\mathbf{scal}}\ge 0.0$.
On exit: the updated scaling factor $\stackrel{~}{\alpha }=\underset{i}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left(\alpha ,\left|{x}_{i}\right|\right)$.
5:     $\mathbf{sumsq}$ – Real (Kind=nag_wp)Input/Output
On entry: the scaled sum of squares $\xi$. On the first call to f06fjf ${\mathbf{sumsq}}=1.0$.
Constraint: ${\mathbf{sumsq}}\ge 1.0$.
On exit: the updated scaled sum of squares $\stackrel{~}{\xi }$, satisfying: $1\le \stackrel{~}{\xi }\le \xi +n$.

None.

Not applicable.

## 8Parallelism and Performance

f06fjf is not threaded in any implementation.