Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dsvdc(3P) — Sun WorkShop 5.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

dsvdc(3P)

NAME

dsvdc - compute the singular value decomposition of a general matrix A. 

SYNOPSIS

SUBROUTINE DSVDC (DA, LDA, N, P, DSVALS, DE, DLSVEC, LDL, DRSVEC, LDR, DWORK, JOB, INFO)

SUBROUTINE SSVDC (SA, LDA, N, P, SSVALS, SE, SLSVEC, LDL, SRSVEC, LDR, SWORK, JOB, INFO)

SUBROUTINE ZSVDC (ZA, LDA, N, P, ZSVALS, ZE, ZLSVEC, LDL, ZRSVEC, LDR, ZWORK, JOB, INFO)

SUBROUTINE CSVDC (CA, LDA, N, P, CSVALS, CE, CLSVEC, LDL, CRSVEC, LDR, CWORK, JOB, INFO)

 

#include <sunperf.h>

void dsvdc(double ∗dx, int ldx, int n, int p, double ∗s, double ∗e, double ∗du, int ldu, double ∗v, int ldv, int job, int ∗info) ;

void ssvdc(float ∗sx, int ldx, int n, int p, float ∗s, float ∗e, float ∗su, int ldu, float ∗v, int ldv, int job, int ∗info) ;

void zsvdc(doublecomplex ∗zx, int ldx, int n, int p, doublecomplex ∗s, doublecomplex ∗e, doublecomplex ∗u, int ldu, doublecomplex ∗v, int ldv, int job, int ∗info) ;

void csvdc(complex ∗cx, int ldx, int n, int p, complex ∗s, complex ∗e, complex ∗cu, int ldu, complex ∗v, int ldv, int job, int ∗info) ;

ARGUMENTS

xA Matrix A. 

LDA Leading dimension of the array A as specified in a dimension or type statement.  LDA >= max(1,N). 

N Number of rows of the matrix A.  N >= 0. 

P Number of columns of the matrix A.  P >= 0. 

xSVALS On exit, the singular values of A arranged in descending order of magnitude. 

xE On exit, normally contains zero, but see INFO below. 

xLSVEC On exit, the matrix of left singular vectors; not referenced if the a digit of JOB = 0. 

LDL Leading dimension of LSVEC as specified in a dimension or type statement.  LDL >= max(1,N). 

xRSVEC On exit, the matrix of right singular vectors; not referenced if the b digit of JOB = 0. 

LDR Leading dimension of RSVEC as specified in a dimension or type statement.  LDR >= max(1,P). 

xWORK Scratch array with a dimension of N. 

JOB Integer in the form ab; determines operation subroutine will perform:
a = 0do not compute the left singular vectors
a = 1return the n left singular vectors in LSVEC
a ∗ 2return the first min(N,P) singular vectors in LSVEC
b = 0do not compute the right singular vectors
b = 1return the right singular vectors in RSVEC

INFO On exit, the singular values and their corresponding singular vectors SVALS(INFO+1), SVALS(INFO+2),...,SVALS(min(N,P)) are correct.  If INFO = 0 then all singular values and singular vectors are correct.  The matrix B defined as LSVECT ∗ A ∗ RSVEC is the bidiagonal matrix with S on its diagonal and E on its superdiagonal.  Therefore the singular values of A and B are the same. 

SAMPLE PROGRAM

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           JOB, LDL, LDR, LDX, N, P
      PARAMETER        (JOB = 21)
      PARAMETER        (N = 3)
      PARAMETER        (P = 3)
      PARAMETER        (LDL = N)
      PARAMETER        (LDR = P)
      PARAMETER        (LDX = N)
C
      DOUBLE PRECISION  EPSLON, EXCEPT(P), LSVALS(LDL,N)
      DOUBLE PRECISION  RSVALS(LDR,P), SVALS(N), WORK(N), X(LDX,P)
      INTEGER           I, ICOL, INFO, IRANK, IROW
C
      EXTERNAL          DSVDC
      INTRINSIC         ABS, SQRT
C
C     Initialize the array X to store the matrix X shown below.
C
C         1  1  3
C     X = 0  1  1
C         1  0  1
C
      DATA X / 1.0D0, 0.0D0, 1.0D0, 1.0D0, 1.0D0, 0.0D0,
     $         3.0D0, 1.0D0, 1.0D0 /
C
      PRINT 1000
      PRINT 1010, ((X(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
      CALL DSVDC (X, LDX, N, P, SVALS, EXCEPT, LSVALS, LDL,
     $            RSVALS, LDR, WORK, JOB, INFO)
      PRINT 1020
      PRINT 1030, SVALS
C
C     Compute the unit roundoff
C
      EPSLON = 1.0D0
   10 IF (DBLE (1.0D0 + EPSLON) .NE. 1.0D0) THEN
        EPSLON = EPSLON / 2.0D0
        GO TO 10
      END IF
C
C     Make a conservative estimate of the rank of A.
C
      IRANK = 0
      EPSLON = SQRT (EPSLON + EPSLON)
      DO 20, I = 1, N
        IF (ABS(SVALS(I)) .GT. EPSLON) THEN
          IRANK = IRANK + 1
        END IF
   20 CONTINUE
      PRINT 1040, IRANK
C
 1000 FORMAT (1X, ’X:’)
 1010 FORMAT (3(3X, F4.1))
 1020 FORMAT (/1X, ’Singular values of X:’)
 1030 FORMAT (3X, F4.1)
 1040 FORMAT (/1X, ’The rank of X is ’, I1)
C
      END

SAMPLE OUTPUT

 
 X:
    1.0    1.0    3.0
    0.0    1.0    1.0
    1.0    0.0    1.0
 
 Singular values of X:
    3.7
    1.0
    0.3
 
 The rank of X is 3

SunOS 5.0  —  Last change: 10 Dec 1998

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026