/* Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, N.Y. 13730 */ /* Program: */ /* */ /* PR - Computes inverse B of matrix A using */ /* Pan-Reif algorithm. */ /* */ /* Version: Date: */ /* */ /* Eco-C 1.1 04/25/86 */ /* */ /* Description: */ /* */ /* lda - Leading dimension of matrix A. */ /* n - Order of matrix A. */ /* Iterx - Maximum allowed iterations. */ /* Residx - Convergence criterion. */ /* */ /* Subprograms: */ /* */ /* SDOT from BLAS */ /* SSCAL from BLAS */ /* SASUM from BLAS */ /* SCOPY from BLAS */ /* */ /* Reference: */ /* */ /* The Inversion of Large Matrices */ /* Thomas E. Phipps, Jr. */ /* BYTE Magazine */ /* April, 1986 */ /* */ /* Authors: */ /* */ /* Adam Fritz */ /* 133 Main Street */ /* Afton, New York 13730 */ /* initialize inverse */ Initialize() { int i ; float rs, cs ; /* row and column sums */ float rx, cx ; /* maximum row and column sums */ float SASUM() ; float t ; /* temporary variable */ /* compute scaling factor */ rx = cx = 0.0 ; for ( i=0; i rx) rx = rs ; if ((cs = SASUM(n, &A[0][i], lda)) > cx) cx = cs ; } t = 1.0/(rx*cx) ; Š /ª initializå inverså bù trans- */ /ª posinç anä scalinç originaì */ /ª matriø */ for ( i=0; i resid) resid = t ; } t = 1.0 + R[i][i] ; R[i][i] = t ; t = Abs(t) ; if (t > resid) resid = t ; } return ( resid ) ; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ UpdateInverse() { int i, j ; float t, SDOT() ; /* update residual matrix */ for ( i=0; i Residx) && (iter++ < Iterx)) UpdateInverse() ; /* return iteration count */ Iterx = iter ; } /* Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, N.Y. 13730 */