Psi4
cholesky.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2019 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef THREE_INDEX_CHOLESKY
30 #define THREE_INDEX_CHOLESKY
31 
32 #include "psi4/pragma.h"
33 #include "psi4/libmints/typedefs.h"
34 
35 namespace psi {
36 
37 class Vector;
38 class TwoBodyAOInt;
39 class BasisSet;
40 
41 class Cholesky {
42  protected:
44  double delta_;
46  size_t memory_;
50  size_t Q_;
51 
52  public:
58  Cholesky(double delta, size_t memory);
60  virtual ~Cholesky();
61 
63  virtual void choleskify();
64 
66  SharedMatrix L() const { return L_; }
68  size_t Q() const { return Q_; }
70  virtual size_t N() = 0;
72  double delta() const { return delta_; }
73 
75  virtual void compute_diagonal(double* target) = 0;
77  virtual void compute_row(int row, double* target) = 0;
78 };
79 
80 class CholeskyMatrix : public Cholesky {
81  protected:
83 
84  public:
85  CholeskyMatrix(SharedMatrix A, double delta, size_t memory);
86  ~CholeskyMatrix() override;
87 
88  size_t N() override;
89  void compute_diagonal(double* target) override;
90  void compute_row(int row, double* target) override;
91 };
92 
93 class PSI_API CholeskyERI : public Cholesky {
94  protected:
95  double schwarz_;
96  std::shared_ptr<BasisSet> basisset_;
97  std::shared_ptr<TwoBodyAOInt> integral_;
98 
99  public:
100  CholeskyERI(std::shared_ptr<TwoBodyAOInt> integral, double schwarz, double delta, size_t memory);
101  ~CholeskyERI() override;
102 
103  size_t N() override;
104  void compute_diagonal(double* target) override;
105  void compute_row(int row, double* target) override;
106 };
107 
108 class CholeskyMP2 : public Cholesky {
109  protected:
112  std::shared_ptr<Vector> eps_aocc_;
113  std::shared_ptr<Vector> eps_avir_;
114 
115  public:
116  CholeskyMP2(SharedMatrix Qia, std::shared_ptr<Vector> eps_aocc, std::shared_ptr<Vector> eps_avir, bool symmetric,
117  double delta, size_t memory);
118  ~CholeskyMP2() override;
119 
120  size_t N() override;
121  void compute_diagonal(double* target) override;
122  void compute_row(int row, double* target) override;
123 };
124 
125 class CholeskyDelta : public Cholesky {
126  protected:
127  std::shared_ptr<Vector> eps_aocc_;
128  std::shared_ptr<Vector> eps_avir_;
129 
130  public:
131  CholeskyDelta(std::shared_ptr<Vector> eps_aocc, std::shared_ptr<Vector> eps_avir, double delta, size_t memory);
132  ~CholeskyDelta() override;
133 
134  size_t N() override;
135  void compute_diagonal(double* target) override;
136  void compute_row(int row, double* target) override;
137 };
138 
139 class CholeskyLocal : public Cholesky {
140  protected:
142 
143  public:
144  CholeskyLocal(SharedMatrix C, double delta, size_t memory);
145  ~CholeskyLocal() override;
146 
147  size_t N() override;
148  void compute_diagonal(double* target) override;
149  void compute_row(int row, double* target) override;
150 };
151 
152 } // Namespace psi
153 #endif
size_t N() override
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:149
Definition: cholesky.h:80
CholeskyLocal(SharedMatrix C, double delta, size_t memory)
Definition: cholesky.cc:299
CholeskyMP2(SharedMatrix Qia, std::shared_ptr< Vector > eps_aocc, std::shared_ptr< Vector > eps_avir, bool symmetric, double delta, size_t memory)
Definition: cholesky.cc:223
size_t N() override
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:301
CholeskyMatrix(SharedMatrix A, double delta, size_t memory)
Definition: cholesky.cc:144
virtual ~Cholesky()
Destructor, resets L_.
Definition: cholesky.cc:54
SharedMatrix L_
Full L (Q x n), if choleskify() called()
Definition: cholesky.h:48
~CholeskyMP2() override
Definition: cholesky.cc:226
~CholeskyLocal() override
Definition: cholesky.cc:300
SharedMatrix Qia_
Definition: cholesky.h:111
void compute_row(int row, double *target) override
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:282
Cholesky(double delta, size_t memory)
Definition: cholesky.cc:53
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:112
virtual void compute_row(int row, double *target)=0
Row row of the original square tensor, provided by the subclass.
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:113
SharedMatrix C_
Definition: cholesky.h:141
double delta() const
Maximum Chebyshev error allowed in the decomposition.
Definition: cholesky.h:72
void compute_diagonal(double *target) override
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:302
Definition: cholesky.h:93
Definition: cholesky.h:125
std::shared_ptr< BasisSet > basisset_
Definition: cholesky.h:96
void compute_row(int row, double *target) override
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:244
SharedMatrix A_
Definition: cholesky.h:82
~CholeskyDelta() override
Definition: cholesky.cc:267
size_t N() override
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:227
std::shared_ptr< TwoBodyAOInt > integral_
Definition: cholesky.h:97
SharedMatrix L() const
Shared pointer to decomposition (Q x N), if choleskify() called.
Definition: cholesky.h:66
virtual void compute_diagonal(double *target)=0
Diagonal of the original square tensor, provided by the subclass.
CholeskyDelta(std::shared_ptr< Vector > eps_aocc, std::shared_ptr< Vector > eps_avir, double delta, size_t memory)
Definition: cholesky.cc:264
void compute_diagonal(double *target) override
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:269
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:128
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
Definition: cholesky.h:108
int delta(const int i, const int j)
Definition: bend.cc:175
virtual void choleskify()
Perform the cholesky decomposition (requires 2QN memory)
Definition: cholesky.cc:55
#define PSI_API
Definition: pragma.h:155
void compute_row(int row, double *target) override
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:157
size_t memory_
Maximum memory to use, in doubles.
Definition: cholesky.h:46
void compute_diagonal(double *target) override
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:150
void compute_diagonal(double *target) override
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:228
size_t Q() const
Number of columns required to reach accuracy delta, if choleskify() called.
Definition: cholesky.h:68
double delta_
Maximum Chebyshev error allowed in the decomposition.
Definition: cholesky.h:44
bool symmetric_
Definition: cholesky.h:110
virtual size_t N()=0
Dimension of the original square tensor, provided by the subclass.
size_t Q_
Number of columns required, if choleskify() called.
Definition: cholesky.h:50
Definition: cholesky.h:139
double schwarz_
Definition: cholesky.h:95
void compute_row(int row, double *target) override
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:312
size_t N() override
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:268
Definition: cholesky.h:41
~CholeskyMatrix() override
Definition: cholesky.cc:148
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:127