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-2018 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 
43 protected:
45  double delta_;
47  size_t memory_;
51  size_t Q_;
52 
53 public:
59  Cholesky(double delta, size_t memory);
61  virtual ~Cholesky();
62 
64  virtual void choleskify();
65 
67  SharedMatrix L() const { return L_; }
69  size_t Q() const { return Q_; }
71  virtual size_t N() = 0;
73  double delta() const { return delta_; }
74 
76  virtual void compute_diagonal(double* target) = 0;
78  virtual void compute_row(int row, double* target) = 0;
79 
80 };
81 
82 class CholeskyMatrix : public Cholesky {
83 
84 protected:
86 public:
87  CholeskyMatrix(SharedMatrix A, double delta, size_t memory);
88  virtual ~CholeskyMatrix();
89 
90  virtual size_t N();
91  virtual void compute_diagonal(double* target);
92  virtual void compute_row(int row, double* target);
93 };
94 
95 class PSI_API CholeskyERI : public Cholesky {
96 
97 protected:
98  double schwarz_;
99  std::shared_ptr<BasisSet> basisset_;
100  std::shared_ptr<TwoBodyAOInt> integral_;
101 public:
102  CholeskyERI(std::shared_ptr<TwoBodyAOInt> integral, double schwarz, double delta, size_t memory);
103  virtual ~CholeskyERI();
104 
105  virtual size_t N();
106  virtual void compute_diagonal(double* target);
107  virtual void compute_row(int row, double* target);
108 };
109 
110 class CholeskyMP2 : public Cholesky {
111 
112 protected:
115  std::shared_ptr<Vector> eps_aocc_;
116  std::shared_ptr<Vector> eps_avir_;
117 public:
118  CholeskyMP2(SharedMatrix Qia, std::shared_ptr<Vector> eps_aocc,
119  std::shared_ptr<Vector> eps_avir, bool symmetric,
120  double delta, size_t memory);
121  virtual ~CholeskyMP2();
122 
123  virtual size_t N();
124  virtual void compute_diagonal(double* target);
125  virtual void compute_row(int row, double* target);
126 };
127 
128 class CholeskyDelta : public Cholesky {
129 
130 protected:
131  std::shared_ptr<Vector> eps_aocc_;
132  std::shared_ptr<Vector> eps_avir_;
133 public:
134  CholeskyDelta(std::shared_ptr<Vector> eps_aocc,
135  std::shared_ptr<Vector> eps_avir,
136  double delta, size_t memory);
137  virtual ~CholeskyDelta();
138 
139  virtual size_t N();
140  virtual void compute_diagonal(double* target);
141  virtual void compute_row(int row, double* target);
142 };
143 
144 class CholeskyLocal : public Cholesky {
145 
146 protected:
148 public:
150  double delta, size_t memory);
151  virtual ~CholeskyLocal();
152 
153  virtual size_t N();
154  virtual void compute_diagonal(double* target);
155  virtual void compute_row(int row, double* target);
156 };
157 
158 } // Namespace psi
159 #endif
Definition: cholesky.h:82
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
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:269
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:49
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:157
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:149
virtual ~CholeskyLocal()
Definition: cholesky.cc:300
virtual ~CholeskyMP2()
Definition: cholesky.cc:226
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:227
SharedMatrix Qia_
Definition: cholesky.h:114
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:244
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:115
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:301
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:116
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:282
SharedMatrix C_
Definition: cholesky.h:147
double delta() const
Maximum Chebyshev error allowed in the decomposition.
Definition: cholesky.h:73
virtual ~CholeskyDelta()
Definition: cholesky.cc:267
Definition: cholesky.h:95
Definition: cholesky.h:128
std::shared_ptr< BasisSet > basisset_
Definition: cholesky.h:99
SharedMatrix A_
Definition: cholesky.h:85
virtual size_t N()
Dimension of the original square tensor, provided by the subclass.
Definition: cholesky.cc:268
std::shared_ptr< TwoBodyAOInt > integral_
Definition: cholesky.h:100
SharedMatrix L() const
Shared pointer to decomposition (Q x N), if choleskify() called.
Definition: cholesky.h:67
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
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:302
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:228
std::shared_ptr< Vector > eps_avir_
Definition: cholesky.h:132
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
Definition: cholesky.h:110
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:128
virtual void compute_row(int row, double *target)
Row row of the original square tensor, provided by the subclass.
Definition: cholesky.cc:312
size_t memory_
Maximum memory to use, in doubles.
Definition: cholesky.h:47
size_t Q() const
Number of columns required to reach accuracy delta, if choleskify() called.
Definition: cholesky.h:69
double delta_
Maximum Chebyshev error allowed in the decomposition.
Definition: cholesky.h:45
bool symmetric_
Definition: cholesky.h:113
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:51
virtual void compute_diagonal(double *target)
Diagonal of the original square tensor, provided by the subclass.
Definition: cholesky.cc:150
Definition: cholesky.h:144
double schwarz_
Definition: cholesky.h:98
Definition: cholesky.h:41
std::shared_ptr< Vector > eps_aocc_
Definition: cholesky.h:131
virtual ~CholeskyMatrix()
Definition: cholesky.cc:148