# cartitv3.h

    00001 //
    00002 // cartitv3.h
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Curtis Janssen <cljanss@limitpt.com>
    00007 // Maintainer: LPS
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifndef _chemistry_qc_intv3_cartitv3_h
    00029 #define _chemistry_qc_intv3_cartitv3_h
    00030
    00031 #include <chemistry/qc/basis/cartiter.h>
    00032
    00033 namespace sc {
    00034
    00035 class CartesianIterV3 : public CartesianIter {
    00036   public:
    00037     CartesianIterV3(int l) : CartesianIter(l) {}
    00038
    00039     void start() {
    00040       bfn_=a_=c_=0;
    00041       b_=l_;
    00042     }
    00043
    00044     void next() {
    00045       if (c_<l_-a_)
    00046         c_++;
    00047       else {
    00048         c_=0;
    00049         a_++;
    00050       }
    00051       bfn_++;
    00052       b_ = l_-a_-c_;
    00053     }
    00054
    00055     operator int() {
    00056       return (a_ <= l_);
    00057     }
    00058 };
    00059
    00060 class RedundantCartesianIterV3 : public RedundantCartesianIter {
    00061   public:
    00062     RedundantCartesianIterV3(int l) : RedundantCartesianIter(l) {}
    00063
    00064     int bfn() {
    00065       int i = a();
    00066       int j = b();
    00067       int am = l();
    00068       return (((((((am)+1)<<1)-(i))*((i)+1))>>1)-(j)-1);
    00069     }
    00070 };
    00071
    00072 class RedundantCartesianSubIterV3 : public RedundantCartesianSubIter {
    00073   public:
    00074     RedundantCartesianSubIterV3(int l) : RedundantCartesianSubIter(l) {}
    00075
    00076     int bfn() {
    00077       int i = a();
    00078       int j = b();
    00079       int am = l();
    00080       return (((((((am)+1)<<1)-(i))*((i)+1))>>1)-(j)-1);
    00081     }
    00082 };
    00083
    00084 }
    00085
    00086 #endif
    00087
    00088 // Local Variables:
    00089 // mode: c++
    00090 // c-file-style: "CLJ"
    00091 // End: