1 /******************************************************************************
2 
3   This source file is part of the Avogadro project.
4 
5   Copyright (C) 2010 Eric C. Brown
6 
7   This source code is released under the New BSD License, (the "License").
8 
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14 
15 ******************************************************************************/
16 
17 #ifndef QTAIMMATHUTILITIES_H
18 #define QTAIMMATHUTILITIES_H
19 
20 #include <QtGlobal>
21 
22 #include <Eigen/Core>
23 
24 using namespace Eigen;
25 
26 namespace Avogadro {
27 namespace QtPlugins {
28 
29 namespace QTAIMMathUtilities {
30 Matrix<qreal, 3, 1> eigenvaluesOfASymmetricThreeByThreeMatrix(
31   const Matrix<qreal, 3, 3>& A);
32 Matrix<qreal, 3, 3> eigenvectorsOfASymmetricThreeByThreeMatrix(
33   const Matrix<qreal, 3, 3>& A);
34 Matrix<qreal, 4, 1> eigenvaluesOfASymmetricFourByFourMatrix(
35   const Matrix<qreal, 4, 4>& A);
36 Matrix<qreal, 4, 4> eigenvectorsOfASymmetricFourByFourMatrix(
37   const Matrix<qreal, 4, 4>& A);
38 
39 qint64 signOfARealNumber(qreal x);
40 qint64 signatureOfASymmetricThreeByThreeMatrix(const Matrix<qreal, 3, 3>& A);
41 qreal ellipticityOfASymmetricThreeByThreeMatrix(const Matrix<qreal, 3, 3>& A);
42 
43 qreal distance(const Matrix<qreal, 3, 1>& a, const Matrix<qreal, 3, 1>& b);
44 
45 Matrix<qreal, 3, 1> sphericalToCartesian(const Matrix<qreal, 3, 1>& rtp,
46                                          const Matrix<qreal, 3, 1>& x0y0z0);
47 Matrix<qreal, 3, 1> sphericalToCartesian(const Matrix<qreal, 3, 1>& rtp);
48 
49 Matrix<qreal, 3, 1> cartesianToSpherical(const Matrix<qreal, 3, 1>& xyz,
50                                          const Matrix<qreal, 3, 1>& x0y0z0);
51 Matrix<qreal, 3, 1> cartesianToSpherical(const Matrix<qreal, 3, 1>& xyz);
52 
53 // Cerjan-Miller-Baker-Popelier Methods
54 
55 // A small number to prevent divide by zero in CMBP routines
56 #define SMALL 1.e-10
57 
58 Matrix<qreal, 3, 1> minusThreeSignatureLocatorGradient(
59   const Matrix<qreal, 3, 1>& g, const Matrix<qreal, 3, 3>& H);
60 Matrix<qreal, 3, 1> minusOneSignatureLocatorGradient(
61   const Matrix<qreal, 3, 1>& g, const Matrix<qreal, 3, 3>& H);
62 Matrix<qreal, 3, 1> plusOneSignatureLocatorGradient(
63   const Matrix<qreal, 3, 1>& g, const Matrix<qreal, 3, 3>& H);
64 Matrix<qreal, 3, 1> plusThreeSignatureLocatorGradient(
65   const Matrix<qreal, 3, 1>& g, const Matrix<qreal, 3, 3>& H);
66 }
67 
68 } // namespace QtPlugins
69 } // namespace Avogadro
70 
71 #endif // QTAIMMATHUTILITIES_H
72