29 #ifndef _chemistry_qc_scf_get_ints_impl_h
30 #define _chemistry_qc_scf_get_ints_impl_h
36 template <
typename ShellRange>
37 CADFCLHF::TwoCenterIntContainerPtr
38 CADFCLHF::ints_to_eigen(
41 Ref<TwoBodyTwoCenterInt>& ints,
44 auto rv = std::make_shared<TwoCenterIntContainer>(iblk.nbf, jblk.nbf);
45 int block_offset_i = 0;
47 int block_offset_j = 0;
49 const auto& ints_ptr = ints_to_eigen(ish, jsh, ints, int_type, ish.basis, jsh.basis);
50 rv->block(block_offset_i, block_offset_j, ish.nbf, jsh.nbf) = *ints_ptr;
51 block_offset_j += jsh.nbf;
53 block_offset_i += ish.nbf;
58 template <
typename ShellRange>
59 CADFCLHF::TwoCenterIntContainerPtr
60 CADFCLHF::ints_to_eigen_threaded(
63 std::vector<Ref<TwoBodyTwoCenterInt>>& ints_for_thread,
66 auto rv = std::make_shared<TwoCenterIntContainer>(iblk.nbf, jblk.nbf);
68 assert(iblk.is_contiguous());
69 assert(jblk.is_contiguous());
70 do_threaded(nthread_, [&](
int ithr){
72 for(
auto&& pair : threaded_shell_block_pair_range(iblk, jblk, ithr, nthread_)){
73 boost::tie(ish, jsh) = pair;
74 const auto& ints_ptr = ints_to_eigen(ish, jsh, ints_for_thread[ithr], int_type, ish.basis, jsh.basis);
76 ish.bfoff - iblk.bfoff, jsh.bfoff - jblk.bfoff,
84 template <
typename ShellRange>
85 Eigen::Map<CADFCLHF::TwoCenterIntContainer>
86 CADFCLHF::ints_to_eigen_map_threaded(
89 std::vector<Ref<TwoBodyTwoCenterInt>>& ints_for_thread,
93 auto rv = Eigen::Map<TwoCenterIntContainer>(buffer, iblk.nbf, jblk.nbf);
95 assert(iblk.is_contiguous());
96 assert(jblk.is_contiguous());
97 do_threaded(nthread_, [&](
int ithr){
99 for(
auto&& pair : threaded_shell_block_pair_range(iblk, jblk, ithr, nthread_)){
100 boost::tie(ish, jsh) = pair;
101 const auto& ints_ptr = ints_to_eigen(ish, jsh, ints_for_thread[ithr], int_type, ish.basis, jsh.basis);
103 ish.bfoff - iblk.bfoff, jsh.bfoff - jblk.bfoff,
112 template <
typename ShellRange>
113 CADFCLHF::ThreeCenterIntContainerPtr
114 CADFCLHF::ints_to_eigen(
117 Ref<TwoBodyTwoCenterInt>& ints,
120 auto rv = std::make_shared<ThreeCenterIntContainer>((
const int)iblk.nbf, (
const int)jsh.nbf);
122 const auto& ints_ptr = ints_to_eigen(ish, jsh, ints, int_type);
123 rv->block(ish.bfoff - iblk.bfoff, 0, ish.nbf, jsh.nbf) = *ints_ptr;
128 template <
typename ShellRange>
129 CADFCLHF::ThreeCenterIntContainerPtr
130 CADFCLHF::ints_to_eigen(
133 Ref<TwoBodyThreeCenterInt>& ints,
136 auto rv = std::make_shared<ThreeCenterIntContainer>(
141 const auto& ints_ptr = ints_to_eigen(ish, jsh, Xsh, ints, int_type, ish.basis, jsh.basis, Xblk.basis);
142 rv->middleCols(Xsh.bfoff - Xblk.bfoff, Xsh.nbf) = *ints_ptr;
147 template <
typename ShellRange1,
typename ShellRange2>
148 CADFCLHF::ThreeCenterIntContainerPtr
149 CADFCLHF::ints_to_eigen(
153 Ref<TwoBodyThreeCenterInt>& ints,
156 auto rv = std::make_shared<ThreeCenterIntContainer>(
162 const auto& ints_ptr = ints_to_eigen(ish, jsh, Xsh, ints, int_type, ish.basis, jsh.basis, Xsh.basis);
164 (ish.bfoff - iblk.bfoff) * jsh.nbf, Xsh.bfoff - Xblk.bfoff,
165 ish.nbf*jsh.nbf, Xsh.nbf
172 template <
typename ShellRange>
173 CADFCLHF::ThreeCenterIntContainerPtr
174 CADFCLHF::ints_to_eigen(
178 Ref<TwoBodyThreeCenterInt>& ints,
181 auto rv = std::make_shared<ThreeCenterIntContainer>(
182 iblk.nbf * jsh.nbf, Xsh.nbf
184 int block_offset = 0;
186 const auto& ints_ptr = ints_to_eigen(ish, jsh, Xsh, ints, int_type, ish.basis, jsh.basis, Xsh.basis);
188 block_offset * jsh.nbf, 0,
189 ish.nbf*jsh.nbf, Xsh.nbf
191 block_offset += ish.nbf;
196 template <
typename ShellRange>
197 Eigen::Map<CADFCLHF::ThreeCenterIntContainer>
198 CADFCLHF::ints_to_eigen_map(
202 Ref<TwoBodyThreeCenterInt>& ints,
204 double* __restrict__ buffer
207 Eigen::Map<ThreeCenterIntContainer> rv(
208 buffer, ish.nbf * jsh.nbf, Xblk.nbf
210 int block_offset = 0;
211 typedef Eigen::Map<RowMatrix, Eigen::Default, Eigen::OuterStride<>> SkipMap;
212 SkipMap tmp(buffer, 0, 0, Eigen::OuterStride<>(1));
214 new (&tmp) SkipMap(buffer + block_offset,
215 ish.nbf*jsh.nbf, Xsh.nbf, Eigen::OuterStride<>(Xblk.nbf)
222 block_offset += Xsh.nbf;
227 template <
typename MapType>
229 CADFCLHF::ints_to_eigen_map(
233 Ref<TwoBodyThreeCenterInt>& ints,
237 int block_offset = 0;
238 const Eigen::Map<const RowMatrix> buffmap(ints->buffer(int_type), ish.nbf*jsh.nbf, Xsh.nbf);
239 ints->compute_shell(ish, jsh, Xsh);
241 ints_computed_locally_ += ish.nbf * jsh.nbf * Xsh.nbf;
245 template <
typename ShellRange>
246 Eigen::Map<CADFCLHF::ThreeCenterIntContainer>
247 CADFCLHF::ints_to_eigen_map(
251 Ref<TwoBodyThreeCenterInt>& ints,
255 Eigen::Map<ThreeCenterIntContainer> rv(
257 iblk.nbf * jsh.nbf, Xsh.nbf
259 int block_offset = 0;
263 ish.nbf, jsh.nbf, Xsh.nbf,
265 buffer + block_offset * jsh.nbf * Xsh.nbf
267 block_offset += ish.nbf;
272 template <
typename ShellRange1,
typename ShellRange2>
273 Eigen::Map<CADFCLHF::ThreeCenterIntContainer>
274 CADFCLHF::ints_to_eigen_map(
278 Ref<TwoBodyThreeCenterInt>& ints,
282 Eigen::Map<ThreeCenterIntContainer> rv(
284 iblk.nbf * jsh.nbf, Xblk.nbf
286 if(Xblk.nshell == 1) {
287 const auto& Xsh = Xblk.first_shell;
288 int block_offset = 0;
292 ish.nbf, jsh.nbf, Xsh.nbf,
294 buffer + block_offset * jsh.nbf * Xsh.nbf
296 block_offset += ish.nbf;
301 int block_offset = 0;
307 ish.nbf, jsh.nbf, Xsh.nbf,
309 buffer + block_offset * jsh.nbf * Xblk.nbf + Xblk_offset,
313 Xblk_offset += Xsh.nbf;
315 block_offset += ish.nbf;
321 template <
typename ShellRange>
322 CADFCLHF::ThreeCenterIntContainerPtr
323 CADFCLHF::ints_to_eigen(
327 Ref<TwoBodyThreeCenterInt>& ints,
330 auto rv = std::make_shared<ThreeCenterIntContainer>(
331 ish.nbf * jblk.nbf, Xsh.nbf
333 int block_offset = 0;
335 const auto& ints_ptr = ints_to_eigen(ish, jsh, Xsh, ints, int_type);
338 mu.bfoff_in_shell*jblk.nbf + block_offset, 0,
340 ) = ints_ptr->block(mu.bfoff_in_shell*jsh.nbf, 0, jsh.nbf, Xsh.nbf);
342 block_offset += jsh.nbf;