f04 Chapter Contents
f04 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_complex_lin_eqn_mult_rhs (f04adc)

## 1  Purpose

nag_complex_lin_eqn_mult_rhs (f04adc) calculates the solution of a set of complex linear equations with multiple right-hand sides.

## 2  Specification

 #include #include
 void nag_complex_lin_eqn_mult_rhs (Integer n, Integer nrhs, Complex a[], Integer tda, const Complex b[], Integer tdb, Complex x[], Integer tdx, NagError *fail)

## 3  Description

Given a set of complex linear equations $AX=B$, the function first 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 side matrix $B$.

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
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}}$]ComplexInput/Output
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: the $n$ by $n$ matrix $A$.
On exit: $A$ is overwritten by the lower triangular matrix $L$ and the off-diagonal elements of the upper triangular matrix $U$. The unit diagonal elements of $U$ are not stored.
4:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge {\mathbf{n}}$.
5:     b[${\mathbf{n}}×{\mathbf{tdb}}$]const ComplexInput
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$.
6:     tdbIntegerInput
On entry: the stride separating matrix column elements in the array b.
Constraint: ${\mathbf{tdb}}\ge {\mathbf{nrhs}}$.
7:     x[${\mathbf{n}}×{\mathbf{tdx}}$]ComplexOutput
Note: the $\left(i,j\right)$th element of the matrix $X$ is stored in ${\mathbf{x}}\left[\left(i-1\right)×{\mathbf{tdx}}+j-1\right]$.
On exit: the $n$ by $r$ solution matrix $X$. See also Section 6.
8:     tdxIntegerInput
On entry: the stride separating matrix column elements in the array x.
Constraint: ${\mathbf{tdx}}\ge {\mathbf{nrhs}}$.
9:     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}}〉$. The 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}}$.
On entry, ${\mathbf{tdx}}=〈\mathit{\text{value}}〉$ while ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdx}}\ge {\mathbf{nrhs}}$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
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$.
NE_SINGULAR
The matrix $A$ is singular, possibly due to rounding errors.

## 7  Accuracy

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

## 8  Further Comments

The time taken by nag_complex_lin_eqn_mult_rhs (f04adc) is approximately proportional to ${n}^{3}$.
The function may be called with the same array supplied for arguments b and x, in which case the solution vectors will overwrite the right-hand sides.

## 9  Example

To solve the set of linear equations $AX=B$ where
 $A = 1 1 + 2 i 2 + 10 i 1 + i 3 i -5 + 14 i 1 + i 5 i -8 + 20 i and B = 1 0 0 .$