Psi4
cartesianiter.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 
28 #ifndef _psi_src_lib_libmints_cartesianiter_h_
29 #define _psi_src_lib_libmints_cartesianiter_h_
30 
31 namespace psi {
32 
36 {
37 protected:
38  int a_;
39  int b_;
40  int c_;
41  int l_;
42  int bfn_;
43 
44 public:
46  CartesianIter(int l);
47  virtual ~CartesianIter();
48 
50  virtual void start();
52  virtual void next();
54  virtual operator int();
55 
57  int n() const { return ((l_>=0)?((((l_)+2)*((l_)+1))>>1):0); }
59  int a() const { return a_; }
61  int b() const { return b_; }
63  int c() const { return c_; }
65  int l() const { return l_; }
67  int l(int i) const { return i ? (i==1 ? b_ : c_) : a_; }
70  int bfn() { return bfn_; }
71 };
72 
78  int done_;
79  int l_;
80  int *axis_;
81 
82 public:
85  virtual ~RedundantCartesianIter();
86 
88  virtual int bfn();
89 
91  void start();
93  void next();
95  operator int() { return !done_; }
96 
98  int a() const;
100  int b() const;
102  int c() const;
104  int l() const { return l_; }
106  int l(int i) const;
108  int axis(int i) const { return axis_[i]; }
109 };
110 
112 {
113  if (l_==0)
114  done_ = 1;
115  else
116  done_ = 0;
117 
118  for (int i=0; i<l_; i++)
119  axis_[i] = 0;
120 }
121 
123 {
124  for (int i=0; i<l_; i++) {
125  if (axis_[i] == 2)
126  axis_[i] = 0;
127  else {
128  axis_[i]++;
129  return;
130  }
131  }
132  done_ = 1;
133 }
134 
135 inline int RedundantCartesianIter::l(int axis) const
136 {
137  int i;
138  int r = 0;
139  for (i=0; i<l_; i++) if (axis_[i]==axis) r++;
140  return r;
141 }
142 
143 inline int RedundantCartesianIter::a() const
144 {
145  return l(0);
146 }
147 
148 inline int RedundantCartesianIter::b() const
149 {
150  return l(1);
151 }
152 
153 inline int RedundantCartesianIter::c() const
154 {
155  return l(2);
156 }
157 
161  int done_;
162  int l_;
163  int e_[3];
164  int *axis_;
165 
166  // the locations of the z's in the axis array
167  int *zloc_;
168  // the locations of the y's in the subarray after the z's are removed
169  int *yloc_;
170 
171  int valid();
172 
173 public:
176  virtual ~RedundantCartesianSubIter();
177 
179  virtual int bfn();
180 
183  void start(int a, int b, int c);
185  void next();
187  operator int() const { return !done_; }
188 
190  int a() const { return e_[0]; }
192  int b() const { return e_[1]; }
194  int c() const { return e_[2]; }
196  int l() const { return l_; }
198  int l(int i) { return e_[i]; }
200  int axis(int i) { return axis_[i]; }
201 };
202 
203 }
204 
205 #endif // _psi_src_lib_libmints_cartesianiter_h_
virtual void start()
Start the iteration.
Definition: cartesianiter.cc:44
virtual ~RedundantCartesianSubIter()
Definition: cartesianiter.cc:107
int a() const
The current exponent of x.
Definition: cartesianiter.h:190
int a_
Definition: cartesianiter.h:38
int * axis_
Definition: cartesianiter.h:164
int b() const
The current exponent of y.
Definition: cartesianiter.h:192
void next()
Move to the next combination of axes.
Definition: cartesianiter.cc:157
void start()
Initialize the iterator.
Definition: cartesianiter.h:111
int l_
Definition: cartesianiter.h:162
int b_
Definition: cartesianiter.h:39
int bfn_
Definition: cartesianiter.h:42
virtual int bfn()
Return the current Cartesian basis function number.
Definition: cartesianiter.cc:83
int l_
Definition: cartesianiter.h:41
Definition: pointgrp.h:105
Definition: cartesianiter.h:77
int l() const
Return the angular momentum.
Definition: cartesianiter.h:65
int c_
Definition: cartesianiter.h:40
RedundantCartesianIter(int l)
Create a object for the given angular momentum.
Definition: cartesianiter.cc:71
int n() const
Returns the number of Cartesian functions.
Definition: cartesianiter.h:57
int c() const
The current exponent of z.
Definition: cartesianiter.h:153
CartesianIter(int l)
Initialize the iterator for the given angular momentum.
Definition: cartesianiter.cc:33
int b() const
Returns the y exponent.
Definition: cartesianiter.h:61
int done_
Definition: cartesianiter.h:78
int l(int i)
Returns a() if i==0, b() if i==1, and c() if i==2.
Definition: cartesianiter.h:198
virtual int bfn()
Return the current Cartesian basis function number.
Definition: cartesianiter.cc:206
virtual void next()
Move to the next Cartesian function.
Definition: cartesianiter.cc:50
int done_
Definition: cartesianiter.h:161
virtual ~RedundantCartesianIter()
Definition: cartesianiter.cc:78
int l() const
The angular momentum.
Definition: cartesianiter.h:104
int l_
Definition: cartesianiter.h:79
int * axis_
Definition: cartesianiter.h:80
int l(int i) const
Returns a() if i==0, b() if i==1, and c() if i==2.
Definition: cartesianiter.h:67
void next()
Move to the next combination of axes.
Definition: cartesianiter.h:122
int a() const
Returns the x exponent.
Definition: cartesianiter.h:59
int valid()
Definition: cartesianiter.cc:192
int axis(int i) const
Return the i&#39;th axis.
Definition: cartesianiter.h:108
int b() const
The current exponent of y.
Definition: cartesianiter.h:148
int c() const
The current exponent of z.
Definition: cartesianiter.h:194
void start(int a, int b, int c)
Definition: cartesianiter.cc:114
int bfn()
Definition: cartesianiter.h:70
int * yloc_
Definition: cartesianiter.h:169
Definition: cartesianiter.h:160
int axis(int i)
Return the i&#39;th axis.
Definition: cartesianiter.h:200
Definition: cartesianiter.h:35
virtual ~CartesianIter()
Definition: cartesianiter.cc:39
int a() const
The current exponent of x.
Definition: cartesianiter.h:143
int l() const
The angular momentum.
Definition: cartesianiter.h:196
int e_[3]
Definition: cartesianiter.h:163
int c() const
Returns the z exponent.
Definition: cartesianiter.h:63
RedundantCartesianSubIter(int l)
Create a object for the given angular momentum.
Definition: cartesianiter.cc:99
int * zloc_
Definition: cartesianiter.h:167