Program Listing for File integral_functions.hpp
↰ Return to documentation for file (src/integrals/integral_functions.hpp)
//
// Created by Zack Williams on 27/11/2020.
//
#ifndef UW12_INTEGRAL_FUNCTIONS_HPP
#define UW12_INTEGRAL_FUNCTIONS_HPP
#include <functional>
#include <vector>
#include "utils/linalg.hpp"
#include "utils/parallel.hpp"
namespace uw12::integrals {
using TwoIndexFn = std::function<linalg::Mat()>;
using ThreeIndexFn = std::function<linalg::Mat(size_t)>;
inline linalg::Mat coulomb_3idx(
const ThreeIndexFn &three_index_fn,
const std::vector<size_t> &df_offsets,
const size_t n_rows,
const size_t n_df
) {
linalg::Mat result(n_rows, n_df);
const auto n_df_sh = df_offsets.size();
const auto parallel_fn =
[&result, &three_index_fn, &df_offsets](const size_t A) {
const auto off_a = df_offsets[A];
const auto shell_results = three_index_fn(A);
linalg::assign_cols(result, shell_results, off_a);
};
parallel::parallel_for(0, n_df_sh, parallel_fn);
return result;
}
} // namespace uw12::integrals
#endif // UW12_INTEGRAL_FUNCTIONS_HPP