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
74 void startup(World& world,
int argc,
char** argv,
bool doprint=
false,
bool make_stdcout_nice_to_reals =
true);
93 template<
typename T, std::
size_t NDIM>
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>
108 template<
typename T, std::
size_t NDIM>
111 template<
typename T, std::
size_t NDIM>
114 template<
typename T, std::
size_t NDIM>
117 template<
typename T, std::
size_t NDIM, std::
size_t LDIM,
typename opT>
120 template<
typename T, std::
size_t NDIM,
typename opT>
123 template<
typename T, std::
size_t NDIM>
140 template <
typename T, std::
size_t NDIM>
148 std::shared_ptr< FunctionImpl<T,NDIM> >
impl;
152 if(
impl==NULL)
return false;
195 if (
this != &
f)
impl =
f.impl;
203 template <
typename R, std::
size_t MDIM>
215 const double eps=1
e-15;
222 for (std::size_t
d=0;
d<
NDIM; ++
d) {
223 if (xsim[
d] < -eps) {
226 else if (xsim[
d] < eps) {
230 if (xsim[
d] > 1.0+eps) {
233 else if (xsim[
d] > 1.0-eps) {
248 const double eps=1
e-15;
255 for (std::size_t
d=0;
d<
NDIM; ++
d) {
256 if (xsim[
d] < -eps) {
259 else if (xsim[
d] < eps) {
263 if (xsim[
d] > 1.0+eps) {
266 else if (xsim[
d] > 1.0-eps) {
270 return impl->eval_local_only(xsim,maxlevel);
288 std::vector<std::pair<bool,T>>& results)
const {
289 const double eps=1
e-15;
292 thread_local std::vector<coordT> xsim;
293 xsim.resize(xuser.size());
294 for (std::size_t ip=0; ip<xuser.size(); ++ip) {
299 for (std::size_t
d=0;
d<
NDIM; ++
d) {
303 else if (xs[
d] < eps) {
307 if (xs[
d] > 1.0+eps) {
310 else if (xs[
d] > 1.0-eps) {
316 results.resize(xuser.size());
317 impl->eval_local_only(xsim.data(), xsim.size(), maxlevel, results.data());
323 std::vector<std::pair<bool,T>> results;
336 const double eps=1
e-15;
343 for (std::size_t
d=0;
d<
NDIM; ++
d) {
344 if (xsim[
d] < -eps) {
347 else if (xsim[
d] < eps) {
351 if (xsim[
d] > 1.0+eps) {
354 else if (xsim[
d] > 1.0-eps) {
373 const double eps=1
e-15;
380 for (std::size_t
d=0;
d<
NDIM; ++
d) {
381 if (xsim[
d] < -eps) {
384 else if (xsim[
d] < eps) {
388 if (xsim[
d] > 1.0+eps) {
391 else if (xsim[
d] > 1.0-eps) {
413 const std::vector<long>& npt,
414 bool eval_refine =
false)
const {
417 const double eps=1
e-14;
421 for (std::size_t
d=0;
d<
NDIM; ++
d) {
430 for (std::size_t
d=0;
d<
NDIM; ++
d) {
435 double delta = eps*(simhi[
d]-simlo[
d]);
439 return impl->eval_plot_cube(simlo, simhi, npt, eval_refine);
458 if (
impl->world.rank() == 0) result =
eval(xuser).get();
459 impl->world.gop.broadcast(result);
467 T
operator()(
double x,
double y=0,
double z=0,
double xx=0,
double yy=0,
double zz=0)
const {
470 if (
NDIM>=2) r[1] = y;
471 if (
NDIM>=3) r[2] = z;
472 if (
NDIM>=4) r[3] = xx;
473 if (
NDIM>=5) r[4] = yy;
474 if (
NDIM>=6) r[5] = zz;
494 impl->world.gop.broadcast(result);
506 template <
typename funcT>
521 template <
typename funcT>
530 impl->world.gop.fence();
547 return impl->is_compressed();
558 return impl->is_reconstructed();
568 return impl ?
impl->is_nonstandard() :
false;
576 return impl ?
impl->is_redundant() :
false;
584 return impl ?
impl->is_redundant_after_merge() :
false;
591 return impl->tree_size();
597 print(
"function",
name,
"not assigned yet");
607 return impl->max_depth();
620 return impl->max_local_depth();
628 return impl->max_nodes();
635 return impl->min_nodes();
650 return impl->size_local();
657 if (!
impl)
return true;
658 return impl->get_autorefine();
676 if (!
impl)
return 0.0;
677 return impl->get_thresh();
705 return impl->get_k();
720 if (!
impl)
return *
this;
730 const std::shared_ptr< FunctionImpl<T,NDIM> >&
get_impl()
const {
748 this->impl->set_functor(functor);
749 print(
"set functor in mra.h");
757 template <
typename R>
759 impl = std::shared_ptr<implT>(
new implT(*
f.get_impl(),
f.get_pmap(), zero));
772 const std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >&
get_pmap()
const {
775 return impl->get_pmap();
818 impl->distribute(newmap);
830 "norm2sq_local needs a tree that holds its coefficients once");
831 return impl->norm2sq_local();
857 if (!
impl->has_summable_coefficients()) {
859 "norm2 is not defined for an on-demand function; materialize it first");
860 impl->world.gop.fence();
866 impl->world.gop.fence();
962 if (not
impl)
return *
this;
964 if (finalstate == current_state)
return *
this;
967 impl->change_tree_state(finalstate,
fence);
985 template <
typename opT>
996 return impl->autorefine_square_test(key, t);
999 template <
typename Archive>
void serialize (Archive& ar) {}
1016 bool fence =
true)
const {
1045 if (
impl)
impl->print_tree_json(os);
1051 os <<
"digraph G {" << std::endl;
1052 if (
impl)
impl->print_tree_graphviz(os);
1053 os <<
"}" << std::endl;
1077 this->
unaryop(SimpleUnaryOpWrapper(
f));
1082 template <
typename opT>
1092 template <
typename opT>
1094 bool fence =
true) {
1102 template <
typename opT>
1104 bool fence =
true) {
1131 template <
typename Q>
1161 template <
typename Q,
typename R>
1182 "gaxpy: this must be reconstructed or redundant_after_merge");
1184 "gaxpy: other must be reconstructed or redundant_after_merge");
1200 template <
typename Q>
1212 return gaxpy(T(1.0), other,
Q(1.0),
true);
1219 template <
typename Q>
1232 return gaxpy(T(1.0), other,
Q(-1.0),
true);
1239 template <
typename Q>
1284 if (!
impl)
return 0.0;
1286 "trace_local needs a tree that holds its coefficients once");
1288 return impl->trace_local();
1304 if (!
impl)
return 0.0;
1305 if (!
impl->has_summable_coefficients()) {
1307 "trace is not defined for an on-demand function; materialize it first");
1308 impl->world.gop.fence();
1314 impl->world.gop.fence();
1320 template <
typename R>
1332 template <typename
R>
1339 return impl->dot_local(*(
g.get_impl()));
1346 template<
typename R>
1352 impl->get_coeffs().clear();
1364 template<
typename opT>
1368 impl->get_coeffs().clear();
1379 impl->get_coeffs().clear();
1387 template<
typename opT>
1391 impl->get_coeffs().clear();
1404 impl->get_coeffs().clear();
1415 template<
typename opT>
1419 impl->get_coeffs().clear();
1432 impl->get_coeffs().clear();
1442 template<
size_t LDIM,
size_t KDIM,
typename opT>
1450 impl->finalize_sum();
1456 template<
size_t LDIM,
size_t KDIM>
1463 impl->finalize_sum();
1472 template <
typename R>
1478 if (not
g.is_initialized())
return 0.0;
1481 if constexpr (std::is_same_v<T,R>) {
1490 if constexpr (std::is_same_v<R,T>) {
1492 return g.inner_on_demand(*
this);
1493 if (
g.is_on_demand())
1494 return this->inner_on_demand(
g);
1530 T
local =
impl->inner_ext_local(
f, leaf_refine);
1546 T
local =
impl->inner_ext_local(
f, leaf_refine);
1548 impl->world.gop.fence();
1561 const bool leaf_refine=
true)
const {
1564 T
local =
impl->inner_adaptive_local(
f, leaf_refine);
1566 impl->world.gop.fence();
1574 template <
typename L>
1589 template<
typename R>
1593 constexpr std::size_t
LDIM=std::max(
NDIM/2,std::size_t(1));
1597 func->replicate_low_dim_functions(
true);
1614 template <
typename R,
size_t LDIM>
1620 static const size_t KDIM=
NDIM-
LDIM;
1629 this->
get_impl()->project_out(result.
get_impl().get(),
g.get_impl().get(),dim,
true);
1633 result.
get_impl()->trickle_down(
false);
1655 template <
typename Archive>
1659 long magic = 0l,
id = 0l, ndim = 0l,
k = 0l;
1661 ar & magic &
id & ndim &
k &
cell;
1664 "Function archive was written by an incompatible MADNESS version; regenerate it.");
1673 std::ostringstream oss;
1674 oss <<
"simulation cells inconsistent: stored cell differs from FunctionDefaults cell.\n"
1675 <<
"Call FunctionDefaults<" <<
NDIM <<
">::clear_cell() before reloading "
1676 <<
"(this will render all existing functions useless!)";
1693 template <
typename Archive>
1707 if (not
impl)
return;
1713 template <
typename Q,
typename opT>
1726 template <
typename Q, std::
size_t D>
1729 std::vector< std::shared_ptr< FunctionImpl<Q,D> > > r(
v.size());
1730 for (
unsigned int i=0; i<
v.size(); ++i) r[i] =
v[i].
get_impl();
1735 template <
typename opT>
1737 std::vector<implT*>
v(vf.size(),NULL);
1738 for (
unsigned int i=0; i<
v.size(); ++i) {
1754 template <
typename opT>
1758 const bool fence=
true) {
1759 std::vector<implT*> vimplin(vin.size(),NULL);
1760 for (
unsigned int i=0; i<vin.size(); ++i) {
1761 if (vin[i].
is_initialized()) vimplin[i] = vin[i].get_impl().get();
1763 std::vector<implT*> vimplout(vout.size(),NULL);
1764 for (
unsigned int i=0; i<vout.size(); ++i) {
1765 if (vout[i].
is_initialized()) vimplout[i] = vout[i].get_impl().get();
1768 impl->multi_to_multi_op_values(
op, vimplin, vimplout,
fence);
1775 template <
typename L,
typename R>
1783 std::vector<FunctionImpl<T,NDIM>*> vresult(right.size());
1784 std::vector<const FunctionImpl<R,NDIM>*> vright(right.size());
1785 for (
unsigned int i=0; i<right.size(); ++i) {
1786 result[i].set_impl(left,
false);
1790 vresult[i] = result[i].impl.get();
1791 vright[i] = right[i].get_impl().get();
1795 vresult[0]->mulXXvec(left.
get_impl().get(), vright, vresult, tol,
fence);
1801 template<
typename L,
typename R>
1811 impl->multiply(leaf_op1,gimpl,fimpl,
fence);
1814 impl->multiply(leaf_op1,fimpl,gimpl,
fence);
1819 template <
typename R,
typename Q>
1830 template <
typename L,
typename R>
1850 impl.reset(
new implT(*
f.impl,
f.get_pmap(),
false));
1864 for (std::size_t i=0; i<
NDIM; ++i)
MADNESS_ASSERT((mirrormap[i]==1) or (mirrormap[i]==-1));
1865 impl.reset(
new implT(*
f.impl,
f.get_pmap(),
false));
1880 const std::vector<long>&
map,
const std::vector<long>&
mirror,
1888 impl.reset(
new implT(*
f.impl,
f.get_pmap(),
false));
1899 double local =
impl->check_symmetry_local();
1901 impl->world.gop.fence();
1902 double asy=sqrt(
local);
1903 if (this->
world().rank()==0)
print(
"asymmetry wrt particle",asy);
1920 impl->chop_at_level(n,
true);
1927 template <
typename T,
typename opT, std::
size_t NDIM>
1936 template <
typename Q,
typename T, std::
size_t NDIM>
1943 result.set_impl(
f,
false);
1944 result.get_impl()->scale_oop(
alpha,*
f.get_impl(),
fence);
1950 template <
typename Q,
typename T, std::
size_t NDIM>
1961 template <
typename Q,
typename T, std::
size_t NDIM>
1970 template <
typename Q,
typename T, std::
size_t NDIM>
1981 template <
typename L,
typename R,std::
size_t NDIM>
1984 bool fence=
true,
bool do_make_redundant=
true) {
1988 std::vector< Function<R,NDIM> > vright(1,right);
1993 template <
typename L,
typename R,std::
size_t NDIM>
1996 bool do_make_redundant=
true) {
2001 template <
typename L,
typename R,
typename opT, std::
size_t NDIM>
2009 result.set_impl(left,
false);
2015 template <
typename Q,
typename opT, std::
size_t NDIM>
2018 if (!
func.is_reconstructed())
func.reconstruct();
2028 template <
typename Q,
typename opT, std::
size_t NDIM>
2031 if (!
func.is_reconstructed())
func.reconstruct();
2041 template <
typename L,
typename R, std::
size_t D>
2046 vresult[0].vmulXX(left, vright, vresult, tol,
fence);
2054 template <
typename L,
typename R, std::
size_t NDIM>
2060 return mul(left,right,
true);
2066 template<
typename T, std::
size_t KDIM, std::
size_t LDIM>
2082 std::vector<std::shared_ptr<FunctionImpl<T,KDIM>>> vleft=
get_impl(left);
2083 std::vector<std::shared_ptr<FunctionImpl<T,LDIM>>> vright=
get_impl(right);
2092 template<
typename T, std::
size_t KDIM, std::
size_t LDIM>
2095 typedef std::vector<Function<T,KDIM>> vector;
2100 template<
typename T, std::
size_t KDIM, std::
size_t LDIM,
typename opT>
2116 print(
"incomplete FunctionFactory in Function::hartree_product");
2125 std::vector<std::shared_ptr<FunctionImpl<T,KDIM>>> vleft;
2126 std::vector<std::shared_ptr<FunctionImpl<T,LDIM>>> vright;
2128 vright.push_back(right.
get_impl());
2141 template <
typename L,
typename R,std::
size_t NDIM>
2151 template <
typename L,
typename R,std::
size_t NDIM>
2161 template <
typename L,
typename R,std::
size_t NDIM>
2170 template<
typename T, std::
size_t NDIM>
2186 template <
typename L,
typename R, std::
size_t NDIM>
2201 return add(left,right,
true);
2206 template <
typename L,
typename R,std::
size_t NDIM>
2217 template <
typename L,
typename R, std::
size_t NDIM>
2229 return sub(left,right,
true);
2238 template <
typename T, std::
size_t NDIM>
2241 bool fence =
true) {
2253 template <
typename T, std::
size_t NDIM>
2262 template <
typename T, std::
size_t NDIM>
2285 template <
typename T,
typename Q, std::
size_t NDIM>
2299 template <
typename T, std::
size_t NDIM>
2316 template <
typename opT,
typename T, std::
size_t LDIM>
2323 typedef std::vector<Function<T,LDIM>> vecfuncL;
2325 vecfuncL& ff1 =
const_cast< vecfuncL&
>(
f1);
2326 vecfuncL& ff2 =
const_cast< vecfuncL&
>(
f2);
2335 for (
auto&
f :
f1)
f.make_nonstandard(
true,
false);
2336 for (
auto&
f :
f2)
f.make_nonstandard(
true,
false);
2349 std::vector<const FunctionImpl<T,LDIM>*> fimpls(
f1.size()), gimpls(
f2.size());
2350 for (
size_t i=0; i<
f1.size(); ++i) {
2351 fimpls[i]=
f1[i].get_impl().get();
2352 gimpls[i]=
f2[i].get_impl().get();
2354 result.
get_impl()->recursive_apply(
op, fimpls, gimpls,
false);
2358 if (
op.print_timings) {
2363 result.
get_impl()->finalize_apply();
2365 if (
op.modified()) {
2366 result.
get_impl()->trickle_down(
true);
2368 result.
get_impl()->reconstruct(
true);
2378 template <
typename opT,
typename R, std::
size_t NDIM>
2383 constexpr std::size_t OPDIM=opT::opdim;
2384 constexpr bool low_dim=(OPDIM*2==
NDIM);
2387 if (
NDIM <= 3 and (not low_dim)) {
2388 result.set_impl(
f,
false);
2389 result.get_impl()->apply(
op, *
f.get_impl(),
fence);
2395 result.set_impl(
f,
false);
2396 r1.set_impl(
f,
false);
2398 result.get_impl()->reset_timer();
2401 result.get_impl()->apply_source_driven(
op, *
f.get_impl(),
fence);
2424 template <
typename opT,
typename R, std::
size_t NDIM>
2439 if (
op.modified()) {
2444 ff.
get_impl()->undo_redundant(
false);
2445 result.
get_impl()->trickle_down(
true);
2455 fff.
get_impl()->timer_filter.print(
"filter");
2456 fff.
get_impl()->timer_compress_svd.print(
"compress_svd");
2465 double elapsed=result.
get_impl()->finalize_apply();
2466 if (
print_timings) printf(
"time in finalize_apply %8.2f\n",elapsed);
2473 result.
get_impl()->reconstruct(
true);
2476 if (
op.destructive()) {
2490 template <
typename opT,
typename R, std::
size_t NDIM>
2500 result.set_impl(ff,
false);
2518 template <
typename T, std::
size_t NDIM>
2530 template <
typename T, std::
size_t NDIM>
2547 template <
typename T, std::
size_t NDIM>
2550 const std::vector<long>&
mirror,
bool fence=
true) {
2561 template <
typename T, std::
size_t NDIM>
2562 typename std::enable_if_t<NDIM%2==0, Function<T,NDIM>>
2568 for (std::size_t
d=0;
d<
LDIM; ++
d) {
2587 template <
typename T, std::
size_t NDIM>
2596 if (symmetry==
"sy_particle") {
2599 }
else if (symmetry==
"cx") {
2603 }
else if (symmetry==
"cy") {
2607 }
else if (symmetry==
"cz") {
2612 if (
f.world().rank()==0) {
2613 print(
"unknown parameter in symmetrize:",symmetry);
2619 result.
get_impl()->average(*
f.get_impl());
2632 template<
typename T, std::
size_t NDIM, std::
size_t LDIM>
2676 template <
typename T, std::
size_t NDIM>
2679 double target_precision = 0.0,
2680 int oversampling = 1,
2681 bool fence =
true) {
2687 if (terms.front().ket.is_initialized()) {
2688 result.
set_impl(terms.front().ket,
false);
2698 target_precision, oversampling,
fence);
2709 template <
typename T, std::
size_t NDIM>
2713 double target_precision = 0.0,
2714 int oversampling = 1,
2715 bool fence =
true) {
2719 if (terms.front().ket.is_initialized()) {
2720 result.
set_impl(terms.front().ket,
false);
2728 result.
get_impl().get(), leaf_ref, terms,
2729 target_precision, oversampling,
fence);
2738 template <
typename T, std::
size_t NDIM>
2742 double target_precision = 0.0,
2743 int oversampling = 1) {
2745 "composite_inner: terms list must not be empty");
2747 "composite_inner: bra Function must be initialised");
2751 if (terms.front().ket.is_initialized()) {
2752 like = terms.front().ket.get_impl().get();
2757 "composite_inner: cannot model accumulator — provide a ket in the first term, "
2758 "or a non-on-demand bra");
2765 target_precision, oversampling);
2769 template <
typename T, std::
size_t NDIM>
2774 double target_precision = 0.0,
2775 int oversampling = 1) {
2777 "composite_inner: terms list must not be empty");
2779 "composite_inner: bra Function must be initialised");
2782 if (terms.front().ket.is_initialized()) {
2783 like = terms.front().ket.get_impl().get();
2788 "composite_inner: cannot model accumulator — provide a ket in the first term, "
2789 "or a non-on-demand bra");
2793 world, like, leaf_ref, terms, bra,
2794 target_precision, oversampling);
2798 template <
typename T, std::
size_t NDIM>
2816 template <
typename T,
typename R, std::
size_t NDIM>
2828 template<std::size_t
NDIM,
typename T, std::size_t
LDIM,
typename R, std::size_t KDIM,
2829 std::size_t CDIM = (KDIM +
LDIM -
NDIM) / 2>
2832 const std::array<int, CDIM> v2,
int task=0) {
2833 bool prepare = ((
task==0) or (
task==1));
2834 bool work = ((
task==0) or (
task==2));
2835 bool finish = ((
task==0) or (
task==3));
2837 static_assert((KDIM +
LDIM -
NDIM) % 2 == 0,
"faulty dimensions in inner (partial version)");
2838 static_assert(KDIM +
LDIM - 2 * CDIM ==
NDIM,
"faulty dimensions in inner (partial version)");
2841 for (
size_t i=0; i<CDIM-1; ++i)
MADNESS_CHECK((v1[i]+1)==v1[i+1]);
2844 for (
size_t i=0; i<CDIM-1; ++i)
MADNESS_CHECK((v2[i]+1)==v2[i+1]);
2859 f.get_impl()->compute_snorm_and_dnorm(
false);
2860 for (
auto&
g : vg)
g.get_impl()->compute_snorm_and_dnorm(
false);
2865 std::vector<Function<resultT,NDIM>> result(vg.size());
2868 for (
size_t i=0; i<vg.size(); ++i) {
2871 result[i].get_impl()->partial_inner(*
f.get_impl(),*(vg[i]).get_impl(),v1,v2);
2885 auto erase_list = [] (
const auto& funcimpl) {
2886 typedef typename std::decay_t<
decltype(funcimpl)>
::keyT keyTT;
2887 std::list<keyTT> to_be_erased;
2888 for (
auto it=funcimpl.get_coeffs().begin(); it!=funcimpl.get_coeffs().end(); ++it) {
2889 const auto& key=it->first;
2890 const auto& node=it->second;
2891 if (not node.has_children()) to_be_erased.push_back(key);
2893 return to_be_erased;
2898 for (
auto&
g : vg) {
2918 template<std::size_t
NDIM,
typename T, std::size_t
LDIM,
typename R, std::size_t KDIM,
2919 std::size_t CDIM = (KDIM +
LDIM -
NDIM) / 2>
2922 const std::array<int, CDIM> v2,
int task=0) {
2930 template <
typename T, std::
size_t LDIM,
typename R, std::
size_t KDIM>
2934 std::array<int,1>({std::get<0>(v1)}),
2935 std::array<int,1>({std::get<0>(v2)}));
2942 template <
typename T, std::
size_t LDIM,
typename R, std::
size_t KDIM>
2946 std::array<int,2>({std::get<0>(v1),std::get<1>(v1)}),
2947 std::array<int,2>({std::get<0>(v2),std::get<1>(v2)}));
2954 template <
typename T, std::
size_t LDIM,
typename R, std::
size_t KDIM>
2958 std::array<int,3>({std::get<0>(v1),std::get<1>(v1),std::get<2>(v1)}),
2959 std::array<int,3>({std::get<0>(v2),std::get<1>(v2),std::get<2>(v2)}));
2972 template <
typename T,
typename opT, std::
size_t NDIM>
2975 std::shared_ptr< FunctionFunctorInterface<double,3> >
func(
new opT(
g));
2987 template <
typename T,
typename opT, std::
size_t NDIM>
2992 template <
typename T,
typename R, std::
size_t NDIM>
2995 return (
f*
R(1.0)).add_scalar(r);
2998 template <
typename T,
typename R, std::
size_t NDIM>
3001 return (
f*
R(1.0)).add_scalar(r);
3004 template <
typename T,
typename R, std::
size_t NDIM>
3007 return (
f*
R(1.0)).add_scalar(-r);
3010 template <
typename T,
typename R, std::
size_t NDIM>
3013 return (
f*
R(-1.0)).add_scalar(r);
3017 template <std::
size_t NDIM>
3027 template <std::
size_t NDIM>
3037 template <std::
size_t NDIM>
3048 template <std::
size_t NDIM>
3062 template <std::
size_t NDIM>
3068 template <std::
size_t NDIM>
3074 template <std::
size_t NDIM>
3081 template <
typename T, std::
size_t NDIM>
3085 return result.
square(
true);
3089 template <
typename T, std::
size_t NDIM>
3093 return result.
abs(
true);
3097 template <
typename T, std::
size_t NDIM>
3106 template <
typename T, std::
size_t NDIM>
3107 typename std::enable_if<TensorTypeData<T>::iscomplex, Function<typename Tensor<T>::scalar_type,
NDIM> >
::type
3113 template <std::
size_t NDIM>
3119 template <std::
size_t NDIM>
3129 template <
typename T, std::
size_t NDIM>
3131 if (
f.is_initialized())
return f.get_impl()->get_tree_state();
3142 template <
typename T, std::
size_t NDIM>
3145 return f.change_tree_state(finalstate,
fence);
3148 template <
typename R, std::
size_t MDIM>
3150 f1.impl.swap(
f2.impl);
3159 template <
class archiveT,
class T, std::
size_t NDIM>
3166 template <
class archiveT,
class T, std::
size_t NDIM>
3174 template <
class T, std::
size_t NDIM>
3180 template <
class T, std::
size_t NDIM>
3193 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.
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
static int get_k()
Returns the default wavelet order.
Definition funcdefaults.h:170
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 const BoundaryConditions< NDIM > & get_bc()
Returns the default boundary conditions.
Definition funcdefaults.h:315
static void set_cell(const Tensor< double > &value)
Sets the user cell for the simulation.
Definition funcdefaults.h:374
static const Tensor< double > & get_cell()
Gets the user cell for the simulation.
Definition funcdefaults.h:352
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:1043
const dcT & get_coeffs() const
Definition mraimpl.h:355
void reconstruct(bool fence)
reconstruct this tree – respects fence
Definition mraimpl.h:1584
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:141
void print_tree_json(std::ostream &os=std::cout) const
Definition mra.h:1043
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:412
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:1879
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:1575
T inner_adaptive(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine=true) const
Definition mra.h:1560
void unaryop_coeff(const opT &op, bool fence=true)
Unary operation applied inplace to the coefficients.
Definition mra.h:1093
bool is_compressed() const
Returns true if compressed, false otherwise. No communication.
Definition mra.h:544
Function< T, NDIM/2 > dirac_convolution(const bool fence=true) const
Definition mra.h:1639
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:758
bool autorefine() const
Returns value of autorefine flag. No communication.
Definition mra.h:655
TreeState operating_state
Definition mra.h:1501
Function< T, NDIM > & add_scalar(T t, bool fence=true)
Inplace add scalar. No communication except for optional fence.
Definition mra.h:1142
void print_size(const std::string name) const
print some info about this
Definition mra.h:595
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:1347
void broaden(const BoundaryConditions< NDIM > &bc=FunctionDefaults< NDIM >::get_bc(), bool fence=true) const
Inplace broadens support in scaling function basis.
Definition mra.h:1015
void print_info() const
Print a summary of the load balancing info.
Definition mra.h:1059
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:1132
void norm_tree(bool fence=true) const
Initializes information about the function norm at all length scales.
Definition mra.h:872
void load(World &world, Archive &ar)
Replaces this function with one loaded from an archive using the default processor map.
Definition mra.h:1656
Function< T, NDIM > & abs_square(bool fence=true)
Returns *this for chaining.
Definition mra.h:1269
void replicate(const DistributionType type, bool fence=true) const
Definition mra.h:784
double norm2sq_local() const
Returns the square of the norm of the local function ... no communication.
Definition mra.h:826
IsSupported< TensorTypeData< Q >, Function< T, NDIM > >::type & operator*=(const Q q)
Inplace scaling by a constant.
Definition mra.h:1241
void sum_down(bool fence=true) const
Sums scaling coeffs down tree restoring state with coeffs only at leaves. Optional fence....
Definition mra.h:973
Level depthpt(const coordT &xuser) const
Definition mra.h:488
bool is_redundant() const
Returns true if redundant, false otherwise. No communication.
Definition mra.h:574
Function< T, NDIM > & operator+=(const Function< Q, NDIM > &other)
Inplace addition of functions in the wavelet basis.
Definition mra.h:1201
Function< T, NDIM > & operator=(const Function< T, NDIM > &f)
Assignment is shallow. No communication, works in either basis.
Definition mra.h:193
void set_autorefine(bool value, bool fence=true)
Sets the value of the autorefine flag. Optional global fence.
Definition mra.h:665
World & world() const
Returns the world.
Definition mra.h:764
T trace() const
Returns global value of int(f(x),x) ... global comm required.
Definition mra.h:1302
double typeT
Definition mra.h:159
friend void swap(Function< R, MDIM > &f1, Function< R, MDIM > &f2)
implements swap algorithm
Definition mra.h:3149
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:1365
const Function< T, NDIM > & change_tree_state(const TreeState finalstate, bool fence=true) const
changes tree state to given state
Definition mra.h:960
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:1714
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:1049
double norm2() const
Returns the 2-norm of the function ... global sum ... works in either basis.
Definition mra.h:853
Function< T, NDIM > & fill_cuspy_tree(const opT &op, const bool fence=true)
Definition mra.h:1388
void change_tensor_type(const TensorArgs &targs, bool fence=true)
change the tensor type of the coefficients in the FunctionNode
Definition mra.h:1706
const Function< T, NDIM > & refine(bool fence=true) const
Inplace autorefines the function using same test as for squaring.
Definition mra.h:1005
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:453
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:1251
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:1376
void verify_tree() const
Verifies the tree data structure ... global sync implied.
Definition mra.h:535
Future< Level > evaldepthpt(const coordT &xuser) const
Definition mra.h:334
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:1457
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:1845
int k() const
Returns the number of multiwavelets (k). No communication.
Definition mra.h:702
const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap() const
Returns a shared pointer to the process map.
Definition mra.h:772
double thresh() const
Returns value of truncation threshold. No communication.
Definition mra.h:674
void set_truncate_mode(int value)
Definition mra.h:694
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:1831
void set_thresh(double value, bool fence=true)
Sets the value of the truncation threshold. Optional global fence.
Definition mra.h:684
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:1736
void distribute(std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > newmap) const
distribute this function according to newmap
Definition mra.h:816
void unaryop(const opT &op, bool fence=true)
Inplace unary operation on function values.
Definition mra.h:1083
const std::shared_ptr< FunctionImpl< T, NDIM > > & get_impl() const
Returns a shared-pointer to the implementation.
Definition mra.h:730
void standard(bool fence=true)
Converts the function standard compressed form. Possible non-blocking comm.
Definition mra.h:919
void unaryop_node(const opT &op, bool fence=true)
Unary operation applied inplace to the nodes.
Definition mra.h:1103
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:718
Function< T, NDIM > & fill_cuspy_tree(const bool fence=true)
Special refinement on 6D boxes where the electrons come close (meet).
Definition mra.h:1401
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mra.h:640
bool is_on_demand() const
Definition mra.h:752
Function< T, NDIM > & operator-=(const Function< Q, NDIM > &other)
Inplace subtraction of functions in the wavelet basis.
Definition mra.h:1220
bool compressed
Definition mra.h:1323
const Function< T, NDIM > & reconstruct(bool fence=true) const
Reconstructs the function, transforming into scaling function basis. Possible non-blocking comm.
Definition mra.h:950
Function< T, NDIM > & abs(bool fence=true)
Returns *this for chaining.
Definition mra.h:1260
Function< T, NDIM > & reduce_rank(const double thresh=0.0, const bool fence=true)
reduce the rank of the coefficient tensors
Definition mra.h:1909
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:1860
std::size_t max_nodes() const
Returns the max number of nodes on a processor.
Definition mra.h:625
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:1443
std::shared_ptr< FunctionImpl< double, NDIM > > impl
Definition mra.h:148
void replicate_on_hosts(bool fence=true) const
Definition mra.h:809
void replicate(bool fence=true) const
Definition mra.h:797
T trace_local() const
Returns local contribution to int(f(x),x) ... no communication.
Definition mra.h:1282
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:1802
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:1162
Vector< double, NDIM > coordT
Definition mra.h:158
void store(Archive &ar) const
Stores the function to an archive.
Definition mra.h:1694
std::size_t max_local_depth() const
Returns the maximum local depth of the function tree ... no communications.
Definition mra.h:617
MADNESS_CHECK_THROW(compressed or redundant,"functions must be compressed or redundant in inner")
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:1820
impl world gop sum(local)
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:604
Function()
Default constructor makes uninitialized function. No communication.
Definition mra.h:176
std::vector< std::pair< bool, T > > eval_local_only(const std::vector< coordT > &xuser, Level maxlevel) const
Definition mra.h:322
std::size_t tree_size() const
Returns the number of nodes in the function tree ... collective global sum.
Definition mra.h:588
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:1615
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:1727
FunctionImpl< double, NDIM > implT
Definition mra.h:155
void clear(bool fence=true)
Clears the function as if constructed uninitialized. Optional fence.
Definition mra.h:1026
void refine_general(const opT &op, bool fence=true) const
Inplace autorefines the function. Optional fence. Possible non-blocking comm.
Definition mra.h:986
static void doconj(const Key< NDIM >, Tensor< T > &t)
Definition mra.h:1113
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:247
TENSOR_RESULT_TYPE(double, R) inner_local(const Function< R
void set_functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor)
Replace the current functor with the provided new one.
Definition mra.h:747
bool impl_initialized() const
Definition mra.h:151
Function< T, NDIM > & fill_nuclear_cuspy_tree(const opT &op, const size_t particle, const bool fence=true)
Definition mra.h:1416
bool is_redundant_after_merge() const
Returns true if redundant_after_merge, false otherwise. No communication.
Definition mra.h:582
return local
Definition mra.h:1516
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:287
auto func
Definition mra.h:1594
~Function()
Destruction of any underlying implementation is deferred to next global fence.
Definition mra.h:200
Function(const Function< T, NDIM > &f)
Copy constructor is shallow. No communication, works in either basis.
Definition mra.h:187
void set_impl(const std::shared_ptr< FunctionImpl< T, NDIM > > &impl)
Replace current FunctionImpl with provided new one.
Definition mra.h:737
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:467
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:1527
std::size_t min_nodes() const
Returns the min number of nodes on a processor.
Definition mra.h:632
void make_redundant(bool fence=true) const
Converts the function to redundant form, i.e. sum coefficients on all levels.
Definition mra.h:935
constexpr std::size_t LDIM
Definition mra.h:1593
static constexpr std::size_t dimT
Definition mra.h:160
change_tree_state(operating_state, false)
bool is_nonstandard() const
Returns true if nonstandard-compressed, false otherwise. No communication.
Definition mra.h:566
void verify() const
Asserts that the function is initialized.
Definition mra.h:164
double err(const funcT &func) const
Returns an estimate of the difference ||this-func|| ... global sum performed.
Definition mra.h:522
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:1543
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:1429
double check_symmetry() const
check symmetry of a function by computing the 2nd derivative
Definition mra.h:1895
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:1755
FunctionFactory< double, NDIM > factoryT
Definition mra.h:157
std::size_t size_local() const
Return the number of coefficients in the function on this processor.
Definition mra.h:647
const Function< T, NDIM > & compress(bool fence=true) const
Compresses the function, transforming into wavelet basis. Possible non-blocking comm.
Definition mra.h:892
bool is_initialized() const
Returns true if the function is initialized.
Definition mra.h:169
bool is_reconstructed() const
Returns true if reconstructed, false otherwise. No communication.
Definition mra.h:555
Function< T, NDIM > & chop_at_level(const int n, const bool fence=true)
remove all nodes with level higher than n
Definition mra.h:1917
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:1776
double errsq_local(const funcT &func) const
Returns an estimate of the difference ||this-func||^2 from local data.
Definition mra.h:507
void make_nonstandard(bool keepleaves, bool fence=true) const
Compresses the function retaining scaling function coeffs. Possible non-blocking comm.
Definition mra.h:905
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:213
void print_tree(std::ostream &os=std::cout) const
Process 0 prints a summary of all nodes in the tree (collective).
Definition mra.h:1036
FunctionNode< double, NDIM > nodeT
Definition mra.h:156
bool redundant
Definition mra.h:1324
Future< long > evalR(const coordT &xuser) const
Evaluates the function rank at a point in user coordinates. Possible non-blocking comm.
Definition mra.h:371
Function(const factoryT &factory)
Constructor from FunctionFactory provides named parameter idiom. Possible non-blocking communication.
Definition mra.h:180
NDIM &g const
Definition mra.h:1321
void unaryop(T(*f)(T))
Inplace unary operation on function values.
Definition mra.h:1074
Function< T, NDIM > conj(bool fence=true)
Inplace complex conjugate. No communication except for optional fence.
Definition mra.h:1121
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:71
Traits class to specify support of numeric types.
Definition type_data.h:56
A tensor is a multidimensional array.
Definition tensor.h:313
Tensor< T > & emul(const Tensor< T > &t)
Inplace multiply by corresponding elements of argument Tensor.
Definition tensor.h:1804
Tensor< T > & conj()
Inplace complex conjugate.
Definition tensor.h:721
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:1587
Interface to be provided by any process map.
Definition worlddc.h:128
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
Function< T, NDIM > composite_product(World &world, std::vector< composite_term< T, NDIM > > terms, double target_precision=0.0, int oversampling=1, bool fence=true)
Definition mra.h:2677
double FunctionDefaults< NDIM >::thresh
Definition mraimpl.h:3879
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:3114
DistributionType
some introspection of how data is distributed
Definition worlddc.h:87
@ NodeReplicated
even if there are several ranks per node
Definition worlddc.h:90
@ RankReplicated
replicate the container over all world ranks
Definition worlddc.h:89
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:2492
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:2208
std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > FunctionDefaults< NDIM >::pmap
Definition mraimpl.h:3898
std::optional< BoundaryConditions< NDIM > > FunctionDefaults< NDIM >::bc
Definition mraimpl.h:3890
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:2003
int FunctionDefaults< NDIM >::k
Definition mraimpl.h:3878
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:2286
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:1938
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:2563
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
@ compressed
d coeffs in internal nodes, s and d coeffs at the root, empty leaves may be present
Definition funcdefaults.h:62
@ redundant
s coeffs everywhere
Definition funcdefaults.h:66
@ 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
T composite_inner_apply(World &world, const FunctionImpl< T, NDIM > *like, const leaf_opT &leaf_op, std::vector< composite_term< T, NDIM > > &terms, Function< T, NDIM > &bra_function, double target_precision, int oversampling)
Definition composite_product_op.h:583
Tensor< double > FunctionDefaults< NDIM >::cell
Definition mraimpl.h:3892
T composite_inner(World &world, std::vector< composite_term< T, NDIM > > terms, Function< T, NDIM > bra, double target_precision=0.0, int oversampling=1)
Definition mra.h:2739
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:2831
static constexpr long FUNCTION_ARCHIVE_MAGIC
Definition mra.h:137
Function< T, NDIM > mirror(const Function< T, NDIM > &f, const std::vector< long > &mirrormap, bool fence=true)
Generate a new function by mirroring within the dimensions .. optional fence.
Definition mra.h:2532
std::vector< CCPairFunction< T, NDIM > > operator*(const double fac, const std::vector< CCPairFunction< T, NDIM > > &arg)
Definition ccpairfunction.h:1111
std::vector< CCPairFunction< T, NDIM > > operator+(const CCPairFunction< T, NDIM > c1, const CCPairFunction< T, NDIM > &c2)
Definition ccpairfunction.h:1066
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< double > > > GaussianConvolution1DCache< double >::map
Definition convolution1d.h:1073
int Level
Definition key.h:60
TreeState get_tree_state(const Function< T, NDIM > &f)
get tree state of a function
Definition mra.h:3130
std::vector< CCPairFunction< T, NDIM > > operator-(const std::vector< CCPairFunction< T, NDIM > > c1, const std::vector< CCPairFunction< T, NDIM > > &c2)
Definition ccpairfunction.h:1082
std::string get_mra_data_dir()
Definition startup.cc:215
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:2171
@ TT_2D
Definition gentensor.h:120
@ TT_FULL
Definition gentensor.h:120
NDIM & f
Definition mra.h:2817
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:2163
Function< T, NDIM > symmetrize(const Function< T, NDIM > &f, const std::string symmetry, bool fence=true)
symmetrize a function
Definition mra.h:2589
NDIM const Function< R, NDIM > & g
Definition mra.h:2817
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:2380
void print(const T &t, Ts &&... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:232
const Future< void > Future< void >::value
Definition future.cc:44
double imag(double x)
Definition complexfun.h:56
void composite_product_apply(FunctionImpl< T, NDIM > *result, const leaf_opT &leaf_op, std::vector< composite_term< T, NDIM > > &terms, double target_precision, int oversampling, bool fence)
Definition composite_product_op.h:528
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:2017
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:65
std::string type(const PairType &n)
Definition PNOParameters.h:18
static bool print_timings
Definition SCF.cc:109
CCPairFunction< T, NDIM > apply(const SeparatedConvolution< T, NDIM/2 > &op, const CCPairFunction< T, NDIM > &arg)
apply the operator to the argument
Definition ccpairfunction.h:901
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:1983
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:1007
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:2633
void load(Function< T, NDIM > &f, const std::string name)
Definition mra.h:3181
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:2800
double real(double x)
Definition complexfun.h:52
@ same
same atoms at the same places
Definition RestartPlan.h:152
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:3175
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:2068
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:2239
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:1070
T(* f)(T)
Definition mra.h:1065
void operator()(const Key< NDIM > &key, Tensor< T > &t) const
Definition mra.h:1067
SimpleUnaryOpWrapper(T(*f)(T))
Definition mra.h:1066
void serialize(Archive &ar)
Definition mra.h:999
bool operator()(implT *impl, const Key< NDIM > &key, const nodeT &t) const
Definition mra.h:995
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:3168
Default store of an object via serialize(ar, t).
Definition archive.h:612
Definition composite_product_op.h:32
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:3051
double resultT
Definition mra.h:3050
void serialize(Archive &ar)
Definition mra.h:3056
void serialize(Archive &ar)
Definition mra.h:3045
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:3040
double resultT
Definition mra.h:3039
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:3030
void serialize(Archive &ar)
Definition mra.h:3034
double resultT
Definition mra.h:3029
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition mra.h:3020
double resultT
Definition mra.h:3019
void serialize(Archive &ar)
Definition mra.h:3024
Definition funcimpl.h:708
returns true if the result of a hartree_product is a leaf node (compute norm & error)
Definition funcimpl.h:539
Definition funcimpl.h:664
Definition lowrankfunction.h:387
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
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
static long abs(long a)
Definition tensor.h:214
#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
Key< D > keyT
Definition writecoeff2.cc:11