Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > c5653a35bb94fee65ffe21230992c863 > files > 407

linbox-doc-1.2.1-1.fc15.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>linbox: examples/doubledet.C</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.7.4 -->
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">linbox</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">examples/doubledet.C</div>  </div>
</div>
<div class="contents">
<p>computes doubleDet.</p>
<div class="fragment"><pre class="fragment"><span class="comment">/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */</span>
<span class="comment">// vim:sts=8:sw=8:ts=8:noet:sr:cino=&gt;s,f0,{0,g0,(0,\:0,t0,+0,=s</span>

<span class="comment">/*</span>
<span class="comment"> * examples/doubledet.C</span>
<span class="comment"> *</span>
<span class="comment"> * Copyright (C) 2008, 2010 C. Pernet</span>
<span class="comment"> *</span>
<span class="comment"> * This file is part of LinBox.</span>
<span class="comment"> *</span>
<span class="comment"> *   LinBox is free software: you can redistribute it and/or modify</span>
<span class="comment"> *   it under the terms of the GNU Lesser General Public License as</span>
<span class="comment"> *   published by the Free Software Foundation, either version 2 of</span>
<span class="comment"> *   the License, or (at your option) any later version.</span>
<span class="comment"> *</span>
<span class="comment"> *   LinBox is distributed in the hope that it will be useful,</span>
<span class="comment"> *   but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment"> *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="comment"> *   GNU Lesser General Public License for more details.</span>
<span class="comment"> *</span>
<span class="comment"> *   You should have received a copy of the GNU Lesser General Public</span>
<span class="comment"> *   License along with LinBox.  If not, see</span>
<span class="comment"> *   &lt;http://www.gnu.org/licenses/&gt;.</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &lt;iostream&gt;</span>

<span class="preprocessor">#include &quot;linbox/linbox-config.h&quot;</span>
<span class="preprocessor">#include &quot;<a class="code" href="_p_i_d-integer_8h.html" title="NO DOC.">linbox/field/PID-integer.h</a>&quot;</span>
<span class="preprocessor">#include &quot;linbox/util/matrix-stream.h&quot;</span>
<span class="preprocessor">#include &quot;<a class="code" href="det_8h.html" title="NO DOC.">linbox/solutions/det.h</a>&quot;</span>
<span class="preprocessor">#include &quot;linbox/blackbox/blas-blackbox.h&quot;</span>
<span class="preprocessor">#include &quot;linbox/algorithms/double-det.h&quot;</span>


<span class="keyword">using namespace </span>LinBox;
<span class="keyword">using namespace </span>std;

<span class="keywordtype">int</span> main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
{
    <span class="comment">// commentator.setMaxDetailLevel (-1);</span>
    <span class="comment">//     commentator.setMaxDepth (-1);</span>
    <span class="comment">//     commentator.setReportStream (std::cerr);</span>

    <a name="_a0"></a><a class="code" href="class_lin_box_1_1_p_i_d__integer.html" title="Domain for integer operations.">PID_integer</a> ZZ;

    ifstream input (argv[1]);
    <span class="keywordflow">if</span> (!input)
    { cerr &lt;&lt; <span class="stringliteral">&quot;Error opening matrix file &quot;</span> &lt;&lt; argv[1] &lt;&lt; endl;
        <span class="keywordflow">return</span> -1;
    }
    <a name="_a1"></a><a class="code" href="class_lin_box_1_1_matrix_stream.html" title="MatrixStream.">MatrixStream &lt;PID_integer&gt;</a> ms (ZZ, input);
    <a name="_a2"></a><a class="code" href="class_lin_box_1_1_blas_blackbox.html" title="Dense matrix representation for BLAS based elimination.">BlasBlackbox &lt;PID_integer&gt;</a> A (ms);
    cout &lt;&lt; <span class="stringliteral">&quot;Matrix is &quot;</span> &lt;&lt; A.<a name="a3"></a><a class="code" href="class_lin_box_1_1_blas_blackbox.html#a0fee90e6b8ef7fcd8d76a7f3e1f268e6" title="Get the number of rows in the matrix.">rowdim</a>() &lt;&lt; <span class="stringliteral">&quot; by &quot;</span> &lt;&lt; A.<a name="a4"></a><a class="code" href="class_lin_box_1_1_blas_blackbox.html#a32edb490d3597f5553152d14b102e227" title="Get the number of columns in the matrix.">coldim</a>() &lt;&lt; endl;

    <span class="keywordflow">if</span> (A.<a class="code" href="class_lin_box_1_1_blas_blackbox.html#a0fee90e6b8ef7fcd8d76a7f3e1f268e6" title="Get the number of rows in the matrix.">rowdim</a>() != A.<a class="code" href="class_lin_box_1_1_blas_blackbox.html#a32edb490d3597f5553152d14b102e227" title="Get the number of columns in the matrix.">coldim</a>() + 1){
        cerr&lt;&lt;<span class="stringliteral">&quot;Wrong dimensions: A must be (n+1) x n&quot;</span>&lt;&lt;endl;
        exit (-1);
    }

    <a class="code" href="group__integers.html#gad62eceb96963b157a2357aba991f6d6e" title="Integers in LinBox.">integer</a> det1, det2;
    Timer tim; tim.clear();
    tim.start();
    <span class="keywordtype">bool</span> proof=<span class="keyword">false</span>;
    <span class="keywordflow">if</span> (argc &gt; 2)
        proof = <span class="keyword">true</span>;

    <span class="comment">//doubleDet (det1, det2, A, true);</span>
    doubleDet (det1, det2, A, proof);
    tim.stop();

    <span class="comment">// Check solution</span>
    <span class="keywordtype">size_t</span> n = A.<a class="code" href="class_lin_box_1_1_blas_blackbox.html#a32edb490d3597f5553152d14b102e227" title="Get the number of columns in the matrix.">coldim</a>();
    <a class="code" href="class_lin_box_1_1_blas_blackbox.html" title="Dense matrix representation for BLAS based elimination.">BlasBlackbox&lt;PID_integer&gt;</a> B (ZZ, n, n);
    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;n-1; ++i)
        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;n; ++j)
            B.<a name="a5"></a><a class="code" href="class_lin_box_1_1_dense_submatrix.html#aa125275fb11b55df52933a488ca9a6f3" title="Set the entry at (i, j).">setEntry</a> (i,j,A.<a name="a6"></a><a class="code" href="class_lin_box_1_1_dense_submatrix.html#a725d135bb8767ea6769811242e20685b" title="Get a read-only individual entry from the matrix.">getEntry</a>(i,j));
    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;n; ++j)
        B.<a class="code" href="class_lin_box_1_1_dense_submatrix.html#aa125275fb11b55df52933a488ca9a6f3" title="Set the entry at (i, j).">setEntry</a> (n-1,j,A.<a class="code" href="class_lin_box_1_1_dense_submatrix.html#a725d135bb8767ea6769811242e20685b" title="Get a read-only individual entry from the matrix.">getEntry</a>(n-1,j));

    <a class="code" href="group__integers.html#gad62eceb96963b157a2357aba991f6d6e" title="Integers in LinBox.">integer</a> db, dc;
    <a name="a7"></a><a class="code" href="group__solutions.html#ga9cfcc847d3a7deac68ad6d98e0cd384f" title="Compute the determinant of A.">det</a> (db, B);
    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;n; ++j)
        B.<a class="code" href="class_lin_box_1_1_dense_submatrix.html#aa125275fb11b55df52933a488ca9a6f3" title="Set the entry at (i, j).">setEntry</a>(n-1,j,A.<a class="code" href="class_lin_box_1_1_dense_submatrix.html#a725d135bb8767ea6769811242e20685b" title="Get a read-only individual entry from the matrix.">getEntry</a>(n,j));
    Timer tim2;
    tim2.clear();
    tim2.start();
    <a class="code" href="group__solutions.html#ga9cfcc847d3a7deac68ad6d98e0cd384f" title="Compute the determinant of A.">det</a>(dc, B);
    tim2.stop();

    <span class="keywordflow">if</span> ((det1 != db) || (det2 != dc))
        std::cerr&lt;&lt;<span class="stringliteral">&quot;Check FAIL&quot;</span>&lt;&lt;endl;

    cout&lt;&lt; <span class="stringliteral">&quot;Det 1 = &quot;</span> &lt;&lt; det1 &lt;&lt; endl;
    cout&lt;&lt; <span class="stringliteral">&quot;Det 2 = &quot;</span> &lt;&lt; det2 &lt;&lt; endl;

    cerr &lt;&lt; <span class="stringliteral">&quot;Double Det: &quot;</span>     &lt;&lt; tim.usertime() &lt;&lt; <span class="stringliteral">&quot;s&quot;</span> &lt;&lt; endl;
    cerr &lt;&lt; <span class="stringliteral">&quot;Each single Det: &quot;</span>&lt;&lt;tim2.usertime() &lt;&lt; <span class="stringliteral">&quot;s&quot;</span> &lt;&lt; endl;

    <span class="keywordflow">return</span> 0 ;
}
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 30 2011 for linbox by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>