MPQC
2.3.1
Main Page
Related Pages
Classes
Files
File List
src
lib
chemistry
qc
basis
cartiter.h
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
39
class
CartesianIter
{
40
protected
:
41
int
a_;
42
int
b_;
43
int
c_;
44
int
l_;
45
int
bfn_;
46
47
public
:
49
CartesianIter
(
int
l
);
50
virtual
~
CartesianIter
();
51
53
virtual
void
start
() =0;
55
virtual
void
next
() =0;
57
virtual
operator
int() =0;
58
60
int
n
() {
return
((l_>=0)?((((l_)+2)*((l_)+1))>>1):0); }
62
int
a
() {
return
a_; }
64
int
b
() {
return
b_; }
66
int
c
() {
return
c_; }
68
int
l
() {
return
l_; }
70
int
l
(
int
i) {
return
i ? (i==1 ? b_ : c_) : a_; }
73
int
bfn
() {
return
bfn_; }
74
};
75
80
class
RedundantCartesianIter
{
81
private
:
82
int
done_;
83
int
l_;
84
int
*axis_;
85
86
public
:
88
RedundantCartesianIter
(
int
l
);
89
virtual
~
RedundantCartesianIter
();
90
92
virtual
int
bfn
() =0;
93
95
void
start
();
97
void
next
();
99
operator
int() {
return
!done_; }
100
102
int
a
();
104
int
b
();
106
int
c
();
108
int
l
() {
return
l_; }
110
int
l
(
int
i);
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
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
:
186
RedundantCartesianSubIter
(
int
l
);
187
virtual
~
RedundantCartesianSubIter
();
188
190
virtual
int
bfn
() =0;
191
194
void
start
(
int
a
,
int
b
,
int
c
);
196
void
next
();
198
operator
int()
const
{
return
!done_; }
199
201
int
a
()
const
{
return
e_[0]; }
203
int
b
()
const
{
return
e_[1]; }
205
int
c
()
const
{
return
e_[2]; }
207
int
l
()
const
{
return
l_; }
209
int
l
(
int
i) {
return
e_[i]; }
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:
Generated at Fri Dec 27 2013 08:49:21 for
MPQC
2.3.1 using the documentation package
Doxygen
1.8.3.1.