home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------//
-
- // Synopsis: Gaussian elimination without pivoting.
-
- // Syntax: GL = ge ( A )
-
- // Description:
-
- // ge computes the factorization A = L*U, where L is unit lower
- // triangular and U is upper triangular. RHO is the growth
- // factor.
-
- // The return value, GL, is a list containing elements:
-
- // L Lower unit triangular matrix.
- // U Upper triangular matrix.
- // RHO Growth factor.
-
- // This file is a translation of ge.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.
-
- //-------------------------------------------------------------------//
-
- ge = function ( A )
- {
- local (A)
-
- n = A.nc;
-
- rho = 0;
- maxA = norm(A[;], "i");
-
- for (k in 1:n-1)
- {
- if (A[k;k] == 0)
- {
- error("Elimination breaks down with zero pivot. Quitting...");
- }
-
- A[k+1:n;k] = A[k+1:n;k]/A[k;k]; // Multipliers.
-
- // Elimination
- i = k+1:n;
- A[i;i] = A[i;i] - A[i;k] * A[k;i];
- rho = max( rho, max(max(abs(A[i;i]))) );
- }
-
- L = tril(A,-1) + eye(n,n);
- U = triu(A);
- rho = rho/maxA;
-
- return << L = L ; U = U; rho = rho >>;
- };
-