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-2018 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  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  if (l_ == 0)
113  done_ = 1;
114  else
115  done_ = 0;
116 
117  for (int i = 0; i < l_; i++) axis_[i] = 0;
118 }
119 
121  for (int i = 0; i < l_; i++) {
122  if (axis_[i] == 2)
123  axis_[i] = 0;
124  else {
125  axis_[i]++;
126  return;
127  }
128  }
129  done_ = 1;
130 }
131 
132 inline int RedundantCartesianIter::l(int axis) const {
133  int i;
134  int r = 0;
135  for (i = 0; i < l_; i++)
136  if (axis_[i] == axis) r++;
137  return r;
138 }
139 
140 inline int RedundantCartesianIter::a() const { return l(0); }
141 
142 inline int RedundantCartesianIter::b() const { return l(1); }
143 
144 inline int RedundantCartesianIter::c() const { return l(2); }
145 
149  int done_;
150  int l_;
151  int e_[3];
152  int *axis_;
153 
154  // the locations of the z's in the axis array
155  int *zloc_;
156  // the locations of the y's in the subarray after the z's are removed
157  int *yloc_;
158 
159  int valid();
160 
161  public:
164  virtual ~RedundantCartesianSubIter();
165 
167  virtual int bfn();
168 
171  void start(int a, int b, int c);
173  void next();
175  operator int() const { return !done_; }
176 
178  int a() const { return e_[0]; }
180  int b() const { return e_[1]; }
182  int c() const { return e_[2]; }
184  int l() const { return l_; }
186  int l(int i) { return e_[i]; }
188  int axis(int i) { return axis_[i]; }
189 };
190 
191 } // namespace psi
192 
193 #endif // _psi_src_lib_libmints_cartesianiter_h_
virtual void start()
Start the iteration.
Definition: cartesianiter.cc:38
virtual ~RedundantCartesianSubIter()
Definition: cartesianiter.cc:88
int a() const
The current exponent of x.
Definition: cartesianiter.h:178
int a_
Definition: cartesianiter.h:38
int * axis_
Definition: cartesianiter.h:152
int b() const
The current exponent of y.
Definition: cartesianiter.h:180
void next()
Move to the next combination of axes.
Definition: cartesianiter.cc:140
void start()
Initialize the iterator.
Definition: cartesianiter.h:111
int l_
Definition: cartesianiter.h:150
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:66
int l_
Definition: cartesianiter.h:41
Definition: pointgrp.h:104
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:59
int n() const
Returns the number of Cartesian functions.
Definition: cartesianiter.h:57
int c() const
The current exponent of z.
Definition: cartesianiter.h:144
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: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:186
virtual int bfn()
Return the current Cartesian basis function number.
Definition: cartesianiter.cc:184
virtual void next()
Move to the next Cartesian function.
Definition: cartesianiter.cc:43
int done_
Definition: cartesianiter.h:149
virtual ~RedundantCartesianIter()
Definition: cartesianiter.cc:64
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:120
int a() const
Returns the x exponent.
Definition: cartesianiter.h:59
int valid()
Definition: cartesianiter.cc:173
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:142
int c() const
The current exponent of z.
Definition: cartesianiter.h:182
void start(int a, int b, int c)
Definition: cartesianiter.cc:94
int bfn()
Definition: cartesianiter.h:70
int * yloc_
Definition: cartesianiter.h:157
Definition: cartesianiter.h:148
int axis(int i)
Return the i&#39;th axis.
Definition: cartesianiter.h:188
Definition: cartesianiter.h:36
virtual ~CartesianIter()
Definition: cartesianiter.cc:36
int a() const
The current exponent of x.
Definition: cartesianiter.h:140
int l() const
The angular momentum.
Definition: cartesianiter.h:184
int e_[3]
Definition: cartesianiter.h:151
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:81
int * zloc_
Definition: cartesianiter.h:155