MADNESS 0.10.1
x_space.h
Go to the documentation of this file.
1// Copyright 2021 Adrian Hurtado
2#ifndef SRC_APPS_MOLRESPONSE_X_SPACE_H_
3#define SRC_APPS_MOLRESPONSE_X_SPACE_H_
4
5#include <madness/mra/mra.h>
7
8#include <algorithm>
9#include <cstdint>
10#include <memory>
11#include <numeric>
12#include <vector>
13
14#include "functypedefs.h"
16
17namespace madness {
18
19typedef std::vector<vector_real_function_3d> response_matrix;
20
21struct X_space;
22
25auto create_response_matrix(const size_t &num_state,
26 const size_t &num_orbitals) -> response_matrix;
27auto to_response_matrix(const X_space &x) -> response_matrix;
28auto to_conjugate_response_matrix(const X_space &x) -> response_matrix;
29auto to_flattened_vector(const X_space &x) -> vector_real_function_3d;
30auto to_X_space(const response_matrix &x) -> X_space;
31auto to_conjugate_X_space(const response_matrix &x) -> X_space;
32
33struct X_space {
34private:
35 size_t n_states; // Num. of resp. states
36 size_t n_orbitals; // Num. of ground states
37
38public:
40 std::list<size_t> active;
41
42public:
43 [[nodiscard]] size_t num_states() const { return n_states; }
44 [[nodiscard]] size_t num_orbitals() const { return n_orbitals; }
45 // default constructor
46 X_space() : n_states(0), n_orbitals(0), x(), y(), active(0) {}
47 // Copy constructor
48 void reset_active() {
49 active.resize(n_states);
50 x.active.resize(n_states);
51 y.active.resize(n_states);
52 size_t i{0};
53 for (auto &ai : active) {
54 ai = i++;
55 }
56 i = 0;
57 for (auto &ai : x.active) {
58 ai = i++;
59 }
60 i = 0;
61 for (auto &ai : y.active) {
62 ai = i++;
63 }
64 }
65 void set_active(const std::list<size_t> &new_active) {
66 active = new_active;
67 x.active = new_active;
68 y.active = new_active;
69 }
73 [[nodiscard]] X_space copy() const {
74 auto &world = x[0][0].world();
75 auto new_x = X_space(*this); // copy
76 for (const auto &i : new_x.active) {
77 new_x.x[i] = madness::copy(world, x[i], false);
78 new_x.y[i] = madness::copy(world, y[i], false);
79 }
80 world.gop.fence();
81
82 return new_x;
83 }
84 /// Create a new copy of the function with different distribution and optional
85 /// fence
86
87 /// Works in either basis. Different distributions imply
88 /// asynchronous communication and the optional fence is
89 /// collective.
90 [[nodiscard]] auto
91 copy(const std::shared_ptr<WorldDCPmapInterface<Key<3>>> &p_map,
92 bool fence = false) const -> X_space {
93 auto &world = x[0][0].world();
94 auto new_x = X_space(*this); // copy
95 for (int i = 0; i < new_x.num_states(); i++) {
96 new_x.x[i] = madness::copy(world, x[i], p_map, false);
97 new_x.y[i] = madness::copy(world, y[i], p_map, false);
98 }
99 world.gop.fence();
100 return new_x;
101 }
102 // assignment
103 auto operator=(const X_space &B) -> X_space & {
104 if (this != &B) { // is it the same object?
105
106 this->n_states = B.num_states();
107 this->n_orbitals = B.num_orbitals();
108 this->x = B.x;
109 this->y = B.y;
110 this->active = B.active;
111 }
112 return *this; // NO SHALLOW COPIES
113 }
114 X_space(World &world, size_t n_states, size_t n_orbitals)
116 x(world, n_states, n_orbitals), y(world, n_states, n_orbitals),
118 reset_active();
119 }
120 void clear() {
121 x.clear();
122 y.clear();
123 active.clear();
124 }
126 const vector_real_function_3d &vy) {
127 if (n_orbitals > 0) {
128 MADNESS_ASSERT(n_orbitals == vx.size());
129 MADNESS_ASSERT(n_orbitals == vy.size());
130 MADNESS_ASSERT(vx.size() == vy.size());
131 } else { // g_states == 0 (empty vector)
132 n_orbitals = vx.size();
133 }
134 MADNESS_ASSERT(vx.size() == num_orbitals());
135 MADNESS_ASSERT(vy.size() == num_orbitals());
136 active.push_back(active.back() + 1);
137 n_states++;
138 x.push_back(vx);
139 y.push_back(vy);
140 // Be smart with g_states
141 }
142 void pop_back() {
143 x.pop_back();
144 y.pop_back();
145 active.pop_back();
146 n_states--;
147 if (n_states == 0) {
148 n_orbitals = 0;
149 }
150 }
151
152 friend auto inplace_apply(
153 X_space &A,
154 const std::function<void(vector_real_function_3d &)> &func) -> void {
155 auto &world = A.x[0][0].world();
156 for (auto &i : A.active) {
157 func(A.x[i]);
158 func(A.y[i]);
159 }
160 world.gop.fence();
161 }
162
163 /**
164 * @brief Apply a function to the X_space
165 * @param A
166 * @param func
167 * @return
168 */
169 friend auto oop_apply(const X_space &A,
170 const std::function<vector_real_function_3d(
171 const vector_real_function_3d &)> &func,
172 bool fence = true) -> X_space {
173 auto &world = A.x[0][0].world();
174 auto result =
175 X_space::zero_functions(world, A.num_states(), A.num_orbitals());
176 result.set_active(A.active);
177 // if (world.rank() == 0) { print("oop_apply"); }
178 for (auto &i : result.active) {
179 // if (world.rank() == 0) { print("oop_apply", i); }
180 result.x[i] = func(A.x[i]);
181 result.y[i] = func(A.y[i]);
182 }
183 if (fence)
184 world.gop.fence();
185 return result;
186 }
187
188 template <typename T>
189 friend auto binary_apply(const X_space &A, const X_space &B,
190 T &func) -> X_space {
192
193 auto &world = A.x[0][0].world();
194 X_space result =
195 X_space::zero_functions(world, A.num_states(), A.num_orbitals());
196 result.set_active(A.active);
197
198 for (const auto &i : result.active) {
199 auto ax = A.x[i];
200 auto bx = B.x[i];
201
202 auto ay = A.y[i];
203 auto by = B.y[i];
204
205 result.x[i] = func(ax, bx);
206 result.y[i] = func(ay, by);
207 }
208 world.gop.fence();
209 return result;
210 }
211
212 template <class T>
213 friend auto binary_inplace(X_space &A, const X_space &B, const T &func) {
215 auto &world = A.x[0][0].world();
216 for (const auto &i : A.active) {
217 auto ax = A.x[i];
218 auto ay = A.y[i];
219
220 auto bx = B.x[i];
221 auto by = B.y[i];
222
223 func(ax, bx);
224 func(ay, by);
225 }
226 world.gop.fence();
227
228 return A;
229 }
230
231 static X_space zero_functions(World &world, size_t n_states,
232 size_t n_orbitals) {
233 auto zeros = X_space(world, n_states, n_orbitals);
234 for (int i = 0; i < zeros.num_states(); i++) {
235 zeros.x[i] =
236 ::madness::zero_functions<double, 3>(world, n_orbitals, true);
237 zeros.y[i] =
238 ::madness::zero_functions<double, 3>(world, n_orbitals, true);
239 }
240 world.gop.fence();
241 return zeros;
242 }
243
244 auto operator+=(const X_space &B) -> X_space & {
245 MADNESS_ASSERT(same_size(*this, B));
246 auto &world = this->x[B.active.front()][0].world();
247 this->active = B.active;
248 this->from_vector(this->to_vector() + B.to_vector());
249
250 // auto add_inplace = [&](auto &a, const auto &b)
251 // {
252 // gaxpy(world, 1.0, a, 1.0, b, true);
253 // };
254 // binary_inplace(*this, B, add_inplace);
255 return *this;
256 }
257
258 friend auto operator+(const X_space &A, const X_space &B) -> X_space {
260
261 auto result = X_space(A.x[A.active.front()][0].world(), A.num_states(),
262 A.num_orbitals());
263 result.set_active(A.active);
264 result.from_vector(A.to_vector() + B.to_vector());
265 return result;
266 }
267
268 friend X_space operator-(const X_space &A, const X_space &B) {
270
271 auto result = X_space(A.x[A.active.front()][0].world(), A.num_states(),
272 A.num_orbitals());
273 result.set_active(A.active);
274 result.from_vector(A.to_vector() - B.to_vector());
275 return result;
276
277 auto sub_ab = [&](const auto &a, const auto &b) {
278 return gaxpy_oop(1.0, a, -1.0, b, true);
279 };
280 return binary_apply(A, B, sub_ab);
281 }
282
283 friend X_space operator*(const X_space &A, const double &b) {
284 World &world = A.x[A.active.front()][0].world();
285
286 auto result = X_space(world, A.num_states(), A.num_orbitals());
287 result.set_active(A.active);
288 result.from_vector(A.to_vector() * b);
289 return result;
290
291 auto scale_a = [&](vector_real_function_3d &vec_ai) {
292 scale(world, vec_ai, b, true);
293 };
294 inplace_apply(result, scale_a);
295 return result;
296 }
297 friend X_space operator*(const double &b, const X_space &A) {
298 World &world = A.x[A.active.front()][0].world();
299 auto result = X_space(world, A.num_states(), A.num_orbitals());
300 result.set_active(A.active);
301 result.from_vector(A.to_vector() * b);
302 return result;
303
304 auto scale_a = [&](vector_real_function_3d &vec_ai) {
305 scale(world, vec_ai, b, true);
306 };
307 inplace_apply(result, scale_a);
308 return result;
309 }
310 friend X_space operator*(const X_space &B, const X_space &A) {
311 World &world = A.x[A.active.front()][0].world();
312 auto result = X_space(A.x[0][0].world(), A.num_states(), A.num_orbitals());
313 result.set_active(A.active);
314 vector_real_function_3d result_vec =
315 mul(world, A.to_vector(), B.to_vector());
316 result.from_vector(result_vec);
317 return result;
318
319 auto mul_ab = [&](vector_real_function_3d &vec_ai,
320 vector_real_function_3d &vec_bi) {
321 return mul(world, vec_ai, vec_bi, false);
322 };
323 return binary_apply(A, B, mul_ab);
324 }
325
327 World &world = A.x[A.active.front()][0].world();
328
329 auto result = X_space(A.x[0][0].world(), A.num_states(), A.num_orbitals());
330 result.set_active(A.active);
331 result.from_vector(A.to_vector() * f);
332 return result;
333
334 auto mul_f = [&](const vector_real_function_3d &vec_ai) {
335 return mul(world, f, vec_ai, false);
336 };
337 return oop_apply(A, mul_f);
338 }
339 friend auto operator*(const Function<double, 3> &f,
340 const X_space &A) -> X_space {
341 World &world = A.x[A.active.front()][0].world();
342 auto result = X_space(A.x[0][0].world(), A.num_states(), A.num_orbitals());
343 result.set_active(A.active);
344 result.from_vector(f * A.to_vector());
345 return result;
346
347 auto mul_f = [&](const vector_real_function_3d &vec_ai) {
348 return mul(world, f, vec_ai, false);
349 };
350 return oop_apply(A, mul_f);
351 }
352
353 friend auto operator*(const X_space &A, const Tensor<double> &b) -> X_space {
356
357 World &world = A.x[0][0].world();
358 auto transform_ai = [&](auto &ai) { return transform(world, ai, b, true); };
359 return oop_apply(A, transform_ai);
360 }
361 /***
362 *
363 * @param A
364 * @param B
365 * @return
366 */
367 friend auto inner(const X_space &A, const X_space &B) -> Tensor<double>;
368
369 void truncate() {
370
371 auto &world = this->x[x.active.front()][0].world();
374 }
375
376 void compress() const {
377
378 auto x = to_vector();
379 auto &world = this->x[active.front()][0].world();
380 madness::compress(world, x, true);
381 }
382 void reconstruct() const {
383
384 auto x = to_vector();
385 auto &world = this->x[active.front()][0].world();
386 madness::reconstruct(world, x, true);
387 }
388
389 void truncate(double thresh) {
390
391 auto &world = this->x[x.active.front()][0].world();
392 this->from_vector(madness::truncate(this->to_vector(), thresh, true));
393 }
394
395 auto norm2s() const -> Tensor<double> {
396 World &world = x[0][0].world();
397 Tensor<double> norms(num_states());
398
399 auto x = to_response_matrix(*this);
400 int b = 0;
401 for (const auto &xb : x) {
402 norms[b++] = norm2(world, xb);
403 }
404 world.gop.fence();
405 return norms;
406 }
407
408 [[nodiscard]] auto component_norm2s() const -> Tensor<double> {
409 World &world = x[0][0].world();
410 auto rx = to_flattened_vector(*this);
411 auto norms = norm2s_T(world, rx);
412 return norms.reshape(n_states, 2 * n_orbitals);
413 }
414
415 friend auto size_states(const X_space &x) -> size_t { return x.n_states; }
416 friend auto size_orbitals(const X_space &x) -> size_t { return x.n_orbitals; }
417 friend auto same_size(const X_space &A, const X_space &B) -> bool {
418 return ((size_states(A) == size_states(B) &&
420 }
421
422 [[nodiscard]] auto to_vector() const -> vector_real_function_3d {
423
424 int n = static_cast<int>(active.size());
425 int m = static_cast<int>(num_orbitals());
426
427 vector_real_function_3d rf(2 * n * m);
428
429 int i = 0;
430 for (const auto &ai : active) {
431 for (int j = 0; j < m; j++) {
432 auto xindex = (2 * i * m) + j;
433 auto yindex = (2 * i * m) + j + m;
434 rf[xindex] = x[ai][j];
435 rf[yindex] = y[ai][j];
436 }
437 i++;
438 }
439 return rf;
440 }
441
442 auto from_vector(const vector_real_function_3d &rf) -> void {
443
444 int m = static_cast<int>(num_orbitals());
445
446 int i = 0;
447 for (const auto &ai : active) {
448 for (int j = 0; j < m; j++) {
449 auto xindex = (2 * i * m) + j;
450 auto yindex = (2 * i * m) + j + m;
451
452 x[ai][j] = rf[xindex];
453 y[ai][j] = rf[yindex];
454 }
455 i++;
456 }
457 }
458};
459
460// but the solver needs the functions initialized to zero for which we also need
461// the world object.
462
463struct X_vector : public X_space {
464 X_vector(World &world, size_t n_orbtials) {
465 this->X_space::zero_functions(world, size_t(1), n_orbtials);
466 }
467
469 : X_space(A.x[0][0].world(), size_t(1), A.num_orbitals()) {
470 x[0] = A.x[b];
471 y[0] = A.y[b];
472 }
473 friend X_vector operator-(const X_vector &A, const X_vector &B) {
475
476 World &world = A.x[0][0].world();
477 X_vector result(world, size_orbitals(A)); // create zero_functions
478 result.x = A.x - B.x;
479 result.y = A.y - B.y;
480 return result;
481 }
482 friend X_vector operator*(const X_vector &A, const double &c) {
483 World &world = A.x[0][0].world();
484 X_vector result(world, size_orbitals(A)); // create zero_functions
485 result.x = A.x * c;
486 result.y = A.y * c;
487 return result;
488 }
489 X_vector copy() const {
490 X_vector copyX(x[0][0].world(), x.num_orbitals);
491 copyX.x = x.copy();
492 copyX.y = y.copy();
493 return copyX;
494 }
495 auto operator+=(const X_vector &B) -> X_vector & {
496 MADNESS_ASSERT(same_size(*this, B));
497 this->x += B.x;
498 this->y += B.y;
499 return *this;
500 }
501 inline friend auto inner(X_vector &A, X_vector &B) -> double {
505
506 Tensor<double> G(1, 1);
507 Tensor<double> G1(1, 1);
508 Tensor<double> G2(1, 1);
509
510 World &world = A.x[0][0].world();
511
512 auto ax = madness::copy(world, A.x[0]);
513 auto ay = madness::copy(world, A.y[0]);
514
515 auto bx = madness::copy(world, B.x[0]);
516 auto by = madness::copy(world, B.y[0]);
517
518 for (auto &ayi : ay) {
519 ax.push_back(madness::copy(ayi));
520 }
521 for (auto &byi : by) {
522 bx.push_back(madness::copy(byi));
523 };
524
525 double result = inner(ax, bx);
526
527 return result;
528 }
529};
530// function object with allocator()()
533 const size_t n_orbtials;
536 // overloading the default constructor () operator
538 // print("allocator called with ", int(n_orbtials), " orbitals");
539 // returning constructor of x_vector
540 return zero_functions<double, 3>(world, n_orbtials);
541 }
542 // Copy constructor
543
547};
548
561
562vector_real_function_3d copyToVector(const X_space &chi);
563
564void copyToXspace(const vector_real_function_3d &rf, X_space &chi);
565// In this implmentation we need to represent each x_space as a contigous block
566// of functions.
567vector_real_function_3d copyToVector(const response_space &chi);
568
570 response_space &chi);
571
574
575public:
577
578 [[nodiscard]] vector_real_function_3d
579 get_x_state(int i, const vector_real_function_3d &rf) const {
580
582 auto index = 2 * num_orbitals * i;
583
584 for (int j = 0; j < num_orbitals; j++) {
585 subset[j] = rf[index + j];
586 }
587 return subset;
588 }
589 [[nodiscard]] vector_real_function_3d
590 get_y_state(int i, const vector_real_function_3d &rf) const {
591
593 auto index = 2 * num_orbitals * i + num_orbitals;
594 for (int j = 0; j < num_orbitals; j++) {
595 subset[j] = rf[index + j];
596 }
597 return subset;
598 }
599};
600
603
604public:
606
607 [[nodiscard]] vector_real_function_3d
608 get_x_state(int i, const vector_real_function_3d &rf) const {
609
611 auto index = num_orbitals * i;
612
613 for (int j = 0; j < num_orbitals; j++) {
614 subset[j] = rf[index + j];
615 }
616 return subset;
617 }
618};
619} // namespace madness
620
621#endif // SRC_APPS_MOLRESPONSE_X_SPACE_H_
Definition test_ar.cc:118
Definition test_ar.cc:141
Definition test_derivative.cc:24
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:100
A multiresolution adaptive numerical function.
Definition mra.h:139
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:69
A tensor is a multidimensional array.
Definition tensor.h:317
Interface to be provided by any process map.
Definition worlddc.h:82
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:161
A parallel world class.
Definition world.h:132
WorldGopInterface & gop
Global operations.
Definition world.h:207
Definition x_space.h:601
response_space_index(int num_orbitals)
Definition x_space.h:605
int num_orbitals
Definition x_space.h:602
vector_real_function_3d get_x_state(int i, const vector_real_function_3d &rf) const
Definition x_space.h:608
Definition x_space.h:572
vector_real_function_3d get_y_state(int i, const vector_real_function_3d &rf) const
Definition x_space.h:590
x_space_indexer(int num_orbitals)
Definition x_space.h:576
vector_real_function_3d get_x_state(int i, const vector_real_function_3d &rf) const
Definition x_space.h:579
int num_orbitals
Definition x_space.h:573
Provides typedefs to hide use of templates and to increase interoperability.
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:28
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
Main include file for MADNESS and defines Function interface.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
Function< TENSOR_RESULT_TYPE(L, R), NDIM > gaxpy_oop(TENSOR_RESULT_TYPE(L, R) alpha, const Function< L, NDIM > &left, TENSOR_RESULT_TYPE(L, R) beta, const Function< R, NDIM > &right, bool fence=true)
Returns new function alpha*left + beta*right optional fence and no automatic compression.
Definition mra.h:1981
response_space scale(response_space a, double b)
Tensor< double > norm2s_T(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norms of a vector of functions.
Definition vmra.h:858
auto to_X_space(const response_matrix &x) -> X_space
Definition x_space.cc:108
Function< TENSOR_RESULT_TYPE(Q, T), NDIM > mul(const Q alpha, const Function< T, NDIM > &f, bool fence=true)
Returns new function equal to alpha*f(x) with optional fence.
Definition mra.h:1765
std::vector< vector_real_function_3d > response_matrix
Definition response_functions.h:20
void truncate(World &world, response_space &v, double tol, bool fence)
Definition basic_operators.cc:31
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition vmra.h:707
auto to_conjugate_X_space(const response_matrix &x) -> X_space
response_matrix [x,y] -> Xspace X.x=y X.y=conjugate(x)
Definition x_space.cc:133
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions.
Definition vmra.h:149
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:162
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition vmra.h:871
void copyToResponseSpace(const vector_real_function_3d &rf, response_space &chi)
Definition x_space.cc:271
std::vector< real_function_3d > vector_real_function_3d
Definition functypedefs.h:94
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
auto create_response_matrix(const size_t &num_states, const size_t &num_orbitals) -> response_matrix
Create a response matrix object.
Definition x_space.cc:40
FunctionFactory< double, 3 > real_factory_3d
Definition functypedefs.h:108
NDIM & f
Definition mra.h:2481
auto to_response_vector(const vector_real_function_3d &vec) -> vector_real_function_3d
Definition x_space.cc:15
Function< double, 3 > real_function_3d
Definition functypedefs.h:80
void copyToXspace(const vector_real_function_3d &rf, X_space &chi)
Definition x_space.cc:233
auto to_response_matrix(const X_space &x) -> response_matrix
Definition x_space.cc:56
vector_real_function_3d copyToVector(const X_space &chi)
Definition x_space.cc:212
constexpr Vector< T, sizeof...(Ts)+1 > vec(T t, Ts... ts)
Factory function for creating a madness::Vector.
Definition vector.h:750
auto to_conjugate_response_matrix(const X_space &x) -> response_matrix
Definition x_space.cc:71
auto to_flattened_vector(const X_space &x) -> vector_real_function_3d
Flattens all response functions into a single vector of functions.
Definition x_space.cc:92
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2066
static const double b
Definition nonlinschro.cc:119
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
static const double m
Definition relops.cc:9
static const double thresh
Definition rk.cc:45
Definition test_ar.cc:261
Definition x_space.h:33
auto norm2s() const -> Tensor< double >
Definition x_space.h:395
void compress() const
Definition x_space.h:376
friend auto operator+(const X_space &A, const X_space &B) -> X_space
Definition x_space.h:258
auto operator=(const X_space &B) -> X_space &
Definition x_space.h:103
X_space(const X_space &A)
Definition x_space.h:70
void reset_active()
Definition x_space.h:48
void clear()
Definition x_space.h:120
size_t num_states() const
Definition x_space.h:43
std::list< size_t > active
Definition x_space.h:40
friend auto inner(const X_space &A, const X_space &B) -> Tensor< double >
Computes the matrix elements between two response spaces.
Definition x_space.cc:185
auto to_vector() const -> vector_real_function_3d
Definition x_space.h:422
static X_space zero_functions(World &world, size_t n_states, size_t n_orbitals)
Definition x_space.h:231
friend X_space operator*(const X_space &A, const double &b)
Definition x_space.h:283
friend auto operator*(const X_space &A, const Tensor< double > &b) -> X_space
Definition x_space.h:353
X_space copy() const
Definition x_space.h:73
friend auto operator*(const Function< double, 3 > &f, const X_space &A) -> X_space
Definition x_space.h:339
auto operator+=(const X_space &B) -> X_space &
Definition x_space.h:244
auto component_norm2s() const -> Tensor< double >
Definition x_space.h:408
size_t num_orbitals() const
Definition x_space.h:44
friend auto size_orbitals(const X_space &x) -> size_t
Definition x_space.h:416
friend auto inplace_apply(X_space &A, const std::function< void(vector_real_function_3d &)> &func) -> void
Definition x_space.h:152
void reconstruct() const
Definition x_space.h:382
size_t n_states
Definition x_space.h:35
friend auto binary_inplace(X_space &A, const X_space &B, const T &func)
Definition x_space.h:213
friend X_space operator-(const X_space &A, const X_space &B)
Definition x_space.h:268
friend auto oop_apply(const X_space &A, const std::function< vector_real_function_3d(const vector_real_function_3d &)> &func, bool fence=true) -> X_space
Apply a function to the X_space.
Definition x_space.h:169
X_space(World &world, size_t n_states, size_t n_orbitals)
Definition x_space.h:114
void push_back(const vector_real_function_3d &vx, const vector_real_function_3d &vy)
Definition x_space.h:125
auto from_vector(const vector_real_function_3d &rf) -> void
Definition x_space.h:442
friend X_space operator*(const X_space &B, const X_space &A)
Definition x_space.h:310
response_space y
Definition x_space.h:39
response_space x
Definition x_space.h:39
friend auto same_size(const X_space &A, const X_space &B) -> bool
Definition x_space.h:417
void truncate()
Definition x_space.h:369
friend X_space operator*(const double &b, const X_space &A)
Definition x_space.h:297
X_space()
Definition x_space.h:46
void set_active(const std::list< size_t > &new_active)
Definition x_space.h:65
size_t n_orbitals
Definition x_space.h:36
friend auto binary_apply(const X_space &A, const X_space &B, T &func) -> X_space
Definition x_space.h:189
auto copy(const std::shared_ptr< WorldDCPmapInterface< Key< 3 > > > &p_map, bool fence=false) const -> X_space
Definition x_space.h:91
void truncate(double thresh)
Definition x_space.h:389
friend X_space operator*(const X_space &A, const Function< double, 3 > &f)
Definition x_space.h:326
void pop_back()
Definition x_space.h:142
friend auto size_states(const X_space &x) -> size_t
Definition x_space.h:415
Definition x_space.h:463
X_vector(World &world, size_t n_orbtials)
Definition x_space.h:464
auto operator+=(const X_vector &B) -> X_vector &
Definition x_space.h:495
X_vector(X_space A, size_t b)
Definition x_space.h:468
friend X_vector operator-(const X_vector &A, const X_vector &B)
Definition x_space.h:473
X_vector copy() const
Definition x_space.h:489
friend X_vector operator*(const X_vector &A, const double &c)
Definition x_space.h:482
friend auto inner(X_vector &A, X_vector &B) -> double
Definition x_space.h:501
Definition x_space.h:549
real_function_3d operator()()
Definition x_space.h:553
World & world
Definition x_space.h:550
response_function_allocator(World &world)
Definition x_space.h:551
response_function_allocator operator=(const response_function_allocator &other)
Definition x_space.h:557
Definition x_space.h:531
World & world
Definition x_space.h:532
vector_real_function_3d operator()()
Definition x_space.h:537
response_matrix_allocator(World &world, size_t n_orbtials)
Definition x_space.h:534
const size_t n_orbtials
Definition x_space.h:533
response_matrix_allocator operator=(const response_matrix_allocator &other)
Definition x_space.h:544
Definition response_functions.h:27
void push_back(const vector_real_function_3d &f)
Definition response_functions.h:409
size_t num_orbitals
Definition response_functions.h:36
void pop_back()
Definition response_functions.h:424
response_space copy() const
Definition response_functions.h:142
std::list< size_t > active
Definition response_functions.h:38
void clear()
Definition response_functions.h:437
Defines and implements most of Tensor.
int G2
Definition testperiodic.cc:64