CheMPS2
ConjugateGradient.h
1 /*
2  CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
3  Copyright (C) 2013-2016 Sebastian Wouters
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #ifndef CONJUGATEGRADIENT_CHEMPS2_H
21 #define CONJUGATEGRADIENT_CHEMPS2_H
22 
23 namespace CheMPS2{
38 
39  public:
40 
42 
46  ConjugateGradient(const int veclength_in, const double RTOL_in, const double DIAG_CUTOFF_in, const bool print_in);
47 
49  virtual ~ConjugateGradient();
50 
52 
54  char step( double ** pointers );
55 
57 
58  int get_num_matvec() const;
59 
60  private:
61 
62  int veclength;
63  double RTOL;
64  double DIAG_CUTOFF;
65  bool print;
66 
67  char state; // Current state of the algorithm
68  int num_matvec; // Current number of matvec multiplications
69 
70  // Helper arrays
71  double * XVEC;
72  double * PRECON;
73  double * RHS;
74  double * WORK;
75  double * RESID;
76  double * PVEC;
77  double * OPVEC;
78 
79  // Helper variables
80  double rnorm;
81  double rdotr;
82 
83  // Internal functions to hop between states
84  void stepL2K();
85  void stepY2Z();
86  void stepJ2K();
87  void stepG2H();
88  double inprod( double * vector );
89  double inprod( double * vector, double * othervector );
90  void apply_precon( double * vector );
91  void apply_precon( double * vector, double * result );
92 
93  };
94 }
95 
96 #endif
97 
char step(double **pointers)
The iterator to converge the ground state vector.
Definition: CASPT2.h:42
int get_num_matvec() const
Get the number of matrix vector multiplications which have been performed.
virtual ~ConjugateGradient()
Destructor.
ConjugateGradient(const int veclength_in, const double RTOL_in, const double DIAG_CUTOFF_in, const bool print_in)
Constructor.