1 #ifndef MPQC_CI_SIGMA2_HPP
2 #define MPQC_CI_SIGMA2_HPP
4 #include "mpqc/ci/string.hpp"
5 #include "mpqc/ci/ci.hpp"
7 #include "mpqc/utility/timer.hpp"
8 #include "mpqc/range.hpp"
9 #include "mpqc/math/matrix.hpp"
14 template<
class CI,
class Spin>
15 void sigma12(
const CI &ci,
16 const String &I,
const Subspace<Spin> &S,
20 size_t count = I.count();
21 const auto &list = ci.template strings<Spin>();
24 std::vector<int> O, E;
25 for (
size_t l = 0; l < I.size(); ++l) {
34 for (
auto k = O.begin(); k < O.end(); ++k) {
38 for (
auto l = E.begin(); l < E.end(); ++l) {
39 String J = I.swap(*k,*l);
42 if (abs(ci.excitation(J) - S.rank()) > 1)
continue;
44 double sgn_kl = sgn(I,*k,*l);
45 int kl = index(*k,*l);
46 int jdx = (ci.test(J) ? list[J] : -1);
53 F(jdx-*S.begin()) += sgn_kl*h(kl);
55 BOOST_FOREACH (
int i, O) {
56 F(jdx-*S.begin()) += 0.5*sgn_kl*V(index(i,i),kl);
61 for (
auto j = E.begin(); j < E.end()-1; ++j) {
63 for (
auto i = O.begin(); i < O.end(); ++i) {
64 String K = J.swap(*i,*j);
65 if (ci.excitation(K) != S.rank())
continue;
68 F(kdx-*S.begin()) += 0.5*sgn_kl*sgn(J,*i,*j)*V(index(*i,*j),kl);
82 template<
class CI,
class Spin>
83 void sigma12(
const CI &ci, Subspace<Spin> I, Subspace<Spin> J,
89 for (
int i = 0; i < (int)I.size(); ++i) {
90 sigma12(ci, ci.template strings<Spin>()[i+*I.begin()], J, H, V, F);
91 for (
size_t j = 0; j < J.size(); ++j) {
94 if (fabs(f) < 1e-14)
continue;
95 S.col(i) += f*C.col(j);