MPQC  3.0.0-alpha
utils.h
1 //
2 // utils.h
3 //
4 // Copyright (C) 2005 Edward Valeev
5 //
6 // Author: Edward Valeev <evaleev@vt.edu>
7 // Maintainer: EV
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _chemistry_qc_lcao_utils_h
29 #define _chemistry_qc_lcao_utils_h
30 
31 #include <vector>
32 #include <math/scmat/matrix.h>
33 #include <chemistry/qc/wfn/spin.h>
34 #include <math/mmisc/pairiter.h>
35 #include <math/distarray4/distarray4.h>
36 
37 namespace sc {
38 
39  class OrbitalSpace;
40 
45  template <PureSpinCase2 spin>
46  RefSCMatrix spinadapt(const RefSCMatrix &A,
47  const Ref<OrbitalSpace> &bra,
48  const Ref<OrbitalSpace> &ket);
53  void antisymmetrize(RefSCMatrix& Aanti, const RefSCMatrix& A,
54  const Ref<OrbitalSpace>& bra,
55  const Ref<OrbitalSpace>& ket,
56  bool accumulate = false);
68  template <bool accumulate>
69  void antisymmetrize(RefSCMatrix& Aanti, const RefSCMatrix& A,
70  const Ref<OrbitalSpace>& bra1,
71  const Ref<OrbitalSpace>& bra2,
72  const Ref<OrbitalSpace>& ket1,
73  const Ref<OrbitalSpace>& ket2);
81  template <bool accumulate>
82  void antisymmetrize(RefSymmSCMatrix& Aanti, const RefSymmSCMatrix& A,
83  const Ref<OrbitalSpace>& bra1);
87  template <bool accumulate>
88  void antisymmetrize(double* Aanti, const double* A,
89  const int n);
94  template <bool Accumulate>
95  void symmetrize(RefSCMatrix& Asymm, const RefSCMatrix& A,
96  const Ref<OrbitalSpace>& bra,
97  const Ref<OrbitalSpace>& ket);
98 
110  template <bool Accumulate, sc::fastpairiter::PairSymm BraSymm, sc::fastpairiter::PairSymm KetSymm>
111  void symmetrize12(RefSCMatrix& Asymm, const RefSCMatrix& A,
112  const Ref<OrbitalSpace>& bra1,
113  const Ref<OrbitalSpace>& bra2,
114  const Ref<OrbitalSpace>& ket1,
115  const Ref<OrbitalSpace>& ket2);
116 
126  template <bool Accumulate,
127  sc::fastpairiter::PairSymm SrcBraSymm,
128  sc::fastpairiter::PairSymm SrcKetSymm,
129  sc::fastpairiter::PairSymm DstBraSymm,
130  sc::fastpairiter::PairSymm DstKetSymm
131  >
132  void symmetrize(RefSCMatrix& Aanti, const RefSCMatrix& A,
133  const Ref<OrbitalSpace>& bra1,
134  const Ref<OrbitalSpace>& bra2,
135  const Ref<OrbitalSpace>& ket1,
136  const Ref<OrbitalSpace>& ket2);
137 
140  std::vector<double> convert(const RefDiagSCMatrix& A);
141 
143  void print_f77_mat(const std::string& comment,
144  const double* A,
145  unsigned int nrow,
146  unsigned int ncol,
147  bool transpose = false);
148 
150  RefSymmSCMatrix to_lower_triangle(const RefSCMatrix& B);
151 
153  void
154  map(const Ref<DistArray4>& src,
155  const Ref<OrbitalSpace>& isrc,
156  const Ref<OrbitalSpace>& jsrc,
157  const Ref<OrbitalSpace>& xsrc,
158  const Ref<OrbitalSpace>& ysrc,
159  Ref<DistArray4>& dest,
160  const Ref<OrbitalSpace>& idest,
161  const Ref<OrbitalSpace>& jdest,
162  const Ref<OrbitalSpace>& xdest,
163  const Ref<OrbitalSpace>& ydest);
164 
167 
168  public:
169  MOPairIterFactory() {}
170  ~MOPairIterFactory() {}
171 
175  RefSCDimension scdim_aa(const Ref<OrbitalSpace>& space1, const Ref<OrbitalSpace>& space2);
177  RefSCDimension scdim_ab(const Ref<OrbitalSpace>& space1, const Ref<OrbitalSpace>& space2);
178  };
179 
180  template <typename T>
181  void bzerofast(T* s, size_t n) {
182  memset(static_cast<void*>(s), 0, n*sizeof(T));
183  }
184 
185 }
186 
187 #endif
188 
sc::print_f77_mat
void print_f77_mat(const std::string &comment, const double *A, unsigned int nrow, unsigned int ncol, bool transpose=false)
print out the Fortran-style matrix
sc::MOPairIterFactory::mopairiter
Ref< SpatialMOPairIter > mopairiter(const Ref< OrbitalSpace > &space1, const Ref< OrbitalSpace > &space2)
Constructs an appropriate MOPairIter object.
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::symmetrize
void symmetrize(const Ref< GPetiteList2 > &plist2, const Ref< Integral > &integral, const RefSymmSCMatrix &skel, const RefSymmSCMatrix &sym)
Uses plist2 to convert the "skeleton" matrix into the full matrix. Only applicable when the two basis...
sc::symmetrize12
void symmetrize12(RefSCMatrix &Asymm, const RefSCMatrix &A, const Ref< OrbitalSpace > &bra1, const Ref< OrbitalSpace > &bra2, const Ref< OrbitalSpace > &ket1, const Ref< OrbitalSpace > &ket2)
Generalization of the above.
Definition: utils.impl.h:329
sc::convert
std::vector< double > convert(const RefDiagSCMatrix &A)
Converts RefDiagSCMatrix to std::vector<double>
sc::RefSCDimension
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition: dim.h:152
sc::spinadapt
RefSCMatrix spinadapt(const RefSCMatrix &A, const Ref< OrbitalSpace > &bra, const Ref< OrbitalSpace > &ket)
Takes the 4-index quantity <ij|A|kl> and returns, depending on the value of the PureSpinCase2 spin,...
Definition: utils.impl.h:38
sc::map
std::vector< int > map(const GaussianBasisSet &B, const GaussianBasisSet &A)
same as operator<<, except A does not have to be contained in B, map[a] = -1 if function a is not in ...
sc::MOPairIterFactory
This class produces MOPairIter objects.
Definition: utils.h:166
sc::MOPairIterFactory::scdim_ab
RefSCDimension scdim_ab(const Ref< OrbitalSpace > &space1, const Ref< OrbitalSpace > &space2)
Constructs an appropriate RefSCDimension object for different-spin pair.
sc::MOPairIterFactory::scdim_aa
RefSCDimension scdim_aa(const Ref< OrbitalSpace > &space1, const Ref< OrbitalSpace > &space2)
Constructs an appropriate RefSCDimension object for same-spin pair.
sc::to_lower_triangle
RefSymmSCMatrix to_lower_triangle(const RefSCMatrix &B)
Returns the lower triangle of the matrix B (which should be symmetric)
sc::antisymmetrize
void antisymmetrize(RefSCMatrix &Aanti, const RefSCMatrix &A, const Ref< OrbitalSpace > &bra, const Ref< OrbitalSpace > &ket, bool accumulate=false)
Antisymmetrizes 4-index quantity <ij|A|kl> -> <ij|A|kl> - <ij|A|lk> and saves to Aanti.
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:23:58 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.