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-2019 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 #include "psi4/pragma.h"
33 
34 namespace psi {
35 
39  protected:
40  int a_;
41  int b_;
42  int c_;
43  int l_;
44  int bfn_;
45 
46  public:
48  CartesianIter(int l);
49  virtual ~CartesianIter();
50 
52  virtual void start();
54  virtual void next();
56  virtual operator int();
57 
59  int n() const { return ((l_ >= 0) ? ((((l_) + 2) * ((l_) + 1)) >> 1) : 0); }
61  int a() const { return a_; }
63  int b() const { return b_; }
65  int c() const { return c_; }
67  int l() const { return l_; }
69  int l(int i) const { return i ? (i == 1 ? b_ : c_) : a_; }
72  int bfn() { return bfn_; }
73 };
74 
80  int done_;
81  int l_;
82  int *axis_;
83 
84  public:
87  virtual ~RedundantCartesianIter();
88 
90  virtual int bfn();
91 
93  void start();
95  void next();
97  operator int() { return !done_; }
98 
100  int a() const;
102  int b() const;
104  int c() const;
106  int l() const { return l_; }
108  int l(int i) const;
110  int axis(int i) const { return axis_[i]; }
111 };
112 
114  if (l_ == 0)
115  done_ = 1;
116  else
117  done_ = 0;
118 
119  for (int i = 0; i < l_; i++) axis_[i] = 0;
120 }
121 
123  for (int i = 0; i < l_; i++) {
124  if (axis_[i] == 2)
125  axis_[i] = 0;
126  else {
127  axis_[i]++;
128  return;
129  }
130  }
131  done_ = 1;
132 }
133 
134 inline int RedundantCartesianIter::l(int axis) const {
135  int i;
136  int r = 0;
137  for (i = 0; i < l_; i++)
138  if (axis_[i] == axis) r++;
139  return r;
140 }
141 
142 inline int RedundantCartesianIter::a() const { return l(0); }
143 
144 inline int RedundantCartesianIter::b() const { return l(1); }
145 
146 inline int RedundantCartesianIter::c() const { return l(2); }
147 
151  int done_;
152  int l_;
153  int e_[3];
154  int *axis_;
155 
156  // the locations of the z's in the axis array
157  int *zloc_;
158  // the locations of the y's in the subarray after the z's are removed
159  int *yloc_;
160 
161  int valid();
162 
163  public:
166  virtual ~RedundantCartesianSubIter();
167 
169  virtual int bfn();
170 
173  void start(int a, int b, int c);
175  void next();
177  operator int() const { return !done_; }
178 
180  int a() const { return e_[0]; }
182  int b() const { return e_[1]; }
184  int c() const { return e_[2]; }
186  int l() const { return l_; }
188  int l(int i) { return e_[i]; }
190  int axis(int i) { return axis_[i]; }
191 };
192 
193 } // namespace psi
194 
195 #endif // _psi_src_lib_libmints_cartesianiter_h_
int a() const
The current exponent of x.
Definition: cartesianiter.h:180
int a_
Definition: cartesianiter.h:40
int * axis_
Definition: cartesianiter.h:154
int b() const
The current exponent of y.
Definition: cartesianiter.h:182
void start()
Initialize the iterator.
Definition: cartesianiter.h:113
int l_
Definition: cartesianiter.h:152
int b_
Definition: cartesianiter.h:41
int bfn_
Definition: cartesianiter.h:44
int l_
Definition: cartesianiter.h:43
Definition: pointgrp.h:104
Definition: cartesianiter.h:79
int l() const
Return the angular momentum.
Definition: cartesianiter.h:67
int c_
Definition: cartesianiter.h:42
int n() const
Returns the number of Cartesian functions.
Definition: cartesianiter.h:59
int c() const
The current exponent of z.
Definition: cartesianiter.h:146
int b() const
Returns the y exponent.
Definition: cartesianiter.h:63
int done_
Definition: cartesianiter.h:80
int l(int i)
Returns a() if i==0, b() if i==1, and c() if i==2.
Definition: cartesianiter.h:188
int done_
Definition: cartesianiter.h:151
int l() const
The angular momentum.
Definition: cartesianiter.h:106
int l_
Definition: cartesianiter.h:81
int * axis_
Definition: cartesianiter.h:82
int l(int i) const
Returns a() if i==0, b() if i==1, and c() if i==2.
Definition: cartesianiter.h:69
void next()
Move to the next combination of axes.
Definition: cartesianiter.h:122
int a() const
Returns the x exponent.
Definition: cartesianiter.h:61
int axis(int i) const
Return the i&#39;th axis.
Definition: cartesianiter.h:110
int b() const
The current exponent of y.
Definition: cartesianiter.h:144
#define PSI_API
Definition: pragma.h:155
int c() const
The current exponent of z.
Definition: cartesianiter.h:184
int bfn()
Definition: cartesianiter.h:72
int * yloc_
Definition: cartesianiter.h:159
Definition: cartesianiter.h:150
int axis(int i)
Return the i&#39;th axis.
Definition: cartesianiter.h:190
Definition: cartesianiter.h:38
int a() const
The current exponent of x.
Definition: cartesianiter.h:142
int l() const
The angular momentum.
Definition: cartesianiter.h:186
int c() const
Returns the z exponent.
Definition: cartesianiter.h:65
int * zloc_
Definition: cartesianiter.h:157