# NAG Library Function Document

## 1Purpose

nag_dpotrs (f07fec) solves a real symmetric positive definite system of linear equations with multiple right-hand sides,
 $AX=B ,$
where $A$ has been factorized by nag_dpotrf (f07fdc).

## 2Specification

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

## 3Description

nag_dpotrs (f07fec) is used to solve a real symmetric positive definite system of linear equations $AX=B$, this function must be preceded by a call to nag_dpotrf (f07fdc) which computes the Cholesky factorization of $A$. The solution $X$ is computed by forward and backward substitution.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, $A={U}^{\mathrm{T}}U$, where $U$ is upper triangular; the solution $X$ is computed by solving ${U}^{\mathrm{T}}Y=B$ and then $UX=Y$.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, $A=L{L}^{\mathrm{T}}$, where $L$ is lower triangular; the solution $X$ is computed by solving $LY=B$ and then ${L}^{\mathrm{T}}X=Y$.

## 4References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5Arguments

1:    $\mathbf{order}$Nag_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.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{uplo}$Nag_UploTypeInput
On entry: specifies how $A$ has been factorized.
${\mathbf{uplo}}=\mathrm{Nag_Upper}$
$A={U}^{\mathrm{T}}U$, where $U$ is upper triangular.
${\mathbf{uplo}}=\mathrm{Nag_Lower}$
$A=L{L}^{\mathrm{T}}$, where $L$ is lower triangular.
Constraint: ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
3:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4:    $\mathbf{nrhs}$IntegerInput
On entry: $r$, the number of right-hand sides.
Constraint: ${\mathbf{nrhs}}\ge 0$.
5:    $\mathbf{a}\left[\mathit{dim}\right]$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)$.
On entry: the Cholesky factor of $A$, as returned by nag_dpotrf (f07fdc).
6:    $\mathbf{pda}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
7:    $\mathbf{b}\left[\mathit{dim}\right]$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: the $n$ by $r$ solution matrix $X$.
8:    $\mathbf{pdb}$IntegerInput
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)$.
9:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
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.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

For each right-hand side vector $b$, the computed solution $x$ is the exact solution of a perturbed system of equations $\left(A+E\right)x=b$, where
• if ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, $\left|E\right|\le c\left(n\right)\epsilon \left|{U}^{\mathrm{T}}\right|\left|U\right|$;
• if ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, $\left|E\right|\le c\left(n\right)\epsilon \left|L\right|\left|{L}^{\mathrm{T}}\right|$,
$c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision.
If $\stackrel{^}{x}$ is the true solution, then the computed solution $x$ satisfies a forward error bound of the form
 $x-x^∞ x∞ ≤cncondA,xε$
where $\mathrm{cond}\left(A,x\right)={‖\left|{A}^{-1}\right|\left|A\right|\left|x\right|‖}_{\infty }/{‖x‖}_{\infty }\le \mathrm{cond}\left(A\right)={‖\left|{A}^{-1}\right|\left|A\right|‖}_{\infty }\le {\kappa }_{\infty }\left(A\right)$.
Note that $\mathrm{cond}\left(A,x\right)$ can be much smaller than $\mathrm{cond}\left(A\right)$.
Forward and backward error bounds can be computed by calling nag_dporfs (f07fhc), and an estimate for ${\kappa }_{\infty }\left(A\right)$ ($\text{}={\kappa }_{1}\left(A\right)$) can be obtained by calling nag_dpocon (f07fgc).

## 8Parallelism and Performance

nag_dpotrs (f07fec) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_dpotrs (f07fec) 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9Further Comments

The total number of floating-point operations is approximately $2{n}^{2}r$.
This function may be followed by a call to nag_dporfs (f07fhc) to refine the solution and return an error estimate.
The complex analogue of this function is nag_zpotrs (f07fsc).

## 10Example

This example solves the system of equations $AX=B$, where
 $A= 4.16 -3.12 0.56 -0.10 -3.12 5.03 -0.83 1.18 0.56 -0.83 0.76 0.34 -0.10 1.18 0.34 1.18 and B= 8.70 8.30 -13.35 2.13 1.89 1.61 -4.14 5.00 .$
Here $A$ is symmetric positive definite and must first be factorized by nag_dpotrf (f07fdc).

### 10.1Program Text

Program Text (f07fece.c)

### 10.2Program Data

Program Data (f07fece.d)

### 10.3Program Results

Program Results (f07fece.r)

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