<!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"/> <meta name="generator" content="Doxygen 1.8.5"/> <title>Eigen: HouseholderQR< MatrixType > Class Template Reference</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); $(window).load(resizeHeight); </script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="eigendoxy.css" rel="stylesheet" type="text/css"> <!-- --> <script type="text/javascript" src="eigen_navtree_hacks.js"></script> <!-- <script type="text/javascript"> --> <!-- </script> --> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <!-- <a name="top"></a> --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td> <td style="padding-left: 0.5em;"> <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>  <span id="projectnumber">3.2.0</span> </div> </td> <td> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.5 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> $(document).ready(function(){initNavTree('classEigen_1_1HouseholderQR.html','');}); </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Pages</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="summary"> <a href="classEigen_1_1HouseholderQR-members.html">List of all members</a> | <a href="#pub-methods">Public Member Functions</a> </div> <div class="headertitle"> <div class="title">HouseholderQR< MatrixType > Class Template Reference<div class="ingroups"><a class="el" href="group__QR__Module.html">QR module</a></div></div> </div> </div><!--header--> <div class="contents"> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><h3>template<typename MatrixType><br/> class Eigen::HouseholderQR< MatrixType ></h3> <p>Householder QR decomposition of a matrix. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">MatrixType</td><td>the type of the matrix of which we are computing the QR decomposition</td></tr> </table> </dd> </dl> <p>This class performs a QR decomposition of a matrix <b>A</b> into matrices <b>Q</b> and <b>R</b> such that </p> <p class="formulaDsp"> <img class="formulaDsp" alt="\[ \mathbf{A} = \mathbf{Q} \, \mathbf{R} \]" src="form_158.png"/> </p> <p> by using Householder transformations. Here, <b>Q</b> a unitary matrix and <b>R</b> an upper triangular matrix. The result is stored in a compact way compatible with LAPACK.</p> <p>Note that no pivoting is performed. This is <b>not</b> a rank-revealing decomposition. If you want that feature, use <a class="el" href="classEigen_1_1FullPivHouseholderQR.html" title="Householder rank-revealing QR decomposition of a matrix with full pivoting. ">FullPivHouseholderQR</a> or <a class="el" href="classEigen_1_1ColPivHouseholderQR.html" title="Householder rank-revealing QR decomposition of a matrix with column-pivoting. ">ColPivHouseholderQR</a> instead.</p> <p>This Householder QR decomposition is faster, but less numerically stable and less feature-full than <a class="el" href="classEigen_1_1FullPivHouseholderQR.html" title="Householder rank-revealing QR decomposition of a matrix with full pivoting. ">FullPivHouseholderQR</a> or <a class="el" href="classEigen_1_1ColPivHouseholderQR.html" title="Householder rank-revealing QR decomposition of a matrix with column-pivoting. ">ColPivHouseholderQR</a>.</p> <dl class="section see"><dt>See Also</dt><dd><a class="el" href="classEigen_1_1MatrixBase.html#abafaafa2e7eb9f485b282041833034bf">MatrixBase::householderQr()</a> </dd></dl> </div><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr class="memitem:a2bb8fa5593d2f447c16ba2e3cfb9c432"><td class="memItemLeft" align="right" valign="top">MatrixType::RealScalar </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#a2bb8fa5593d2f447c16ba2e3cfb9c432">absDeterminant</a> () const </td></tr> <tr class="separator:a2bb8fa5593d2f447c16ba2e3cfb9c432"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a5851b8e7d2a7f91592e7fa69f8b7684c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#a5851b8e7d2a7f91592e7fa69f8b7684c">compute</a> (const MatrixType &matrix)</td></tr> <tr class="separator:a5851b8e7d2a7f91592e7fa69f8b7684c"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a321e96844544eacde2272c3a487048e9"><td class="memItemLeft" align="right" valign="top">const HCoeffsType & </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#a321e96844544eacde2272c3a487048e9">hCoeffs</a> () const </td></tr> <tr class="separator:a321e96844544eacde2272c3a487048e9"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a520fc76215d7722387a76e7b7a484ee0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classEigen_1_1HouseholderSequence.html">HouseholderSequenceType</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#a520fc76215d7722387a76e7b7a484ee0">householderQ</a> () const </td></tr> <tr class="separator:a520fc76215d7722387a76e7b7a484ee0"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab7e9b80266fe7d1592e4c9de652d9f50"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#ab7e9b80266fe7d1592e4c9de652d9f50">HouseholderQR</a> ()</td></tr> <tr class="memdesc:ab7e9b80266fe7d1592e4c9de652d9f50"><td class="mdescLeft"> </td><td class="mdescRight">Default Constructor. <a href="#ab7e9b80266fe7d1592e4c9de652d9f50">More...</a><br/></td></tr> <tr class="separator:ab7e9b80266fe7d1592e4c9de652d9f50"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:abf25ea0833fe1e846c20968103f69141"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#abf25ea0833fe1e846c20968103f69141">HouseholderQR</a> (Index rows, Index cols)</td></tr> <tr class="memdesc:abf25ea0833fe1e846c20968103f69141"><td class="mdescLeft"> </td><td class="mdescRight">Default Constructor with memory preallocation. <a href="#abf25ea0833fe1e846c20968103f69141">More...</a><br/></td></tr> <tr class="separator:abf25ea0833fe1e846c20968103f69141"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab592f6a05d7ba94c0108382baa8c993e"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#ab592f6a05d7ba94c0108382baa8c993e">HouseholderQR</a> (const MatrixType &matrix)</td></tr> <tr class="memdesc:ab592f6a05d7ba94c0108382baa8c993e"><td class="mdescLeft"> </td><td class="mdescRight">Constructs a QR factorization from a given matrix. <a href="#ab592f6a05d7ba94c0108382baa8c993e">More...</a><br/></td></tr> <tr class="separator:ab592f6a05d7ba94c0108382baa8c993e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a82a3f15f0cda1f4f874d50951344b5a9"><td class="memItemLeft" align="right" valign="top">MatrixType::RealScalar </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#a82a3f15f0cda1f4f874d50951344b5a9">logAbsDeterminant</a> () const </td></tr> <tr class="separator:a82a3f15f0cda1f4f874d50951344b5a9"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a7b142db8924dd7fad99acbdd0ff4bdd1"><td class="memItemLeft" align="right" valign="top">const MatrixType & </td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#a7b142db8924dd7fad99acbdd0ff4bdd1">matrixQR</a> () const </td></tr> <tr class="separator:a7b142db8924dd7fad99acbdd0ff4bdd1"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a3912046746c14d7b4e9dba999da46a68"><td class="memTemplParams" colspan="2">template<typename Rhs > </td></tr> <tr class="memitem:a3912046746c14d7b4e9dba999da46a68"><td class="memTemplItemLeft" align="right" valign="top">const internal::solve_retval<br class="typebreak"/> < <a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a>, Rhs > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classEigen_1_1HouseholderQR.html#a3912046746c14d7b4e9dba999da46a68">solve</a> (const <a class="el" href="classEigen_1_1MatrixBase.html">MatrixBase</a>< Rhs > &b) const </td></tr> <tr class="separator:a3912046746c14d7b4e9dba999da46a68"><td class="memSeparator" colspan="2"> </td></tr> </table> <h2 class="groupheader">Constructor & Destructor Documentation</h2> <a class="anchor" id="ab7e9b80266fe7d1592e4c9de652d9f50"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a> </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Default Constructor. </p> <p>The default constructor is useful in cases in which the user intends to perform decompositions via <a class="el" href="classEigen_1_1HouseholderQR.html#a5851b8e7d2a7f91592e7fa69f8b7684c">HouseholderQR::compute(const MatrixType&)</a>. </p> </div> </div> <a class="anchor" id="abf25ea0833fe1e846c20968103f69141"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a> </td> <td>(</td> <td class="paramtype">Index </td> <td class="paramname"><em>rows</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">Index </td> <td class="paramname"><em>cols</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Default Constructor with memory preallocation. </p> <p>Like the default constructor but with preallocation of the internal data according to the specified problem <em>size</em>. </p> <dl class="section see"><dt>See Also</dt><dd><a class="el" href="classEigen_1_1HouseholderQR.html#ab7e9b80266fe7d1592e4c9de652d9f50" title="Default Constructor. ">HouseholderQR()</a> </dd></dl> </div> </div> <a class="anchor" id="ab592f6a05d7ba94c0108382baa8c993e"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a> </td> <td>(</td> <td class="paramtype">const MatrixType & </td> <td class="paramname"><em>matrix</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Constructs a QR factorization from a given matrix. </p> <p>This constructor computes the QR factorization of the matrix <em>matrix</em> by calling the method <a class="el" href="classEigen_1_1HouseholderQR.html#a5851b8e7d2a7f91592e7fa69f8b7684c">compute()</a>. It is a short cut for:</p> <div class="fragment"><div class="line">* HouseholderQR<MatrixType> qr(matrix.rows(), matrix.cols());</div> <div class="line">* qr.compute(matrix);</div> <div class="line">* </div> </div><!-- fragment --><dl class="section see"><dt>See Also</dt><dd><a class="el" href="classEigen_1_1HouseholderQR.html#a5851b8e7d2a7f91592e7fa69f8b7684c">compute()</a> </dd></dl> <p>References <a class="el" href="classEigen_1_1HouseholderQR.html#a5851b8e7d2a7f91592e7fa69f8b7684c">HouseholderQR< MatrixType >::compute()</a>.</p> </div> </div> <h2 class="groupheader">Member Function Documentation</h2> <a class="anchor" id="a2bb8fa5593d2f447c16ba2e3cfb9c432"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">MatrixType::RealScalar absDeterminant </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </div><div class="memdoc"> <dl class="section return"><dt>Returns</dt><dd>the absolute value of the determinant of the matrix of which *this is the QR decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the QR decomposition has already been computed.</dd></dl> <dl class="section note"><dt>Note</dt><dd>This is only for square matrices.</dd></dl> <dl class="section warning"><dt>Warning</dt><dd>a determinant can be very big or small, so for matrices of large enough dimension, there is a risk of overflow/underflow. One way to work around that is to use <a class="el" href="classEigen_1_1HouseholderQR.html#a82a3f15f0cda1f4f874d50951344b5a9">logAbsDeterminant()</a> instead.</dd></dl> <dl class="section see"><dt>See Also</dt><dd><a class="el" href="classEigen_1_1HouseholderQR.html#a82a3f15f0cda1f4f874d50951344b5a9">logAbsDeterminant()</a>, <a class="el" href="classEigen_1_1MatrixBase.html#ad63cea11a4bf220298dce4489a1704c7">MatrixBase::determinant()</a> </dd></dl> </div> </div> <a class="anchor" id="a5851b8e7d2a7f91592e7fa69f8b7684c"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a>< MatrixType > & compute </td> <td>(</td> <td class="paramtype">const MatrixType & </td> <td class="paramname"><em>matrix</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Performs the QR factorization of the given matrix <em>matrix</em>. The result of the factorization is stored into <code>*this</code>, and a reference to <code>*this</code> is returned.</p> <dl class="section see"><dt>See Also</dt><dd>class <a class="el" href="classEigen_1_1HouseholderQR.html" title="Householder QR decomposition of a matrix. ">HouseholderQR</a>, <a class="el" href="classEigen_1_1HouseholderQR.html#ab592f6a05d7ba94c0108382baa8c993e" title="Constructs a QR factorization from a given matrix. ">HouseholderQR(const MatrixType&)</a> </dd></dl> <p>Referenced by <a class="el" href="classEigen_1_1HouseholderQR.html#ab592f6a05d7ba94c0108382baa8c993e">HouseholderQR< MatrixType >::HouseholderQR()</a>.</p> </div> </div> <a class="anchor" id="a321e96844544eacde2272c3a487048e9"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">const HCoeffsType& hCoeffs </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <dl class="section return"><dt>Returns</dt><dd>a const reference to the vector of Householder coefficients used to represent the factor <code>Q</code>.</dd></dl> <p>For advanced uses only. </p> </div> </div> <a class="anchor" id="a520fc76215d7722387a76e7b7a484ee0"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classEigen_1_1HouseholderSequence.html">HouseholderSequenceType</a> householderQ </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>This method returns an expression of the unitary matrix Q as a sequence of Householder transformations.</p> <p>The returned expression can directly be used to perform matrix products. It can also be assigned to a dense <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors. ">Matrix</a> object. Here is an example showing how to recover the full or thin matrix Q, as well as how to perform matrix products using operator*:</p> <p>Example: </p> <div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gabab09c32e96cfa9829a88400627af162">MatrixXf</a> A(<a class="code" href="classEigen_1_1DenseBase.html#a8e759dafdd9ecc446d397b7f5435f60a">MatrixXf::Random</a>(5,3)), thinQ(<a class="code" href="classEigen_1_1MatrixBase.html#a0650b65c6ae6c3d19a138b72a6d68568">MatrixXf::Identity</a>(5,3)), Q;</div> <div class="line">A.setRandom();</div> <div class="line">HouseholderQR<MatrixXf> qr(A);</div> <div class="line">Q = qr.householderQ();</div> <div class="line">thinQ = qr.householderQ() * thinQ;</div> <div class="line">std::cout << <span class="stringliteral">"The complete unitary matrix Q is:\n"</span> << Q << <span class="stringliteral">"\n\n"</span>;</div> <div class="line">std::cout << <span class="stringliteral">"The thin matrix Q is:\n"</span> << thinQ << <span class="stringliteral">"\n\n"</span>;</div> </div><!-- fragment --><p> Output: </p> <pre class="fragment">The complete unitary matrix Q is: -0.676 0.0793 0.713 -0.0788 -0.147 -0.221 -0.322 -0.37 -0.366 -0.759 -0.353 -0.345 -0.214 0.841 -0.0518 0.582 -0.462 0.555 0.176 -0.329 -0.174 -0.747 -0.00907 -0.348 0.539 The thin matrix Q is: -0.676 0.0793 0.713 -0.221 -0.322 -0.37 -0.353 -0.345 -0.214 0.582 -0.462 0.555 -0.174 -0.747 -0.00907 </pre> </div> </div> <a class="anchor" id="a82a3f15f0cda1f4f874d50951344b5a9"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">MatrixType::RealScalar logAbsDeterminant </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </div><div class="memdoc"> <dl class="section return"><dt>Returns</dt><dd>the natural log of the absolute value of the determinant of the matrix of which *this is the QR decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the QR decomposition has already been computed.</dd></dl> <dl class="section note"><dt>Note</dt><dd>This is only for square matrices.</dd> <dd> This method is useful to work around the risk of overflow/underflow that's inherent to determinant computation.</dd></dl> <dl class="section see"><dt>See Also</dt><dd><a class="el" href="classEigen_1_1HouseholderQR.html#a2bb8fa5593d2f447c16ba2e3cfb9c432">absDeterminant()</a>, <a class="el" href="classEigen_1_1MatrixBase.html#ad63cea11a4bf220298dce4489a1704c7">MatrixBase::determinant()</a> </dd></dl> </div> </div> <a class="anchor" id="a7b142db8924dd7fad99acbdd0ff4bdd1"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">const MatrixType& matrixQR </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <dl class="section return"><dt>Returns</dt><dd>a reference to the matrix where the Householder QR decomposition is stored in a LAPACK-compatible way. </dd></dl> </div> </div> <a class="anchor" id="a3912046746c14d7b4e9dba999da46a68"></a> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">const internal::solve_retval<<a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a>, Rhs> solve </td> <td>(</td> <td class="paramtype">const <a class="el" href="classEigen_1_1MatrixBase.html">MatrixBase</a>< Rhs > & </td> <td class="paramname"><em>b</em></td><td>)</td> <td> const</td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>This method finds a solution x to the equation Ax=b, where A is the matrix of which *this is the QR decomposition, if any exists.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">b</td><td>the right-hand-side of the equation to solve.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a solution.</dd></dl> <dl class="section note"><dt>Note</dt><dd>The case where b is a matrix is not yet implemented. Also, this code is space inefficient.</dd></dl> <p>This method just tries to find as good a solution as possible. If you want to check whether a solution exists or if it is accurate, just call this function to get a result and then compute the error of this result, or use <a class="el" href="classEigen_1_1DenseBase.html#a158c2184951e6e415c2e9b98db8e8966">MatrixBase::isApprox()</a> directly, for instance like this:</p> <div class="fragment"><div class="line"><span class="keywordtype">bool</span> a_solution_exists = (A*result).isApprox(b, precision); </div> </div><!-- fragment --><p> This method avoids dividing by zero, so that the non-existence of a solution doesn't by itself mean that you'll get <code>inf</code> or <code>nan</code> values.</p> <p>If there exists more than one solution, this method will arbitrarily choose one.</p> <p>Example: </p> <div class="fragment"><div class="line"><span class="keyword">typedef</span> Matrix<float,3,3> Matrix3x3;</div> <div class="line">Matrix3x3 m = Matrix3x3::Random();</div> <div class="line"><a class="code" href="group__matrixtypedefs.html#ga2b787393a7fc870d99aa634f60b2510c">Matrix3f</a> y = <a class="code" href="classEigen_1_1DenseBase.html#a8e759dafdd9ecc446d397b7f5435f60a">Matrix3f::Random</a>();</div> <div class="line">cout << <span class="stringliteral">"Here is the matrix m:"</span> << endl << m << endl;</div> <div class="line">cout << <span class="stringliteral">"Here is the matrix y:"</span> << endl << y << endl;</div> <div class="line"><a class="code" href="group__matrixtypedefs.html#ga2b787393a7fc870d99aa634f60b2510c">Matrix3f</a> x;</div> <div class="line">x = m.householderQr().solve(y);</div> <div class="line">assert(y.isApprox(m*x));</div> <div class="line">cout << <span class="stringliteral">"Here is a solution x to the equation mx=y:"</span> << endl << x << endl;</div> </div><!-- fragment --><p> Output: </p> <pre class="fragment">Here is the matrix m: 0.68 0.597 -0.33 -0.211 0.823 0.536 0.566 -0.605 -0.444 Here is the matrix y: 0.108 -0.27 0.832 -0.0452 0.0268 0.271 0.258 0.904 0.435 Here is a solution x to the equation mx=y: 0.609 2.68 1.67 -0.231 -1.57 0.0713 0.51 3.51 1.05 </pre> </div> </div> <hr/>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="ForwardDeclarations_8h_source.html">ForwardDeclarations.h</a></li> <li><a class="el" href="HouseholderQR_8h_source.html">HouseholderQR.h</a></li> </ul> </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="namespaceEigen.html">Eigen</a></li><li class="navelem"><a class="el" href="classEigen_1_1HouseholderQR.html">HouseholderQR</a></li> <li class="footer">Generated on Mon Oct 28 2013 11:04:29 for Eigen by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.5 </li> </ul> </div> <!-- Piwik --> <!-- <script type="text/javascript"> var pkBaseURL = (("https:" == document.location.protocol) ? "https://stats.sylphide-consulting.com/piwik/" : "http://stats.sylphide-consulting.com/piwik/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); </script><script type="text/javascript"> try { var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 20); piwikTracker.trackPageView(); piwikTracker.enableLinkTracking(); } catch( err ) {} </script><noscript><p><img src="http://stats.sylphide-consulting.com/piwik/piwik.php?idsite=20" style="border:0" alt="" /></p></noscript> --> <!-- End Piwik Tracking Code --> </body> </html>