diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /math/slalib/svdcov.f | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'math/slalib/svdcov.f')
-rw-r--r-- | math/slalib/svdcov.f | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/math/slalib/svdcov.f b/math/slalib/svdcov.f new file mode 100644 index 00000000..02a6be0e --- /dev/null +++ b/math/slalib/svdcov.f @@ -0,0 +1,78 @@ + SUBROUTINE slSVDC (N, NP, NC, W, V, WORK, CVM) +*+ +* - - - - - - - +* S V D C +* - - - - - - - +* +* From the W and V matrices from the SVD factorisation of a matrix +* (as obtained from the slSVD routine), obtain the covariance matrix. +* +* (double precision) +* +* Given: +* N i number of rows and columns in matrices W and V +* NP i first dimension of array containing matrix V +* NC i first dimension of array to receive CVM +* W d(N) NxN diagonal matrix W (diagonal elements only) +* V d(NP,NP) array containing NxN orthogonal matrix V +* +* Returned: +* WORK d(N) workspace +* CVM d(NC,NC) array to receive covariance matrix +* +* Reference: +* Numerical Recipes, section 14.3. +* +* P.T.Wallace Starlink December 1988 +* +* Copyright (C) 1995 Rutherford Appleton Laboratory +* +* License: +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program (see SLA_CONDITIONS); if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +* Copyright (C) 1995 Association of Universities for Research in Astronomy Inc. +*- + + IMPLICIT NONE + + INTEGER N,NP,NC + DOUBLE PRECISION W(N),V(NP,NP),WORK(N),CVM(NC,NC) + + INTEGER I,J,K + DOUBLE PRECISION S + + + + DO I=1,N + S=W(I) + IF (S.NE.0D0) THEN + WORK(I)=1D0/(S*S) + ELSE + WORK(I)=0D0 + END IF + END DO + DO I=1,N + DO J=1,I + S=0D0 + DO K=1,N + S=S+V(I,K)*V(J,K)*WORK(K) + END DO + CVM(I,J)=S + CVM(J,I)=S + END DO + END DO + + END |