RDKit
Open-source cheminformatics and machine learning.
PowerEigenSolver.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 
11 #ifndef _RD_POWER_EIGENSOLVER_H
12 #define _RD_POWER_EIGENSOLVER_H
13 
14 #include <Numerics/Vector.h>
15 #include <Numerics/Matrix.h>
16 #include <Numerics/SymmMatrix.h>
17 
18 namespace RDNumeric {
19  namespace EigenSolvers {
20  //! Compute the \c numEig largest eigenvalues and, optionally, the corresponding
21  //! eigenvectors.
22  /*!
23 
24  \param numEig the number of eigenvalues we are interested in
25  \param mat symmetric input matrix of dimension N*N
26  \param eigenValues Vector used to return the eigenvalues (size = numEig)
27  \param eigenVectors Optional matrix used to return the eigenvectors (size = N*numEig)
28  \param seed Optional values to seed the random value generator used to
29  initialize the eigen vectors
30  \return a boolean indicating whether or not the calculation converged.
31 
32  <b>Notes:</b>
33  - The matrix, \c mat, is changed in this function
34 
35  <b>Algorithm:</b>
36 
37  We use the iterative power method, which works like this:
38 
39  \verbatim
40  u = arbitrary unit vector
41  tol = 0.001
42  currEigVal = 0.0;
43  prevEigVal = -1.0e100
44  while (abs(currEigVal - prevEigVal) > tol) :
45  v = Au
46  prevEigVal = currEigVal
47  currEigVal = v[i] // where i is the id os the largest absolute component
48  u = c*v
49  \endverbatim
50 
51 
52  */
53  bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
54  DoubleVector &eigenValues,
55  DoubleMatrix *eigenVectors=0,
56  int seed=-1);
57  //! \overload
58  static bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
59  DoubleVector &eigenValues,
60  DoubleMatrix &eigenVectors,
61  int seed=-1) {
62  return powerEigenSolver(numEig,mat,eigenValues,&eigenVectors,seed);
63  }
64  };
65 };
66 
67 #endif
68 
69 
70 
bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat, DoubleVector &eigenValues, DoubleMatrix *eigenVectors=0, int seed=-1)
A symmetric matrix class.
Definition: SymmMatrix.h:28
A class to represent vectors of numbers.
Definition: Vector.h:28