32#ifndef MADNESS_MRA_MRA_H__INCLUDED
33#define MADNESS_MRA_MRA_H__INCLUDED
48#define FUNCTION_INSTANTIATE_1
49#define FUNCTION_INSTANTIATE_2
50#define FUNCTION_INSTANTIATE_3
51#if !defined(HAVE_IBMBGP) || !defined(HAVE_IBMBGQ)
52#define FUNCTION_INSTANTIATE_4
53#define FUNCTION_INSTANTIATE_5
54#define FUNCTION_INSTANTIATE_6
78 void startup(World& world,
int argc,
char** argv,
bool doprint=
false,
bool make_stdcout_nice_to_reals =
true);
96 template<
typename T, std::
size_t NDIM>
99 template<
typename T, std::
size_t NDIM>
102 template<
typename T, std::
size_t NDIM>
105 template<
typename T, std::
size_t NDIM>
106 class FunctionFactory;
108 template<
typename T, std::
size_t NDIM>
109 class FunctionFunctorInterface;
111 template<
typename T, std::
size_t NDIM>
114 template<
typename T, std::
size_t NDIM>
117 template<
typename T, std::
size_t NDIM>
120 template<
typename T, std::
size_t NDIM, std::
size_t LDIM,
typename opT>
123 template<
typename T, std::
size_t NDIM,
typename opT>
126 template<
typename T, std::
size_t NDIM>
143 template <
typename T, std::
size_t NDIM>
151 std::shared_ptr< FunctionImpl<T,NDIM> >
impl;
155 if(
impl==NULL)
return false;
198 if (
this != &
f)
impl =
f.impl;
206 template <
typename R, std::
size_t MDIM>
218 const double eps=1
e-15;
225 for (std::size_t
d=0;
d<
NDIM; ++
d) {
226 if (xsim[
d] < -eps) {
229 else if (xsim[
d] < eps) {
233 if (xsim[
d] > 1.0+eps) {
236 else if (xsim[
d] > 1.0-eps) {
251 const double eps=1
e-15;
258 for (std::size_t
d=0;
d<
NDIM; ++
d) {
259 if (xsim[
d] < -eps) {
262 else if (xsim[
d] < eps) {
266 if (xsim[
d] > 1.0+eps) {
269 else if (xsim[
d] > 1.0-eps) {
273 return impl->eval_local_only(xsim,maxlevel);
291 std::vector<std::pair<bool,T>>& results)
const {
292 const double eps=1
e-15;
295 thread_local std::vector<coordT> xsim;
296 xsim.resize(xuser.size());
297 for (std::size_t ip=0; ip<xuser.size(); ++ip) {
302 for (std::size_t
d=0;
d<
NDIM; ++
d) {
306 else if (xs[
d] < eps) {
310 if (xs[
d] > 1.0+eps) {
313 else if (xs[
d] > 1.0-eps) {
319 results.resize(xuser.size());
320 impl->eval_local_only(xsim.data(), xsim.size(), maxlevel, results.data());
326 std::vector<std::pair<bool,T>> results;
339 const double eps=1
e-15;
346 for (std::size_t
d=0;
d<
NDIM; ++
d) {
347 if (xsim[
d] < -eps) {
350 else if (xsim[
d] < eps) {
354 if (xsim[
d] > 1.0+eps) {
357 else if (xsim[
d] > 1.0-eps) {
376 const double eps=1
e-15;
383 for (std::size_t
d=0;
d<
NDIM; ++
d) {
384 if (xsim[
d] < -eps) {
387 else if (xsim[
d] < eps) {
391 if (xsim[
d] > 1.0+eps) {
394 else if (xsim[
d] > 1.0-eps) {
416 const std::vector<long>& npt,
417 bool eval_refine =
false)
const {
420 const double eps=1
e-14;
424 for (std::size_t
d=0;
d<
NDIM; ++
d) {
425 simlo[
d] = cell(
d,0);
426 simhi[
d] = cell(
d,1);
433 for (std::size_t
d=0;
d<
NDIM; ++
d) {
438 double delta = eps*(simhi[
d]-simlo[
d]);
442 return impl->eval_plot_cube(simlo, simhi, npt, eval_refine);
461 if (
impl->world.rank() == 0) result =
eval(xuser).get();
462 impl->world.gop.broadcast(result);
470 T
operator()(
double x,
double y=0,
double z=0,
double xx=0,
double yy=0,
double zz=0)
const {
473 if (
NDIM>=2) r[1] = y;
474 if (
NDIM>=3) r[2] = z;
475 if (
NDIM>=4) r[3] = xx;
476 if (
NDIM>=5) r[4] = yy;
477 if (
NDIM>=6) r[5] = zz;
497 impl->world.gop.broadcast(result);
509 template <
typename funcT>
524 template <
typename funcT>
533 impl->world.gop.fence();
550 return impl->is_compressed();
561 return impl->is_reconstructed();
571 return impl ?
impl->is_nonstandard() :
false;
579 return impl ?
impl->is_redundant() :
false;
587 return impl ?
impl->is_redundant_after_merge() :
false;
594 return impl->tree_size();
600 print(
"function",
name,
"not assigned yet");
610 return impl->max_depth();
623 return impl->max_local_depth();
631 return impl->max_nodes();
638 return impl->min_nodes();
653 return impl->size_local();
660 if (!
impl)
return true;
661 return impl->get_autorefine();
671 impl->set_autorefine(value);
679 if (!
impl)
return 0.0;
680 return impl->get_thresh();
690 impl->set_thresh(value);
699 return impl->get_k();
714 if (!
impl)
return *
this;
724 const std::shared_ptr< FunctionImpl<T,NDIM> >&
get_impl()
const {
742 this->impl->set_functor(functor);
743 print(
"set functor in mra.h");
751 template <
typename R>
753 impl = std::shared_ptr<implT>(
new implT(*
f.get_impl(),
f.get_pmap(), zero));
766 const std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >&
get_pmap()
const {
769 return impl->get_pmap();
812 impl->distribute(newmap);
824 "norm2sq_local needs a tree that holds its coefficients once");
825 return impl->norm2sq_local();
851 if (!
impl->has_summable_coefficients()) {
853 "norm2 is not defined for an on-demand function; materialize it first");
854 impl->world.gop.fence();
860 impl->world.gop.fence();
956 if (not
impl)
return *
this;
958 if (finalstate == current_state)
return *
this;
961 impl->change_tree_state(finalstate,
fence);
979 template <
typename opT>
990 return impl->autorefine_square_test(key, t);
993 template <
typename Archive>
void serialize (Archive& ar) {}
1010 bool fence =
true)
const {
1039 if (
impl)
impl->print_tree_json(os);
1045 os <<
"digraph G {" << std::endl;
1046 if (
impl)
impl->print_tree_graphviz(os);
1047 os <<
"}" << std::endl;
1076 template <
typename opT>
1086 template <
typename opT>
1088 bool fence =
true) {
1096 template <
typename opT>
1098 bool fence =
true) {
1125 template <
typename Q>
1155 template <
typename Q,
typename R>
1176 "gaxpy: this must be reconstructed or redundant_after_merge");
1178 "gaxpy: other must be reconstructed or redundant_after_merge");
1194 template <
typename Q>
1206 return gaxpy(T(1.0), other,
Q(1.0),
true);
1213 template <
typename Q>
1226 return gaxpy(T(1.0), other,
Q(-1.0),
true);
1233 template <
typename Q>
1278 if (!
impl)
return 0.0;
1280 "trace_local needs a tree that holds its coefficients once");
1282 return impl->trace_local();
1298 if (!
impl)
return 0.0;
1299 if (!
impl->has_summable_coefficients()) {
1301 "trace is not defined for an on-demand function; materialize it first");
1302 impl->world.gop.fence();
1308 impl->world.gop.fence();
1314 template <
typename R>
1326 template <typename
R>
1333 return impl->dot_local(*(
g.get_impl()));
1340 template<
typename R>
1346 impl->get_coeffs().clear();
1358 template<
typename opT>
1362 impl->get_coeffs().clear();
1373 impl->get_coeffs().clear();
1381 template<
typename opT>
1385 impl->get_coeffs().clear();
1398 impl->get_coeffs().clear();
1409 template<
typename opT>
1413 impl->get_coeffs().clear();
1426 impl->get_coeffs().clear();
1436 template<
size_t LDIM,
size_t KDIM,
typename opT>
1444 impl->finalize_sum();
1450 template<
size_t LDIM,
size_t KDIM>
1457 impl->finalize_sum();
1466 template <
typename R>
1472 if (not
g.is_initialized())
return 0.0;
1475 if constexpr (std::is_same_v<T,R>) {
1484 if constexpr (std::is_same_v<R,T>) {
1486 return g.inner_on_demand(*
this);
1487 if (
g.is_on_demand())
1488 return this->inner_on_demand(
g);
1524 T
local =
impl->inner_ext_local(
f, leaf_refine);
1540 T
local =
impl->inner_ext_local(
f, leaf_refine);
1542 impl->world.gop.fence();
1555 const bool leaf_refine=
true)
const {
1558 T
local =
impl->inner_adaptive_local(
f, leaf_refine);
1560 impl->world.gop.fence();
1568 template <
typename L>
1583 template<
typename R>
1587 constexpr std::size_t
LDIM=std::max(
NDIM/2,std::size_t(1));
1591 func->replicate_low_dim_functions(
true);
1608 template <
typename R,
size_t LDIM>
1614 static const size_t KDIM=
NDIM-
LDIM;
1623 this->
get_impl()->project_out(result.
get_impl().get(),
g.get_impl().get(),dim,
true);
1627 result.
get_impl()->trickle_down(
false);
1649 template <
typename Archive>
1653 long magic = 0l,
id = 0l, ndim = 0l,
k = 0l;
1655 ar & magic &
id & ndim &
k & cell;
1658 "Function archive was written by an incompatible MADNESS version; regenerate it.");
1667 std::ostringstream oss;
1668 oss <<
"simulation cells inconsistent: stored cell differs from FunctionDefaults cell.\n"
1669 <<
"Call FunctionDefaults<" <<
NDIM <<
">::clear_cell() before reloading "
1670 <<
"(this will render all existing functions useless!)";
1687 template <
typename Archive>
1701 if (not
impl)
return;
1707 template <
typename Q,
typename opT>
1720 template <
typename Q, std::
size_t D>
1723 std::vector< std::shared_ptr< FunctionImpl<Q,D> > > r(
v.size());
1724 for (
unsigned int i=0; i<
v.size(); ++i) r[i] =
v[i].
get_impl();
1729 template <
typename opT>
1731 std::vector<implT*>
v(vf.size(),NULL);
1732 for (
unsigned int i=0; i<
v.size(); ++i) {
1748 template <
typename opT>
1752 const bool fence=
true) {
1753 std::vector<implT*> vimplin(vin.size(),NULL);
1754 for (
unsigned int i=0; i<vin.size(); ++i) {
1755 if (vin[i].
is_initialized()) vimplin[i] = vin[i].get_impl().get();
1757 std::vector<implT*> vimplout(vout.size(),NULL);
1758 for (
unsigned int i=0; i<vout.size(); ++i) {
1759 if (vout[i].
is_initialized()) vimplout[i] = vout[i].get_impl().get();
1762 impl->multi_to_multi_op_values(
op, vimplin, vimplout,
fence);
1769 template <
typename L,
typename R>
1777 std::vector<FunctionImpl<T,NDIM>*> vresult(right.size());
1778 std::vector<const FunctionImpl<R,NDIM>*> vright(right.size());
1779 for (
unsigned int i=0; i<right.size(); ++i) {
1780 result[i].set_impl(left,
false);
1784 vresult[i] = result[i].impl.get();
1785 vright[i] = right[i].get_impl().get();
1789 vresult[0]->mulXXvec(left.
get_impl().get(), vright, vresult, tol,
fence);
1795 template<
typename L,
typename R>
1805 impl->multiply(leaf_op1,gimpl,fimpl,
fence);
1808 impl->multiply(leaf_op1,fimpl,gimpl,
fence);
1813 template <
typename R,
typename Q>
1824 template <
typename L,
typename R>
1844 impl.reset(
new implT(*
f.impl,
f.get_pmap(),
false));
1858 for (std::size_t i=0; i<
NDIM; ++i)
MADNESS_ASSERT((mirrormap[i]==1) or (mirrormap[i]==-1));
1859 impl.reset(
new implT(*
f.impl,
f.get_pmap(),
false));
1874 const std::vector<long>& map,
const std::vector<long>&
mirror,
1880 for (std::size_t i=0; i<map.size(); ++i)
MADNESS_ASSERT(map[i]>=0 &&
static_cast<std::size_t
>(map[i])<
NDIM);
1882 impl.reset(
new implT(*
f.impl,
f.get_pmap(),
false));
1893 double local =
impl->check_symmetry_local();
1895 impl->world.gop.fence();
1896 double asy=sqrt(
local);
1897 if (this->
world().rank()==0)
print(
"asymmetry wrt particle",asy);
1914 impl->chop_at_level(n,
true);
1921 template <
typename T,
typename opT, std::
size_t NDIM>
1930 template <
typename Q,
typename T, std::
size_t NDIM>
1938 result.get_impl()->scale_oop(
alpha,*
f.get_impl(),
fence);
1944 template <
typename Q,
typename T, std::
size_t NDIM>
1955 template <
typename Q,
typename T, std::
size_t NDIM>
1964 template <
typename Q,
typename T, std::
size_t NDIM>
1975 template <
typename L,
typename R,std::
size_t NDIM>
1978 bool fence=
true,
bool do_make_redundant=
true) {
1982 std::vector< Function<R,NDIM> > vright(1,right);
1987 template <
typename L,
typename R,std::
size_t NDIM>
1990 bool do_make_redundant=
true) {
1995 template <
typename L,
typename R,
typename opT, std::
size_t NDIM>
2009 template <
typename Q,
typename opT, std::
size_t NDIM>
2010 Function<typename opT::resultT, NDIM>
2012 if (!
func.is_reconstructed())
func.reconstruct();
2022 template <
typename Q,
typename opT, std::
size_t NDIM>
2023 Function<typename opT::resultT, NDIM>
2035 template <
typename L,
typename R, std::
size_t D>
2040 vresult[0].vmulXX(left, vright, vresult, tol,
fence);
2048 template <
typename L,
typename R, std::
size_t NDIM>
2054 return mul(left,right,
true);
2060 template<
typename T, std::
size_t KDIM, std::
size_t LDIM>
2061 Function<T,KDIM+LDIM>
2076 std::vector<std::shared_ptr<FunctionImpl<T,KDIM>>> vleft=
get_impl(left);
2077 std::vector<std::shared_ptr<FunctionImpl<T,LDIM>>> vright=
get_impl(right);
2086 template<
typename T, std::
size_t KDIM, std::
size_t LDIM>
2087 Function<T,KDIM+LDIM>
2089 typedef std::vector<Function<T,KDIM>> vector;
2094 template<
typename T, std::
size_t KDIM, std::
size_t LDIM,
typename opT>
2095 Function<T,KDIM+LDIM>
2110 print(
"incomplete FunctionFactory in Function::hartree_product");
2119 std::vector<std::shared_ptr<FunctionImpl<T,KDIM>>> vleft;
2120 std::vector<std::shared_ptr<FunctionImpl<T,LDIM>>> vright;
2122 vright.push_back(right.
get_impl());
2135 template <
typename L,
typename R,std::
size_t NDIM>
2145 template <
typename L,
typename R,std::
size_t NDIM>
2155 template <
typename L,
typename R,std::
size_t NDIM>
2164 template<
typename T, std::
size_t NDIM>
2180 template <
typename L,
typename R, std::
size_t NDIM>
2195 return add(left,right,
true);
2200 template <
typename L,
typename R,std::
size_t NDIM>
2211 template <
typename L,
typename R, std::
size_t NDIM>
2223 return sub(left,right,
true);
2232 template <
typename T, std::
size_t NDIM>
2235 bool fence =
true) {
2240 result.
set_impl(std::shared_ptr<implT>(
new implT(*
f.get_impl(), pmap,
false)));
2247 template <
typename T, std::
size_t NDIM>
2256 template <
typename T, std::
size_t NDIM>
2264 result.
set_impl(std::make_shared<implT>(
world,*
f.get_impl(), pmap,
false));
2279 template <
typename T,
typename Q, std::
size_t NDIM>
2293 template <
typename T, std::
size_t NDIM>
2310 template <
typename opT,
typename T, std::
size_t LDIM>
2317 typedef std::vector<Function<T,LDIM>> vecfuncL;
2319 vecfuncL& ff1 =
const_cast< vecfuncL&
>(
f1);
2320 vecfuncL& ff2 =
const_cast< vecfuncL&
>(
f2);
2322 bool same=(ff1[0].get_impl()==ff2[0].get_impl());
2329 for (
auto&
f :
f1)
f.make_nonstandard(
true,
false);
2330 for (
auto&
f :
f2)
f.make_nonstandard(
true,
false);
2342 for (
size_t i=0; i<
f1.size(); ++i)
2346 if (
op.print_timings) {
2351 result.
get_impl()->finalize_apply();
2353 if (
op.modified()) {
2354 result.
get_impl()->trickle_down(
true);
2356 result.
get_impl()->reconstruct(
true);
2366 template <
typename opT,
typename R, std::
size_t NDIM>
2371 constexpr std::size_t OPDIM=opT::opdim;
2372 constexpr bool low_dim=(OPDIM*2==
NDIM);
2375 if (
NDIM <= 3 and (not low_dim)) {
2377 result.get_impl()->apply(
op, *
f.get_impl(),
fence);
2384 r1.set_impl(
f,
false);
2386 result.get_impl()->reset_timer();
2389 result.get_impl()->apply_source_driven(
op, *
f.get_impl(),
fence);
2412 template <
typename opT,
typename R, std::
size_t NDIM>
2427 if (
op.modified()) {
2432 ff.
get_impl()->undo_redundant(
false);
2433 result.
get_impl()->trickle_down(
true);
2443 fff.
get_impl()->timer_filter.print(
"filter");
2444 fff.
get_impl()->timer_compress_svd.print(
"compress_svd");
2453 double elapsed=result.
get_impl()->finalize_apply();
2454 if (
print_timings) printf(
"time in finalize_apply %8.2f\n",elapsed);
2461 result.
get_impl()->reconstruct(
true);
2464 if (
op.destructive()) {
2478 template <
typename opT,
typename R, std::
size_t NDIM>
2506 template <
typename T, std::
size_t NDIM>
2518 template <
typename T, std::
size_t NDIM>
2535 template <
typename T, std::
size_t NDIM>
2538 const std::vector<long>&
mirror,
bool fence=
true) {
2549 template <
typename T, std::
size_t NDIM>
2550 typename std::enable_if_t<NDIM%2==0, Function<T,NDIM>>
2553 std::vector<long> map(
NDIM);
2556 for (std::size_t
d=0;
d<
LDIM; ++
d) {
2575 template <
typename T, std::
size_t NDIM>
2581 std::vector<long> map(
NDIM);
2584 if (symmetry==
"sy_particle") {
2585 map[0]=3; map[1]=4; map[2]=5;
2586 map[3]=0; map[4]=1; map[5]=2;
2587 }
else if (symmetry==
"cx") {
2588 map[0]=0; map[1]=2; map[2]=1;
2589 map[3]=3; map[4]=5; map[5]=4;
2591 }
else if (symmetry==
"cy") {
2592 map[0]=2; map[1]=1; map[2]=0;
2593 map[3]=5; map[4]=4; map[5]=3;
2595 }
else if (symmetry==
"cz") {
2596 map[0]=1; map[1]=0; map[2]=2;
2597 map[3]=4; map[4]=3; map[5]=5;
2600 if (
f.world().rank()==0) {
2601 print(
"unknown parameter in symmetrize:",symmetry);
2607 result.
get_impl()->average(*
f.get_impl());
2620 template<
typename T, std::
size_t NDIM, std::
size_t LDIM>
2649 template <
typename T, std::
size_t NDIM>
2667 template <
typename T,
typename R, std::
size_t NDIM>
2679 template<std::size_t
NDIM,
typename T, std::size_t
LDIM,
typename R, std::size_t KDIM,
2680 std::size_t CDIM = (KDIM +
LDIM -
NDIM) / 2>
2683 const std::array<int, CDIM> v2,
int task=0) {
2684 bool prepare = ((
task==0) or (
task==1));
2685 bool work = ((
task==0) or (
task==2));
2686 bool finish = ((
task==0) or (
task==3));
2688 static_assert((KDIM +
LDIM -
NDIM) % 2 == 0,
"faulty dimensions in inner (partial version)");
2689 static_assert(KDIM +
LDIM - 2 * CDIM ==
NDIM,
"faulty dimensions in inner (partial version)");
2692 for (
size_t i=0; i<CDIM-1; ++i)
MADNESS_CHECK((v1[i]+1)==v1[i+1]);
2695 for (
size_t i=0; i<CDIM-1; ++i)
MADNESS_CHECK((v2[i]+1)==v2[i+1]);
2710 f.get_impl()->compute_snorm_and_dnorm(
false);
2711 for (
auto&
g : vg)
g.get_impl()->compute_snorm_and_dnorm(
false);
2716 std::vector<Function<resultT,NDIM>> result(vg.size());
2719 for (
size_t i=0; i<vg.size(); ++i) {
2722 result[i].get_impl()->partial_inner(*
f.get_impl(),*(vg[i]).get_impl(),v1,v2);
2736 auto erase_list = [] (
const auto& funcimpl) {
2737 typedef typename std::decay_t<
decltype(funcimpl)>
::keyT keyTT;
2738 std::list<keyTT> to_be_erased;
2739 for (
auto it=funcimpl.get_coeffs().begin(); it!=funcimpl.get_coeffs().end(); ++it) {
2740 const auto& key=it->first;
2741 const auto& node=it->second;
2742 if (not node.has_children()) to_be_erased.push_back(key);
2744 return to_be_erased;
2749 for (
auto&
g : vg) {
2769 template<std::size_t
NDIM,
typename T, std::size_t
LDIM,
typename R, std::size_t KDIM,
2770 std::size_t CDIM = (KDIM +
LDIM -
NDIM) / 2>
2773 const std::array<int, CDIM> v2,
int task=0) {
2781 template <
typename T, std::
size_t LDIM,
typename R, std::
size_t KDIM>
2785 std::array<int,1>({std::get<0>(v1)}),
2786 std::array<int,1>({std::get<0>(v2)}));
2793 template <
typename T, std::
size_t LDIM,
typename R, std::
size_t KDIM>
2797 std::array<int,2>({std::get<0>(v1),std::get<1>(v1)}),
2798 std::array<int,2>({std::get<0>(v2),std::get<1>(v2)}));
2805 template <
typename T, std::
size_t LDIM,
typename R, std::
size_t KDIM>
2809 std::array<int,3>({std::get<0>(v1),std::get<1>(v1),std::get<2>(v1)}),
2810 std::array<int,3>({std::get<0>(v2),std::get<1>(v2),std::get<2>(v2)}));
2823 template <
typename T,
typename opT, std::
size_t NDIM>
2826 std::shared_ptr< FunctionFunctorInterface<double,3> >
func(
new opT(
g));
2838 template <
typename T,
typename opT, std::
size_t NDIM>
2843 template <
typename T,
typename R, std::
size_t NDIM>
2846 return (
f*
R(1.0)).add_scalar(r);
2849 template <
typename T,
typename R, std::
size_t NDIM>
2852 return (
f*
R(1.0)).add_scalar(r);
2855 template <
typename T,
typename R, std::
size_t NDIM>
2858 return (
f*
R(1.0)).add_scalar(-r);
2861 template <
typename T,
typename R, std::
size_t NDIM>
2864 return (
f*
R(-1.0)).add_scalar(r);
2868 template <std::
size_t NDIM>
2878 template <std::
size_t NDIM>
2888 template <std::
size_t NDIM>
2899 template <std::
size_t NDIM>
2913 template <std::
size_t NDIM>
2919 template <std::
size_t NDIM>
2925 template <std::
size_t NDIM>
2932 template <
typename T, std::
size_t NDIM>
2936 return result.
square(
true);
2940 template <
typename T, std::
size_t NDIM>
2944 return result.
abs(
true);
2948 template <
typename T, std::
size_t NDIM>
2949 typename std::enable_if<!TensorTypeData<T>::iscomplex, Function<T,NDIM> >
::type
2957 template <
typename T, std::
size_t NDIM>
2958 typename std::enable_if<TensorTypeData<T>::iscomplex, Function<typename Tensor<T>::scalar_type,
NDIM> >
::type
2964 template <std::
size_t NDIM>
2970 template <std::
size_t NDIM>
2980 template <
typename T, std::
size_t NDIM>
2982 if (
f.is_initialized())
return f.get_impl()->get_tree_state();
2993 template <
typename T, std::
size_t NDIM>
2999 template <
typename R, std::
size_t MDIM>
3001 f1.impl.swap(
f2.impl);
3010 template <
class archiveT,
class T, std::
size_t NDIM>
3017 template <
class archiveT,
class T, std::
size_t NDIM>
3025 template <
class T, std::
size_t NDIM>
3031 template <
class T, std::
size_t NDIM>
3044 template<
typename T, std::
size_t NDIM>
double q(double t)
Definition DKops.h:18
This header should include pretty much everything needed for the parallel runtime.
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
This class is used to specify boundary conditions for all operators.
Definition bc.h:72
CompositeFunctorInterface implements a wrapper of holding several functions and functors.
Definition function_interface.h:172
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:101
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap()
Returns the default process map that was last initialized via set_default_pmap()
Definition funcdefaults.h:415
static void set_cell(const Tensor< double > &value)
Sets the user cell for the simulation.
Definition funcdefaults.h:374
FunctionFactory implements the named-parameter idiom for Function.
Definition function_factory.h:86
FunctionFactory & nofence()
Definition function_factory.h:282
virtual FunctionFactory & thresh(double thresh)
Definition function_factory.h:198
FunctionFactory & fence(bool fence=true)
Definition function_factory.h:276
virtual FunctionFactory & k(int k)
Definition function_factory.h:193
FunctionFactory & empty()
Definition function_factory.h:246
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:970
const dcT & get_coeffs() const
Definition mraimpl.h:355
void reconstruct(bool fence)
reconstruct this tree – respects fence
Definition mraimpl.h:1509
bool is_on_demand() const
Definition mraimpl.h:285
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition funcimpl.h:136
A multiresolution adaptive numerical function.
Definition mra.h:144
void print_tree_json(std::ostream &os=std::cout) const
Definition mra.h:1037
Tensor< T > eval_cube(const Tensor< double > &cell, const std::vector< long > &npt, bool eval_refine=false) const
Evaluates a cube/slice of points (probably for plotting) ... collective but no fence necessary.
Definition mra.h:415
TENSOR_RESULT_TYPE(T, R) inner(const Function< R
Returns the inner product.
Function< T, NDIM > & map_and_mirror(const Function< T, NDIM > &f, const std::vector< long > &map, const std::vector< long > &mirror, bool fence)
This is replaced with mirror(map(f)) ... private.
Definition mra.h:1873
void gaxpy_ext(const Function< L, NDIM > &left, T(*f)(const coordT &), T alpha, T beta, double tol, bool fence=true) const
Definition mra.h:1569
T inner_adaptive(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine=true) const
Definition mra.h:1554
void unaryop_coeff(const opT &op, bool fence=true)
Unary operation applied inplace to the coefficients.
Definition mra.h:1087
bool is_compressed() const
Returns true if compressed, false otherwise. No communication.
Definition mra.h:547
Function< T, NDIM/2 > dirac_convolution(const bool fence=true) const
Definition mra.h:1633
return impl inner_local * g())
void set_impl(const Function< R, NDIM > &f, bool zero=true)
Replace current FunctionImpl with a new one using the same parameters & map as f.
Definition mra.h:752
bool autorefine() const
Returns value of autorefine flag. No communication.
Definition mra.h:658
TreeState operating_state
Definition mra.h:1495
Function< T, NDIM > & add_scalar(T t, bool fence=true)
Inplace add scalar. No communication except for optional fence.
Definition mra.h:1136
void print_size(const std::string name) const
print some info about this
Definition mra.h:598
Function< T, NDIM > & fill_tree(const Function< R, NDIM > &g, bool fence=true)
With this being an on-demand function, fill the MRA tree according to different criteria.
Definition mra.h:1341
void broaden(const BoundaryConditions< NDIM > &bc=FunctionDefaults< NDIM >::get_bc(), bool fence=true) const
Inplace broadens support in scaling function basis.
Definition mra.h:1009
void print_info() const
Print a summary of the load balancing info.
Definition mra.h:1053
Function< T, NDIM > & scale(const Q q, bool fence=true)
Inplace, scale the function by a constant. No communication except for optional fence.
Definition mra.h:1126
void norm_tree(bool fence=true) const
Initializes information about the function norm at all length scales.
Definition mra.h:866
void load(World &world, Archive &ar)
Replaces this function with one loaded from an archive using the default processor map.
Definition mra.h:1650
Function< T, NDIM > & abs_square(bool fence=true)
Returns *this for chaining.
Definition mra.h:1263
void replicate(const DistributionType type, bool fence=true) const
Definition mra.h:778
double norm2sq_local() const
Returns the square of the norm of the local function ... no communication.
Definition mra.h:820
IsSupported< TensorTypeData< Q >, Function< T, NDIM > >::type & operator*=(const Q q)
Inplace scaling by a constant.
Definition mra.h:1235
void sum_down(bool fence=true) const
Sums scaling coeffs down tree restoring state with coeffs only at leaves. Optional fence....
Definition mra.h:967
Level depthpt(const coordT &xuser) const
Definition mra.h:491
bool is_redundant() const
Returns true if redundant, false otherwise. No communication.
Definition mra.h:577
Function< T, NDIM > & operator+=(const Function< Q, NDIM > &other)
Inplace addition of functions in the wavelet basis.
Definition mra.h:1195
Function< T, NDIM > & operator=(const Function< T, NDIM > &f)
Assignment is shallow. No communication, works in either basis.
Definition mra.h:196
void set_autorefine(bool value, bool fence=true)
Sets the value of the autorefine flag. Optional global fence.
Definition mra.h:668
World & world() const
Returns the world.
Definition mra.h:758
T trace() const
Returns global value of int(f(x),x) ... global comm required.
Definition mra.h:1296
T typeT
Definition mra.h:162
friend void swap(Function< R, MDIM > &f1, Function< R, MDIM > &f2)
implements swap algorithm
Definition mra.h:3000
Function< T, NDIM > & fill_tree(const opT &op, bool fence=true)
With this being an on-demand function, fill the MRA tree according to different criteria.
Definition mra.h:1359
const Function< T, NDIM > & change_tree_state(const TreeState finalstate, bool fence=true) const
changes tree state to given state
Definition mra.h:954
Function< typename opT::resultT, NDIM > & unary_op_coeffs(const Function< Q, NDIM > &func, const opT &op, bool fence)
This is replaced with left*right ... private.
Definition mra.h:1708
void print_tree_graphviz(std::ostream &os=std::cout) const
Process 0 prints a graphviz-formatted output of all nodes in the tree (collective)
Definition mra.h:1043
double norm2() const
Returns the 2-norm of the function ... global sum ... works in either basis.
Definition mra.h:847
Function< T, NDIM > & fill_cuspy_tree(const opT &op, const bool fence=true)
Definition mra.h:1382
void change_tensor_type(const TensorArgs &targs, bool fence=true)
change the tensor type of the coefficients in the FunctionNode
Definition mra.h:1700
const Function< T, NDIM > & refine(bool fence=true) const
Inplace autorefines the function using same test as for squaring.
Definition mra.h:999
TENSOR_RESULT_TYPE(T, R) inner_on_demand(const Function< R
Returns the inner product for one on-demand function.
T operator()(const coordT &xuser) const
Evaluates the function at a point in user coordinates. Collective operation.
Definition mra.h:456
MADNESS_ASSERT(g.is_compressed())
Function< T, NDIM > & square(bool fence=true)
Inplace squaring of function ... global comm only if not reconstructed.
Definition mra.h:1245
Function< T, NDIM > & fill_tree(bool fence=true)
With this being an on-demand function, fill the MRA tree according to different criteria.
Definition mra.h:1370
void verify_tree() const
Verifies the tree data structure ... global sync implied.
Definition mra.h:538
Future< Level > evaldepthpt(const coordT &xuser) const
Definition mra.h:337
void do_hartree_product(const std::vector< std::shared_ptr< FunctionImpl< T, LDIM > > > left, const std::vector< std::shared_ptr< FunctionImpl< T, KDIM > > > right)
perform the hartree product of f*g, invoked by result
Definition mra.h:1451
Function< T, NDIM > & mapdim(const Function< T, NDIM > &f, const std::vector< long > &map, bool fence)
This is replaced with mapdim(f) ... private.
Definition mra.h:1839
int k() const
Returns the number of multiwavelets (k). No communication.
Definition mra.h:696
const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap() const
Returns a shared pointer to the process map.
Definition mra.h:766
double thresh() const
Returns value of truncation threshold. No communication.
Definition mra.h:677
Function< T, NDIM > & gaxpy_oop(T alpha, const Function< L, NDIM > &left, T beta, const Function< R, NDIM > &right, bool fence)
This is replaced with alpha*left + beta*right ... private.
Definition mra.h:1825
void set_thresh(double value, bool fence=true)
Sets the value of the truncation threshold. Optional global fence.
Definition mra.h:687
Function< T, NDIM > & multiop_values(const opT &op, const std::vector< Function< T, NDIM > > &vf)
This is replaced with op(vector of functions) ... private.
Definition mra.h:1730
void distribute(std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > newmap) const
distribute this function according to newmap
Definition mra.h:810
void unaryop(const opT &op, bool fence=true)
Inplace unary operation on function values.
Definition mra.h:1077
const std::shared_ptr< FunctionImpl< T, NDIM > > & get_impl() const
Returns a shared-pointer to the implementation.
Definition mra.h:724
void standard(bool fence=true)
Converts the function standard compressed form. Possible non-blocking comm.
Definition mra.h:913
void unaryop_node(const opT &op, bool fence=true)
Unary operation applied inplace to the nodes.
Definition mra.h:1097
Function< T, NDIM > & truncate(double tol=0.0, bool fence=true)
Truncate the function with optional fence. Compresses with fence if not compressed.
Definition mra.h:712
Function< T, NDIM > & fill_cuspy_tree(const bool fence=true)
Special refinement on 6D boxes where the electrons come close (meet)
Definition mra.h:1395
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mra.h:643
bool is_on_demand() const
Definition mra.h:746
Function< T, NDIM > & operator-=(const Function< Q, NDIM > &other)
Inplace subtraction of functions in the wavelet basis.
Definition mra.h:1214
bool compressed
Definition mra.h:1317
const Function< T, NDIM > & reconstruct(bool fence=true) const
Reconstructs the function, transforming into scaling function basis. Possible non-blocking comm.
Definition mra.h:944
Function< T, NDIM > & abs(bool fence=true)
Returns *this for chaining.
Definition mra.h:1254
Function< T, NDIM > & reduce_rank(const double thresh=0.0, const bool fence=true)
reduce the rank of the coefficient tensors
Definition mra.h:1903
Function< T, NDIM > & mirror(const Function< T, NDIM > &f, const std::vector< long > &mirrormap, bool fence)
This is replaced with mirror(f) ... private.
Definition mra.h:1854
std::size_t max_nodes() const
Returns the max number of nodes on a processor.
Definition mra.h:628
void do_hartree_product(const std::vector< std::shared_ptr< FunctionImpl< T, LDIM > > > left, const std::vector< std::shared_ptr< FunctionImpl< T, KDIM > > > right, const opT *op)
perform the hartree product of f*g, invoked by result
Definition mra.h:1437
std::shared_ptr< FunctionImpl< T, NDIM > > impl
Definition mra.h:151
void replicate_on_hosts(bool fence=true) const
Definition mra.h:803
void replicate(bool fence=true) const
Definition mra.h:791
T trace_local() const
Returns local contribution to int(f(x),x) ... no communication.
Definition mra.h:1276
void mul_on_demand(const Function< L, NDIM > &f, const Function< R, NDIM > &g, bool fence=true)
Same as operator* but with optional fence and no automatic reconstruction.
Definition mra.h:1796
Function< T, NDIM > & gaxpy(const T &alpha, const Function< Q, NDIM > &other, const R &beta, bool fence=true)
Inplace, general bi-linear operation in wavelet basis. No communication except for optional fence.
Definition mra.h:1156
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition mra.h:161
void store(Archive &ar) const
Stores the function to an archive.
Definition mra.h:1688
std::size_t max_local_depth() const
Returns the maximum local depth of the function tree ... no communications.
Definition mra.h:620
void vtransform(const std::vector< Function< R, NDIM > > &v, const Tensor< Q > &c, std::vector< Function< T, NDIM > > &vresult, double tol, bool fence=true)
sparse transformation of a vector of functions ... private
Definition mra.h:1814
TENSOR_RESULT_TYPE(T, R) local
std::size_t max_depth() const
Returns the maximum depth of the function tree ... collective global sum.
Definition mra.h:607
Function()
Default constructor makes uninitialized function. No communication.
Definition mra.h:179
std::vector< std::pair< bool, T > > eval_local_only(const std::vector< coordT > &xuser, Level maxlevel) const
Definition mra.h:325
std::size_t tree_size() const
Returns the number of nodes in the function tree ... collective global sum.
Definition mra.h:591
Function< TENSOR_RESULT_TYPE(T, R), NDIM-LDIM > project_out(const Function< R, LDIM > &g, const int dim) const
project this on the low-dim function g: h(x) = <f(x,y) | g(y)>
Definition mra.h:1609
static std::vector< std::shared_ptr< FunctionImpl< Q, D > > > vimpl(const std::vector< Function< Q, D > > &v)
Returns vector of FunctionImpl pointers corresponding to vector of functions.
Definition mra.h:1721
FunctionImpl< T, NDIM > implT
Definition mra.h:158
void clear(bool fence=true)
Clears the function as if constructed uninitialized. Optional fence.
Definition mra.h:1020
void refine_general(const opT &op, bool fence=true) const
Inplace autorefines the function. Optional fence. Possible non-blocking comm.
Definition mra.h:980
static void doconj(const Key< NDIM >, Tensor< T > &t)
Definition mra.h:1107
std::pair< bool, T > eval_local_only(const Vector< double, NDIM > &xuser, Level maxlevel) const
Evaluate function only if point is local returning (true,value); otherwise return (false,...
Definition mra.h:250
void set_functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor)
Replace the current functor with the provided new one.
Definition mra.h:741
bool impl_initialized() const
Definition mra.h:154
Function< T, NDIM > & fill_nuclear_cuspy_tree(const opT &op, const size_t particle, const bool fence=true)
Definition mra.h:1410
bool is_redundant_after_merge() const
Returns true if redundant_after_merge, false otherwise. No communication.
Definition mra.h:585
return local
Definition mra.h:1510
void eval_local_only(const std::vector< coordT > &xuser, Level maxlevel, std::vector< std::pair< bool, T > > &results) const
Batched eval_local_only writing into a caller-provided buffer.
Definition mra.h:290
auto func
Definition mra.h:1588
~Function()
Destruction of any underlying implementation is deferred to next global fence.
Definition mra.h:203
Function(const Function< T, NDIM > &f)
Copy constructor is shallow. No communication, works in either basis.
Definition mra.h:190
void set_impl(const std::shared_ptr< FunctionImpl< T, NDIM > > &impl)
Replace current FunctionImpl with provided new one.
Definition mra.h:731
T operator()(double x, double y=0, double z=0, double xx=0, double yy=0, double zz=0) const
Evaluates the function at a point in user coordinates. Collective operation.
Definition mra.h:470
T inner_ext_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine=true, const bool keep_redundant=false) const
Definition mra.h:1521
std::size_t min_nodes() const
Returns the min number of nodes on a processor.
Definition mra.h:635
void make_redundant(bool fence=true) const
Converts the function to redundant form, i.e. sum coefficients on all levels.
Definition mra.h:929
constexpr std::size_t LDIM
Definition mra.h:1587
static constexpr std::size_t dimT
Definition mra.h:163
change_tree_state(operating_state, false)
bool is_nonstandard() const
Returns true if nonstandard-compressed, false otherwise. No communication.
Definition mra.h:569
void verify() const
Asserts that the function is initialized.
Definition mra.h:167
double err(const funcT &func) const
Returns an estimate of the difference ||this-func|| ... global sum performed.
Definition mra.h:525
T inner_ext(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine=true, const bool keep_redundant=false) const
Definition mra.h:1537
Function< T, NDIM > & fill_nuclear_cuspy_tree(const size_t particle, const bool fence=true)
Special refinement on 6D boxes for the nuclear potentials (regularized with cusp, non-regularized wit...
Definition mra.h:1423
double check_symmetry() const
check symmetry of a function by computing the 2nd derivative
Definition mra.h:1889
void multi_to_multi_op_values(const opT &op, const std::vector< Function< T, NDIM > > &vin, std::vector< Function< T, NDIM > > &vout, const bool fence=true)
apply op on the input vector yielding an output vector of functions
Definition mra.h:1749
FunctionFactory< T, NDIM > factoryT
Definition mra.h:160
std::size_t size_local() const
Return the number of coefficients in the function on this processor.
Definition mra.h:650
const Function< T, NDIM > & compress(bool fence=true) const
Compresses the function, transforming into wavelet basis. Possible non-blocking comm.
Definition mra.h:886
bool is_initialized() const
Returns true if the function is initialized.
Definition mra.h:172
bool is_reconstructed() const
Returns true if reconstructed, false otherwise. No communication.
Definition mra.h:558
Function< T, NDIM > & chop_at_level(const int n, const bool fence=true)
remove all nodes with level higher than n
Definition mra.h:1911
MADNESS_ASSERT(is_compressed())
void vmulXX(const Function< L, NDIM > &left, const std::vector< Function< R, NDIM > > &right, std::vector< Function< T, NDIM > > &result, double tol, bool fence)
Multiplication of function * vector of functions using recursive algorithm of mulxx.
Definition mra.h:1770
double errsq_local(const funcT &func) const
Returns an estimate of the difference ||this-func||^2 from local data.
Definition mra.h:510
void make_nonstandard(bool keepleaves, bool fence=true) const
Compresses the function retaining scaling function coeffs. Possible non-blocking comm.
Definition mra.h:899
if(VERIFY_TREE) verify_tree()
Future< T > eval(const coordT &xuser) const
Evaluates the function at a point in user coordinates. Possible non-blocking comm.
Definition mra.h:216
void print_tree(std::ostream &os=std::cout) const
Process 0 prints a summary of all nodes in the tree (collective)
Definition mra.h:1030
FunctionNode< T, NDIM > nodeT
Definition mra.h:159
bool redundant
Definition mra.h:1318
Future< long > evalR(const coordT &xuser) const
Evaluates the function rank at a point in user coordinates. Possible non-blocking comm.
Definition mra.h:374
Function(const factoryT &factory)
Constructor from FunctionFactory provides named parameter idiom. Possible non-blocking communication.
Definition mra.h:183
NDIM &g const
Definition mra.h:1315
void unaryop(T(*f)(T))
Inplace unary operation on function values.
Definition mra.h:1068
Function< T, NDIM > conj(bool fence=true)
Inplace complex conjugate. No communication except for optional fence.
Definition mra.h:1115
A future is a possibly yet unevaluated value.
Definition future.h:370
remote_refT remote_ref(World &world) const
Returns a structure used to pass references to another process.
Definition future.h:672
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
Traits class to specify support of numeric types.
Definition type_data.h:56
A tensor is a multidimensional array.
Definition tensor.h:318
Tensor< T > & emul(const Tensor< T > &t)
Inplace multiply by corresponding elements of argument Tensor.
Definition tensor.h:1800
Tensor< T > & conj()
Inplace complex conjugate.
Definition tensor.h:717
A simple, fixed dimension vector.
Definition vector.h:64
void erase(const keyT &key)
Erases entry from container (non-blocking comm if remote)
Definition worlddc.h:1552
Interface to be provided by any process map.
Definition worlddc.h:125
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:177
bool set_forbid_fence(bool value)
Set forbid_fence flag to new value and return old value.
Definition worldgop.h:677
A parallel world class.
Definition world.h:134
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:354
WorldGopInterface & gop
Global operations.
Definition world.h:216
World * get_world() const
Returns a pointer to the world.
Definition parallel_archive.h:130
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition parallel_archive.h:321
Objects that implement their own parallel archive interface should derive from this class.
Definition parallel_archive.h:58
static const double R
Definition csqrt.cc:46
Declaration and initialization of tree traversal functions and generic derivative.
double(* f1)(const coord_3d &)
Definition derivatives.cc:55
double(* f2)(const coord_3d &)
Definition derivatives.cc:56
const double delta
Definition dielectric_external_field.cc:119
Provides FunctionDefaults and utilities for coordinate transformation.
Provides FunctionCommonData, FunctionImpl and FunctionFactory.
Defines/implements plotting interface for functions.
Provides typedefs to hide use of templates and to increase interoperability.
const double beta
Definition gygi_soltion.cc:62
static const double v
Definition hatom_sf_dirac.cc:20
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
Multidimension Key for MRA tree and associated iterators.
Implements (2nd generation) static load/data balancing for functions.
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#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
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
Header to declare stuff which has not yet found a home.
static const bool VERIFY_TREE
Definition mra.h:57
Definition potentialmanager.cc:41
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
double abs(double x)
Definition complexfun.h:48
Function< double, NDIM > abssq(const Function< double_complex, NDIM > &z, bool fence=true)
Returns a new function that is the square of the absolute value of the input.
Definition mra.h:2965
DistributionType
some introspection of how data is distributed
Definition worlddc.h:84
@ NodeReplicated
even if there are several ranks per node
Definition worlddc.h:87
@ RankReplicated
replicate the container over all world ranks
Definition worlddc.h:86
Function< TENSOR_RESULT_TYPE(typename opT::opT, R), NDIM > apply_1d_realspace_push(const opT &op, const Function< R, NDIM > &f, int axis, bool fence=true)
Definition mra.h:2480
Function< TENSOR_RESULT_TYPE(L, R), NDIM > sub(const Function< L, NDIM > &left, const Function< R, NDIM > &right, bool fence=true)
Same as operator- but with optional fence and no automatic compression.
Definition mra.h:2202
Function< TENSOR_RESULT_TYPE(L, R), NDIM > binary_op(const Function< L, NDIM > &left, const Function< R, NDIM > &right, const opT &op, bool fence=true)
Generate new function = op(left,right) where op acts on the function values.
Definition mra.h:1997
Function< Q, NDIM > convert(const Function< T, NDIM > &f, bool fence=true)
Type conversion implies a deep copy. No communication except for optional fence.
Definition mra.h:2280
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:1932
std::enable_if_t< NDIM%2==0, Function< T, NDIM > > swap_particles(const Function< T, NDIM > &f)
swap particles 1 and 2
Definition mra.h:2551
TreeState
Definition funcdefaults.h:60
@ nonstandard_after_apply
s and d coeffs, state after operator application
Definition funcdefaults.h:65
@ redundant_after_merge
s coeffs everywhere, must be summed up to yield the result
Definition funcdefaults.h:67
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:61
@ nonstandard
s and d coeffs in internal nodes
Definition funcdefaults.h:63
@ unknown
Definition funcdefaults.h:69
@ nonstandard_with_leaves
like nonstandard, with s coeffs at the leaves
Definition funcdefaults.h:64
static void user_to_sim(const Vector< double, NDIM > &xuser, Vector< double, NDIM > &xsim)
Convert user coords (cell[][]) to simulation coords ([0,1]^ndim)
Definition funcdefaults.h:469
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > innerXX(const Function< T, LDIM > &f, const std::vector< Function< R, KDIM > > &vg, const std::array< int, CDIM > v1, const std::array< int, CDIM > v2, int task=0)
Computes the partial scalar/inner product between two functions, returns a low-dim function.
Definition mra.h:2682
static constexpr long FUNCTION_ARCHIVE_MAGIC
Definition mra.h:140
std::vector< CCPairFunction< T, NDIM > > operator*(const double fac, const std::vector< CCPairFunction< T, NDIM > > &arg)
Definition ccpairfunction.h:1089
int Level
Definition key.h:59
TreeState get_tree_state(const Function< T, NDIM > &f)
get tree state of a function
Definition mra.h:2981
std::vector< CCPairFunction< T, NDIM > > operator-(const std::vector< CCPairFunction< T, NDIM > > c1, const std::vector< CCPairFunction< T, NDIM > > &c2)
Definition ccpairfunction.h:1060
std::string get_mra_data_dir()
Definition startup.cc:209
Function< T, NDIM > gaxpy_oop_reconstructed(const double alpha, const Function< T, NDIM > &left, const double beta, const Function< T, NDIM > &right, const bool fence=true)
Returns new function alpha*left + beta*right optional fence, having both addends reconstructed.
Definition mra.h:2165
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:227
@ TT_2D
Definition gentensor.h:120
@ TT_FULL
Definition gentensor.h:120
NDIM & f
Definition mra.h:2668
Function< TENSOR_RESULT_TYPE(L, R), NDIM > add(const Function< L, NDIM > &left, const Function< R, NDIM > &right, bool fence=true)
Same as operator+ but with optional fence and no automatic compression.
Definition mra.h:2157
Function< T, NDIM > symmetrize(const Function< T, NDIM > &f, const std::string symmetry, bool fence=true)
symmetrize a function
Definition mra.h:2577
Function< TENSOR_RESULT_TYPE(typename opT::opT, R), NDIM > apply_only(const opT &op, const Function< R, NDIM > &f, bool fence=true)
Apply operator ONLY in non-standard form - required other steps missing !!
Definition mra.h:2368
double imag(double x)
Definition complexfun.h:56
Function< typename opT::resultT, NDIM > unary_op(const Function< Q, NDIM > &func, const opT &op, bool fence=true)
Out of place application of unary operation to function values with optional fence.
Definition mra.h:2011
void startup(World &world, int argc, char **argv, bool doprint=false, bool make_stdcout_nice_to_reals=true)
initialize the internal state of the MADmra library
Definition startup.cc:64
std::string type(const PairType &n)
Definition PNOParameters.h:18
static bool print_timings
Definition SCF.cc:108
CCPairFunction< T, NDIM > apply(const SeparatedConvolution< T, NDIM/2 > &op, const CCPairFunction< T, NDIM > &arg)
apply the operator to the argument
Definition ccpairfunction.h:896
std::vector< CCPairFunction< T, NDIM > > operator+(const std::vector< CCPairFunction< T, NDIM > > c1, const std::vector< CCPairFunction< T, NDIM > > &c2)
Definition ccpairfunction.h:1052
Function< TENSOR_RESULT_TYPE(L, R), NDIM > mul_sparse(const Function< L, NDIM > &left, const Function< R, NDIM > &right, double tol, bool fence=true, bool do_make_redundant=true)
Sparse multiplication; the scalar interface redirects to the vector one in vmra.h.
Definition mra.h:1977
Function< T, CCPairFunction< T, NDIM >::LDIM > inner(const CCPairFunction< T, NDIM > &c, const Function< T, CCPairFunction< T, NDIM >::LDIM > &f, const std::tuple< int, int, int > v1, const std::tuple< int, int, int > v2)
Definition ccpairfunction.h:993
Function< T, NDIM > multiply(const Function< T, NDIM > f, const Function< T, LDIM > g, const int particle, const bool fence=true)
multiply a high-dimensional function with a low-dimensional function
Definition mra.h:2621
void load(Function< T, NDIM > &f, const std::string name)
Definition mra.h:3032
Function< T, NDIM > project(const Function< T, NDIM > &other, int k=FunctionDefaults< NDIM >::get_k(), double thresh=FunctionDefaults< NDIM >::get_thresh(), bool fence=true)
Definition mra.h:2651
double real(double x)
Definition complexfun.h:52
@ same
same atoms at the same places
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
void save(const Function< T, NDIM > &f, const std::string name)
Definition mra.h:3026
Function< T, KDIM+LDIM > hartree_product(const std::vector< Function< T, KDIM > > &left, const std::vector< Function< T, LDIM > > &right)
Performs a Hartree/outer product on the two given low-dimensional function vectors.
Definition mra.h:2062
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:2233
static const double d
Definition nonlinschro.cc:121
Implements most functionality of separated operators.
Implements ParallelInputArchive and ParallelOutputArchive for parallel serialization of data.
double Q(double a)
Definition relops.cc:20
static const double c
Definition relops.cc:10
static const double L
Definition rk.cc:46
Definition test_ar.cc:204
void serialize(Archive &ar)
Definition mra.h:1064
T(* f)(T)
Definition mra.h:1059
void operator()(const Key< NDIM > &key, Tensor< T > &t) const
Definition mra.h:1061
SimpleUnaryOpWrapper(T(*f)(T))
Definition mra.h:1060
void serialize(Archive &ar)
Definition mra.h:993
bool operator()(implT *impl, const Key< NDIM > &key, const nodeT &t) const
Definition mra.h:989
Definition type_data.h:146
TensorArgs holds the arguments for creating a LowRankTensor.
Definition gentensor.h:134
Default load of an object via serialize(ar, t).
Definition archive.h:667
static void store(const ParallelOutputArchive< archiveT > &ar, const Function< T, NDIM > &f)
Definition mra.h:3019
Default store of an object via serialize(ar, t).
Definition archive.h:612
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:2902
double resultT
Definition mra.h:2901
void serialize(Archive &ar)
Definition mra.h:2907
void serialize(Archive &ar)
Definition mra.h:2896
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:2891
double resultT
Definition mra.h:2890
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:2881
void serialize(Archive &ar)
Definition mra.h:2885
double resultT
Definition mra.h:2880
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:2871
double resultT
Definition mra.h:2870
void serialize(Archive &ar)
Definition mra.h:2875
Definition funcimpl.h:633
returns true if the result of a hartree_product is a leaf node (compute norm & error)
Definition funcimpl.h:523
Definition funcimpl.h:587
Definition lowrankfunction.h:336
double real(double a)
Definition tdse4.cc:78
Defines and implements most of Tensor.
#define UNARY_OPTIMIZED_ITERATOR(X, x, exp)
Definition tensor_macros.h:658
AtomicInt sum
Definition test_atomicint.cc:46
double norm(const T i1)
Definition test_cloud.cc:85
int task(int i)
Definition test_runtime.cpp:4
void e()
Definition test_sig.cc:75
static const double alpha
Definition testcosine.cc:10
constexpr std::size_t NDIM
Definition testgconv.cc:54
std::size_t axis
Definition testpdiff.cc:59
#define TENSOR_RESULT_TYPE(L, R)
This macro simplifies access to TensorResultType.
Definition type_data.h:205
Defines operations on vectors of Functions.
Implements WorldContainer.
#define PROFILE_FUNC
Definition worldprofile.h:209
#define PROFILE_MEMBER_FUNC(classname)
Definition worldprofile.h:210