Rev 47490 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
c-----------------------------------------------------------------------cc R : A Computer Langage for Statistical Data Analysisc Copyright (C) 1996, 1997 Robert Gentleman and Ross Ihakac Copyright (C) 2001-08 The R Development Core Teamcc This program is free software; you can redistribute it and/or modifyc it under the terms of the GNU General Public License as published byc the Free Software Foundation; either version 2 of the License, orc (at your option) any later version.cc This program is distributed in the hope that it will be useful,c but WITHOUT ANY WARRANTY; without even the implied warranty ofc MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thec GNU General Public License for more details.cc You should have received a copy of the GNU General Public Licensec along with this program; if not, a copy is available atc http://www.r-project.org/Licenses/cc-----------------------------------------------------------------------cc ch2inv(x, ldx, n, v, info) computes the inverse of a positive-definitec symmetric matrix from its choleski factorization.c This can be used, e.g., to compute the dispersion matrix for the estimatedc parameters in a regression analysis.cc On Entrycc x double precision(ldx,n) {ldx >= n}c the choleski decomposition or the qr decompositionc as computed by dqrdc or dqrdc2. Only thec UPPER TRIANGULAR part, x(i,j), 1 <= i <= j <= n, is accessed.cc ldx integer, ldx >= nc the leading dimension of the array xcc n integerc the number of rows and columns of the matrix xcc On Returncc v double precision(n,n)c the value of inverse(x'x)cc This version dated Aug 24, 1996.c Ross Ihaka, University of Auckland.cc This is currently only used via R's chol2inv(..., LINPACK = TRUE)c which is said to be only for compatibility with R < 1.7.0csubroutine ch2inv(x, ldx, n, v, info)c implicit noneinteger n, ldx, infodouble precision x(ldx, n), v(n, n)cdouble precision d(2)integer i, jcdo 20 i=1,nif(x(i,i) .eq. 0.0d0) theninfo = ireturnend ifdo 10 j=i,nv(i,j) = x(i,j)10 continue20 continuecall dpodi(v, n, n, d, 1)do 40 i=2,ndo 30 j=1,i-1v(i,j) = v(j,i)30 continue40 continuereturnend