# NAG Library Routine Document

## 1Purpose

f06tpf performs a $QR$ factorization (as a sequence of plane rotations) of a complex upper triangular matrix that has been modified by a rank-1 update.

## 2Specification

Fortran Interface
 Subroutine f06tpf ( n, x, incx, y, incy, a, lda, c, s)
 Integer, Intent (In) :: n, incx, incy, lda Real (Kind=nag_wp), Intent (Out) :: c(n-1) Complex (Kind=nag_wp), Intent (In) :: alpha, y(*) Complex (Kind=nag_wp), Intent (Inout) :: x(*), a(lda,*) Complex (Kind=nag_wp), Intent (Out) :: s(n)
#include nagmk26.h
 void f06tpf_ (const Integer *n, const Complex *alpha, Complex x[], const Integer *incx, const Complex y[], const Integer *incy, Complex a[], const Integer *lda, double c[], Complex s[])

## 3Description

f06tpf performs a $QR$ factorization of an upper triangular matrix which has been modified by a rank-1 update:
 $αxyT + U=QR$
where $U$ and $R$ are $n$ by $n$ complex upper triangular matrices with real diagonal elements, $x$ and $y$ are $n$-element complex vectors, $\alpha$ is a complex scalar, and $Q$ is an $n$ by $n$ complex unitary matrix.
$Q$ is formed as the product of two sequences of plane rotations and a unitary diagonal matrix $D$:
 $QH = DQn-1 ⋯ Q2 Q1 P1 P2 ⋯ Pn-1$
where
• ${P}_{k}$ is a rotation in the $\left(k,n\right)$ plane, chosen to annihilate ${x}_{k}$: thus $Px=\beta {e}_{n}$, where $P={P}_{1}{P}_{2}\cdots {P}_{n-1}$ and ${e}_{n}$ is the last column of the unit matrix;
• ${Q}_{k}$ is a rotation in the $\left(k,n\right)$ plane, chosen to annihilate the $\left(n,k\right)$ element of $\left(\alpha \beta {e}_{n}{y}^{\mathrm{T}}+PU\right)$, and thus restore it to upper triangular form;
• $D=\mathrm{diag}\left(1,\dots ,1,{d}_{n}\right)$, with ${d}_{n}$ chosen to make ${r}_{nn}$ real; $\left|{d}_{n}\right|=1$.
The $2$ by $2$ plane rotation part of ${P}_{k}$ or ${Q}_{k}$ has the form
 $ck s-k -sk ck$
with ${c}_{k}$ real. The tangents of the rotations ${P}_{k}$ are returned in the array x; the cosines and sines of these rotations can be recovered by calling f06bcf. The cosines and sines of the rotations ${Q}_{k}$ are returned directly in the arrays c and s.

None.

## 5Arguments

1:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the order of the matrices $U$ and $R$.
Constraint: ${\mathbf{n}}\ge 0$.
2:     $\mathbf{alpha}$ – Complex (Kind=nag_wp)Input
On entry: the scalar $\alpha$.
3:     $\mathbf{x}\left(*\right)$ – Complex (Kind=nag_wp) arrayInput/Output
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.
On exit: the referenced elements are overwritten by details of the sequence of plane rotations.
4:     $\mathbf{incx}$ – IntegerInput
On entry: the increment in the subscripts of x between successive elements of $x$.
Constraint: ${\mathbf{incx}}>0$.
5:     $\mathbf{y}\left(*\right)$ – Complex (Kind=nag_wp) arrayInput
Note: the dimension of the array y must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,1+\left({\mathbf{n}}-1\right)×{\mathbf{incy}}\right)$.
On entry: the $n$-element vector $y$. ${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}}$.
Intermediate elements of y are not referenced.
6:     $\mathbf{incy}$ – IntegerInput
On entry: the increment in the subscripts of y between successive elements of $y$.
Constraint: ${\mathbf{incy}}>0$.
7:     $\mathbf{a}\left({\mathbf{lda}},*\right)$ – Complex (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array a must be at least ${\mathbf{n}}$.
On entry: the $n$ by $n$ upper triangular matrix $U$. The imaginary parts of the diagonal elements must be zero.
On exit: the upper triangular matrix $R$. The imaginary parts of the diagonal elements must be zero.
8:     $\mathbf{lda}$ – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f06tpf is called.
Constraint: ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
9:     $\mathbf{c}\left({\mathbf{n}}-1\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the cosines of the rotations ${Q}_{\mathit{k}}$, for $\mathit{k}=1,2,\dots ,n-1$.
10:   $\mathbf{s}\left({\mathbf{n}}\right)$ – Complex (Kind=nag_wp) arrayOutput
On exit: the sines of the rotations ${Q}_{\mathit{k}}$, for $\mathit{k}=1,2,\dots ,n-1$; ${\mathbf{s}}\left(n\right)$ holds ${d}_{n}$, the $n$th diagonal element of $D$.

None.

Not applicable.

## 8Parallelism and Performance

f06tpf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10Example

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