RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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 of the largest absolute component
51
u = c*v
52
\endverbatim
53
54
55
*/
56
bool
RDKIT_EIGENSOLVERS_EXPORT
powerEigenSolver
(
57
unsigned
int
numEig,
DoubleSymmMatrix
&mat,
DoubleVector
&eigenValues,
58
DoubleMatrix
*eigenVectors =
nullptr
,
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
};
// namespace EigenSolvers
66
};
// namespace RDNumeric
67
68
#endif
Matrix.h
SymmMatrix.h
Vector.h
RDNumeric::Matrix< double >
RDNumeric::SymmMatrix
A symmetric matrix class.
Definition
SymmMatrix.h:30
RDNumeric::Vector
A class to represent vectors of numbers.
Definition
Vector.h:29
export.h
RDKIT_EIGENSOLVERS_EXPORT
#define RDKIT_EIGENSOLVERS_EXPORT
Definition
export.h:145
RDNumeric::EigenSolvers::powerEigenSolver
bool RDKIT_EIGENSOLVERS_EXPORT powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat, DoubleVector &eigenValues, DoubleMatrix *eigenVectors=nullptr, int seed=-1)
RDNumeric
Definition
AlignPoints.h:18
Numerics
EigenSolvers
PowerEigenSolver.h
Generated on Mon Sep 30 2024 05:19:34 for RDKit by
1.9.8