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,
57  DoubleSymmMatrix &mat,
58  DoubleVector &eigenValues,
59  DoubleMatrix *eigenVectors = 0,
60  int seed = -1);
61 //! \overload
62 static inline bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
63  DoubleVector &eigenValues,
64  DoubleMatrix &eigenVectors, int seed = -1) {
65  return powerEigenSolver(numEig, mat, eigenValues, &eigenVectors, seed);
66 }
67 }; // namespace EigenSolvers
68 }; // namespace RDNumeric
69 
70 #endif
RDNumeric::EigenSolvers::powerEigenSolver
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.
Vector.h
RDNumeric::SymmMatrix
A symmetric matrix class.
Definition: SymmMatrix.h:30
Matrix.h
RDNumeric::Vector
A class to represent vectors of numbers.
Definition: Vector.h:29
RDNumeric::Matrix
A matrix class for general, non-square matrices.
Definition: Matrix.h:29
RDKIT_EIGENSOLVERS_EXPORT
#define RDKIT_EIGENSOLVERS_EXPORT
Definition: export.h:190
RDNumeric
Definition: AlignPoints.h:18
SymmMatrix.h
export.h