home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------//
-
- // Synopsis: Matrix giving maximal growth factor for Gaussian
- // elim. with pivoting.
-
- // Syntax: G = gfpp ( T )
-
- // Description:
-
- // G is a matrix of order N for which Gaussian elimination with
- // partial pivoting yields a growth factor 2^(N-1). T is an
- // arbitrary nonsingular upper triangular matrix of order
- // N-1. gfpp(T, C) sets all the multipliers to C (0 <= C <= 1)
- // and gives growth factor (1+C)^(N-1). gfpp(N, C) (a special
- // case) is the same as GFPP(EYE(N-1), C) and generates the
- // well-known example of Wilkinson.
-
- // Reference:
- // N.J. Higham and D.J. Higham, Large growth factors in
- // Gaussian elimination with pivoting, SIAM J. Matrix Analysis and
- // Appl., 10 (1989), pp. 155-164.
-
- // This file is a translation of gfpp.m from version 2.0 of
- // "The Test Matrix Toolbox for Matlab", described in Numerical
- // Analysis Report No. 237, December 1993, by N. J. Higham.
-
- //-------------------------------------------------------------------//
-
- gfpp = function ( T , c )
- {
- local (T, c)
-
- if (any(any(T != triu(T))) || any(!diag(T)))
- {
- error("First argument must be a nonsingular upper triangular matrix.");
- }
-
- if (!exist (c)) { c = 1; }
- if (c < 0 || c > 1)
- {
- error("Second parameter must be a scalar between 0 and 1 inclusive.");
- }
-
- m = T.nr; n = T.nc;
- if (m == 1) // Handle the special case T = scalar
- {
- n = T;
- m = n-1;
- T = eye(n-1,n-1);
- else
- n = m+1;
- }
-
- d = 1+c;
- L = eye(n,n) - c*tril(ones(n,n), -1);
- U = [T, (d.^[0:n-2])'; zeros(1,m), d^(n-1)];
- A = L*U;
- theta = max(abs(A[:]));
- A[;n] = (theta/norm(A[;n],inf())) * A[;n];
-
- return A;
- };
-