ulapack_8hpp-source.html

来自「Bayes滤波器算法C++类说明文档,源码见Bayes滤波器算法」· HTML 代码 · 共 217 行 · 第 1/2 页

HTML
217
字号
00103     {00104         <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK_1_1rawLAPACK.html#a5">sgetrf_</a>(m,n,da,lda,ipivot,info);00105     }00106 }<span class="comment">// namespace rawLAPACK</span>00107 00108 00109 <span class="comment">/* Support types */</span><a name="l00110"></a><a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a0">00110</a> <span class="keyword">typedef</span> boost::numeric::ublas::vector&lt;int&gt; <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a0">pivot_t</a>;<a name="l00111"></a><a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a1">00111</a> <span class="keyword">typedef</span> Bayesian_filter_matrix::DenseVec <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a1">vector_t</a>;<a name="l00112"></a><a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a2">00112</a> <span class="keyword">typedef</span> Bayesian_filter_matrix::DenseColMatrix <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a2">matrix_t</a>;00113 00114 <span class="comment">/* LAPACK Interface*/</span>00115 00116 00117 00118 <span class="comment">// QR Factorization of a MxN General Matrix A.</span>00119 <span class="comment">//    a       (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A. On exit , the upper triangle and diagonal is the min(M,N) by N upper triangular matrix R.  The lower triangle, together with the tau vector, is the orthogonal matrix Q as a product of min(M,N) elementary reflectors.</span>00120 <span class="comment">//    tau     (OUT - vector (min(M,N))) Vector of the same numerical type as A. The scalar factors of the elementary reflectors.</span>00121 <span class="comment">//    info    (OUT - int)</span>00122 <span class="comment">//   0   : function completed normally</span>00123 <span class="comment">//   &lt; 0 : The ith argument, where i = abs(return value) had an illegal value.</span><a name="l00124"></a><a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a3">00124</a> <span class="keywordtype">int</span> <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a3">geqrf</a> (matrix_t&amp; a, vector_t&amp; tau)00125 {00126     <span class="keywordtype">int</span>              _m = int(a.size1());00127     <span class="keywordtype">int</span>              _n = int(a.size2());00128     <span class="keywordtype">int</span>              _lda = int(a.size1());00129     <span class="keywordtype">int</span>              _info;00130 00131     <span class="comment">// make_sure tau's size is greater than or equal to min(m,n)</span>00132     <span class="keywordflow">if</span> (int(tau.size()) &lt; (_n&lt;_m ? _n : _m) )00133         <span class="keywordflow">return</span> -104;00134 00135     <span class="keywordtype">int</span> ldwork = _n*_n;00136     <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a1">vector_t</a> dwork(ldwork);00137     rawLAPACK::geqrf (_m, _n, a.data().begin(), _lda, tau.data().begin(), dwork.data().begin(), ldwork, _info);00138 00139     <span class="keywordflow">return</span> _info;00140 }00141 00142 <span class="comment">// LU factorization of a general matrix A.  </span>00143 <span class="comment">//    Computes an LU factorization of a general M-by-N matrix A using</span>00144 <span class="comment">//    partial pivoting with row interchanges. Factorization has the form</span>00145 <span class="comment">//    A = P*L*U.</span>00146 <span class="comment">//    a       (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A to be factored. On exit, the factors L and U from the factorization A = P*L*U.</span>00147 <span class="comment">//    ipivot  (OUT - vector(min(M,N))) Integer vector. The row i of A was interchanged with row IPIV(i).</span>00148 <span class="comment">//    info    (OUT - int)</span>00149 <span class="comment">//   0   :  successful exit</span>00150 <span class="comment">//   &lt; 0 :  If INFO = -i, then the i-th argument had an illegal value.</span>00151 <span class="comment">//   &gt; 0 :  If INFO = i, then U(i,i) is exactly zero. The  factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.</span><a name="l00152"></a><a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a4">00152</a> <span class="keywordtype">int</span> <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a4">getrf</a> (matrix_t&amp; a, pivot_t&amp; ipivot)00153 {00154     matrix_t::value_type* _a = a.data().begin();00155     <span class="keywordtype">int</span> _m = int(a.size1());00156     <span class="keywordtype">int</span> _n = int(a.size2());00157     <span class="keywordtype">int</span> _lda = _m;  <span class="comment">// minor size</span>00158     <span class="keywordtype">int</span> _info;00159 00160     rawLAPACK::getrf (_m, _n,   _a, _lda, ipivot.data().begin(), _info);00161 00162     <span class="keywordflow">return</span> _info;00163 }00164 00165 <span class="comment">// Solution to a system using LU factorization </span>00166 <span class="comment">//   Solves a system of linear equations A*X = B with a general NxN</span>00167 <span class="comment">//   matrix A using the LU factorization computed by GETRF.</span>00168 <span class="comment">//   transa  (IN - char)  'T' for the transpose of A, 'N' otherwise.</span>00169 <span class="comment">//   a       (IN - matrix(M,N)) The factors L and U from the factorization A = P*L*U as computed by GETRF.</span>00170 <span class="comment">//   ipivot  (IN - vector(min(M,N))) Integer vector. The pivot indices from GETRF; row i of A was interchanged with row IPIV(i).</span>00171 <span class="comment">//   b       (IN/OUT - matrix(ldb,NRHS)) Matrix of same numerical type as A. On entry, the right hand side matrix B. On exit, the solution matrix X.</span>00172 <span class="comment">//</span>00173 <span class="comment">//   info    (OUT - int)</span>00174 <span class="comment">//   0   : function completed normally</span>00175 <span class="comment">//   &lt; 0 : The ith argument, where i = abs(return value) had an illegal value.</span>00176 <span class="comment">//   &gt; 0 : if INFO =  i,  U(i,i)  is  exactly  zero;  the  matrix is singular and its inverse could not be computed.</span><a name="l00177"></a><a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a5">00177</a> <span class="keywordtype">int</span> <a class="code" href="namespaceBayesian__filter__matrix_1_1LAPACK.html#a5">getrs</a> (<span class="keywordtype">char</span> transa, matrix_t&amp; a,00178         pivot_t&amp; ipivot, matrix_t&amp; b)00179 {00180     matrix_t::value_type* _a = a.data().begin();00181     <span class="keywordtype">int</span> a_n = int(a.size1());00182     <span class="keywordtype">int</span> _lda = a_n;00183     <span class="keywordtype">int</span> p_n = int(ipivot.size());00184 00185     matrix_t::value_type* _b = b.data().begin();00186     <span class="keywordtype">int</span> b_n = int(b.size1());00187     <span class="keywordtype">int</span> _ldb = b_n;00188     <span class="keywordtype">int</span> _nrhs = int(b.size2()); <span class="comment">/* B's size2 is the # of vectors on rhs */</span>00189 00190     <span class="keywordflow">if</span> (a_n != b_n) <span class="comment">/*Test to see if AX=B has correct dimensions */</span>00191         <span class="keywordflow">return</span> -101;00192     <span class="keywordflow">if</span> (p_n &lt; a_n)     <span class="comment">/*Check to see if ipivot is big enough */</span>00193         <span class="keywordflow">return</span> -102;00194 00195     <span class="keywordtype">int</span> _info;00196     rawLAPACK::getrs (transa, a_n, _nrhs, _a,   _lda, ipivot.data().begin(), 00197                 _b, _ldb, _info);00198 00199     <span class="keywordflow">return</span> _info;00200 } 00201 00202 }<span class="comment">//namespace LAPACK</span>00203 }<span class="comment">//namespace Bayesian_filter_matrix</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Feb 16 11:20:41 2004 for Bayes++ Bayesian Filtering Classes by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.2 </small></address></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?