votca 2026-dev
Loading...
Searching...
No Matches
aomatrix.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2021 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "A_ol I_ol" BA_olI_ol,
14 * WITHOUT WARRANTIE_ol OR CONDITION_ol OF ANY KIND, either express or implied.
15 * olee_ the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20// Standard includes
21#include <vector>
22// Local VOTCA includes
23#include "votca/xtp/aomatrix.h"
25
26namespace votca {
27namespace xtp {
28
29Eigen::MatrixXd AOOverlap::Pseudo_InvSqrt(double etol) {
32 Eigen::VectorXd diagonal = Eigen::VectorXd::Zero(es.values.size());
34 for (Index i = 0; i < diagonal.size(); ++i) {
35 if (es.values(i) < etol) {
37 } else {
38 diagonal(i) = 1.0 / std::sqrt(es.values(i));
39 }
40 }
41
42 return es.vectors * diagonal.asDiagonal() * es.vectors.transpose();
43}
44
45Eigen::MatrixXd AOOverlap::Sqrt() {
48 return es.vectors * es.values.cwiseSqrt().asDiagonal() *
49 es.vectors.transpose();
50}
51
52// This converts V into ((S-1/2 V S-1/2)-1/2 S-1/2)T, which is needed to
53// construct 4c integrals,
54Eigen::MatrixXd AOCoulomb::Pseudo_InvSqrt_GWBSE(const AOOverlap& auxoverlap,
55 double etol) {
56
57 const SymmetricEigenSystem eo = SymmetricEigen(auxoverlap.Matrix());
59 Eigen::VectorXd diagonal_overlap = Eigen::VectorXd::Zero(eo.values.size());
60 for (Index i = 0; i < diagonal_overlap.size(); ++i) {
61 if (eo.values(i) < etol) {
63 } else {
64 diagonal_overlap(i) = 1.0 / std::sqrt(eo.values(i));
65 }
66 }
67 Eigen::MatrixXd Ssqrt =
68 eo.vectors * diagonal_overlap.asDiagonal() * eo.vectors.transpose();
69
70 Eigen::MatrixXd ortho = Ssqrt * aomatrix_ * Ssqrt;
71 const SymmetricEigenSystem es = SymmetricEigen(ortho);
72 Eigen::VectorXd diagonal = Eigen::VectorXd::Zero(es.values.size());
73
74 for (Index i = 0; i < diagonal.size(); ++i) {
75 if (es.values(i) < etol) {
77 } else {
78 diagonal(i) = 1.0 / std::sqrt(es.values(i));
79 }
80 }
81
82 Eigen::MatrixXd Vm1 =
83 es.vectors * diagonal.asDiagonal() * es.vectors.transpose();
84 Eigen::MatrixXd result = (Vm1 * Ssqrt).transpose();
85 return result;
86}
87
88Eigen::MatrixXd AOCoulomb::Pseudo_InvSqrt(double etol) {
90 Eigen::VectorXd diagonal = Eigen::VectorXd::Zero(es.values.size());
92 for (Index i = 0; i < diagonal.size(); ++i) {
93 if (es.values(i) < etol) {
95 } else {
96 diagonal(i) = 1.0 / std::sqrt(es.values(i));
97 }
98 }
99
100 return es.vectors * diagonal.asDiagonal() * es.vectors.transpose();
101}
102
103} // namespace xtp
104} // namespace votca
Eigen::MatrixXd aomatrix_
Definition aomatrix.h:82
Eigen::MatrixXd Pseudo_InvSqrt(double etol)
Definition aomatrix.cc:88
Eigen::MatrixXd Pseudo_InvSqrt_GWBSE(const AOOverlap &auxoverlap, double etol)
Definition aomatrix.cc:54
Eigen::MatrixXd Pseudo_InvSqrt(double etol)
Definition aomatrix.cc:29
const Eigen::MatrixXd & Matrix() const
Definition aomatrix.h:52
double smallestEigenvalue
Definition aomatrix.h:63
Eigen::MatrixXd Sqrt()
Definition aomatrix.cc:45
Eigen::MatrixXd aomatrix_
Definition aomatrix.h:64
Charge transport classes.
Definition ERIs.h:28
SymmetricEigenSystem SymmetricEigen(const Eigen::MatrixXd &A, bool vectors=true)
With vectors = false only the eigenvalues are computed.
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26