F04 Chapter Contents
F04 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF04AJF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F04AJF calculates the approximate solution of a set of real linear equations with multiple right-hand sides, $AX=B$, where $A$ has been factorized by F03AFF.

## 2  Specification

 SUBROUTINE F04AJF ( N, IR, A, LDA, P, B, LDB)
 INTEGER N, IR, LDA, LDB REAL (KIND=nag_wp) A(LDA,N), P(N), B(LDB,IR)

## 3  Description

To solve a set of real linear equations $AX=B$, F04AJF must be preceded by a call to F03AFF 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  Parameters

1:     N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 1$.
2:     IR – INTEGERInput
On entry: $r$, the number of right-hand sides.
3:     A(LDA,N) – REAL (KIND=nag_wp) arrayInput
On entry: details of the $LU$ factorization, as returned by F03AEF.
4:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F04AJF is called.
Constraint: ${\mathbf{LDA}}\ge {\mathbf{N}}$.
5:     P(N) – REAL (KIND=nag_wp) arrayInput
On entry: details of the row interchanges as returned by F03AFF.
6:     B(LDB,IR) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the $n$ by $r$ right-hand side matrix $B$.
On exit: B is overwritten by the solution matrix $X$.
7:     LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F04AJF is called.
Constraint: ${\mathbf{LDB}}\ge {\mathbf{N}}$.

## 6  Error Indicators and Warnings

If an error is detected in an input parameter F04AJF will act as if a soft noisy exit has been requested (see Section 3.3.4 in the Essential Introduction).

## 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 F04AJF is approximately proportional to ${n}^{2}r$.

## 9  Example

This example solves 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 (f04ajfe.f90)

### 9.2  Program Data

Program Data (f04ajfe.d)

### 9.3  Program Results

Program Results (f04ajfe.r)