Program Listing for File base_integrals.hpp

Return to documentation for file (src/integrals/base_integrals.hpp)

#ifndef UW12_BASE_INTEGRALS_HPP
#define UW12_BASE_INTEGRALS_HPP

#include <memory>
#include <mutex>

#include "integral_functions.hpp"

namespace uw12::integrals {
class BaseIntegrals {
 public:
  BaseIntegrals();

  BaseIntegrals(
      const TwoIndexFn &two_index_fn,
      const ThreeIndexFn &three_index_fn,
      const ThreeIndexFn &three_index_ri_fn,
      const std::vector<size_t> &df_sizes,
      size_t n_ao,
      size_t n_df,
      size_t n_ri,
      bool store_ao_integrals = true,
      bool store_ri_integrals = true
  );

  BaseIntegrals(
      const TwoIndexFn &two_index_fn,
      const ThreeIndexFn &three_index_fn,
      const std::vector<size_t> &df_sizes,
      size_t n_ao,
      size_t n_df,
      bool store_ao_integrals = true
  );

  BaseIntegrals(
      const linalg::Mat &J3_0,
      const linalg::Mat &J2,
      const ThreeIndexFn &three_index_ri,
      const std::vector<size_t> &df_sizes,
      bool use_ri,
      size_t n_ao,
      size_t n_df,
      size_t n_ri,
      bool store_ri_integrals = false
  );

  BaseIntegrals(
      const linalg::Mat &J3_0, const linalg::Mat &J2, const linalg::Mat &J3_ri_0
  );

  BaseIntegrals(const linalg::Mat &J3_0, const linalg::Mat &J2);

  BaseIntegrals(const linalg::Mat &J3, const linalg::Vec &df_vals);

  [[nodiscard]] linalg::Mat two_index() const;

  [[nodiscard]] linalg::Mat three_index(size_t A) const;

  [[nodiscard]] linalg::Mat three_index_ri(size_t A) const;

  [[nodiscard]] bool has_two_index_fn() const;

  [[nodiscard]] bool has_three_index_fn() const;

  [[nodiscard]] bool has_three_index_ri_fn() const;

  [[nodiscard]] const linalg::Mat &get_P2() const;

  [[nodiscard]] const std::vector<size_t> &get_df_sizes() const;

  [[nodiscard]] std::vector<size_t> get_df_offsets() const;

  [[nodiscard]] const linalg::Vec &get_df_vals() const;

  [[nodiscard]] const linalg::Mat &get_J3_0() const;

  [[nodiscard]] const linalg::Mat &get_J3() const;

  [[nodiscard]] const linalg::Mat &get_J3_ri_0() const;

  [[nodiscard]] const linalg::Mat &get_J3_ri() const;

  [[nodiscard]] size_t get_number_ao() const;

  [[nodiscard]] size_t get_number_df() const;

  [[nodiscard]] size_t get_number_ri() const;

  [[nodiscard]] bool storing_ri() const;

  [[nodiscard]] bool storing_ao() const;

  [[nodiscard]] bool has_P2() const;

  [[nodiscard]] bool has_df_vals() const;

  [[nodiscard]] bool has_J3_0() const;

  [[nodiscard]] bool has_J3() const;

  [[nodiscard]] bool has_J3_ri() const;

  [[nodiscard]] bool has_J3_ri_0() const;

 private:
  BaseIntegrals(
      TwoIndexFn two_index_fn_,
      ThreeIndexFn three_index_fn_,
      ThreeIndexFn three_index_ri_fn_,
      const std::vector<size_t> &df_sizes_,
      size_t n_ao_,
      size_t n_df_,
      size_t n_ri_,
      bool store_ao_integrals_,
      bool store_ri_integrals_,
      bool two_index_fn_provided_,
      bool three_index_fn_provided_,
      bool three_index_ri_fn_provided_,
      const std::shared_ptr<linalg::Mat> &J3_0_ = nullptr,
      const std::shared_ptr<linalg::Mat> &J3_ = nullptr,
      const std::shared_ptr<linalg::Mat> &J2_ = nullptr,
      const std::shared_ptr<linalg::Vec> &df_vals_ = nullptr,
      const std::shared_ptr<linalg::Mat> &J3_ri_0_ = nullptr
  );

  void set_J2_values() const;

  TwoIndexFn two_index_fn;
  ThreeIndexFn three_index_fn;
  ThreeIndexFn three_index_fn_ri;

  size_t n_ao{};
  size_t n_df{};
  size_t n_ri{};

  std::vector<size_t> df_sizes;

  std::shared_ptr<linalg::Mat> J3_0;
  std::shared_ptr<linalg::Mat> J3;
  std::shared_ptr<linalg::Mat> J3_ri_0;
  std::shared_ptr<linalg::Mat> J3_ri;
  std::shared_ptr<linalg::Mat> P2;
  std::shared_ptr<linalg::Vec> df_vals;

  std::shared_ptr<std::mutex> J3_lock;
  std::shared_ptr<std::mutex> J3_ri_lock;
  std::shared_ptr<std::mutex> eig_lock;

  bool two_index_fn_provided{};
  bool three_index_fn_provided{};
  bool three_index_ri_fn_provided{};

  bool store_ao_integrals{};
  bool store_ri_integrals{};
};
}  // namespace uw12::integrals

#endif  // UW12_BASE_INTEGRALS_HPP