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 #include <RDGeneral/export.h>
12 #ifndef _RD_POWER_EIGENSOLVER_H
13 #define _RD_POWER_EIGENSOLVER_H
14 
15 #include <Numerics/Vector.h>
16 #include <Numerics/Matrix.h>
17 #include <Numerics/SymmMatrix.h>
18 
19 namespace RDNumeric {
20 namespace EigenSolvers {
21 //! Compute the \c numEig largest eigenvalues and, optionally, the
22 //corresponding
23 //! eigenvectors.
24 /*!
25 
26 \param numEig the number of eigenvalues we are interested in
27 \param mat symmetric input matrix of dimension N*N
28 \param eigenValues Vector used to return the eigenvalues (size = numEig)
29 \param eigenVectors Optional matrix used to return the eigenvectors (size =
30 N*numEig)
31 \param seed Optional values to seed the random value generator used to
32  initialize the eigen vectors
33 \return a boolean indicating whether or not the calculation converged.
34 
35 <b>Notes:</b>
36 - The matrix, \c mat, is changed in this function
37 
38 <b>Algorithm:</b>
39 
40 We use the iterative power method, which works like this:
41 
42 \verbatim
43  u = arbitrary unit vector
44  tol = 0.001
45  currEigVal = 0.0;
46  prevEigVal = -1.0e100
47  while (abs(currEigVal - prevEigVal) > tol) :
48  v = Au
49  prevEigVal = currEigVal
50  currEigVal = v[i] // where i is the id os the largest absolute component
51  u = c*v
52 \endverbatim
53 
54 
55 */
56 bool RDKIT_EIGENSOLVERS_EXPORT powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
57  DoubleVector &eigenValues, DoubleMatrix *eigenVectors = 0,
58  int seed = -1);
59 //! \overload
60 static inline bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
61  DoubleVector &eigenValues,
62  DoubleMatrix &eigenVectors, int seed = -1) {
63  return powerEigenSolver(numEig, mat, eigenValues, &eigenVectors, seed);
64 }
65 };
66 };
67 
68 #endif
#define RDKIT_EIGENSOLVERS_EXPORT
Definition: export.h:177
bool RDKIT_EIGENSOLVERS_EXPORT powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat, DoubleVector &eigenValues, DoubleMatrix *eigenVectors=0, int seed=-1)
Compute the numEig largest eigenvalues and, optionally, the.
A symmetric matrix class.
Definition: SymmMatrix.h:30
A class to represent vectors of numbers.
Definition: Vector.h:29