f07 Chapter Contents
f07 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_dsysv (f07mac)

## 1  Purpose

nag_dsysv (f07mac) computes the solution to a real system of linear equations
 $AX=B ,$
where $A$ is an $n$ by $n$ symmetric matrix and $X$ and $B$ are $n$ by $r$ matrices.

## 2  Specification

 #include #include
 void nag_dsysv (Nag_OrderType order, Nag_UploType uplo, Integer n, Integer nrhs, double a[], Integer pda, Integer ipiv[], double b[], Integer pdb, NagError *fail)

## 3  Description

nag_dsysv (f07mac) uses the diagonal pivoting method to factor $A$ as
 order uplo $\mathbit{A}$ Nag_ColMajor Nag_Upper $UD{U}^{\mathrm{T}}$ Nag_ColMajor Nag_Lower $LD{L}^{\mathrm{T}}$ Nag_RowMajor Nag_Upper ${U}^{\mathrm{T}}DU$ Nag_RowMajor Nag_Lower ${L}^{\mathrm{T}}DL$
where $U$ (or $L$) is a product of permutation and unit upper (lower) triangular matrices, and $D$ is symmetric and block diagonal with $1$ by $1$ and $2$ by $2$ diagonal blocks. The factored form of $A$ is then used to solve the system of equations $AX=B$.
Note that, in general, different permutations (pivot sequences) and diagonal block structures are obtained for ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$

## 4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 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 $\mathrm{Nag_ColMajor}$.
2:     uploNag_UploTypeInput
On entry: if ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the upper triangle of $A$ is stored.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the lower triangle of $A$ is stored.
Constraint: ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
3:     nIntegerInput
On entry: $n$, the number of linear equations, i.e., the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4:     nrhsIntegerInput
On entry: $r$, the number of right-hand sides, i.e., the number of columns of the matrix $B$.
Constraint: ${\mathbf{nrhs}}\ge 0$.
5:     a[$\mathit{dim}$]doubleInput/Output
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)$.
On entry: the $n$ by $n$ symmetric matrix $A$.
If ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${A}_{ij}$ is stored in ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$.
If ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${A}_{ij}$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the upper triangular part of $A$ must be stored and the elements of the array below the diagonal are not referenced.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the lower triangular part of $A$ must be stored and the elements of the array above the diagonal are not referenced.
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, the block diagonal matrix $D$ and the multipliers used to obtain the factor $U$ or $L$ from the factorization $A=UD{U}^{\mathrm{T}}$, $A=LD{L}^{\mathrm{T}}$, $A={U}^{\mathrm{T}}DU$ or $A={L}^{\mathrm{T}}DL$ as computed by nag_dsytrf (f07mdc).
6:     pdaIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix $A$ in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
7:     ipiv[$\mathit{dim}$]IntegerOutput
Note: the dimension, dim, of the array ipiv must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On exit: details of the interchanges and the block structure of $D$. More precisely,
• if ${\mathbf{ipiv}}\left[i-1\right]=k>0$, ${d}_{ii}$ is a $1$ by $1$ pivot block and the $i$th row and column of $A$ were interchanged with the $k$th row and column;
• if ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ and ${\mathbf{ipiv}}\left[i-2\right]={\mathbf{ipiv}}\left[i-1\right]=-l<0$, $\left(\begin{array}{cc}{d}_{i-1,i-1}& {\stackrel{-}{d}}_{i,i-1}\\ {\stackrel{-}{d}}_{i,i-1}& {d}_{ii}\end{array}\right)$ is a $2$ by $2$ pivot block and the $\left(i-1\right)$th row and column of $A$ were interchanged with the $l$th row and column;
• if ${\mathbf{uplo}}=\mathrm{Nag_Lower}$ and ${\mathbf{ipiv}}\left[i-1\right]={\mathbf{ipiv}}\left[i\right]=-m<0$, $\left(\begin{array}{cc}{d}_{ii}& {d}_{i+1,i}\\ {d}_{i+1,i}& {d}_{i+1,i+1}\end{array}\right)$ is a $2$ by $2$ pivot block and the $\left(i+1\right)$th row and column of $A$ were interchanged with the $m$th row and column.
8:     b[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array b must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdb}}×{\mathbf{nrhs}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdb}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $B$ is stored in
• ${\mathbf{b}}\left[\left(j-1\right)×{\mathbf{pdb}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n$ by $r$ right-hand side matrix $B$.
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, the $n$ by $r$ solution matrix $X$.
9:     pdbIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
10:   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.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{nrhs}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nrhs}}\ge 0$.
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}>0$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}>0$.
NE_INT_2
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)$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nrhs}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\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_SINGULAR
$D\left(⟨\mathit{\text{value}}⟩,⟨\mathit{\text{value}}⟩\right)$ is exactly zero. The factorization has been completed, but the block diagonal matrix $D$ is exactly singular, so the solution could not be computed.

## 7  Accuracy

The computed solution for a single right-hand side, $\stackrel{^}{x}$, satisfies an equation of the form
 $A+E x^=b ,$
where
 $E1 = Oε A1$
and $\epsilon$ is the machine precision. An approximate error bound for the computed solution is given by
 $x^-x1 x1 ≤ κA E1 A1 ,$
where $\kappa \left(A\right)={‖{A}^{-1}‖}_{1}{‖A‖}_{1}$, the condition number of $A$ with respect to the solution of the linear equations. See Section 4.4 of Anderson et al. (1999) for further details.
nag_dsysvx (f07mbc) is a comprehensive LAPACK driver that returns forward and backward error bounds and an estimate of the condition number. Alternatively, nag_real_sym_lin_solve (f04bhc) solves $Ax=b$ and returns a forward error bound and condition estimate. nag_real_sym_lin_solve (f04bhc) calls nag_dsysv (f07mac) to solve the equations.

## 8  Parallelism and Performance

nag_dsysv (f07mac) is not threaded by NAG in any implementation.
nag_dsysv (f07mac) 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.

The total number of floating-point operations is approximately $\frac{1}{3}{n}^{3}+2{n}^{2}r$, where $r$ is the number of right-hand sides.
The complex analogues of nag_dsysv (f07mac) are nag_zhesv (f07mnc) for Hermitian matrices, and nag_zsysv (f07nnc) for symmetric matrices.

## 10  Example

This example solves the equations
 $Ax=b ,$
where $A$ is the symmetric matrix
 $A = -1.81 2.06 0.63 -1.15 2.06 1.15 1.87 4.20 0.63 1.87 -0.21 3.87 -1.15 4.20 3.87 2.07 and b = 0.96 6.07 8.38 9.50 .$
Details of the factorization of $A$ are also output.

### 10.1  Program Text

Program Text (f07mace.c)

### 10.2  Program Data

Program Data (f07mace.d)

### 10.3  Program Results

Program Results (f07mace.r)