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 {
62 virtual void start(
const int first_ij =0) =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_; }
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_);};
287 operator int()
const;
304 const PureSpinCase2& S);
308 void start(
const int first_ij=0);
312 operator int()
const;
320namespace 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_; }
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>
MOPairIter gives the ordering of orbital pairs.
Definition pairiter.h:38
int nj() const
Returns the number of functions in space j.
Definition pairiter.h:71
int i() const
Returns index i.
Definition pairiter.h:73
virtual void next()=0
Move to the next pair.
virtual void start(const int first_ij=0)=0
Start the iteration.
int nij() const
Returns the number of pair combinations for this iterator.
Definition pairiter.h:77
int j() const
Returns index j.
Definition pairiter.h:75
MOPairIter(unsigned int n_i, unsigned int n_j)
Initialize an iterator for the MO space dimensions.
int ni() const
Returns the number of functions in space i.
Definition pairiter.h:69
int ij() const
Returns the current iteration.
Definition pairiter.h:79
The base class for all reference counted objects.
Definition ref.h:192
A template class that maintains references counts.
Definition ref.h:361
SpatialMOPairIter_eq gives the ordering of same-spin and different-spin orbital pairs if both orbital...
Definition pairiter.h:109
void next()
Move to the next pair.
Definition pairiter.h:182
int ij_aa() const
Returns compound index ij for alpha-alpha case.
Definition pairiter.h:194
int nij_ab() const
Returns the number of functions in alpha-beta space.
Definition pairiter.h:191
void start(const int ij_offset=0)
Initialize the iterator assuming that iteration will start with pair ij_offset.
Definition pairiter.h:175
SpatialMOPairIter_eq(unsigned int n)
Initialize an iterator for the given MO spaces.
int ij_ab() const
Returns compound index ij for alpha-beta case.
Definition pairiter.h:196
int nij_aa() const
Returns the number of functions in alpha-alpha space.
Definition pairiter.h:189
int ij_ba() const
Returns compound index ij for beta-alpha case.
Definition pairiter.h:198
SpatialMOPairIter_neq gives the ordering of pairs of spatial orbitals from different spaces.
Definition pairiter.h:204
int ij_ab() const
Returns compound index ij for alpha-beta case.
Definition pairiter.h:268
void next()
Move to the next pair.
Definition pairiter.h:255
int ij_aa() const
Returns compound index ij for alpha-alpha case.
Definition pairiter.h:266
int ij_ba() const
Returns compound index ij for beta-alpha case.
Definition pairiter.h:270
int nij_ab() const
Returns the number of functions in alpha-beta space.
Definition pairiter.h:264
int nij_aa() const
Returns the number of functions in alpha-alpha space.
Definition pairiter.h:262
void start(const int ij_offset=0)
Initialize the iterator assuming that iteration will start with pair ij_offset.
Definition pairiter.h:248
SpatialMOPairIter_neq(unsigned int n_i, unsigned int n_j)
Initialize an iterator for the given MO spaces.
SpatialMOPairIter gives the ordering of pairs of spatial orbitals.
Definition pairiter.h:85
virtual int nij_ab() const =0
Returns the number of functions in alpha-beta space.
virtual int ij_ab() const =0
Returns compound index ij for alpha-beta case.
virtual int ij_ba() const =0
Returns compound index ij for beta-alpha case.
virtual int ij_aa() const =0
Returns compound index ij for alpha-alpha case.
SpatialMOPairIter(unsigned int n_i, unsigned int n_j)
Initialize a spatial pair iterator for the given MO spaces.
Definition pairiter.h:89
virtual int nij_aa() const =0
Returns the number of functions in alpha-alpha space.
SpinMOPairIter iterates over pairs of spinorbitals.
Definition pairiter.h:277
void next()
Move to the next pair.
void start(const int first_ij=0)
Start the iteration.
SpinMOPairIter iterates over pairs of spinorbitals of spin case Spin12 This class differs from other ...
Definition pairiter.h:330
void next()
Move to the next pair.
int j() const
current index 2
Definition pairiter.h:346
int ij(int i, int j) const
returns an ij given i and j.
int i() const
current index 1
Definition pairiter.h:344
void start()
Start the iteration.
Definition pairiter.impl.h:42
int ij() const
current composite index
Definition pairiter.h:342
Contains all MPQC code up to version 3.
Definition mpqcin.h:14