2 #ifndef SRC_APPS_MOLRESPONSE_X_SPACE_H_
3 #define SRC_APPS_MOLRESPONSE_X_SPACE_H_
50 for (
auto &ai:
active) { ai = i++; }
61 auto &world =
x[0][0].world();
63 for (
const auto &i:
active) {
79 bool fence =
false) const ->
X_space {
80 auto &world =
x[0][0].world();
82 for (
int i = 0; i < new_x.num_states(); i++) {
93 this->n_states =
B.num_states();
94 this->n_orbitals =
B.num_orbitals();
97 this->active =
B.active;
143 auto &world =
A.x[0][0].world();
144 for (
auto &i:
A.active) {
161 auto &world =
A.x[0][0].world();
165 for (
auto &i: result.active) {
167 result.x[i] =
func(
A.x[i]);
168 result.y[i] =
func(
A.y[i]);
179 auto &world =
A.x[0][0].world();
183 for (
const auto &i: result.
active) {
190 result.
x[i] =
func(ax, bx);
191 result.
y[i] =
func(ay, by);
201 auto &world =
A.x[0][0].world();
202 for (
const auto &i:
A.active) {
220 for (
int i = 0; i < zeros.num_states(); i++) {
221 zeros.x[i] = ::madness::zero_functions<double, 3>(
223 zeros.y[i] = ::madness::zero_functions<double, 3>(
232 auto &world = this->x[0][0].world();
233 auto add_inplace = [&](
auto &
a,
const auto &
b) {
234 gaxpy(world, 1.0,
a, 1.0,
b,
false);
243 auto add_ab = [&](
const auto &
a,
const auto &
b) {
252 auto sub_ab = [&](
const auto &
a,
const auto &
b) {
259 World &world =
A.x[0][0].world();
260 auto result =
A.copy();
262 scale(world, vec_ai,
b,
false);
268 World &world =
A.x[0][0].world();
269 auto result =
A.copy();
271 scale(world, vec_ai,
b,
false);
279 World &world =
A.x[0][0].world();
281 return mul(world,
f, vec_ai,
false);
287 World &world =
A.x[0][0].world();
289 return mul(world,
f, vec_ai,
false);
299 World &world =
A.x[0][0].world();
300 auto transform_ai = [&](
auto &ai) {
315 auto &world = rx[0][0].world();
316 auto truncate_i = [&](
auto &fi) {
325 auto &world = rx[0][0].world();
326 auto truncate_i = [&](
auto &fi) {
333 World &world =
x[0][0].world();
338 for (
const auto &xb:
x) { norms[
b++] =
norm2(world, xb); }
344 World &world =
x[0][0].world();
378 World &world =
A.x[0][0].world();
380 result.
x =
A.x -
B.x;
381 result.
y =
A.y -
B.y;
385 World &world =
A.x[0][0].world();
412 World &world =
A.x[0][0].world();
423 double result =
inner(ax, bx);
real_convolution_3d A(World &world)
Definition: DKops.h:230
Definition: test_ar.cc:118
Definition: test_ar.cc:141
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:204
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:66
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:205
static double function(const coord_3d &r)
Normalized gaussian.
Definition: functionio.cc:100
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
#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.
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
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:1701
response_space scale(response_space a, double b)
auto to_X_space(const response_matrix &x) -> X_space
Definition: x_space.cc:99
std::vector< vector_real_function_3d > response_matrix
Definition: response_functions.h:19
void truncate(World &world, response_space &v, double tol, bool fence)
Definition: basic_operators.cc:30
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:122
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:2002
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition: vmra.h:851
std::vector< real_function_3d > vector_real_function_3d
Definition: functypedefs.h:79
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:35
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:1917
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
FunctionFactory< double, 3 > real_factory_3d
Definition: functypedefs.h:93
NDIM & f
Definition: mra.h:2416
auto to_response_vector(const vector_real_function_3d &vec) -> vector_real_function_3d
Definition: x_space.cc:14
Function< double, 3 > real_function_3d
Definition: functypedefs.h:65
auto to_response_matrix(const X_space &x) -> response_matrix
Definition: x_space.cc:51
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:839
auto to_conjugate_response_matrix(const X_space &x) -> response_matrix
Definition: x_space.cc:65
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:689
Vector< T, sizeof...(Ts)+1 > vec(T t, Ts... ts)
Factory function for creating a madness::Vector.
Definition: vector.h:711
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:85
void gaxpy(const double a, ScalarResult< T > &left, const double b, const T &right, const bool fence=true)
the result type of a macrotask must implement gaxpy
Definition: macrotaskq.h:140
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 thresh
Definition: rk.cc:45
auto norm2s() const -> Tensor< double >
Definition: x_space.h:332
friend auto oop_apply(const X_space &A, const std::function< vector_real_function_3d(const vector_real_function_3d &)> &func) -> X_space
Apply a function to the X_space.
Definition: x_space.h:157
friend auto operator+(const X_space &A, const X_space &B) -> X_space
Definition: x_space.h:241
auto operator=(const X_space &B) -> X_space &
Definition: x_space.h:90
X_space(const X_space &A)
Definition: x_space.h:57
void reset_active()
Definition: x_space.h:47
void clear()
Definition: x_space.h:108
size_t num_states() const
Definition: x_space.h:42
std::list< size_t > active
Definition: x_space.h:39
auto copy(const std::shared_ptr< WorldDCPmapInterface< Key< 3 >>> &p_map, bool fence=false) const -> X_space
Definition: x_space.h:78
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:168
static X_space zero_functions(World &world, size_t n_states, size_t n_orbitals)
Definition: x_space.h:217
friend X_space operator*(const X_space &A, const double &b)
Definition: x_space.h:258
friend auto operator*(const X_space &A, const Tensor< double > &b) -> X_space
Definition: x_space.h:294
X_space copy() const
Definition: x_space.h:60
friend auto operator*(const Function< double, 3 > &f, const X_space &A) -> X_space
Definition: x_space.h:285
auto operator+=(const X_space &B) -> X_space &
Definition: x_space.h:230
auto component_norm2s() const -> Tensor< double >
Definition: x_space.h:343
size_t num_orbitals() const
Definition: x_space.h:43
friend auto size_orbitals(const X_space &x) -> size_t
Definition: x_space.h:353
friend auto inplace_apply(X_space &A, const std::function< void(vector_real_function_3d &)> &func) -> void
Definition: x_space.h:139
size_t n_states
Definition: x_space.h:34
friend auto binary_inplace(X_space &A, const X_space &B, const T &func)
Definition: x_space.h:198
friend X_space operator-(const X_space &A, const X_space &B)
Definition: x_space.h:250
X_space(World &world, size_t n_states, size_t n_orbitals)
Definition: x_space.h:102
void push_back(const vector_real_function_3d &vx, const vector_real_function_3d &vy)
Definition: x_space.h:113
response_space y
Definition: x_space.h:38
response_space x
Definition: x_space.h:38
friend auto same_size(const X_space &A, const X_space &B) -> bool
Definition: x_space.h:356
void truncate()
Definition: x_space.h:313
friend X_space operator*(const double &b, const X_space &A)
Definition: x_space.h:267
X_space()
Definition: x_space.h:45
void set_active(const std::list< size_t > &new_active)
Definition: x_space.h:52
size_t n_orbitals
Definition: x_space.h:35
friend auto binary_apply(const X_space &A, const X_space &B, T &func) -> X_space
Definition: x_space.h:175
void truncate(double thresh)
Definition: x_space.h:323
friend X_space operator*(const X_space &A, const Function< double, 3 > &f)
Definition: x_space.h:277
void pop_back()
Definition: x_space.h:130
friend auto size_states(const X_space &x) -> size_t
Definition: x_space.h:350
Definition: x_space.h:365
X_vector(World &world, size_t n_orbtials)
Definition: x_space.h:366
auto operator+=(const X_vector &B) -> X_vector &
Definition: x_space.h:397
X_vector(X_space A, size_t b)
Definition: x_space.h:370
friend X_vector operator-(const X_vector &A, const X_vector &B)
Definition: x_space.h:375
X_vector copy() const
Definition: x_space.h:391
friend X_vector operator*(const X_vector &A, const double &c)
Definition: x_space.h:384
friend auto inner(X_vector &A, X_vector &B) -> double
Definition: x_space.h:403
Definition: x_space.h:448
real_function_3d operator()()
Definition: x_space.h:452
World & world
Definition: x_space.h:449
response_function_allocator(World &world)
Definition: x_space.h:450
response_function_allocator operator=(const response_function_allocator &other)
Definition: x_space.h:456
Definition: x_space.h:429
World & world
Definition: x_space.h:430
vector_real_function_3d operator()()
Definition: x_space.h:435
response_matrix_allocator(World &world, size_t n_orbtials)
Definition: x_space.h:432
const size_t n_orbtials
Definition: x_space.h:431
response_matrix_allocator operator=(const response_matrix_allocator &other)
Definition: x_space.h:443
Definition: response_functions.h:25
void push_back(const vector_real_function_3d &f)
Definition: response_functions.h:300
size_t num_orbitals
Definition: response_functions.h:34
void pop_back()
Definition: response_functions.h:312
size_t size() const
Definition: response_functions.h:337
response_space copy() const
Definition: response_functions.h:122
std::list< size_t > active
Definition: response_functions.h:36
void clear()
Definition: response_functions.h:323
pcomplex_operatorT G
Definition: tdse1d.cc:167
Defines and implements most of Tensor.
int G1
Definition: testperiodic.cc:63
int G2
Definition: testperiodic.cc:64