# NAG FL Interfacef07fff (dpoequ)

## 1Purpose

f07fff computes a diagonal scaling matrix $S$ intended to equilibrate a real $n$ by $n$ symmetric positive definite matrix $A$ and reduce its condition number.

## 2Specification

Fortran Interface
 Subroutine f07fff ( n, a, lda, s, amax, info)
 Integer, Intent (In) :: n, lda Integer, Intent (Out) :: info Real (Kind=nag_wp), Intent (In) :: a(lda,*) Real (Kind=nag_wp), Intent (Out) :: s(n), scond, amax
#include <nag.h>
 void f07fff_ (const Integer *n, const double a[], const Integer *lda, double s[], double *scond, double *amax, Integer *info)
The routine may be called by the names f07fff, nagf_lapacklin_dpoequ or its LAPACK name dpoequ.

## 3Description

f07fff computes a diagonal scaling matrix $S$ chosen so that
 $sj=1 / ajj .$
This means that the matrix $B$ given by
 $B=SAS ,$
has diagonal elements equal to unity. This in turn means that the condition number of $B$, ${\kappa }_{2}\left(B\right)$, is within a factor $n$ of the matrix of smallest possible condition number over all possible choices of diagonal scalings (see Corollary 7.6 of Higham (2002)).
Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
2: $\mathbf{a}\left({\mathbf{lda}},*\right)$Real (Kind=nag_wp) array Input
Note: the second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the matrix $A$ whose scaling factors are to be computed. Only the diagonal elements of the array a are referenced.
3: $\mathbf{lda}$Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f07fff is called.
Constraint: ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
4: $\mathbf{s}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: if ${\mathbf{info}}={\mathbf{0}}$, s contains the diagonal elements of the scaling matrix $S$.
5: $\mathbf{scond}$Real (Kind=nag_wp) Output
On exit: if ${\mathbf{info}}={\mathbf{0}}$, scond contains the ratio of the smallest value of s to the largest value of s. If ${\mathbf{scond}}\ge 0.1$ and amax is neither too large nor too small, it is not worth scaling by $S$.
6: $\mathbf{amax}$Real (Kind=nag_wp) Output
On exit: $\mathrm{max}\left|{a}_{ij}\right|$. If amax is very close to overflow or underflow, the matrix $A$ should be scaled.
7: $\mathbf{info}$Integer Output
On exit: ${\mathbf{info}}=0$ unless the routine detects an error (see Section 6).

## 6Error Indicators and Warnings

${\mathbf{info}}<0$
If ${\mathbf{info}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{info}}>0$
The $〈\mathit{\text{value}}〉$th diagonal element of $A$ is not positive (and hence $A$ cannot be positive definite).

## 7Accuracy

The computed scale factors will be close to the exact scale factors.

## 8Parallelism and Performance

f07fff is not threaded in any implementation.

The complex analogue of this routine is f07ftf.

## 10Example

This example equilibrates the symmetric positive definite matrix $A$ given by
 $A = -4.16 -3.12×105 -0.56 -0.10 -3.12×105 -5.03×1010 -0.83×105 -1.18×105 -0.56 -0.83×105 -0.76 -0.34 -0.10 -1.18×105 -0.34 -1.18 .$
Details of the scaling factors and the scaled matrix are output.

### 10.1Program Text

Program Text (f07fffe.f90)

### 10.2Program Data

Program Data (f07fffe.d)

### 10.3Program Results

Program Results (f07fffe.r)