RDKit: PowerEigenSolver.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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