MPQC  3.0.0-alpha
coefs_impl.h
1 //
2 // coefs_impl.h
3 //
4 // Copyright (C) 2014 David Hollman
5 //
6 // Author: David Hollman
7 // Maintainer: DSH
8 // Created: Apr 16, 2014
9 //
10 // This file is part of the SC Toolkit.
11 //
12 // The SC Toolkit is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Library General Public License as published by
14 // the Free Software Foundation; either version 2, or (at your option)
15 // any later version.
16 //
17 // The SC Toolkit is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Library General Public License for more details.
21 //
22 // You should have received a copy of the GNU Library General Public License
23 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
24 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 //
26 // The U.S. Government is granted a limited license as per AL 91-7.
27 //
28 
29 #ifndef _chemistry_qc_scf_coefs_impl_h
30 #define _chemistry_qc_scf_coefs_impl_h
31 
32 #include "iters.h"
33 #include "cadfclhf.h"
34 
35 namespace sc {
36 
37 template<template<typename...> class container, typename map_type>
38 void
39 CADFCLHF::get_coefs_ish_jsh(
40  const ShellData& ish,
41  const ShellData& jsh,
42  int ithr,
43  container<map_type>& coefsA,
44  container<map_type>& coefsB
45 ) {
46  const int dfnbfAB = ish.center == jsh.center ? ish.atom_dfnbf : ish.atom_dfnbf + jsh.atom_dfnbf;
47 
48  // Probably more efficient to just do all of the decompositions
49  // in threads beforehand, but oh well
50  std::shared_ptr<Decomposition> decomp = get_decomposition( //latex `\label{sc:coefgetdecomp}`
51  ish, jsh, metric_ints_2c_[ithr]
52  );
53 
54  Eigen::MatrixXd ij_M_X(ish.nbf*jsh.nbf, dfnbfAB);
55  for(const auto&& ksh : iter_shells_on_center(dfbs_, ish.center)){
56  auto ij_M_k = ints_to_eigen(
57  ish, jsh, ksh,
58  metric_ints_3c_[ithr],
59  metric_oper_type_
60  );
61  // Surely this transfer can be done more efficiently
62  for(const auto&& ibf : function_range(ish)){
63  for(const auto&& jbf : function_range(jsh)){
64  const int ijbf = ibf.bfoff_in_shell * jsh.nbf + jbf.bfoff_in_shell;
65  ij_M_X.row(ijbf).segment(ksh.bfoff_in_atom, ksh.nbf) = ij_M_k->row(ijbf);
66  } // end loop over functions in jsh
67  } // end loop over functions in ish
68  } // end loop over shells on ish.center
69 
70  if(ish.center != jsh.center){
71  for(const auto&& ksh : iter_shells_on_center(dfbs_, jsh.center)){
72  auto ij_M_k = ints_to_eigen(
73  ish, jsh, ksh,
74  metric_ints_3c_[ithr],
75  metric_oper_type_
76  );
77  for(const auto&& ibf : function_range(ish)){
78  for(const auto&& jbf : function_range(jsh)){
79  const int ijbf = ibf.bfoff_in_shell * jsh.nbf + jbf.bfoff_in_shell;
80  const int dfbfoff = ish.atom_dfnbf + ksh.bfoff_in_atom;
81  ij_M_X.row(ijbf).segment(dfbfoff, ksh.nbf) = ij_M_k->row(ijbf);
82  } // end loop over functions in jsh
83  } // end loop over functions in ish
84  } // end loop over shells on jsh.center
85  } // end if ish.center != jsh.center
86 
87  //----------------------------------------//
88 
89  //auto& Ctmp = decomp->solve(ij_M_X.transpose());
90  //int ijbf = 0;
91  //for(auto& Ca : coefsA) {
92  // Ca = Ctmp.col(ijbf++).head(ish.atom_dfnbf);
93  //}
94  //ijbf = 0;
95  //for(auto& Cb : coefsB) {
96  // Cb = Ctmp.col(ijbf++).tail(jsh.atom_dfnbf);
97  //}
98 
99  for(int ijbf = 0; ijbf < ij_M_X.rows(); ++ijbf) {
100  auto& Ctmp = decomp->solve(ij_M_X.row(ijbf).transpose());
101  coefsA[ijbf] = Ctmp.head(ish.atom_dfnbf);
102  if(!coefsB.empty()) {
103  coefsB[ijbf] = Ctmp.tail(jsh.atom_dfnbf);
104  }
105  }
106 
107 }
108 
109 } // end namespace sc
110 
111 #endif /* _chemistry_qc_scf_coefs_impl_h */
ShellData
Definition: cadf_attic.h:100
function_iterable
Definition: cadf_attic.h:375
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

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