svdcov, svdstd

Singular value decomposition functions


Synopsis

    function svdcov(
        x[*][*]      : float,
        y[*][*]      : float,
        nsvd         : integer,
        homlft[*][*] : float,
        hetlft[*][*] : float,
        homrgt[*][*] : float,
        hetrgt[*][*] : float
    )

    function svdstd(
        x[*][*]      : float,
        y[*][*]      : float,
        nsvd         : integer,
        homlft[*][*] : float,
        hetlft[*][*] : float,
        homrgt[*][*] : float,
        hetrgt[*][*] : float
    )


Arguments

x
Two-dimensional input array, dimensioned num_stations in x by time
y
Two-dimensional input array, dimensioned num_stations in y by time
nsvd
scalar integer that specifies the number of SVD patterns to be calculated
homlft
Left homogeneous array (output), a two dimensional array dimensioned nsvd x num_stations in x. Space for this must be explicitly allocated by the user.
hetlft
Left heterogeneous array (output), a two dimensional array dimensioned nsvd x num_stations in x. Space for this must be explicitly allocated by the user.
homrgt
Right homogeneous array (output), a two dimensional array dimensioned nsvd x num_stations in y. Space for this must be explicitly allocated by the user.
hetrgt
right heterogeneous array (output), a two dimensional array dimensioned nsvd x num_stations in y. Space for this must be explicitly allocated by the user.

Description

The functions svdcov and svdstd both compute the singular value decomposition (SVD) of x and y and return the percent variance explained by the patterns (a float array of length nsvd). In addition, svdstd standardizes the input data.

Both of these functions return the following attributes:

fnorm (scalar, float)
fnorm

condn (scalar, float)
condition number

rank (scalar, float)
calculated rank

lapack_err (scalar, float)
LAPACK error code

Example

begin
  ; ================================>  ; PARAMETERS
  ntime   = 8                          ; # time steps
  ncols   = 3                          ; # columns (stations or grid pts) for S
  ncolz   = 6                          ; # columns (stations or grid pts) for Z
  nsvd    = 3                          ; # svd patterns to calculate 
                                       ;   [nsvd <= min(ncols, ncolz) ]
  xmsg    = -999.9                     ; missing value
                                     
; ================================>  ; READ THE ASCII FILE
                                     ; open "files" as 2-D
  s     = asciiread ("svdrdm_S.asc",(/ntime,ncols/), "float")
  z     = asciiread ("svdrdm_Z.asc",(/ntime,ncolz/), "float")

  s!0   = "time"                       ; name dimensions for reordering
  s!1   = "col"
  z!0   = "time"
  z!1   = "col"

  homlft = new((/nsvd,ncols/),float)
  hetlft = new((/nsvd,ncols/),float)
  homrgt = new((/nsvd,ncolz/),float)
  hetrgt = new((/nsvd,ncolz/),float)

  x = svdcov(s(col|:,time|:),z(col|:,time|:),nsvd,homlft,hetlft,homrgt,hetrgt) 
  print("svdcov: percent variance= " + x)
  
  s2 = s(col |:,time |:)                ; for a cleaner look one might do this
  z2 = z(col |:,time |:)
 
  y = svdstd(s2,z2,nsvd,homlft,hetlft,homrgt,hetrgt) 
  print("svdstd: percent variance= " + y)
end

Reference Manual Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?


$Revision: 1.9 $ $Date: 1999/03/19 15:32:28 $