Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_linsys_real_blkdiag_fac_solve (f04lh)

## Purpose

nag_linsys_real_blkdiag_fac_solve (f04lh) calculates the approximate solution of a set of real linear equations with multiple right-hand sides, AX = B$AX=B$ or ATX = B${A}^{\mathrm{T}}X=B$, where A$A$ is an almost block-diagonal matrix which has been factorized by nag_matop_real_gen_blkdiag_lu (f01lh).

## Syntax

[b, ifail] = f04lh(trans, blkstr, a, pivot, b, 'n', n, 'nbloks', nbloks, 'lena', lena, 'ir', ir)
[b, ifail] = nag_linsys_real_blkdiag_fac_solve(trans, blkstr, a, pivot, b, 'n', n, 'nbloks', nbloks, 'lena', lena, 'ir', ir)

## Description

nag_linsys_real_blkdiag_fac_solve (f04lh) solves a set of real linear equations AX = B$AX=B$ or ATX = B${A}^{\mathrm{T}}X=B$, where A$A$ is almost block-diagonal. A$A$ must first be factorized by nag_matop_real_gen_blkdiag_lu (f01lh). nag_linsys_real_blkdiag_fac_solve (f04lh) then computes X$X$ by forward and backward substitution over the blocks.

## References

Diaz J C, Fairweather G and Keast P (1983) Fortran packages for solving certain almost block diagonal linear systems by modified alternate row and column elimination ACM Trans. Math. Software 9 358–375

## Parameters

### Compulsory Input Parameters

1:     trans – string (length ≥ 1)
Specifies the equations to be solved.
trans = 'N'${\mathbf{trans}}=\text{'N'}$
Solve AX = B$AX=B$.
trans = 'T'${\mathbf{trans}}=\text{'T'}$
Solve ATX = B${A}^{\mathrm{T}}X=B$.
Constraint: trans = 'N'${\mathbf{trans}}=\text{'N'}$ or 'T'$\text{'T'}$.
2:     blkstr(3$3$,nbloks) – int64int32nag_int array
Information which describes the block structure of A$A$, as supplied to nag_linsys_real_blkdiag_fac_solve (f04lh).
3:     a(lena) – double array
lena, the dimension of the array, must satisfy the constraint lenak = 1nbloksblkstr(1,k) × blkstr(2,k)${\mathbf{lena}}\ge \sum _{k=1}^{{\mathbf{nbloks}}}{\mathbf{blkstr}}\left(1,k\right)×{\mathbf{blkstr}}\left(2,k\right)$.
The elements in the factorization of A$A$, as returned by nag_linsys_real_blkdiag_fac_solve (f04lh).
4:     pivot(n) – int64int32nag_int array
n, the dimension of the array, must satisfy the constraint n > 0${\mathbf{n}}>0$.
Details of the interchanges in the factorization, as returned by nag_linsys_real_blkdiag_fac_solve (f04lh).
5:     b(ldb,ir) – double array
ldb, the first dimension of the array, must satisfy the constraint ldbn$\mathit{ldb}\ge {\mathbf{n}}$.
The n$n$ by r$r$ right-hand side matrix B$B$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array pivot and the first dimension of the array b. (An error is raised if these dimensions are not equal.)
n$n$, the order of the matrix A$A$.
Constraint: n > 0${\mathbf{n}}>0$.
2:     nbloks – int64int32nag_int scalar
Default: The dimension of the array blkstr.
The total number of blocks of the matrix A$A$, as supplied to nag_linsys_real_blkdiag_fac_solve (f04lh).
Constraint: 0 < nbloksn$0<{\mathbf{nbloks}}\le {\mathbf{n}}$.
3:     lena – int64int32nag_int scalar
Default: The dimension of the array a.
The dimension of the array a as declared in the (sub)program from which nag_linsys_real_blkdiag_fac_solve (f04lh) is called.
Constraint: lenak = 1nbloksblkstr(1,k) × blkstr(2,k)${\mathbf{lena}}\ge \sum _{k=1}^{{\mathbf{nbloks}}}{\mathbf{blkstr}}\left(1,k\right)×{\mathbf{blkstr}}\left(2,k\right)$.
4:     ir – int64int32nag_int scalar
Default: The second dimension of the array b.
r$r$, the number of right-hand sides.
Constraint: ir > 0${\mathbf{ir}}>0$.

ldb

### Output Parameters

1:     b(ldb,ir) – double array
ldbn$\mathit{ldb}\ge {\mathbf{n}}$.
b stores the n$n$ by r$r$ solution matrix X$X$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 1${\mathbf{n}}<1$, or nbloks < 1${\mathbf{nbloks}}<1$, or ir < 1${\mathbf{ir}}<1$, or ldb < n$\mathit{ldb}<{\mathbf{n}}$, or ${\mathbf{n}}<{\mathbf{nbloks}}$, or lena is too small, or illegal values detected in blkstr, or trans ≠ 'N'${\mathbf{trans}}\ne \text{'N'}$ or 'T'$\text{'T'}$.

## Accuracy

The accuracy of the computed solution depends on the conditioning of the original matrix A$A$.

None.

## Example

```function nag_linsys_real_blkdiag_fac_solve_example
trans = 'N';
n = int64(18);
blkstr = [int64(2),4,5,3,4;4,7,8,6,5;3,4,2,3,0];
a = [-1;
-1;
-0.98;
0.25;
-0.79;
-0.87;
-0.15;
0.35;
0.78;
-0.82;
-0.83;
-0.21;
0.31;
0.12;
-0.98;
-0.93;
-0.85;
-0.01;
-0.58;
-0.84;
0.89;
0.75;
0.04;
0.37;
-0.69;
0.32;
0.87;
-0.94;
-0.98;
-1;
0.38;
-0.96;
-0.76;
-0.53;
-1;
-1;
-0.99;
-0.87;
-0.93;
0.85;
0.17;
-0.91;
-0.14;
-0.91;
-0.39;
-1.37;
-0.28;
-1;
0.1;
0.79;
1.29;
0.9;
-0.59;
-0.89;
-0.71;
-1.59;
0.78;
-0.99;
-0.68;
0.39;
1.1;
-0.93;
0.21;
-0.09;
-0.99;
-1.63;
-0.76;
-0.73;
-0.58;
-0.12;
-1.01;
0.48;
-0.48;
-0.21;
-0.75;
-0.27;
0.08;
-0.67;
-0.24;
0.61;
0.56;
-0.41;
0.54;
-0.99;
0.4;
-0.41;
0.16;
-0.93;
0.16;
-0.16;
0.7;
-0.46;
0.98;
0.43;
0.71;
-0.47;
-0.25;
0.89;
-0.97;
-0.98;
-0.92;
-0.94;
-0.6;
-0.73;
-0.52;
-0.54;
-0.3;
0.07;
-0.46;
-1;
0.18;
0.04;
-0.58;
-0.36];
tol = 0;
b = [-2.92;
-1.27;
-1.3;
-1.17;
-2.1;
-4.51;
-1.71;
-4.59;
-4.19;
-0.93;
-3.31;
0.52;
-0.12;
-0.05;
-0.98;
-2.07;
-2.73;
-1.95];
[a, pivot, tol, index, ifail] = nag_matop_real_gen_blkdiag_lu(n, blkstr, a, tol);
[bOut, ifail] = nag_linsys_real_blkdiag_fac_solve(trans, blkstr, a, pivot, b)
```
```

bOut =

1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000

ifail =

0

```
```function f04lh_example
trans = 'N';
n = int64(18);
blkstr = [int64(2),4,5,3,4;4,7,8,6,5;3,4,2,3,0];
a = [-1;
-1;
-0.98;
0.25;
-0.79;
-0.87;
-0.15;
0.35;
0.78;
-0.82;
-0.83;
-0.21;
0.31;
0.12;
-0.98;
-0.93;
-0.85;
-0.01;
-0.58;
-0.84;
0.89;
0.75;
0.04;
0.37;
-0.69;
0.32;
0.87;
-0.94;
-0.98;
-1;
0.38;
-0.96;
-0.76;
-0.53;
-1;
-1;
-0.99;
-0.87;
-0.93;
0.85;
0.17;
-0.91;
-0.14;
-0.91;
-0.39;
-1.37;
-0.28;
-1;
0.1;
0.79;
1.29;
0.9;
-0.59;
-0.89;
-0.71;
-1.59;
0.78;
-0.99;
-0.68;
0.39;
1.1;
-0.93;
0.21;
-0.09;
-0.99;
-1.63;
-0.76;
-0.73;
-0.58;
-0.12;
-1.01;
0.48;
-0.48;
-0.21;
-0.75;
-0.27;
0.08;
-0.67;
-0.24;
0.61;
0.56;
-0.41;
0.54;
-0.99;
0.4;
-0.41;
0.16;
-0.93;
0.16;
-0.16;
0.7;
-0.46;
0.98;
0.43;
0.71;
-0.47;
-0.25;
0.89;
-0.97;
-0.98;
-0.92;
-0.94;
-0.6;
-0.73;
-0.52;
-0.54;
-0.3;
0.07;
-0.46;
-1;
0.18;
0.04;
-0.58;
-0.36];
tol = 0;
b = [-2.92;
-1.27;
-1.3;
-1.17;
-2.1;
-4.51;
-1.71;
-4.59;
-4.19;
-0.93;
-3.31;
0.52;
-0.12;
-0.05;
-0.98;
-2.07;
-2.73;
-1.95];
[a, pivot, tol, index, ifail] = f01lh(n, blkstr, a, tol);
[bOut, ifail] = f04lh(trans, blkstr, a, pivot, b)
```
```

bOut =

1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000

ifail =

0

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013