1 #ifndef MPQC_CI_COLLAPSE_HPP
2 #define MPQC_CI_COLLAPSE_HPP
4 #include "mpqc/ci/string.hpp"
6 #include "mpqc/math.hpp"
7 #include "mpqc/array.hpp"
8 #include "mpqc/python.hpp"
9 #include "mpqc/file.hpp"
10 #include "mpqc/task.hpp"
22 if (ci.collapse && (M > ci.collapse)) {
23 printf(
"collapse %lu to %lu\n", M, ci.collapse);
28 Matrix v(alpha.size(), beta.size());
29 Matrix C(alpha.size(), beta.size());
30 Matrix S(alpha.size(), beta.size());
34 for (
int i = 0; i < M; ++i) {
35 ds.b(alpha,beta,i) >> v;
38 printf(
"C* = %e*C(%i)\n", c(i), i);
46 for (
int i = 0; i < M; ++i) {
47 ds.Hb(alpha,beta,i) >> v;
50 printf(
"S* = %e*S(%i)\n", c(i), i);
57 for (
int j = 1; j < ci.collapse; ++j) {
59 auto last = iters[it-j];
60 for (
int i = 0; i < last.M; ++i) {
61 double a = last.a(i,k);
62 ds.b(alpha,beta,i) >> v;
64 printf(
"C* = %e*C(%i)\n", a, i);
66 Matrix b(alpha.size(), beta.size());
67 ds.b(alpha,beta,i) >> b;
69 std::cout << C << std::endl;
80 for (
int i = 0; i < M; ++i) {
88 for (
auto rb : range(beta).block(128)) {
90 Matrix c(alpha.size(), rb.size());
91 const Matrix &s = D(alpha, rb);
92 for (
int j = 0; j < M; ++j) {
94 ds.b(alpha,rb,j) >> c;
96 #pragma omp parallel for schedule(dynamic,1) reduction(+:q)
97 for (
int b = 0; b < rb.size(); ++b) {
98 q +=
dot(c.col(b), s.col(b));
107 iters[it].lambda = lambda;