[0b990d] | 1 | //
|
---|
| 2 | // cartiter.h
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
|
---|
| 5 | //
|
---|
| 6 | // Author: Curtis Janssen <cljanss@limitpt.com>
|
---|
| 7 | // Maintainer: LPS
|
---|
| 8 | //
|
---|
| 9 | // This file is part of the SC Toolkit.
|
---|
| 10 | //
|
---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
|
---|
| 12 | // it under the terms of the GNU Library General Public License as published by
|
---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
|
---|
| 14 | // any later version.
|
---|
| 15 | //
|
---|
| 16 | // The SC Toolkit 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 Library General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU Library General Public License
|
---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
|
---|
| 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | //
|
---|
| 25 | // The U.S. Government is granted a limited license as per AL 91-7.
|
---|
| 26 | //
|
---|
| 27 |
|
---|
| 28 | #ifndef _chemistry_qc_basis_cartiter_h
|
---|
| 29 | #define _chemistry_qc_basis_cartiter_h
|
---|
| 30 |
|
---|
| 31 | #ifdef __GNUC__
|
---|
| 32 | #pragma interface
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | namespace sc {
|
---|
| 36 |
|
---|
| 37 | /** CartesianIter gives the ordering of the Cartesian functions
|
---|
| 38 | within a shell for the particular integrals specialization. */
|
---|
| 39 | class CartesianIter {
|
---|
| 40 | protected:
|
---|
| 41 | int a_;
|
---|
| 42 | int b_;
|
---|
| 43 | int c_;
|
---|
| 44 | int l_;
|
---|
| 45 | int bfn_;
|
---|
| 46 |
|
---|
| 47 | public:
|
---|
| 48 | /// Initialize an iterator for the given angular momentum.
|
---|
| 49 | CartesianIter(int l);
|
---|
| 50 | virtual ~CartesianIter();
|
---|
| 51 |
|
---|
| 52 | /// Start the iteration.
|
---|
| 53 | virtual void start() =0;
|
---|
| 54 | /// Move to the next Cartesian function.
|
---|
| 55 | virtual void next() =0;
|
---|
| 56 | /// Returns nonzero if the iterator currently hold valid data.
|
---|
| 57 | virtual operator int() =0;
|
---|
| 58 |
|
---|
| 59 | /// Returns the number of Cartesian functions.
|
---|
| 60 | int n() { return ((l_>=0)?((((l_)+2)*((l_)+1))>>1):0); }
|
---|
| 61 | /// Returns the exponent of x.
|
---|
| 62 | int a() { return a_; }
|
---|
| 63 | /// Returns the exponent of y.
|
---|
| 64 | int b() { return b_; }
|
---|
| 65 | /// Returns the exponent of z.
|
---|
| 66 | int c() { return c_; }
|
---|
| 67 | /// Returns the angular momentum.
|
---|
| 68 | int l() { return l_; }
|
---|
| 69 | /// Returns a() if i==0, b() if i==1, and c() if i==2.
|
---|
| 70 | int l(int i) { return i ? (i==1 ? b_ : c_) : a_; }
|
---|
| 71 | /** Returns the number of the current basis function within the shell.
|
---|
| 72 | This starts at 0 and sequentially increases as next() is called. */
|
---|
| 73 | int bfn() { return bfn_; }
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | /** RedundantCartesianIter objects loop through all possible combinations
|
---|
| 77 | of a given number of axes. This is used to compute the transformation
|
---|
| 78 | matrices that maps a set of Cartesian functions to another set of
|
---|
| 79 | Cartesian functions in a rotated coordinate system. */
|
---|
| 80 | class RedundantCartesianIter {
|
---|
| 81 | private:
|
---|
| 82 | int done_;
|
---|
| 83 | int l_;
|
---|
| 84 | int *axis_;
|
---|
| 85 |
|
---|
| 86 | public:
|
---|
| 87 | /// Create a object for the given angular momentum.
|
---|
| 88 | RedundantCartesianIter(int l);
|
---|
| 89 | virtual ~RedundantCartesianIter();
|
---|
| 90 |
|
---|
| 91 | /// Return the current Cartesian basis function number.
|
---|
| 92 | virtual int bfn() =0;
|
---|
| 93 |
|
---|
| 94 | /// Initialize the iterator.
|
---|
| 95 | void start();
|
---|
| 96 | /// Move to the next combination of axes.
|
---|
| 97 | void next();
|
---|
| 98 | /// Returns nonzero if the iterator currently hold valid data.
|
---|
| 99 | operator int() { return !done_; }
|
---|
| 100 |
|
---|
| 101 | /// The current exponent of x.
|
---|
| 102 | int a();
|
---|
| 103 | /// The current exponent of y.
|
---|
| 104 | int b();
|
---|
| 105 | /// The current exponent of z.
|
---|
| 106 | int c();
|
---|
| 107 | /// The angular momentum.
|
---|
| 108 | int l() { return l_; }
|
---|
| 109 | /// Returns a() if i==0, b() if i==1, and c() if i==2.
|
---|
| 110 | int l(int i);
|
---|
| 111 | /// Return the i'th axis.
|
---|
| 112 | int axis(int i) { return axis_[i]; }
|
---|
| 113 | };
|
---|
| 114 |
|
---|
| 115 | inline void
|
---|
| 116 | RedundantCartesianIter::start()
|
---|
| 117 | {
|
---|
| 118 | if (l_==0)
|
---|
| 119 | done_ = 1;
|
---|
| 120 | else
|
---|
| 121 | done_ = 0;
|
---|
| 122 |
|
---|
| 123 | for (int i=0; i<l_; i++)
|
---|
| 124 | axis_[i] = 0;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | inline void
|
---|
| 128 | RedundantCartesianIter::next()
|
---|
| 129 | {
|
---|
| 130 | for (int i=0; i<l_; i++) {
|
---|
| 131 | if (axis_[i] == 2)
|
---|
| 132 | axis_[i] = 0;
|
---|
| 133 | else {
|
---|
| 134 | axis_[i]++;
|
---|
| 135 | return;
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 | done_ = 1;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | inline int
|
---|
| 142 | RedundantCartesianIter::l(int axis)
|
---|
| 143 | {
|
---|
| 144 | int i;
|
---|
| 145 | int r = 0;
|
---|
| 146 | for (i=0; i<l_; i++) if (axis_[i]==axis) r++;
|
---|
| 147 | return r;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | inline int
|
---|
| 151 | RedundantCartesianIter::a()
|
---|
| 152 | {
|
---|
| 153 | return l(0);
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | inline int
|
---|
| 157 | RedundantCartesianIter::b()
|
---|
| 158 | {
|
---|
| 159 | return l(1);
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | inline int
|
---|
| 163 | RedundantCartesianIter::c()
|
---|
| 164 | {
|
---|
| 165 | return l(2);
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | /** Like RedundantCartesianIter, except a, b, and c are fixed to a given
|
---|
| 169 | value. */
|
---|
| 170 | class RedundantCartesianSubIter {
|
---|
| 171 | private:
|
---|
| 172 | int done_;
|
---|
| 173 | int l_;
|
---|
| 174 | int e_[3];
|
---|
| 175 | int *axis_;
|
---|
| 176 |
|
---|
| 177 | // the locations of the z's in the axis array
|
---|
| 178 | int *zloc_;
|
---|
| 179 | // the locations of the y's in the subarray after the z's are removed
|
---|
| 180 | int *yloc_;
|
---|
| 181 |
|
---|
| 182 | int valid();
|
---|
| 183 |
|
---|
| 184 | public:
|
---|
| 185 | /// Create a object for the given angular momentum.
|
---|
| 186 | RedundantCartesianSubIter(int l);
|
---|
| 187 | virtual ~RedundantCartesianSubIter();
|
---|
| 188 |
|
---|
| 189 | /// Return the current Cartesian basis function number.
|
---|
| 190 | virtual int bfn() =0;
|
---|
| 191 |
|
---|
| 192 | /** Initialize the iterator. The constraints on a, b, and c are
|
---|
| 193 | given as arguments. */
|
---|
| 194 | void start(int a, int b, int c);
|
---|
| 195 | /// Move to the next combination of axes.
|
---|
| 196 | void next();
|
---|
| 197 | /// Returns nonzero if the iterator currently hold valid data.
|
---|
| 198 | operator int() const { return !done_; }
|
---|
| 199 |
|
---|
| 200 | /// The current exponent of x.
|
---|
| 201 | int a() const { return e_[0]; }
|
---|
| 202 | /// The current exponent of y.
|
---|
| 203 | int b() const { return e_[1]; }
|
---|
| 204 | /// The current exponent of z.
|
---|
| 205 | int c() const { return e_[2]; }
|
---|
| 206 | /// The angular momentum.
|
---|
| 207 | int l() const { return l_; }
|
---|
| 208 | /// Returns a() if i==0, b() if i==1, and c() if i==2.
|
---|
| 209 | int l(int i) { return e_[i]; }
|
---|
| 210 | /// Return the i'th axis.
|
---|
| 211 | int axis(int i) { return axis_[i]; }
|
---|
| 212 | };
|
---|
| 213 |
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | #endif
|
---|
| 217 |
|
---|
| 218 | // Local Variables:
|
---|
| 219 | // mode: c++
|
---|
| 220 | // c-file-style: "ETS"
|
---|
| 221 | // End:
|
---|