Psi4
odometer.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 
32 /*
33 ** ODOMETER(): Generalized odometer object. Each `digit' can have its
34 ** own min and max values (and actually each position can be filled by an
35 ** integer, not just a single digit). The low-index digits are the
36 ** faster moving ones. There is also a special lexical increment which
37 ** ensures that digit i is greater than digit i+1.
38 **
39 ** Methods:
40 ** Odometer(): Default constructor gives 0 digits and all NULL arrays.
41 ** Odometer(int n): Construct an odometer with n digits
42 ** ~Odometer(): Free's the dynamically allocated memory
43 ** size(int m): Set the length of a default-constructed odometer to m
44 ** resize(int m): Change the length of an odometer to m
45 ** set_max(int m): set the maximum for every digit to m
46 ** set_max(int *m): set the max for each digit according to array m
47 ** set_min(int m), set_min(int *m): similar to set_max()
48 ** set_value(int m), set_value(int *m): similar to set_max()
49 ** set_max_lex(int m): set max values for each digit such that the
50 ** lowest index digit has max m, the next has max m-1, etc.
51 ** set_min_lex(int m): set min values for each digit such that the
52 ** highest index digit has min m, the next has min m-1, etc.
53 ** get_value(int *m): copy the values array into array m
54 ** increment(): increment the odometer (at position 0)
55 ** increment_lex(): lexical index...increment but make sure that
56 ** value[i] > value[i+1]
57 ** reset(): return all digits to their min values
58 ** print(): print out odometer reading (high index digits first)
59 ** at_max(): has the odometer reached its maximum reading? (1 or 0)
60 ** at_min(): has the odometer reached its minimum reading? (1 or 0)
61 ** get_length(): returns the length (number of digits) of the odometer
62 ** boundscheck(): make sure max's are > min's, and vice versa
63 **
64 */
65 
66 #ifndef _psi_src_bin_detci_odometer_h
67 #define _psi_src_bin_detci_odometer_h
68 
69 namespace psi { namespace detci {
70 
71 class Odometer {
72 
73  protected:
74  unsigned length ;
75  int* max ;
76  int* min ;
77  int* value ;
78 
79  public:
80  Odometer() ;
81  Odometer(unsigned len) { size(len); }
82  ~Odometer() ;
83 
84  void size(unsigned s) ;
85  void resize(unsigned s) ;
86  void set_max(int m) ;
87  void set_max_lex(int m) ;
88  void set_max(int* m) ;
89  void set_min(int m) ;
90  void set_min_lex(int m) ;
91  void set_min(int* m) ;
92  void set_value(int m) ;
93  void set_value(int* m) ;
94  void get_value(int* m) ;
95  void increment() ;
96  void increment_lex() ;
97  void reset() ;
98  void print() ;
99  unsigned at_max() ;
100  unsigned at_min() ;
101  unsigned get_length()
102  {return length; }
103  unsigned boundscheck() ;
104 } ;
105 
106 }} // namespace psi::detci
107 
108 #endif // header guard
void set_min(int m)
Definition: odometer.cc:136
unsigned at_max()
Definition: odometer.cc:245
void size(unsigned s)
Definition: odometer.cc:71
unsigned at_min()
Definition: odometer.cc:258
int * max
Definition: odometer.h:75
unsigned boundscheck()
Definition: odometer.cc:271
void reset()
Definition: odometer.cc:189
int * value
Definition: odometer.h:77
void set_value(int m)
Definition: odometer.cc:162
Definition: odometer.h:71
unsigned get_length()
Definition: odometer.h:101
void set_max_lex(int m)
Definition: odometer.cc:120
Odometer(unsigned len)
Definition: odometer.h:81
void get_value(int *m)
Definition: odometer.cc:171
void increment()
Definition: odometer.cc:198
~Odometer()
Definition: odometer.cc:61
SharedWavefunction detci(SharedWavefunction, Options &)
Definition: detci.cc:64
void resize(unsigned s)
Definition: odometer.cc:87
unsigned length
Definition: odometer.h:74
void set_max(int m)
Definition: odometer.cc:112
Odometer()
Definition: odometer.cc:53
void increment_lex()
Definition: odometer.cc:214
void print()
Definition: odometer.cc:234
void set_min_lex(int m)
Definition: odometer.cc:145
int * min
Definition: odometer.h:76