nag_dgeequ (f07afc) (PDF version)
f07 Chapter Contents
f07 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_dgeequ (f07afc)

## 1  Purpose

nag_dgeequ (f07afc) computes diagonal scaling matrices ${D}_{R}$ and ${D}_{C}$ intended to equilibrate a real $m$ by $n$ matrix $A$ and reduce its condition number.

## 2  Specification

 #include #include
 void nag_dgeequ (Nag_OrderType order, Integer m, Integer n, const double a[], Integer pda, double r[], double c[], double *rowcnd, double *colcnd, double *amax, NagError *fail)

## 3  Description

nag_dgeequ (f07afc) computes the diagonal scaling matrices. The diagonal scaling matrices are chosen to try to make the elements of largest absolute value in each row and column of the matrix $B$ given by
 $B=DRADC$
have absolute value $1$. The diagonal elements of ${D}_{R}$ and ${D}_{C}$ are restricted to lie in the safe range $\left(\delta ,1/\delta \right)$, where $\delta$ is the value returned by function nag_real_safe_small_number (X02AMC). Use of these scaling factors is not guaranteed to reduce the condition number of $A$ but works well in practice.

None.

## 5  Arguments

1:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or Nag_ColMajor.
2:     mIntegerInput
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
3:     nIntegerInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4:     a[$\mathit{dim}$]const doubleInput
Note: the dimension, dim, of the array a must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{n}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}×{\mathbf{pda}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $A$ is stored in
• ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the matrix $A$ whose scaling factors are to be computed.
5:     pdaIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
6:     r[m]doubleOutput
On exit: if NE_NOERROR or NE_MAT_COL_ZERO, r contains the row scale factors, the diagonal elements of ${D}_{R}$. The elements of r will be positive.
7:     c[n]doubleOutput
On exit: if NE_NOERROR, c contains the column scale factors, the diagonal elements of ${D}_{C}$. The elements of c will be positive.
8:     rowcnddouble *Output
On exit: if NE_NOERROR or NE_MAT_COL_ZERO, rowcnd contains the ratio of the smallest value of ${\mathbf{r}}\left[i-1\right]$ to the largest value of ${\mathbf{r}}\left[i-1\right]$. If ${\mathbf{rowcnd}}\ge 0.1$ and amax is neither too large nor too small, it is not worth scaling by ${D}_{R}$.
9:     colcnddouble *Output
On exit: if NE_NOERROR, colcnd contains the ratio of the smallest value of ${\mathbf{c}}\left[i-1\right]$ to the largest value of ${\mathbf{c}}\left[i-1\right]$.
If ${\mathbf{colcnd}}\ge 0.1$, it is not worth scaling by ${D}_{C}$.
10:   amaxdouble *Output
On exit: $\mathrm{max}\left|{a}_{ij}\right|$. If amax is very close to overflow or underflow, the matrix $A$ should be scaled.
11:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}>0$.
NE_INT_2
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$ and ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_MAT_COL_ZERO
The $〈\mathit{\text{value}}〉$ column of $A$ is exactly zero.
NE_MAT_ROW_ZERO
The $〈\mathit{\text{value}}〉$ row of $A$ is exactly zero.

## 7  Accuracy

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

## 8  Further Comments

The complex analogue of this function is nag_zgeequ (f07atc).

## 9  Example

This example equilibrates the general matrix $A$ given by
 $A = -1.80×1010 -2.88×1010 -2.05 -8.90×109 -5.25 -2.95 -9.50×10-9 -3.80 -1.58 -2.69 -2.90×10-10 -1.04 -1.11 -0.66 -5.90×10-11 -0.80 .$
Details of the scaling factors, and the scaled matrix are output.

### 9.1  Program Text

Program Text (f07afce.c)

### 9.2  Program Data

Program Data (f07afce.d)

### 9.3  Program Results

Program Results (f07afce.r)

nag_dgeequ (f07afc) (PDF version)
f07 Chapter Contents
f07 Chapter Introduction
NAG C Library Manual