1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>FreeMat: SVD Singular Value Decomposition of a Matrix</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">FreeMat
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('transforms_svd.html','');});
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">SVD Singular Value Decomposition of a Matrix </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Section: <a class="el" href="sec_transforms.html">Transforms/Decompositions</a> </p>
<h1><a class="anchor" id="Usage"></a>
Usage</h1>
<p>Computes the singular value decomposition (SVD) of a matrix. The <code>svd</code> function has three forms. The first returns only the singular values of the matrix: </p>
<pre class="fragment"> s = svd(A)
</pre><p> The second form returns both the singular values in a diagonal matrix <code>S</code>, as well as the left and right eigenvectors. </p>
<pre class="fragment"> [U,S,V] = svd(A)
</pre><p> The third form returns a more compact decomposition, with the left and right singular vectors corresponding to zero singular values being eliminated. The syntax is </p>
<pre class="fragment"> [U,S,V] = svd(A,0)
</pre> <h1><a class="anchor" id="Function"></a>
Internals</h1>
<p>Recall that <code>sigma_i</code> is a singular value of an <code>M x N</code> matrix <code>A</code> if there exists two vectors <code>u_i, v_i</code> where <code>u_i</code> is of length <code>M</code>, and <code>v_i</code> is of length <code>u_i</code> and </p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ A v_i = \sigma_i u_i \]" src="form_161.png"/>
</p>
<p> and generally </p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ A = \sum_{i=1}^{K} \sigma_i u_i*v_i', \]" src="form_162.png"/>
</p>
<p> where <code>K</code> is the rank of <code>A</code>. In matrix form, the left singular vectors <code>u_i</code> are stored in the matrix <code>U</code> as </p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ U = [u_1,\ldots,u_m], V = [v_1,\ldots,v_n] \]" src="form_163.png"/>
</p>
<p> The matrix <code>S</code> is then of size <code>M x N</code> with the singular values along the diagonal. The SVD is computed using the <code>LAPACK</code> class of functions <code>GESVD</code> (Note that this has changed. Previous versions of FreeMat used <code>GESDD</code>, which yields a valid, but slightly different choice of the decomposition. Starting in version 4, it was changed to <code>GESVD</code> to improve compatibility. </p>
<h1><a class="anchor" id="Examples"></a>
Examples</h1>
<p>Here is an example of a partial and complete singular value decomposition.</p>
<pre class="fragment">--> A = float(randn(2,3))
A =
0.1962 -1.7828 -1.0621
-0.6022 -0.6335 0.5810
--> [U,S,V] = svd(A)
U =
-0.9929 -0.1189
-0.1189 0.9929
S =
2.0957 0 0
0 1.0268 0
V =
-0.0588 -0.6051 0.7940
0.8806 -0.4061 -0.2443
0.4702 0.6848 0.5567
--> U*S*V'
ans =
0.1962 -1.7828 -1.0621
-0.6022 -0.6335 0.5810
--> svd(A)
ans =
2.0957
1.0268
</pre> </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="index.html">FreeMat Documentation</a></li><li class="navelem"><a class="el" href="sec_transforms.html">Transforms/Decompositions</a></li>
<li class="footer">Generated on Thu Jul 25 2013 17:18:29 for FreeMat by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.1.1 </li>
</ul>
</div>
</body>
</html>
|