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 program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef THREE_INDEX_CHOLESKY
29 #define THREE_INDEX_CHOLESKY
30 #include "psi4/libmints/sieve.h"
31 
32 namespace psi {
33 
34 class Matrix;
35 class Vector;
36 class TwoBodyAOInt;
37 class BasisSet;
38 class Cholesky {
39 
40 protected:
42  double delta_;
44  unsigned long int memory_;
48  size_t Q_;
49 
50 public:
56  Cholesky(double delta, unsigned long int memory);
58  virtual ~Cholesky();
59 
61  virtual void choleskify();
62 
64  SharedMatrix L() const { return L_; }
66  size_t Q() const { return Q_; }
68  virtual size_t N() = 0;
70  double delta() const { return delta_; }
71 
73  virtual void compute_diagonal(double* target) = 0;
75  virtual void compute_row(int row, double* target) = 0;
76 
77 };
78 
79 class CholeskyMatrix : public Cholesky {
80 
81 protected:
83 public:
84  CholeskyMatrix(SharedMatrix A, double delta, unsigned long int memory);
85  virtual ~CholeskyMatrix();
86 
87  virtual size_t N();
88  virtual void compute_diagonal(double* target);
89  virtual void compute_row(int row, double* target);
90 };
91 
92 class CholeskyERI : public Cholesky {
93 
94 protected:
95  double schwarz_;
96  std::shared_ptr<BasisSet> basisset_;
97  std::shared_ptr<TwoBodyAOInt> integral_;
98 public:
99  CholeskyERI(std::shared_ptr<TwoBodyAOInt> integral, double schwarz, double delta, unsigned long int memory);
100  virtual ~CholeskyERI();
101 
102  virtual size_t N();
103  virtual void compute_diagonal(double* target);
104  virtual void compute_row(int row, double* target);
105 };
106 
107 class CholeskyMP2 : public Cholesky {
108 
109 protected:
112  std::shared_ptr<Vector> eps_aocc_;
113  std::shared_ptr<Vector> eps_avir_;
114 public:
115  CholeskyMP2(SharedMatrix Qia, std::shared_ptr<Vector> eps_aocc,
116  std::shared_ptr<Vector> eps_avir, bool symmetric,
117  double delta, unsigned long int memory);
118  virtual ~CholeskyMP2();
119 
120  virtual size_t N();
121  virtual void compute_diagonal(double* target);
122  virtual void compute_row(int row, double* target);
123 };
124 
125 class CholeskyDelta : public Cholesky {
126 
127 protected:
128  std::shared_ptr<Vector> eps_aocc_;
129  std::shared_ptr<Vector> eps_avir_;
130 public:
131  CholeskyDelta(std::shared_ptr<Vector> eps_aocc,
132  std::shared_ptr<Vector> eps_avir,
133  double delta, unsigned long int memory);
134  virtual ~CholeskyDelta();
135 
136  virtual size_t N();
137  virtual void compute_diagonal(double* target);
138  virtual void compute_row(int row, double* target);
139 };
140 
141 class CholeskyLocal : public Cholesky {
142 
143 protected:
145 public:
147  double delta, unsigned long int memory);
148  virtual ~CholeskyLocal();
149 
150  virtual size_t N();
151  virtual void compute_diagonal(double* target);
152  virtual void compute_row(int row, double* target);
153 };
154 
155 } // Namespace psi
156 #endif
CholeskyMP2(SharedMatrix Qia, std::shared_ptr< Vector > eps_aocc, std::shared_ptr< Vector > eps_avir, bool symmetric, double delta, unsigned long int memory)
Definition: cholesky.cc:251
Definition: cholesky.h:79
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:320
virtual ~Cholesky()
Destructor, resets L_.
Definition: cholesky.cc:56
SharedMatrix L_
Full L (Q x n), if choleskify() called()
Definition: cholesky.h:46
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:173
virtual ~CholeskyERI()
Definition: cholesky.cc:184
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:161
virtual ~CholeskyLocal()
Definition: cholesky.cc:358
virtual ~CholeskyMP2()
Definition: cholesky.cc:260
CholeskyMatrix(SharedMatrix A, double delta, unsigned long int memory)
Definition: cholesky.cc:150
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:263
SharedMatrix Qia_
Definition: cholesky.h:111
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:284
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.
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:361
CholeskyLocal(SharedMatrix C, double delta, unsigned long int memory)
Definition: cholesky.cc:352
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:113
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:334
SharedMatrix C_
Definition: cholesky.h:144
double delta() const
Maximum Chebyshev error allowed in the decomposition.
Definition: cholesky.h:70
virtual ~CholeskyDelta()
Definition: cholesky.cc:313
Definition: cholesky.h:92
Definition: cholesky.h:125
std::shared_ptr< BasisSet > basisset_
Definition: cholesky.h:96
SharedMatrix A_
Definition: cholesky.h:82
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:316
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:64
virtual void compute_diagonal(double *target)=0
Diagonal of the original square tensor, provided by the subclass.
Cholesky(double delta, unsigned long int memory)
Definition: cholesky.cc:52
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:365
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:267
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:129
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:50
Definition: cholesky.h:107
virtual void choleskify()
Perform the cholesky decomposition (requires 2QN memory)
Definition: cholesky.cc:59
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:191
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:376
unsigned long int memory_
Maximum memory to use, in doubles.
Definition: cholesky.h:44
size_t Q() const
Number of columns required to reach accuracy delta, if choleskify() called.
Definition: cholesky.h:66
CholeskyERI(std::shared_ptr< TwoBodyAOInt > integral, double schwarz, double delta, unsigned long int memory)
Definition: cholesky.cc:178
double delta_
Maximum Chebyshev error allowed in the decomposition.
Definition: cholesky.h:42
bool symmetric_
Definition: cholesky.h:110
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:187
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:213
size_t Q_
Number of columns required, if choleskify() called.
Definition: cholesky.h:48
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:165
Definition: cholesky.h:141
double schwarz_
Definition: cholesky.h:95
Definition: PsiFileImpl.h:38
Definition: cholesky.h:38
CholeskyDelta(std::shared_ptr< Vector > eps_aocc, std::shared_ptr< Vector > eps_avir, double delta, unsigned long int memory)
Definition: cholesky.cc:305
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:128
virtual ~CholeskyMatrix()
Definition: cholesky.cc:158