# NAG Library Routine Document

## 1Purpose

f11mgf computes an estimate of the reciprocal of the condition number of a sparse matrix given an $LU$ factorization of the matrix computed by f11mef.

## 2Specification

Fortran Interface
 Subroutine f11mgf ( norm, n, il, lval, iu, uval,
 Integer, Intent (In) :: n, il(*), iu(*) Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: lval(*), uval(*), anorm Real (Kind=nag_wp), Intent (Out) :: rcond Character (1), Intent (In) :: norm
#include nagmk26.h
 void f11mgf_ ( const char *norm, const Integer *n, const Integer il[], const double lval[], const Integer iu[], const double uval[], const double *anorm, double *rcond, Integer *ifail, const Charlen length_norm)

## 3Description

f11mgf estimates the condition number of a real sparse matrix $A$, in either the $1$-norm or the $\infty$-norm:
 $κ1A=A1 A-11 or κ∞A=A∞ A-1∞.$
Note that ${\kappa }_{\infty }\left(A\right)={\kappa }_{1}\left({A}^{\mathrm{T}}\right)$.
Because the condition number is infinite if $A$ is singular, the routine actually returns an estimate of the reciprocal of the condition number.
The routine should be preceded by a call to f11mlf to compute ${‖A‖}_{1}$ or ${‖A‖}_{\infty }$, and a call to f11mef to compute the $LU$ factorization of $A$. The routine then estimates ${‖{A}^{-1}‖}_{1}$ or ${‖{A}^{-1}‖}_{\infty }$ and computes the reciprocal of the condition number.

None.

## 5Arguments

1:     $\mathbf{norm}$ – Character(1)Input
On entry: indicates whether ${\kappa }_{1}\left(A\right)$ or ${\kappa }_{\infty }\left(A\right)$ is to be estimated.
${\mathbf{norm}}=\text{'1'}$ or $\text{'O'}$
${\kappa }_{1}\left(A\right)$ is estimated.
${\mathbf{norm}}=\text{'I'}$
${\kappa }_{\infty }\left(A\right)$ is estimated.
Constraint: ${\mathbf{norm}}=\text{'1'}$, $\text{'O'}$ or $\text{'I'}$.
2:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
3:     $\mathbf{il}\left(*\right)$ – Integer arrayInput
Note: the dimension of the array il must be at least as large as the dimension of the array of the same name in f11mef.
On entry: records the sparsity pattern of matrix $L$ as computed by f11mef.
4:     $\mathbf{lval}\left(*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the dimension of the array lval must be at least as large as the dimension of the array of the same name in f11mef.
On entry: records the nonzero values of matrix $L$ and some nonzero values of matrix $U$ as computed by f11mef.
5:     $\mathbf{iu}\left(*\right)$ – Integer arrayInput
Note: the dimension of the array iu must be at least as large as the dimension of the array of the same name in f11mef.
On entry: records the sparsity pattern of matrix $U$ as computed by f11mef.
6:     $\mathbf{uval}\left(*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the dimension of the array uval must be at least as large as the dimension of the array of the same name in f11mef.
On entry: records some nonzero values of matrix $U$ as computed by f11mef.
7:     $\mathbf{anorm}$ – Real (Kind=nag_wp)Input
On entry: if ${\mathbf{norm}}=\text{'1'}$ or $\text{'O'}$, the $1$-norm of the matrix $A$.
If ${\mathbf{norm}}=\text{'I'}$, the $\infty$-norm of the matrix $A$.
anorm may be computed by calling f11mlf with the same value for the argument norm.
Constraint: ${\mathbf{anorm}}\ge 0.0$.
8:     $\mathbf{rcond}$ – Real (Kind=nag_wp)Output
On exit: an estimate of the reciprocal of the condition number of $A$. rcond is set to zero if exact singularity is detected or the estimate underflows. If rcond is less than machine precision, $A$ is singular to working precision.
9:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{anorm}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{anorm}}\ge 0.0$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{norm}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{norm}}=\text{'1'}$, $\text{'O'}$ or $\text{'I'}$.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

The computed estimate rcond is never less than the true value $\rho$, and in practice is nearly always less than $10\rho$, although examples can be constructed where rcond is much larger.

## 8Parallelism and Performance

f11mgf 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.

A call to f11mgf involves solving a number of systems of linear equations of the form $Ax=b$ or ${A}^{\mathrm{T}}x=b$.

## 10Example

This example estimates the condition number in the $1$-norm of the matrix $A$, where
 $A= 2.00 1.00 0 0 0 0 0 1.00 -1.00 0 4.00 0 1.00 0 1.00 0 0 0 1.00 2.00 0 -2.00 0 0 3.00 .$
Here $A$ is nonsymmetric and must first be factorized by f11mef. The true condition number in the $1$-norm is $10.875$.

### 10.1Program Text

Program Text (f11mgfe.f90)

### 10.2Program Data

Program Data (f11mgfe.d)

### 10.3Program Results

Program Results (f11mgfe.r)

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