# moindexspace.h

    00001 //
    00002 // moindexspace.h
    00003 //
    00004 // Copyright (C) 2004 Edward Valeev
    00005 //
    00006 // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
    00007 // Maintainer: EV
    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 #ifdef __GNUG__
    00029 #pragma interface
    00030 #endif
    00031
    00032 #ifndef _chemistry_qc_mbptr12_moindexspace_h
    00033 #define _chemistry_qc_mbptr12_moindexspace_h
    00034
    00035 #include <vector>
    00036 #include <util/ref/ref.h>
    00037 #include <util/state/statein.h>
    00038 #include <util/state/stateout.h>
    00039 #include <math/scmat/abstract.h>
    00040 #include <util/state/statein.h>
    00041 #include <chemistry/qc/basis/basis.h>
    00042
    00043 using namespace std;
    00044
    00045 namespace sc {
    00046
    00055 class MOIndexSpace : virtual public SavableState {
    00056
    00057 public:
    00058
    00060   enum IndexOrder { symmetry = 0, energy = 1, undefined = 2 };
    00061
    00062   MOIndexSpace(StateIn&);
    00080   MOIndexSpace(std::string name, const RefSCMatrix& full_coefs,
    00081                const Ref<GaussianBasisSet> basis, const Ref<Integral>& integral,
    00082                const vector<int>& offsets, const vector<int>& nmopi,
    00083                IndexOrder moorder = symmetry,
    00084                const RefDiagSCMatrix& evals = 0);
    00090   MOIndexSpace(std::string name, const RefSCMatrix& full_coefs,
    00091                const Ref<GaussianBasisSet> basis, const Ref<Integral>& integral,
    00092                const RefDiagSCMatrix& evals, int nfzc, int nfzv, IndexOrder moorder = energy);
    00095   MOIndexSpace(std::string name, const RefSCMatrix& full_coefs,
    00096                const Ref<GaussianBasisSet> basis, const Ref<Integral>& integral);
    00097
    00100   MOIndexSpace(std::string name, const Ref<MOIndexSpace>& orig_space,
    00101                const RefSCMatrix& new_coefs,
    00102                const Ref<GaussianBasisSet>& new_basis);
    00103   ~MOIndexSpace();
    00104
    00105   void save_data_state(StateOut&);
    00106
    00108   const std::string name() const;
    00110   const Ref<GaussianBasisSet> basis() const;
    00112   Ref<Integral> integral() const;
    00114   const RefSCMatrix coefs() const;
    00116   const RefDiagSCMatrix evals() const;
    00118   vector<int> mosym() const;
    00120   IndexOrder moorder() const;
    00122   int rank() const;
    00124   int full_rank() const;
    00126   int nblocks() const;
    00128   vector<int> nmo() const;
    00130   vector<int> offsets() const;
    00132   int to_full_space(const int i) const;
    00133
    00135   size_t memory_in_use() const;
    00136
    00138   void print(std::ostream&o=ExEnv::out0()) const;
    00140   void print_summary(std::ostream& os) const;
    00141
    00142 private:
    00143   std::string name_;               // String identifier for the orbital space
    00144
    00145   Ref<GaussianBasisSet> basis_;    // The AO basis
    00146   Ref<Integral> integral_;         // The integral factory
    00147   RefSCMatrix coefs_;              // AO->MO transformation coefficients (nao by nmo matrix)
    00148   RefDiagSCMatrix evals_;          // "eigenvalues" associated with the MOs
    00149   RefSCDimension modim_;           // The MO dimension
    00150   vector<int> mosym_;              // irrep of each orbital
    00151
    00152   int rank_;          // The rank of this space
    00153   int full_rank_;     // Rank of the full space, i.e. number of MOs
    00154   int nblocks_;       // Number of blocks
    00155   vector<int> nmo_;        // Number of MOs in each block
    00156   vector<int> offsets_;    // Index of the first MO in each block relative to the first MO of that block in full space
    00157   vector<int> map_to_full_space_;  // Full-space index
    00158
    00159   IndexOrder moorder_;
    00160
    00161   // checks mosym_ for irrep indices outside of the allowed range
    00162   void check_mosym() const;
    00163
    00164   // determines offsets_ and nmo_ from nfzc, nfzv, and evals
    00165   void frozen_to_blockinfo(const int nfzc, const int nfzv, const RefDiagSCMatrix& evals);
    00166
    00167   // computes coefficient matrix from the full coefficient matrix. If moorder_ == energy
    00168   // then the MO vectors will be sorted by their eigenvalues
    00169   void full_coefs_to_coefs(const RefSCMatrix& full_coefs, const RefDiagSCMatrix& evals);
    00170
    00171   // initialize the object
    00172   void init();
    00173
    00174   // sorting functions borrowed from mbpt.cc
    00175   static void dquicksort(double *item,int *index,int n);
    00176   static void dqs(double *item,int *index,int left,int right);
    00177
    00178 };
    00179
    00180 }
    00181
    00182 #endif
    00183
    00184 // Local Variables:
    00185 // mode: c++
    00186 // c-file-style: "CLJ"
    00187 // End:
    00188
    00189