hide long namesshow long names
hide short namesshow short names
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_matop_real_gen_blkdiag_lu (f01lh)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_matop_real_gen_blkdiag_lu (f01lh) factorizes a real almost block diagonal matrix.

Syntax

[a, pivot, tol, kpivot, ifail] = f01lh(n, blkstr, a, tol, 'nbloks', nbloks, 'lena', lena)
[a, pivot, tol, kpivot, ifail] = nag_matop_real_gen_blkdiag_lu(n, blkstr, a, tol, 'nbloks', nbloks, 'lena', lena)

Description

nag_matop_real_gen_blkdiag_lu (f01lh) factorizes a real almost block diagonal matrix, A, by row elimination with alternate row and column pivoting such that no ‘fill-in’ is produced. The code, which is derived from ARCECO described in Diaz et al. (1983), uses Level 1 and Level 2 BLAS. No three successive diagonal blocks may have columns in common and therefore the almost block diagonal matrix must have the form shown in the following diagram:
Figure 1
Figure 1
This function may be followed by nag_linsys_real_blkdiag_fac_solve (f04lh), which is designed to solve sets of linear equations AX=B or ATX=B.

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:     n int64int32nag_int scalar
n, the order of the matrix A.
Constraint: n>0.
2:     blkstr3nbloks int64int32nag_int array
Information which describes the block structure of A as follows:
  • blkstr1k must contain the number of rows in the kth block, k=1,2,,nbloks;
  • blkstr2k must contain the number of columns in the kth block, k=1,2,,nbloks;
  • blkstr3k must contain the number of columns of overlap between the kth and k+1th blocks, k=1,2,,nbloks-1. blkstr3nbloks need not be set.
The following conditions delimit the structure of A:
  • blkstr1k,blkstr2k>0,  k=1,2,,nbloks,
  • blkstr3k0,   k=1,2,,nbloks-1,
(there must be at least one column and one row in each block and a non-negative number of columns of overlap);
  • blkstr3k-1+blkstr3kblkstr2k,  k=2,3,,nbloks-1,
(the total number of columns in overlaps in each block must not exceed the number of columns in that block);
  • blkstr21blkstr11,
  • blkstr21 + k =2 j blkstr2 k -blkstr3 k -1 k =1 j blkstr1 k , j=2,3,,nbloks-1 ,
  • k=1jblkstr2k-blkstr3kk=1jblkstr1k,  j=1,2,,nbloks-1,
(the index of the first column of the overlap between the jth and j+1th blocks must be  the index of the last row of the jth block, and the index of the last column of overlap must be  the index of the last row of the jth block);
  • k =1 nbloks blkstr1 k =n ,
  • blkstr21 + k =2 nbloks blkstr2 k -blkstr3 k -1 =nk ,
(both the number of rows and the number of columns of A must equal n).
3:     alena – double array
The elements of the almost block diagonal matrix stored block by block, with each block stored column by column. The sizes of the blocks and the overlaps are defined by the argument blkstr.
If ars is the first element in the kth block, then an arbitrary element aij in the kth block must be stored in the array element:
a pk+ j-r mk+ i-s+1  
where
pk=l= 1 k- 1blkstr1l×blkstr2l  
is the base address of the kth block, and
mk=blkstr1k  
is the number of rows of the kth block.
See Further Comments for comments on scaling.
4:     tol – double scalar
A relative tolerance to be used to indicate whether or not the matrix is singular. For a discussion on how tol is used see Further Comments. If tol is non-positive, then tol is reset to 10ε, where ε is the machine precision.

Optional Input Parameters

1:     nbloks int64int32nag_int scalar
Default: the dimension of the array blkstr.
n, the total number of blocks of the matrix A.
Constraint: 0<nbloksn.
2:     lena int64int32nag_int scalar
Default: the dimension of the array a.
The dimension of the array a.
Constraint: lena k =1 nbloks blkstr1 k × blkstr2 k .

Output Parameters

1:     alena – double array
The factorized form of the matrix.
2:     pivotn int64int32nag_int array
Details of the interchanges.
3:     tol – double scalar
Unchanged unless tol0.0 on entry, in which case it is set to 10ε.
4:     kpivot int64int32nag_int scalar
If ifail=2, kpivot contains the value k, where k is the first position on the diagonal of the matrix A where too small a pivot was detected. Otherwise kpivot is set to 0.
5:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
On entry,n<1,
ornbloks<1,
orn<nbloks,
orlena is too small,
orillegal values detected in blkstr.
W  ifail=2
The factorization has been completed, but a small pivot has been detected.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The accuracy of nag_matop_real_gen_blkdiag_lu (f01lh) depends on the conditioning of the matrix A.

Further Comments

Singularity or near singularity in A is determined by the argument tol. If the absolute value of any pivot is less than tol×amax, where amax is the maximum absolute value of an element of A, then A is said to be singular. The position on the diagonal of A of the first of any such pivots is indicated by the argument kpivot. The factorization, and the test for near singularity, will be more accurate if before entry A is scaled so that the -norms of the rows and columns of A are all of approximately the same order of magnitude. (The -norm is the maximum absolute value of any element in the row or column.)

Example

This example solves the set of linear equations Ax=b where
A= -1.00 -0.98 -0.79 -0.15 -1.00 -0.25 -0.87 0.35 0.78 0.31 -0.85 0.89 -0.69 -0.98 -0.76 -0.82 0.12 -0.01 0.75 0.32 -1.00 -0.53 -0.83 -0.98 -0.58 0.04 0.87 0.38 -1.00 -0.21 -0.93 -0.84 0.37 -0.94 -0.96 -1.00 -0.99 -0.91 -0.28 -0.90 0.78 -0.93 -0.76 0.48 -0.87 -0.14 -1.00 -0.59 -0.99 0.21 -0.73 -0.48 -0.93 -0.91 0.10 -0.89 -0.68 -0.09 -0.58 -0.21 0.85 -0.39 0.79 -0.71 0.39 -0.99 -0.12 -0.75 0.17 -1.37 1.29 -1.59 1.10 -1.63 -1.01 -0.27 0.08 0.61 0.54 -0.41 0.16 -0.46 -0.67 0.56 -0.99 0.16 -0.16 0.98 -0.24 -0.41 0.40 -0.93 0.70 0.43 0.71 -0.97 -0.60 -0.30 0.18 -0.47 -0.98 -0.73 0.07 0.04 -0.25 -0.92 -0.52 -0.46 -0.58 -0.89 -0.94 -0.54 -1.00 -0.36  
and
b= -2.92 -1.17 -1.30 -1.17 -2.10 -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  
The exact solution is
x=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1T.  
function f01lh_example


fprintf('f01lh example results\n\n');

% Block structure of A
n = int64(18);
blkstr = [int64(2),4,5,3,4;
                  4, 7,8,6,5;
                  3, 4,2,3,0];
a1 = [-1.00  -0.98  -0.79  -0.15;
      -1.00   0.25  -0.87   0.35];
a2 = [ 0.78   0.31  -0.85   0.89  -0.69  -0.98 -0.76;
      -0.82   0.12  -0.01   0.75   0.32  -1.00 -0.53;
      -0.83  -0.98  -0.58   0.04   0.87   0.38 -1.00;
      -0.21  -0.93  -0.84   0.37  -0.94  -0.96 -1.00];
a3 = [-0.99  -0.91  -0.28   0.90   0.78  -0.93  -0.76   0.48;
      -0.87  -0.14  -1.00  -0.59  -0.99   0.21  -0.73  -0.48;
      -0.93  -0.91   0.10  -0.89  -0.68  -0.09  -0.58  -0.21;
       0.85  -0.39   0.79  -0.71   0.39  -0.99  -0.12  -0.75;
       0.17  -1.37   1.29  -1.59   1.10  -1.63  -1.01  -0.27];
a4 = [ 0.08   0.61   0.54  -0.41   0.16  -0.46;
      -0.67   0.56  -0.99   0.16  -0.16   0.98;
      -0.24  -0.41   0.40  -0.93   0.70   0.43];
a5 = [ 0.71  -0.97  -0.60  -0.30   0.18; 
      -0.47  -0.98  -0.73   0.07   0.04; 
      -0.25  -0.92  -0.52  -0.46  -0.58; 
       0.89  -0.94  -0.54  -1.00  -0.36];
% Flatten A
a = [reshape(a1,[ 8,1]);
     reshape(a2,[28,1]);
     reshape(a3,[40,1]);
     reshape(a4,[18,1]);
     reshape(a5,[20,1])];

% Right hand side     
b  = [-2.92;  -1.27;  -1.30;  -1.17;  -2.10;  -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];
    
% Factorize A
tol = 0;
[AF, pivot, tol, index, ifail] = ...
f01lh(n, blkstr, a, tol);

% Solve system
trans = 'N';
[x, ifail] = f04lh( ...
                    trans, blkstr, AF, pivot, b);
disp('Component solution');
disp(x);


f01lh example results

Component solution
    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


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–2015