f04 Chapter Contents
f04 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_real_lu_solve_mult_rhs (f04ajc)

## 1  Purpose

nag_real_lu_solve_mult_rhs (f04ajc) calculates the approximate solution of a set of real linear equations with multiple right-hand sides, $AX=B$, where $A$ has been factorized by nag_real_lu (f03afc).

## 2  Specification

 #include #include
 void nag_real_lu_solve_mult_rhs (Integer n, Integer nrhs, const double a[], Integer tda, const Integer pivot[], double b[], Integer tdb, NagError *fail)

## 3  Description

To solve a set of real linear equations $AX=B$, this function must be preceded by a call to nag_real_lu (f03afc) which computes an $LU$ factorization of $A$ with partial pivoting, $PA=LU$, where $P$ is a permutation matrix, $L$ is lower triangular and $U$ is unit upper triangular. The columns $x$ of the solution $X$ are found by forward and backward substitution in $Ly=Pb$ and $Ux=y$, where $b$ is a column of the right-hand sides.

## 4  References

Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5  Arguments

1:     nIntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 1$.
2:     nrhsIntegerInput
On entry: $r$, the number of right-hand sides.
Constraint: ${\mathbf{nrhs}}\ge 1$.
3:     a[${\mathbf{n}}×{\mathbf{tda}}$]const doubleInput
Note: the $\left(i,j\right)$th element of the matrix $A$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{tda}}+j-1\right]$.
On entry: details of the $LU$ factorization, as returned by nag_real_lu (f03afc).
4:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge {\mathbf{n}}$.
5:     pivot[n]const IntegerInput
On entry: details of the row interchanges as returned by nag_real_lu (f03afc).
6:     b[${\mathbf{n}}×{\mathbf{tdb}}$]doubleInput/Output
Note: the $\left(i,j\right)$th element of the matrix $B$ is stored in ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{tdb}}+j-1\right]$.
On entry: the $n$ by $r$ right-hand side matrix $B$.
On exit: $B$ is overwritten by the solution matrix $X$.
7:     tdbIntegerInput
On entry: the stride separating matrix column elements in the array b.
Constraint: ${\mathbf{tdb}}\ge {\mathbf{nrhs}}$.
8:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, ${\mathbf{tda}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tda}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{tdb}}=〈\mathit{\text{value}}〉$ while ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdb}}\ge {\mathbf{nrhs}}$.
NE_INT_ARG_LT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
On entry, ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nrhs}}\ge 1$.

## 7  Accuracy

The accuracy of the computed solutions depends on the conditioning of the original matrix. For a detailed error analysis see page 106 of Wilkinson and Reinsch (1971).

The time taken by nag_real_lu_solve_mult_rhs (f04ajc) is approximately proportional to ${n}^{2}r$.

## 9  Example

To solve the set of linear equations $AX=B$ where
 $A = 33 16 72 -24 -10 -57 -8 -4 -17 and B = -359 281 85 .$

### 9.1  Program Text

Program Text (f04ajce.c)

### 9.2  Program Data

Program Data (f04ajce.d)

### 9.3  Program Results

Program Results (f04ajce.r)