</table>
<hr>
<pre>/***************************************************************************
 * $Id: power1.cpp,v 1.4 2003/09/05 08:12:50 troyer Exp $
 *
 * A simple example of power method
 *
 * Copyright (C) 2001-2003 by Prakash Dayal &lt;prakash@comp-phys.org&gt;
 *                            Matthias Troyer &lt;troyer@comp-phys.org&gt;
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 **************************************************************************/

#include &lt;ietl/interface/ublas.h&gt;
#include &lt;ietl/power.h&gt;
#include &lt;ietl/vectorspace.h&gt;
#include &lt;ietl/iteration.h&gt;
#include &lt;boost/numeric/ublas/symmetric.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;
#include &lt;boost/random.hpp&gt;
#include &lt;boost/limits.hpp&gt;


typedef boost::numeric::ublas::symmetric_matrix&lt;double, boost::numeric::ublas::lower&gt; Matrix; 
typedef boost::numeric::ublas::vector&lt;double&gt; Vector;

int main () {
  int N = 10;
  Matrix mat(N, N);
  int n = 1;
  for(int i=0;i&lt;N;i++)
    for(int j=0;j&lt;=i;j++)
      mat(i,j) = n++;   
  
  std::cout &lt;&lt; &quot;Matrix: &quot; &lt;&lt; mat &lt;&lt; std::endl;
  
  ietl::vectorspace&lt;Vector&gt; vec(N);
  boost::lagged_fibonacci607 gen;  
  int max_iter = std::numeric_limits&lt;int&gt;::max();
  double rel_tol = 5.*std::numeric_limits&lt;double&gt;::epsilon();
  double abs_tol = std::numeric_limits&lt;double&gt;::epsilon();
  ietl::basic_iteration&lt;double&gt; iter(max_iter, rel_tol, abs_tol);
  
  std::pair&lt;double,Vector&gt; result = ietl::power(mat, gen, iter, vec); 
  std::cout.precision(20);
  std::cout &lt;&lt; &quot;Eigenvalue: &quot;&lt;&lt; result.first &lt;&lt; std::endl;
  std::cout &lt;&lt; &quot;Eigenvector: &quot; &lt;&lt; result.second &lt;&lt; std::endl;  
  return 0;
}
</pre>
