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