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 namespace psi {
33 
34 class Vector;
35 class TwoBodyAOInt;
36 class BasisSet;
37 
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:252
Definition: cholesky.h:79
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:321
virtual ~Cholesky()
Destructor, resets L_.
Definition: cholesky.cc:57
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: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
CholeskyMatrix(SharedMatrix A, double delta, unsigned long int memory)
Definition: cholesky.cc:151
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:264
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:285
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:362
CholeskyLocal(SharedMatrix C, double delta, unsigned long int memory)
Definition: cholesky.cc:353
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:335
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:314
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:317
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:53
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:129
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
Definition: cholesky.h:107
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
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:179
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: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:48
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:166
Definition: cholesky.h:141
double schwarz_
Definition: cholesky.h:95
Definition: PsiFileImpl.h:39
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:306
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:128
virtual ~CholeskyMatrix()
Definition: cholesky.cc:159