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_abcc {
00088     long nj_, nkl_;
00089   public:
00090     canonical_abcc(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 kl = (k>l?(((k*long(k+1))>>1)+l):(((l*long(l+1))>>1)+k));
00097       return kl + nkl_*sc_int_least64_t(j + nj_*i);
00098     }
00099 };
00100 
00105 class canonical_aabb {
00106     long nij_;
00107   public:
00108     canonical_aabb(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       long ij = (i>j?(((i*long(i+1))>>1)+j):(((j*long(j+1))>>1)+i));
00115       long kl = (k>l?(((k*long(k+1))>>1)+l):(((l*long(l+1))>>1)+k));
00116       return ij + nij_*sc_int_least64_t(kl);
00117     }
00118 };
00119 
00123 class canonical_abab {
00124     long nj_;
00125   public:
00126     canonical_abab(const Ref<GaussianBasisSet> bi,
00127                    const Ref<GaussianBasisSet> bj,
00128                    const Ref<GaussianBasisSet> bk,
00129                    const Ref<GaussianBasisSet> bl
00130                    );
00131     sc_int_least64_t offset(int i, int j, int k, int l) {
00132       long ij = i*nj_ + j;
00133       long kl = k*nj_ + l;
00134       sc_int_least64_t
00135           off = (ij>kl?(((ij*sc_int_least64_t(ij+1))>>1)+kl)
00136                  :(((kl*sc_int_least64_t(kl+1))>>1)+ij));
00137       return off;
00138     }
00139 };
00140 
00144 class canonical_abcd {
00145     int ni_, nj_, nk_;
00146   public:
00147     canonical_abcd(const Ref<GaussianBasisSet> bi,
00148                    const Ref<GaussianBasisSet> bj,
00149                    const Ref<GaussianBasisSet> bk,
00150                    const Ref<GaussianBasisSet> bl
00151                    );
00152     sc_int_least64_t offset(int i, int j, int k, int l) {
00153       return (i + ni_*sc_int_least64_t(j + nj_*long(k + nk_*l)));
00154     }
00155 };
00156 
00159 class GenPetite4: public RefCount {
00160 protected:
00161   bool c1_;
00162   int ng_;
00163   int **shell_map_i_;
00164   int **shell_map_j_;
00165   int **shell_map_k_;
00166   int **shell_map_l_;
00167   Ref<GaussianBasisSet> b1_, b2_, b3_, b4_;
00168 public:
00169   GenPetite4(const Ref<GaussianBasisSet> &b1,
00170              const Ref<GaussianBasisSet> &b2,
00171              const Ref<GaussianBasisSet> &b3,
00172              const Ref<GaussianBasisSet> &b4);
00173   ~GenPetite4();
00174   virtual int in_p4(int i, int j, int k, int l) = 0;
00175 };
00176 
00179 extern Ref<GenPetite4>
00180 construct_gpetite(const Ref<GaussianBasisSet> &b1,
00181                   const Ref<GaussianBasisSet> &b2,
00182                   const Ref<GaussianBasisSet> &b3,
00183                   const Ref<GaussianBasisSet> &b4);
00184 
00191 template <class C4>
00192 class GPetite4: public GenPetite4 {
00193     C4 c_;
00194   public:
00195     GPetite4(const Ref<GaussianBasisSet> &b1,
00196              const Ref<GaussianBasisSet> &b2,
00197              const Ref<GaussianBasisSet> &b3,
00198              const Ref<GaussianBasisSet> &b4,
00199              const C4& c);
00200     ~GPetite4();
00201     int in_p4(int i, int j, int k, int l);
00202 };
00203 
00204 template <class C4>
00205 inline int
00206 GPetite4<C4>::in_p4(int i, int j, int k, int l)
00207 {
00208   if (c1_) return 1;
00209 
00210   sc_int_least64_t ijkl = c_.offset(i,j,k,l);
00211   int nijkl = 1;
00212 
00213   for (int g=1; g < ng_; g++) {
00214       int gi = shell_map_i_[i][g];
00215       int gj = shell_map_j_[j][g];
00216       int gk = shell_map_k_[k][g];
00217       int gl = shell_map_l_[l][g];
00218       sc_int_least64_t gijkl = c_.offset(gi,gj,gk,gl);
00219 
00220       if (gijkl > ijkl) return 0;
00221       else if (gijkl == ijkl) nijkl++;
00222   }
00223 
00224   return ng_/nijkl;
00225 }
00226 
00227 }
00228 
00229 
00230 
00231 #endif
00232 
00233 // Local Variables:
00234 // mode: c++
00235 // c-file-style: "ETS"
00236 // End:

Generated at Wed Sep 5 14:02:29 2007 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.5.2.
These pages are hosted on SourceForge.net