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-2017 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/libmints/typedefs.h"
33 
34 namespace psi {
35 
36 class Vector;
37 class TwoBodyAOInt;
38 class BasisSet;
39 
40 class Cholesky {
41 
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 
81 class CholeskyMatrix : public Cholesky {
82 
83 protected:
85 public:
86  CholeskyMatrix(SharedMatrix A, double delta, size_t memory);
87  virtual ~CholeskyMatrix();
88 
89  virtual size_t N();
90  virtual void compute_diagonal(double* target);
91  virtual void compute_row(int row, double* target);
92 };
93 
94 class CholeskyERI : public Cholesky {
95 
96 protected:
97  double schwarz_;
98  std::shared_ptr<BasisSet> basisset_;
99  std::shared_ptr<TwoBodyAOInt> integral_;
100 public:
101  CholeskyERI(std::shared_ptr<TwoBodyAOInt> integral, double schwarz, double delta, size_t memory);
102  virtual ~CholeskyERI();
103 
104  virtual size_t N();
105  virtual void compute_diagonal(double* target);
106  virtual void compute_row(int row, double* target);
107 };
108 
109 class CholeskyMP2 : public Cholesky {
110 
111 protected:
114  std::shared_ptr<Vector> eps_aocc_;
115  std::shared_ptr<Vector> eps_avir_;
116 public:
117  CholeskyMP2(SharedMatrix Qia, std::shared_ptr<Vector> eps_aocc,
118  std::shared_ptr<Vector> eps_avir, bool symmetric,
119  double delta, size_t memory);
120  virtual ~CholeskyMP2();
121 
122  virtual size_t N();
123  virtual void compute_diagonal(double* target);
124  virtual void compute_row(int row, double* target);
125 };
126 
127 class CholeskyDelta : public Cholesky {
128 
129 protected:
130  std::shared_ptr<Vector> eps_aocc_;
131  std::shared_ptr<Vector> eps_avir_;
132 public:
133  CholeskyDelta(std::shared_ptr<Vector> eps_aocc,
134  std::shared_ptr<Vector> eps_avir,
135  double delta, size_t memory);
136  virtual ~CholeskyDelta();
137 
138  virtual size_t N();
139  virtual void compute_diagonal(double* target);
140  virtual void compute_row(int row, double* target);
141 };
142 
143 class CholeskyLocal : public Cholesky {
144 
145 protected:
147 public:
149  double delta, size_t memory);
150  virtual ~CholeskyLocal();
151 
152  virtual size_t N();
153  virtual void compute_diagonal(double* target);
154  virtual void compute_row(int row, double* target);
155 };
156 
157 } // Namespace psi
158 #endif
Definition: cholesky.h:81
CholeskyLocal(SharedMatrix C, double delta, size_t memory)
Definition: cholesky.cc:353
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:252
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:321
CholeskyMatrix(SharedMatrix A, double delta, size_t memory)
Definition: cholesky.cc:151
virtual ~Cholesky()
Destructor, resets L_.
Definition: cholesky.cc:57
SharedMatrix L_
Full L (Q x n), if choleskify() called()
Definition: cholesky.h:48
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:174
virtual ~CholeskyERI()
Definition: cholesky.cc:185
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:162
virtual ~CholeskyLocal()
Definition: cholesky.cc:359
virtual ~CholeskyMP2()
Definition: cholesky.cc:261
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:264
SharedMatrix Qia_
Definition: cholesky.h:113
Cholesky(double delta, size_t memory)
Definition: cholesky.cc:53
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:285
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:114
virtual void compute_row(int row, double *target)=0
Row row of the original square tensor, provided by the subclass.
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:362
CholeskyERI(std::shared_ptr< TwoBodyAOInt > integral, double schwarz, double delta, size_t memory)
Definition: cholesky.cc:179
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:115
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:335
SharedMatrix C_
Definition: cholesky.h:146
double delta() const
Maximum Chebyshev error allowed in the decomposition.
Definition: cholesky.h:72
virtual ~CholeskyDelta()
Definition: cholesky.cc:314
Definition: cholesky.h:94
Definition: cholesky.h:127
std::shared_ptr< BasisSet > basisset_
Definition: cholesky.h:98
SharedMatrix A_
Definition: cholesky.h:84
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:317
std::shared_ptr< TwoBodyAOInt > integral_
Definition: cholesky.h:99
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:306
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:366
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:268
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:131
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
Definition: cholesky.h:109
virtual void choleskify()
Perform the cholesky decomposition (requires 2QN memory)
Definition: cholesky.cc:60
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:192
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:377
size_t memory_
Maximum memory to use, in doubles.
Definition: cholesky.h:46
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:112
virtual size_t N()=0
Dimension of the original square tensor, provided by the subclass.
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:188
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:214
size_t Q_
Number of columns required, if choleskify() called.
Definition: cholesky.h:50
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:166
Definition: cholesky.h:143
double schwarz_
Definition: cholesky.h:97
Definition: cholesky.h:40
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:130
virtual ~CholeskyMatrix()
Definition: cholesky.cc:159