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 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 _psi_src_lib_libmints_cartesianiter_h_
30 #define _psi_src_lib_libmints_cartesianiter_h_
31 
32 namespace psi {
33 
37 {
38 protected:
39  int a_;
40  int b_;
41  int c_;
42  int l_;
43  int bfn_;
44 
45 public:
47  CartesianIter(int l);
48  virtual ~CartesianIter();
49 
51  virtual void start();
53  virtual void next();
55  virtual operator int();
56 
58  int n() const { return ((l_>=0)?((((l_)+2)*((l_)+1))>>1):0); }
60  int a() const { return a_; }
62  int b() const { return b_; }
64  int c() const { return c_; }
66  int l() const { return l_; }
68  int l(int i) const { return i ? (i==1 ? b_ : c_) : a_; }
71  int bfn() { return bfn_; }
72 };
73 
79  int done_;
80  int l_;
81  int *axis_;
82 
83 public:
86  virtual ~RedundantCartesianIter();
87 
89  virtual int bfn();
90 
92  void start();
94  void next();
96  operator int() { return !done_; }
97 
99  int a() const;
101  int b() const;
103  int c() const;
105  int l() const { return l_; }
107  int l(int i) const;
109  int axis(int i) const { return axis_[i]; }
110 };
111 
113 {
114  if (l_==0)
115  done_ = 1;
116  else
117  done_ = 0;
118 
119  for (int i=0; i<l_; i++)
120  axis_[i] = 0;
121 }
122 
124 {
125  for (int i=0; i<l_; i++) {
126  if (axis_[i] == 2)
127  axis_[i] = 0;
128  else {
129  axis_[i]++;
130  return;
131  }
132  }
133  done_ = 1;
134 }
135 
136 inline int RedundantCartesianIter::l(int axis) const
137 {
138  int i;
139  int r = 0;
140  for (i=0; i<l_; i++) if (axis_[i]==axis) r++;
141  return r;
142 }
143 
144 inline int RedundantCartesianIter::a() const
145 {
146  return l(0);
147 }
148 
149 inline int RedundantCartesianIter::b() const
150 {
151  return l(1);
152 }
153 
154 inline int RedundantCartesianIter::c() const
155 {
156  return l(2);
157 }
158 
162  int done_;
163  int l_;
164  int e_[3];
165  int *axis_;
166 
167  // the locations of the z's in the axis array
168  int *zloc_;
169  // the locations of the y's in the subarray after the z's are removed
170  int *yloc_;
171 
172  int valid();
173 
174 public:
177  virtual ~RedundantCartesianSubIter();
178 
180  virtual int bfn();
181 
184  void start(int a, int b, int c);
186  void next();
188  operator int() const { return !done_; }
189 
191  int a() const { return e_[0]; }
193  int b() const { return e_[1]; }
195  int c() const { return e_[2]; }
197  int l() const { return l_; }
199  int l(int i) { return e_[i]; }
201  int axis(int i) { return axis_[i]; }
202 };
203 
204 }
205 
206 #endif // _psi_src_lib_libmints_cartesianiter_h_
virtual void start()
Start the iteration.
Definition: cartesianiter.cc:45
virtual ~RedundantCartesianSubIter()
Definition: cartesianiter.cc:108
int a() const
The current exponent of x.
Definition: cartesianiter.h:191
int a_
Definition: cartesianiter.h:39
int * axis_
Definition: cartesianiter.h:165
int b() const
The current exponent of y.
Definition: cartesianiter.h:193
void next()
Move to the next combination of axes.
Definition: cartesianiter.cc:158
void start()
Initialize the iterator.
Definition: cartesianiter.h:112
int l_
Definition: cartesianiter.h:163
int b_
Definition: cartesianiter.h:40
int bfn_
Definition: cartesianiter.h:43
virtual int bfn()
Return the current Cartesian basis function number.
Definition: cartesianiter.cc:84
int l_
Definition: cartesianiter.h:42
Definition: pointgrp.h:106
Definition: cartesianiter.h:78
int l() const
Return the angular momentum.
Definition: cartesianiter.h:66
int c_
Definition: cartesianiter.h:41
RedundantCartesianIter(int l)
Create a object for the given angular momentum.
Definition: cartesianiter.cc:72
int n() const
Returns the number of Cartesian functions.
Definition: cartesianiter.h:58
int c() const
The current exponent of z.
Definition: cartesianiter.h:154
CartesianIter(int l)
Initialize the iterator for the given angular momentum.
Definition: cartesianiter.cc:34
int b() const
Returns the y exponent.
Definition: cartesianiter.h:62
int done_
Definition: cartesianiter.h:79
int l(int i)
Returns a() if i==0, b() if i==1, and c() if i==2.
Definition: cartesianiter.h:199
virtual int bfn()
Return the current Cartesian basis function number.
Definition: cartesianiter.cc:207
virtual void next()
Move to the next Cartesian function.
Definition: cartesianiter.cc:51
int done_
Definition: cartesianiter.h:162
virtual ~RedundantCartesianIter()
Definition: cartesianiter.cc:79
int l() const
The angular momentum.
Definition: cartesianiter.h:105
int l_
Definition: cartesianiter.h:80
int * axis_
Definition: cartesianiter.h:81
int l(int i) const
Returns a() if i==0, b() if i==1, and c() if i==2.
Definition: cartesianiter.h:68
void next()
Move to the next combination of axes.
Definition: cartesianiter.h:123
int a() const
Returns the x exponent.
Definition: cartesianiter.h:60
int valid()
Definition: cartesianiter.cc:193
int axis(int i) const
Return the i&#39;th axis.
Definition: cartesianiter.h:109
int b() const
The current exponent of y.
Definition: cartesianiter.h:149
int c() const
The current exponent of z.
Definition: cartesianiter.h:195
void start(int a, int b, int c)
Definition: cartesianiter.cc:115
int bfn()
Definition: cartesianiter.h:71
int * yloc_
Definition: cartesianiter.h:170
Definition: cartesianiter.h:161
int axis(int i)
Return the i&#39;th axis.
Definition: cartesianiter.h:201
Definition: cartesianiter.h:36
virtual ~CartesianIter()
Definition: cartesianiter.cc:40
int a() const
The current exponent of x.
Definition: cartesianiter.h:144
int l() const
The angular momentum.
Definition: cartesianiter.h:197
int e_[3]
Definition: cartesianiter.h:164
int c() const
Returns the z exponent.
Definition: cartesianiter.h:64
RedundantCartesianSubIter(int l)
Create a object for the given angular momentum.
Definition: cartesianiter.cc:100
int * zloc_
Definition: cartesianiter.h:168