Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit e860409

Browse files
committed
libint::svector may be a std::vector or not
1 parent c4a0aeb commit e860409

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/gint/gaussian/libint.cc

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "Shell.hh"
2626
#include "gint/IntegralUpdateKeys.hh"
2727
#include "read_basisset.hh"
28+
#include <iterator>
2829
#include <krims/DataFiles/FindDataFile.hh>
2930
#include <krims/FileSystem.hh>
3031

@@ -45,7 +46,13 @@ std::vector<std::pair<double, std::array<double, 3>>> inline make_libint_point_c
4546
return ret;
4647
}
4748

48-
/** Convert a gint::gaussian::Basis to a libint basis */
49+
// If boost has the container::small_vector available libint uses this datastructure.
50+
// Unfortunately a std::vector cannot be directly converted to this datastructure
51+
// and we need to distinguish between two codepaths, namely one with explict conversion
52+
// and one without
53+
/** Convert a gint::gaussian::Basis to a libint basis if the vector types agree */
54+
template <bool vectors_types_agree =
55+
std::is_same<libint2::svector<real_type>, std::vector<real_type>>::value>
4956
std::vector<libint2::Shell> make_libint_basis(Basis basis) {
5057
std::vector<libint2::Shell> ret;
5158
ret.reserve(basis.size());
@@ -55,7 +62,26 @@ std::vector<libint2::Shell> make_libint_basis(Basis basis) {
5562
libint2::Shell tosh{std::move(sh.exponents), {std::move(cntr)}, std::move(sh.origin)};
5663
ret.push_back(std::move(tosh));
5764
}
65+
return ret;
66+
}
67+
68+
/** Convert a gint::gaussian::Basis to a libint basis if the vector types do not agree */
69+
template <>
70+
std::vector<libint2::Shell> make_libint_basis<false>(Basis basis) {
71+
std::vector<libint2::Shell> ret;
72+
ret.reserve(basis.size());
5873

74+
for (const Shell& sh : basis) {
75+
libint2::svector<real_type> l_coefficients{
76+
std::make_move_iterator(sh.coefficients.begin()),
77+
std::make_move_iterator(sh.coefficients.end())};
78+
libint2::svector<real_type> l_exponents{std::make_move_iterator(sh.exponents.begin()),
79+
std::make_move_iterator(sh.exponents.end())};
80+
81+
libint2::Shell::Contraction cntr{sh.l, sh.pure, std::move(l_coefficients)};
82+
libint2::Shell tosh{std::move(l_exponents), {std::move(cntr)}, std::move(sh.origin)};
83+
ret.push_back(std::move(tosh));
84+
}
5985
return ret;
6086
}
6187

0 commit comments

Comments
 (0)