<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Kerrie,<br>
    <br>
    They should be different by a factor of 1/(n-1), since eofunc is
    computing the covariance matrix itself. In your case, that factor is
    exactly 1/3.<br>
    <br>
    best wishes,<br>
    <br>
    gil<br>
    <br>
    <br>
    <br>
    On 11/29/11 2:14 PM, Kerrie Geil wrote:
    <blockquote
cite="mid:CAKBe+-ARF8sVMzHmmQM=R_wTWhgGAwgZj57H98FW_RN+3qsSfw@mail.gmail.com"
      type="cite">Hi All,<br>
      <br>
      Can anyone tell me why the singular value decomposition
      (svd_lapack) below yields different eigenvalues than the
      eigenanalysis (eofunc, eofunc_ts), while both output the exact
      same EOFs and PCs? Can't see what I'm doing wrong.&nbsp; Code and
      output are below.<br>
      <br>
      Thanks!<br>
      Kerrie<br>
      <br>
      <br>
;######################################################################################<br>
      ;### data array A=(/ntime,nspace/) ###<br>
      A=(/ (/-2.,1./),(/7.,-8./),(/-3.,0./),(/5.,-9./) /)<br>
      A!0="time"<br>
      A!1="space"<br>
      ntime=4&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;;### number of rows, time dimension 0 ###<br>
      nspace=2&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;;### number of columns, space dimension 1 ###<br>
      <br>
      &nbsp;&nbsp; &nbsp;Aprime&nbsp;&nbsp;&nbsp; = dim_rmvmean_n(A,0)<br>
      &nbsp;&nbsp; &nbsp;;### singular value decomposition of Aprime ###&nbsp;&nbsp; &nbsp;<br>
      &nbsp;&nbsp; &nbsp;;### Aprime=(u)(s)(vtranspose)-----&gt; (4x2)=(4x2)(2x2)(2x2)
      ###<br>
      &nbsp;&nbsp; &nbsp;u&nbsp;&nbsp; = new ( (/ntime,nspace/) , float ) &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;###
      columns of u are PC eigenvectors ###<br>
      &nbsp; &nbsp; vtranspose &nbsp; = new ( (/nspace,nspace/) , float
      )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;### rows of vtranspose are EOF eigenvectors
      ###<br>
      &nbsp;&nbsp; &nbsp;s&nbsp;&nbsp; = svd_lapack (Aprime, "S" , "S", 0,&nbsp; vtranspose, u)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
      &nbsp;;### s^2=eigenvalues<br>
      &nbsp;&nbsp; &nbsp;;### s is returned with only the non-zero (diagonal) values<br>
      <br>
      &nbsp;&nbsp; &nbsp;print("for SVD")<br>
      &nbsp;&nbsp; &nbsp;print("U:")<br>
      &nbsp;&nbsp; &nbsp;write_matrix (u, "2f10.4", False)<br>
      &nbsp;&nbsp; &nbsp;print("V:")<br>
      &nbsp;&nbsp; &nbsp;write_matrix (vtranspose, "2f10.4", False)<br>
      &nbsp;&nbsp; &nbsp;print("lambda:")<br>
      &nbsp;&nbsp; &nbsp;print(s^2)<br>
      <br>
      <br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;At=transpose(A)&nbsp;&nbsp; &nbsp;;### make time the rightmost dimension
      ###<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eof=eofunc(At,2,False)&nbsp;&nbsp; &nbsp;;### rows of eof are EOFs ###<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eoftranspose=transpose(eof)<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pc=eofunc_ts_Wrap(At,eof,False)&nbsp;&nbsp; &nbsp;;### rows of pc are PCs
      ###<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pctranspose=transpose(pc)&nbsp;&nbsp; &nbsp;;### for similarity to SVD
      matrices, now columns of pc are PCs ###<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pc_colsum=dim_sum_n(pctranspose^2,0)&nbsp;&nbsp; &nbsp;;### square each
      component and sum the columns ###<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pctranspose(:,0)=pctranspose(:,0)/sqrt(pc_colsum(0))&nbsp;&nbsp;
      &nbsp;;### normalize PC1<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pctranspose(:,1)=pctranspose(:,1)/sqrt(pc_colsum(1))&nbsp;&nbsp;
      &nbsp;;### normalize PC2<br>
      <br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print("for eofunc")<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print("U:")<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;write_matrix (pctranspose, "2f10.4", False)<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print("V:")<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;write_matrix (eof, "2f10.4", False)<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print("lambda:")<br>
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print(eof@eval)<br>
;######################################################################################<br>
      <br>
      <br>
      OUPUT IS:<br>
      <br>
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; for SVD</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; U:</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp; 0.5010&nbsp;&nbsp;&nbsp; 0.4050</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp; -0.5261&nbsp;&nbsp;&nbsp; 0.5745</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp; 0.4983&nbsp;&nbsp; -0.3748</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp; -0.4732&nbsp;&nbsp; -0.6046</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; V:</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp; -0.6898&nbsp;&nbsp;&nbsp; 0.7240</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp; 0.7240&nbsp;&nbsp;&nbsp; 0.6898</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; lambda:</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; 153.4626</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(1)&nbsp;&nbsp;&nbsp; 3.287447</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; </span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; </span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; for eofunc</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; U:</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp; 0.5010&nbsp;&nbsp;&nbsp; 0.4050</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp; -0.5261&nbsp;&nbsp;&nbsp; 0.5745</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp; 0.4983&nbsp;&nbsp; -0.3748</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp; -0.4732&nbsp;&nbsp; -0.6046</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; V:</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp; -0.6898&nbsp;&nbsp;&nbsp; 0.7240</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp; 0.7240&nbsp;&nbsp;&nbsp; 0.6898</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">&nbsp; </span><br style="color:
        rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; lambda:</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(0)&nbsp;&nbsp;&nbsp; 51.15419</span><br
        style="color: rgb(51, 51, 255);">
      <span style="color: rgb(51, 51, 255);">(1)&nbsp;&nbsp;&nbsp; 1.095816</span><br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++
Gil Compo, Research Scientist, CIRES
University of Colorado 

Mail : CIRES Climate Diagnostics Center
NOAA Physical Sciences Division
Earth System Research Laboratory
325 Broadway R/PSD1, Boulder, CO 80305-3328
Email: <a class="moz-txt-link-abbreviated" href="mailto:compo@colorado.edu">compo@colorado.edu</a>
Phone: (303) 497-6115 Fax: (303) 497-6449
<a class="moz-txt-link-freetext" href="http://www.esrl.noaa.gov/psd/people/gilbert.p.compo">http://www.esrl.noaa.gov/psd/people/gilbert.p.compo</a>
+++++++++++++++++++++++++++++++++++++++++++++++++++
"Stop and consider the wondrous works of God."
 Job 37:34
--------------------------------------------------- 
The contents of this message are mine personally 
and do not necessarily reflect any position of 
NOAA or the University of Colorado.
</pre>
  </body>
</html>