49 vector_complex_function_3d& awfs_new,
50 vector_complex_function_3d& bwfs_new,
51 const vector_complex_function_3d& awfs_old,
52 const vector_complex_function_3d& bwfs_old,
53 const vector_complex_function_3d& rm)
56 vector_complex_function_3d vm = awfs_old;
59 vm.insert(vm.end(), bwfs_old.begin(), bwfs_old.end());
63 compress(world, vm,
false);
64 compress(world, rm,
false);
71 for (
int s=0; s<
m; s++)
73 const vector_complex_function_3d& vs =
_subspace[s].first;
74 const vector_complex_function_3d& rs =
_subspace[s].second;
75 for (
unsigned int i=0; i<vm.size(); i++)
77 ms[s] += vm[i].inner_local(rs[i]);
78 sm[s] += vs[i].inner_local(rm[i]);
81 world.gop.sum(ms.ptr(),
m);
82 world.gop.sum(sm.ptr(),
m);
84 tensor_complex newQ(
m,
m);
85 if (
m > 1) newQ(Slice(0,-2),Slice(0,-2)) =
_Q;
90 if (world.rank() == 0)
print(
_Q);
94 if (world.rank() == 0) {
98 if (abs(
c[
m-1]) < 3.0) {
101 else if (rcond < 0.01) {
102 if (world.rank() == 0)
103 print(
"Increasing subspace singular value threshold ",
c[
m-1], rcond);
107 if (world.rank() == 0)
108 print(
"Forcing full step due to subspace malfunction");
116 world.gop.broadcast_serializable(
c, 0);
117 if (world.rank() == 0) {
118 print(
"Subspace solution",
c);
122 vector_complex_function_3d phisa_new = zero_functions_compressed<double_complex,3>(world, awfs_old.size());
123 vector_complex_function_3d phisb_new = zero_functions_compressed<double_complex,3>(world, bwfs_old.size());
124 std::complex<double> one = std::complex<double>(1.0,0.0);
126 const vector_complex_function_3d& vm =
_subspace[
m].first;
127 const vector_complex_function_3d& rm =
_subspace[
m].second;
128 const vector_complex_function_3d vma(vm.begin(),vm.begin()+awfs_old.size());
129 const vector_complex_function_3d rma(rm.begin(),rm.begin()+awfs_old.size());
130 const vector_complex_function_3d vmb(vm.end()-bwfs_old.size(), vm.end());
131 const vector_complex_function_3d rmb(rm.end()-bwfs_old.size(), rm.end());
133 gaxpy(world, one, phisa_new,
c(
m), vma,
false);
134 gaxpy(world, one, phisa_new,-
c(
m), rma,
false);
135 gaxpy(world, one, phisb_new,
c(
m), vmb,
false);
136 gaxpy(world, one, phisb_new,-
c(
m), rmb,
false);
147 _Q =
_Q(Slice(1,-1),Slice(1,-1));
149 awfs_new = phisa_new;
150 bwfs_new = phisb_new;
156 vector_complex_function_3d& awfs_new,
157 const vector_complex_function_3d& awfs_old,
158 const vector_complex_function_3d& rm)
161 vector_complex_function_3d vm = awfs_old;
164 compress(world, vm,
false);
165 compress(world, rm,
false);
170 tensor_complex ms(
m);
171 tensor_complex sm(
m);
172 for (
int s=0; s<
m; s++)
174 const vector_complex_function_3d& vs =
_subspace[s].first;
175 const vector_complex_function_3d& rs =
_subspace[s].second;
176 for (
unsigned int i=0; i<vm.size(); i++)
178 ms[s] += vm[i].inner_local(rs[i]);
179 sm[s] += vs[i].inner_local(rm[i]);
182 world.gop.sum(ms.ptr(),
m);
183 world.gop.sum(sm.ptr(),
m);
185 tensor_complex newQ(
m,
m);
186 if (
m > 1) newQ(Slice(0,-2),Slice(0,-2)) =
_Q;
191 if (world.rank() == 0)
print(
_Q);
195 if (world.rank() == 0) {
196 double rcond = 1
e-12;
199 if (abs(
c[
m-1]) < 3.0) {
202 else if (rcond < 0.01) {
203 if (world.rank() == 0)
204 print(
"Increasing subspace singular value threshold ",
c[
m-1], rcond);
208 if (world.rank() == 0)
209 print(
"Forcing full step due to subspace malfunction");
217 world.gop.broadcast_serializable(
c, 0);
218 if (world.rank() == 0) {
219 print(
"Subspace solution",
c);
223 vector_complex_function_3d phisa_new = zero_functions_compressed<double_complex,3>(world, awfs_old.size());
224 std::complex<double> one = std::complex<double>(1.0,0.0);
226 const vector_complex_function_3d& vm =
_subspace[
m].first;
227 const vector_complex_function_3d& rm =
_subspace[
m].second;
228 const vector_complex_function_3d vma(vm.begin(),vm.begin()+awfs_old.size());
229 const vector_complex_function_3d rma(rm.begin(),rm.begin()+awfs_old.size());
231 gaxpy(world, one, phisa_new,
c(
m), vma,
false);
232 gaxpy(world, one, phisa_new,-
c(
m), rma,
false);
243 _Q =
_Q(Slice(1,-1),Slice(1,-1));
245 awfs_new = phisa_new;