28 #ifndef _math_mmisc_pairiter_h
29 #define _math_mmisc_pairiter_h
33 #include <util/ref/ref.h>
41 static const int classdebug_ = 0;
52 int classdebug()
const {
58 MOPairIter(
unsigned int n_i,
unsigned int n_j);
62 virtual void start(
const int first_ij =0) =0;
64 virtual void next() =0;
66 virtual operator int()
const =0;
69 int ni()
const {
return ni_; }
71 int nj()
const {
return nj_; }
73 int i()
const {
return i_; }
75 int j()
const {
return j_; }
77 int nij()
const {
return nij_; }
79 int ij()
const {
return ij_; }
94 virtual int nij_aa()
const =0;
96 virtual int nij_ab()
const =0;
99 virtual int ij_aa()
const =0;
101 virtual int ij_ab()
const =0;
103 virtual int ij_ba()
const =0;
117 void init_ij(
const int ij) {
120 throw std::runtime_error(
"SpatialMOPairIter_eq::start() -- argument ij out of range");
123 const int renorm_ij =
ij%nij_;
125 i_ = (int)floor((sqrt(1.0+8.0*renorm_ij) - 1.0)/2.0);
126 const int i_off = i_*(i_+1)/2;
127 j_ = renorm_ij - i_off;
129 ij_ab_ = i_*nj_ + j_;
130 ji_ab_ = j_*ni_ + i_;
133 const int i_off = i_*(i_-1)/2;
145 if (ij_ab_ == nij_ab_-1) {
158 ij_aa_ += (i_ == j_) ? 0 : 1;
164 ij_aa_ += (i_ == j_) ? 0 : 1;
186 operator int()
const {
return (nij_ > ij_);};
194 int ij_aa()
const {
return (i_ == j_) ? -1 : ij_aa_; }
196 int ij_ab()
const {
return ij_ab_; }
198 int ij_ba()
const {
return ji_ab_; }
208 void init_ij(
const int ij) {
211 throw std::runtime_error(
"SpatialMOPairIter_neq::start() -- argument ij out of range");
214 const int renorm_ij =
ij%nij_;
217 j_ = renorm_ij - i_*nj_;
259 operator int()
const {
return (nij_ > ij_);};
283 void start(
const int first_ij=0);
287 operator int()
const;
304 const PureSpinCase2& S);
308 void start(
const int first_ij=0);
312 operator int()
const;
320 namespace fastpairiter {
321 enum PairSymm { Symm = 1, AntiSymm = -1, ASymm = 0};
328 template <PairSymm PSymm>
340 operator int()
const;
342 int ij()
const {
return IJ_; }
344 int i()
const {
return I_; }
346 int j()
const {
return J_; }
350 int ij(
int i,
int j)
const;
351 int nij()
const {
return nIJ_; }
364 template <PairSymm PSymm>
365 std::size_t npair(
unsigned int nI,
unsigned int nJ);
371 #include <math/mmisc/pairiter.impl.h>
SpinMOPairIter iterates over pairs of spinorbitals of spin case Spin12 This class differs from other ...
Definition: pairiter.h:329
int nj() const
Returns the number of functions in space j.
Definition: pairiter.h:71
int ij_ba() const
Returns compound index ij for beta-alpha case.
Definition: pairiter.h:198
MOPairIter gives the ordering of orbital pairs.
Definition: pairiter.h:38
A template class that maintains references counts.
Definition: ref.h:361
int ij_aa() const
Returns compound index ij for alpha-alpha case.
Definition: pairiter.h:266
int ij() const
Returns the current iteration.
Definition: pairiter.h:79
SpatialMOPairIter_neq(unsigned int n_i, unsigned int n_j)
Initialize an iterator for the given MO spaces.
SpatialMOPairIter_eq(unsigned int n)
Initialize an iterator for the given MO spaces.
void next()
Move to the next pair.
Definition: pairiter.h:182
int j() const
Returns index j.
Definition: pairiter.h:75
SpatialMOPairIter_neq gives the ordering of pairs of spatial orbitals from different spaces.
Definition: pairiter.h:204
int nij_ab() const
Returns the number of functions in alpha-beta space.
Definition: pairiter.h:264
virtual int ij_aa() const =0
Returns compound index ij for alpha-alpha case.
virtual void start(const int first_ij=0)=0
Start the iteration.
void start(const int first_ij=0)
Start the iteration.
void start(const int ij_offset=0)
Initialize the iterator assuming that iteration will start with pair ij_offset.
Definition: pairiter.h:175
int nij_aa() const
Returns the number of functions in alpha-alpha space.
Definition: pairiter.h:262
int ij_aa() const
Returns compound index ij for alpha-alpha case.
Definition: pairiter.h:194
virtual int ij_ab() const =0
Returns compound index ij for alpha-beta case.
virtual void next()=0
Move to the next pair.
int i() const
Returns index i.
Definition: pairiter.h:73
SpatialMOPairIter_eq gives the ordering of same-spin and different-spin orbital pairs if both orbital...
Definition: pairiter.h:109
int ij_ab() const
Returns compound index ij for alpha-beta case.
Definition: pairiter.h:268
int ij() const
current composite index
Definition: pairiter.h:342
SpatialMOPairIter(unsigned int n_i, unsigned int n_j)
Initialize a spatial pair iterator for the given MO spaces.
Definition: pairiter.h:89
int ni() const
Returns the number of functions in space i.
Definition: pairiter.h:69
SpinMOPairIter iterates over pairs of spinorbitals.
Definition: pairiter.h:276
void next()
Move to the next pair.
int nij() const
Returns the number of pair combinations for this iterator.
Definition: pairiter.h:77
void start()
Start the iteration.
Definition: pairiter.impl.h:42
SpatialMOPairIter gives the ordering of pairs of spatial orbitals.
Definition: pairiter.h:85
virtual int nij_aa() const =0
Returns the number of functions in alpha-alpha space.
int nij_aa() const
Returns the number of functions in alpha-alpha space.
Definition: pairiter.h:189
virtual int ij_ba() const =0
Returns compound index ij for beta-alpha case.
int ij_ba() const
Returns compound index ij for beta-alpha case.
Definition: pairiter.h:270
The base class for all reference counted objects.
Definition: ref.h:192
int i() const
current index 1
Definition: pairiter.h:344
virtual int nij_ab() const =0
Returns the number of functions in alpha-beta space.
int j() const
current index 2
Definition: pairiter.h:346
void start(const int ij_offset=0)
Initialize the iterator assuming that iteration will start with pair ij_offset.
Definition: pairiter.h:248
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
int ij_ab() const
Returns compound index ij for alpha-beta case.
Definition: pairiter.h:196
int nij_ab() const
Returns the number of functions in alpha-beta space.
Definition: pairiter.h:191
void next()
Move to the next pair.
Definition: pairiter.h:255
void next()
Move to the next pair.
MOPairIter(unsigned int n_i, unsigned int n_j)
Initialize an iterator for the MO space dimensions.
Generated at Sun Jan 26 2020 23:24:00 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.