Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 623999701586b0ea103ff2ccad7954a6 > files > 7948

boost-doc-1.44.0-1.fc14.noarch.rpm

<!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"/>
<title>ublas: blas.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>blas.hpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
<a name="l00002"></a>00002 <span class="comment">//  Copyright (c) 2000-2002</span>
<a name="l00003"></a>00003 <span class="comment">//  Joerg Walter, Mathias Koch</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">//  Distributed under the Boost Software License, Version 1.0. (See</span>
<a name="l00006"></a>00006 <span class="comment">//  accompanying file LICENSE_1_0.txt or copy at</span>
<a name="l00007"></a>00007 <span class="comment">//  http://www.boost.org/LICENSE_1_0.txt)</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">//  The authors gratefully acknowledge the support of</span>
<a name="l00010"></a>00010 <span class="comment">//  GeNeSys mbH &amp; Co. KG in producing this work.</span>
<a name="l00011"></a>00011 <span class="comment">//</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#ifndef _BOOST_UBLAS_BLAS_</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define _BOOST_UBLAS_BLAS_</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;boost/numeric/ublas/traits.hpp&gt;</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>numeric { <span class="keyword">namespace </span>ublas {
<a name="l00019"></a>00019         
<a name="l00020"></a>00020 
<a name="l00026"></a>00026     <span class="keyword">namespace </span>blas_1 {
<a name="l00027"></a>00027 
<a name="l00035"></a>00035         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V&gt;
<a name="l00036"></a>00036         <span class="keyword">typename</span> type_traits&lt;typename V::value_type&gt;::real_type
<a name="l00037"></a>00037         asum (<span class="keyword">const</span> V &amp;v) {
<a name="l00038"></a>00038             <span class="keywordflow">return</span> norm_1 (v);
<a name="l00039"></a>00039         }
<a name="l00040"></a>00040 
<a name="l00048"></a>00048         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V&gt;
<a name="l00049"></a>00049         <span class="keyword">typename</span> type_traits&lt;typename V::value_type&gt;::real_type
<a name="l00050"></a>00050         nrm2 (<span class="keyword">const</span> V &amp;v) {
<a name="l00051"></a>00051             <span class="keywordflow">return</span> norm_2 (v);
<a name="l00052"></a>00052         }
<a name="l00053"></a>00053 
<a name="l00061"></a>00061         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V&gt;
<a name="l00062"></a>00062         <span class="keyword">typename</span> type_traits&lt;typename V::value_type&gt;::real_type
<a name="l00063"></a>00063         amax (<span class="keyword">const</span> V &amp;v) {
<a name="l00064"></a>00064             <span class="keywordflow">return</span> norm_inf (v);
<a name="l00065"></a>00065         }
<a name="l00066"></a>00066 
<a name="l00076"></a>00076         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V1, <span class="keyword">class</span> V2&gt;
<a name="l00077"></a>00077         <span class="keyword">typename</span> promote_traits&lt;typename V1::value_type, typename V2::value_type&gt;::promote_type
<a name="l00078"></a>00078         dot (<span class="keyword">const</span> V1 &amp;v1, <span class="keyword">const</span> V2 &amp;v2) {
<a name="l00079"></a>00079             <span class="keywordflow">return</span> inner_prod (v1, v2);
<a name="l00080"></a>00080         }
<a name="l00081"></a>00081 
<a name="l00091"></a>00091         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V1, <span class="keyword">class</span> V2&gt;
<a name="l00092"></a>00092         V1 &amp; copy (V1 &amp;v1, <span class="keyword">const</span> V2 &amp;v2) 
<a name="l00093"></a>00093         {
<a name="l00094"></a>00094             <span class="keywordflow">return</span> v1.assign (v2);
<a name="l00095"></a>00095         }
<a name="l00096"></a>00096 
<a name="l00105"></a>00105         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V1, <span class="keyword">class</span> V2&gt;
<a name="l00106"></a>00106         <span class="keywordtype">void</span> swap (V1 &amp;v1, V2 &amp;v2) 
<a name="l00107"></a>00107         {
<a name="l00108"></a>00108             v1.swap (v2);
<a name="l00109"></a>00109         }
<a name="l00110"></a>00110 
<a name="l00120"></a>00120         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V, <span class="keyword">class</span> T&gt;
<a name="l00121"></a>00121         V &amp; scal (V &amp;v, <span class="keyword">const</span> T &amp;t) 
<a name="l00122"></a>00122         {
<a name="l00123"></a>00123             <span class="keywordflow">return</span> v *= t;
<a name="l00124"></a>00124         }
<a name="l00125"></a>00125 
<a name="l00137"></a>00137         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V1, <span class="keyword">class</span> T, <span class="keyword">class</span> V2&gt;
<a name="l00138"></a>00138         V1 &amp; axpy (V1 &amp;v1, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> V2 &amp;v2) 
<a name="l00139"></a>00139         {
<a name="l00140"></a>00140             <span class="keywordflow">return</span> v1.plus_assign (t * v2);
<a name="l00141"></a>00141         }
<a name="l00142"></a>00142 
<a name="l00160"></a>00160         <span class="keyword">template</span>&lt;<span class="keyword">class</span> T1, <span class="keyword">class</span> V1, <span class="keyword">class</span> T2, <span class="keyword">class</span> V2&gt;
<a name="l00161"></a>00161         <span class="keywordtype">void</span> rot (<span class="keyword">const</span> T1 &amp;t1, V1 &amp;v1, <span class="keyword">const</span> T2 &amp;t2, V2 &amp;v2) 
<a name="l00162"></a>00162         {
<a name="l00163"></a>00163             <span class="keyword">typedef</span> <span class="keyword">typename</span> promote_traits&lt;typename V1::value_type, typename V2::value_type&gt;::promote_type promote_type;
<a name="l00164"></a>00164             vector&lt;promote_type&gt; vt (t1 * v1 + t2 * v2);
<a name="l00165"></a>00165             v2.assign (- t2 * v1 + t1 * v2);
<a name="l00166"></a>00166             v1.assign (vt);
<a name="l00167"></a>00167         }
<a name="l00168"></a>00168 
<a name="l00169"></a>00169     }
<a name="l00170"></a>00170 
<a name="l00176"></a>00176     <span class="keyword">namespace </span>blas_2 {
<a name="l00177"></a>00177 
<a name="l00187"></a>00187         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V, <span class="keyword">class</span> M&gt;
<a name="l00188"></a>00188         V &amp; tmv (V &amp;v, <span class="keyword">const</span> M &amp;m) 
<a name="l00189"></a>00189         {
<a name="l00190"></a>00190             <span class="keywordflow">return</span> v = prod (m, v);
<a name="l00191"></a>00191         }
<a name="l00192"></a>00192 
<a name="l00204"></a>00204         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V, <span class="keyword">class</span> M, <span class="keyword">class</span> C&gt;
<a name="l00205"></a>00205         V &amp; tsv (V &amp;v, <span class="keyword">const</span> M &amp;m, C) 
<a name="l00206"></a>00206         {
<a name="l00207"></a>00207             <span class="keywordflow">return</span> v = solve (m, v, C ());
<a name="l00208"></a>00208         }
<a name="l00209"></a>00209 
<a name="l00225"></a>00225         <span class="keyword">template</span>&lt;<span class="keyword">class</span> V1, <span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> M, <span class="keyword">class</span> V2&gt;
<a name="l00226"></a>00226         V1 &amp; gmv (V1 &amp;v1, <span class="keyword">const</span> T1 &amp;t1, <span class="keyword">const</span> T2 &amp;t2, <span class="keyword">const</span> M &amp;m, <span class="keyword">const</span> V2 &amp;v2) 
<a name="l00227"></a>00227         {
<a name="l00228"></a>00228             <span class="keywordflow">return</span> v1 = t1 * v1 + t2 * prod (m, v2);
<a name="l00229"></a>00229         }
<a name="l00230"></a>00230 
<a name="l00244"></a>00244         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M, <span class="keyword">class</span> T, <span class="keyword">class</span> V1, <span class="keyword">class</span> V2&gt;
<a name="l00245"></a>00245         M &amp; gr (M &amp;m, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> V1 &amp;v1, <span class="keyword">const</span> V2 &amp;v2) 
<a name="l00246"></a>00246         {
<a name="l00247"></a>00247 <span class="preprocessor">#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG</span>
<a name="l00248"></a>00248 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m += t * outer_prod (v1, v2);
<a name="l00249"></a>00249 <span class="preprocessor">#else</span>
<a name="l00250"></a>00250 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m = m + t * outer_prod (v1, v2);
<a name="l00251"></a>00251 <span class="preprocessor">#endif</span>
<a name="l00252"></a>00252 <span class="preprocessor"></span>        }
<a name="l00253"></a>00253 
<a name="l00265"></a>00265         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M, <span class="keyword">class</span> T, <span class="keyword">class</span> V&gt;
<a name="l00266"></a>00266         M &amp; sr (M &amp;m, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> V &amp;v) 
<a name="l00267"></a>00267         {
<a name="l00268"></a>00268 <span class="preprocessor">#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG</span>
<a name="l00269"></a>00269 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m += t * outer_prod (v, v);
<a name="l00270"></a>00270 <span class="preprocessor">#else</span>
<a name="l00271"></a>00271 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m = m + t * outer_prod (v, v);
<a name="l00272"></a>00272 <span class="preprocessor">#endif</span>
<a name="l00273"></a>00273 <span class="preprocessor"></span>        }
<a name="l00274"></a>00274 
<a name="l00286"></a>00286         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M, <span class="keyword">class</span> T, <span class="keyword">class</span> V&gt;
<a name="l00287"></a>00287         M &amp; hr (M &amp;m, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> V &amp;v) 
<a name="l00288"></a>00288         {
<a name="l00289"></a>00289 <span class="preprocessor">#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG</span>
<a name="l00290"></a>00290 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m += t * outer_prod (v, conj (v));
<a name="l00291"></a>00291 <span class="preprocessor">#else</span>
<a name="l00292"></a>00292 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m = m + t * outer_prod (v, conj (v));
<a name="l00293"></a>00293 <span class="preprocessor">#endif</span>
<a name="l00294"></a>00294 <span class="preprocessor"></span>        }
<a name="l00295"></a>00295 
<a name="l00309"></a>00309         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M, <span class="keyword">class</span> T, <span class="keyword">class</span> V1, <span class="keyword">class</span> V2&gt;
<a name="l00310"></a>00310         M &amp; sr2 (M &amp;m, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> V1 &amp;v1, <span class="keyword">const</span> V2 &amp;v2) 
<a name="l00311"></a>00311         {
<a name="l00312"></a>00312 <span class="preprocessor">#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG</span>
<a name="l00313"></a>00313 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m += t * (outer_prod (v1, v2) + outer_prod (v2, v1));
<a name="l00314"></a>00314 <span class="preprocessor">#else</span>
<a name="l00315"></a>00315 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m = m + t * (outer_prod (v1, v2) + outer_prod (v2, v1));
<a name="l00316"></a>00316 <span class="preprocessor">#endif</span>
<a name="l00317"></a>00317 <span class="preprocessor"></span>        }
<a name="l00318"></a>00318 
<a name="l00332"></a>00332         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M, <span class="keyword">class</span> T, <span class="keyword">class</span> V1, <span class="keyword">class</span> V2&gt;
<a name="l00333"></a>00333         M &amp; hr2 (M &amp;m, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> V1 &amp;v1, <span class="keyword">const</span> V2 &amp;v2) 
<a name="l00334"></a>00334         {
<a name="l00335"></a>00335 <span class="preprocessor">#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG</span>
<a name="l00336"></a>00336 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m += t * outer_prod (v1, conj (v2)) + type_traits&lt;T&gt;::conj (t) * outer_prod (v2, conj (v1));
<a name="l00337"></a>00337 <span class="preprocessor">#else</span>
<a name="l00338"></a>00338 <span class="preprocessor"></span>            <span class="keywordflow">return</span> m = m + t * outer_prod (v1, conj (v2)) + type_traits&lt;T&gt;::conj (t) * outer_prod (v2, conj (v1));
<a name="l00339"></a>00339 <span class="preprocessor">#endif</span>
<a name="l00340"></a>00340 <span class="preprocessor"></span>        }
<a name="l00341"></a>00341 
<a name="l00342"></a>00342     }
<a name="l00343"></a>00343 
<a name="l00349"></a>00349     <span class="keyword">namespace </span>blas_3 {
<a name="l00350"></a>00350 
<a name="l00365"></a>00365         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M1, <span class="keyword">class</span> T, <span class="keyword">class</span> M2, <span class="keyword">class</span> M3&gt;
<a name="l00366"></a>00366         M1 &amp; tmm (M1 &amp;m1, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> M2 &amp;m2, <span class="keyword">const</span> M3 &amp;m3) 
<a name="l00367"></a>00367         {
<a name="l00368"></a>00368             <span class="keywordflow">return</span> m1 = t * prod (m2, m3);
<a name="l00369"></a>00369         }
<a name="l00370"></a>00370 
<a name="l00384"></a>00384         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M1, <span class="keyword">class</span> T, <span class="keyword">class</span> M2, <span class="keyword">class</span> C&gt;
<a name="l00385"></a>00385         M1 &amp; tsm (M1 &amp;m1, <span class="keyword">const</span> T &amp;t, <span class="keyword">const</span> M2 &amp;m2, C) 
<a name="l00386"></a>00386         {
<a name="l00387"></a>00387             <span class="keywordflow">return</span> m1 = solve (m2, t * m1, C ());
<a name="l00388"></a>00388         }
<a name="l00389"></a>00389 
<a name="l00405"></a>00405         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M1, <span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> M2, <span class="keyword">class</span> M3&gt;
<a name="l00406"></a>00406         M1 &amp; gmm (M1 &amp;m1, <span class="keyword">const</span> T1 &amp;t1, <span class="keyword">const</span> T2 &amp;t2, <span class="keyword">const</span> M2 &amp;m2, <span class="keyword">const</span> M3 &amp;m3) 
<a name="l00407"></a>00407         {
<a name="l00408"></a>00408             <span class="keywordflow">return</span> m1 = t1 * m1 + t2 * prod (m2, m3);
<a name="l00409"></a>00409         }
<a name="l00410"></a>00410 
<a name="l00425"></a>00425         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M1, <span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> M2&gt;
<a name="l00426"></a>00426         M1 &amp; srk (M1 &amp;m1, <span class="keyword">const</span> T1 &amp;t1, <span class="keyword">const</span> T2 &amp;t2, <span class="keyword">const</span> M2 &amp;m2) 
<a name="l00427"></a>00427         {
<a name="l00428"></a>00428             <span class="keywordflow">return</span> m1 = t1 * m1 + t2 * prod (m2, trans (m2));
<a name="l00429"></a>00429         }
<a name="l00430"></a>00430 
<a name="l00445"></a>00445         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M1, <span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> M2&gt;
<a name="l00446"></a>00446         M1 &amp; hrk (M1 &amp;m1, <span class="keyword">const</span> T1 &amp;t1, <span class="keyword">const</span> T2 &amp;t2, <span class="keyword">const</span> M2 &amp;m2) 
<a name="l00447"></a>00447         {
<a name="l00448"></a>00448             <span class="keywordflow">return</span> m1 = t1 * m1 + t2 * prod (m2, herm (m2));
<a name="l00449"></a>00449         }
<a name="l00450"></a>00450 
<a name="l00467"></a>00467         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M1, <span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> M2, <span class="keyword">class</span> M3&gt;
<a name="l00468"></a>00468         M1 &amp; sr2k (M1 &amp;m1, <span class="keyword">const</span> T1 &amp;t1, <span class="keyword">const</span> T2 &amp;t2, <span class="keyword">const</span> M2 &amp;m2, <span class="keyword">const</span> M3 &amp;m3) 
<a name="l00469"></a>00469         {
<a name="l00470"></a>00470             <span class="keywordflow">return</span> m1 = t1 * m1 + t2 * (prod (m2, trans (m3)) + prod (m3, trans (m2)));
<a name="l00471"></a>00471         }
<a name="l00472"></a>00472 
<a name="l00489"></a>00489         <span class="keyword">template</span>&lt;<span class="keyword">class</span> M1, <span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> M2, <span class="keyword">class</span> M3&gt;
<a name="l00490"></a>00490         M1 &amp; hr2k (M1 &amp;m1, <span class="keyword">const</span> T1 &amp;t1, <span class="keyword">const</span> T2 &amp;t2, <span class="keyword">const</span> M2 &amp;m2, <span class="keyword">const</span> M3 &amp;m3) 
<a name="l00491"></a>00491         {
<a name="l00492"></a>00492             <span class="keywordflow">return</span> m1 = 
<a name="l00493"></a>00493                       t1 * m1 
<a name="l00494"></a>00494                     + t2 * prod (m2, herm (m3)) 
<a name="l00495"></a>00495                     + type_traits&lt;T2&gt;::conj (t2) * prod (m3, herm (m2));
<a name="l00496"></a>00496         }
<a name="l00497"></a>00497 
<a name="l00498"></a>00498     }
<a name="l00499"></a>00499 
<a name="l00500"></a>00500 }}}
<a name="l00501"></a>00501 
<a name="l00502"></a>00502 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Sun Jul 4 20:30:49 2010 for ublas by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>