# gpetite.h

    00001 //
    00002 // gpetite.h --- definition of the generalized petite list class
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Edward Seidl <seidl@janed.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_basis_gpetite_h
    00029 #define _chemistry_qc_basis_gpetite_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma interface
    00033 #endif
    00034
    00035 #include <stdexcept>
    00036
    00037 #include <scconfig.h>
    00038 #include <util/misc/scint.h>
    00039 #include <chemistry/qc/basis/basis.h>
    00040 #include <chemistry/qc/basis/petite.h>
    00041
    00042 namespace sc {
    00043
    00047 class canonical_aaaa {
    00048   public:
    00049     canonical_aaaa();
    00050     canonical_aaaa(const Ref<GaussianBasisSet> bi,
    00051                    const Ref<GaussianBasisSet> bj,
    00052                    const Ref<GaussianBasisSet> bk,
    00053                    const Ref<GaussianBasisSet> bl
    00054                    );
    00055     sc_int_least64_t offset(int i, int j, int k, int l) {
    00056       long ij = (i>j?(((i*long(i+1))>>1)+j):(((j*long(j+1))>>1)+i));
    00057       long kl = (k>l?(((k*long(k+1))>>1)+l):(((l*long(l+1))>>1)+k));
    00058       sc_int_least64_t
    00059           off = (ij>kl?(((ij*sc_int_least64_t(ij+1))>>1)+kl)
    00060                  :(((kl*sc_int_least64_t(kl+1))>>1)+ij));
    00061       return off;
    00062     }
    00063 };
    00064
    00069 class canonical_aabc {
    00070     long nk_, nl_;
    00071   public:
    00072     canonical_aabc(const Ref<GaussianBasisSet> bi,
    00073                    const Ref<GaussianBasisSet> bj,
    00074                    const Ref<GaussianBasisSet> bk,
    00075                    const Ref<GaussianBasisSet> bl
    00076                    );
    00077     sc_int_least64_t offset(int i, int j, int k, int l) {
    00078       long ij = (i>j?(((i*long(i+1))>>1)+j):(((j*long(j+1))>>1)+i));
    00079       return k + nk_*sc_int_least64_t(l + nl_*ij);
    00080     }
    00081 };
    00082
    00087 class canonical_aabb {
    00088     long nij_;
    00089   public:
    00090     canonical_aabb(const Ref<GaussianBasisSet> bi,
    00091                    const Ref<GaussianBasisSet> bj,
    00092                    const Ref<GaussianBasisSet> bk,
    00093                    const Ref<GaussianBasisSet> bl
    00094                    );
    00095     sc_int_least64_t offset(int i, int j, int k, int l) {
    00096       long ij = (i>j?(((i*long(i+1))>>1)+j):(((j*long(j+1))>>1)+i));
    00097       long kl = (k>l?(((k*long(k+1))>>1)+l):(((l*long(l+1))>>1)+k));
    00098       return ij + nij_*sc_int_least64_t(kl);
    00099     }
    00100 };
    00101
    00105 class canonical_abcd {
    00106     int ni_, nj_, nk_;
    00107   public:
    00108     canonical_abcd(const Ref<GaussianBasisSet> bi,
    00109                    const Ref<GaussianBasisSet> bj,
    00110                    const Ref<GaussianBasisSet> bk,
    00111                    const Ref<GaussianBasisSet> bl
    00112                    );
    00113     sc_int_least64_t offset(int i, int j, int k, int l) {
    00114       return (i + ni_*sc_int_least64_t(j + nj_*long(k + nk_*l)));
    00115     }
    00116 };
    00117
    00120 class GenPetite4: public RefCount {
    00121 protected:
    00122   bool c1_;
    00123   int ng_;
    00124   int **shell_map_i_;
    00125   int **shell_map_j_;
    00126   int **shell_map_k_;
    00127   int **shell_map_l_;
    00128   Ref<GaussianBasisSet> b1_, b2_, b3_, b4_;
    00129 public:
    00130   GenPetite4(const Ref<GaussianBasisSet> &b1,
    00131              const Ref<GaussianBasisSet> &b2,
    00132              const Ref<GaussianBasisSet> &b3,
    00133              const Ref<GaussianBasisSet> &b4);
    00134   ~GenPetite4();
    00135   virtual int in_p4(int i, int j, int k, int l) = 0;
    00136 };
    00137
    00140 extern Ref<GenPetite4>
    00141 construct_gpetite(const Ref<GaussianBasisSet> &b1,
    00142                   const Ref<GaussianBasisSet> &b2,
    00143                   const Ref<GaussianBasisSet> &b3,
    00144                   const Ref<GaussianBasisSet> &b4);
    00145
    00152 template <class C4>
    00153 class GPetite4: public GenPetite4 {
    00154     C4 c_;
    00155   public:
    00156     GPetite4(const Ref<GaussianBasisSet> &b1,
    00157              const Ref<GaussianBasisSet> &b2,
    00158              const Ref<GaussianBasisSet> &b3,
    00159              const Ref<GaussianBasisSet> &b4,
    00160              const C4& c);
    00161     ~GPetite4();
    00162     int in_p4(int i, int j, int k, int l);
    00163 };
    00164
    00165 template <class C4>
    00166 inline int
    00167 GPetite4<C4>::in_p4(int i, int j, int k, int l)
    00168 {
    00169   if (c1_) return 1;
    00170
    00171   sc_int_least64_t ijkl = c_.offset(i,j,k,l);
    00172   int nijkl = 1;
    00173
    00174   for (int g=1; g < ng_; g++) {
    00175       int gi = shell_map_i_[i][g];
    00176       int gj = shell_map_j_[j][g];
    00177       int gk = shell_map_k_[k][g];
    00178       int gl = shell_map_l_[l][g];
    00179       sc_int_least64_t gijkl = c_.offset(gi,gj,gk,gl);
    00180
    00181       if (gijkl > ijkl) return 0;
    00182       else if (gijkl == ijkl) nijkl++;
    00183   }
    00184
    00185   return ng_/nijkl;
    00186 }
    00187
    00188 }
    00189
    00190
    00191
    00192 #endif
    00193
    00194 // Local Variables:
    00195 // mode: c++
    00196 // c-file-style: "ETS"
    00197 // End: