32#ifndef MADNESS_MRA_FUNCIMPL_H__INCLUDED
33#define MADNESS_MRA_FUNCIMPL_H__INCLUDED
58 template <
typename T, std::
size_t NDIM>
61 template<
typename T, std::
size_t NDIM>
64 template<
typename T, std::
size_t NDIM>
67 template<
typename T, std::
size_t NDIM>
70 template<
typename T, std::
size_t NDIM>
71 class FunctionFactory;
73 template<
typename T, std::
size_t NDIM, std::
size_t MDIM>
74 class CompositeFunctorInterface;
85 template<
typename keyT>
104 template <
typename keyT>
115 Level n = key.level();
116 if (n == 0)
return 0;
118 if (n <= 3 || (n&0x1)) hash = key.
hash();
135 template<
typename T, std::
size_t NDIM>
187 if (
this != &other) {
298 print(
"set_coeff: may have a problem");
299 print(
"set_coeff: coeff.dim[0] =", coeffs.
dim(0),
", 2* MAXK =", 2*
MAXK);
310 template <
typename Q>
371 }
else if (
coeff().dim(0) == cdata.
vk[0]) {
374 }
else if (
coeff().is_full_tensor()) {
380 }
else if (
coeff().is_svd_tensor()) {
396 template <
typename Q,
typename R>
437 if (
c.is_local(parent))
468 if (
c.is_local(parent))
486 return this->_coeffs.trace_conj((
rhs._coeffs));
489 template <
typename Archive>
500 s <<
"\"has_coeff\":" << this->
has_coeff()
501 <<
",\"has_children\":" << this->
has_children() <<
",\"norm\":";
508 s <<
norm <<
",\"norm_tree\":" <<
nt <<
",\"snorm\":"
511 if (this->
coeff().is_assigned())
512 s <<
",\"dim\":" << this->
coeff().
dim(0);
517 template <
typename T, std::
size_t NDIM>
534 template<
typename T,
size_t NDIM>
561 if (key.
level()<2)
return false;
563 std::vector<Slice>
s0(
NDIM/2,s);
565 const double tol=
f->get_thresh();
566 const double thresh=
f->truncate_tol(tol, key)*0.3;
569 const double gnorm=
gcoeff.normf();
598 template<
typename T,
size_t NDIM,
typename opT>
614 if (key.
level()<2)
return false;
615 const double cnorm=coeff.
normf();
621 if (key.
level()<2)
return false;
627 const std::vector<opkeyT>& disp =
op->get_disp(key.
level());
628 const opkeyT&
d = *disp.begin();
644 template<
typename T,
size_t NDIM,
size_t LDIM,
typename opT>
676 if (key.
level()<2)
return false;
678 const double tol=
f->get_thresh();
679 const double thresh=
f->truncate_tol(tol, key);
682 const double gnorm=
gcoeff.normf();
701 const std::vector<Key<NDIM> >& disp =
op->get_disp(key.
level());
714 template<
typename T,
size_t NDIM>
726 template<
typename T, std::
size_t NDIM>
750 template<
typename T, std::
size_t NDIM>
776 template<
typename T,
typename R>
783 template<
typename T, std::
size_t NDIM>
792 dnorm(node.get_dnorm()) {}
801 template <
typename Archive>
825 template<
typename T,
size_t NDIM>
959 template<
typename T, std::
size_t NDIM>
962 s <<
ct.key() <<
ct.is_leaf() <<
" " <<
ct.get_impl();
981 template <
typename T, std::
size_t NDIM>
988 typedef std::shared_ptr< FunctionImpl<T,NDIM> >
pimplT;
995 typedef std::pair<const keyT,nodeT>
datumT;
1023 std::shared_ptr< FunctionFunctorInterface<T,NDIM> >
functor;
1045 return neighbor_halo_.load(std::memory_order_acquire) !=
nullptr;
1052 delete neighbor_halo_.exchange(
nullptr, std::memory_order_acq_rel);
1058 return h ?
h->size() : 0;
1069 std::memory_order_acquire))
1074 for (
const auto&
kv : buf) {
1077 acc->second =
kv.second;
1084 if (!
h)
return false;
1086 if (
h->find(
acc, key)) { out =
acc->second;
return true; }
1144 if (it->second.is_leaf())
1165 template <
typename Q>
1179 template <
typename Q>
1213 const std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >&
get_pmap()
const;
1225 std::list<keyT>
keys;
1239 template <
typename Q>
1249 template<
typename Q>
1257 if (single_owner >= 0) {
1275 template <
typename Q>
1282 auto v=other.
task(pid, &implQ::serialize_remote_coeffs);
1289 std::vector<unsigned char>
v;
1302 template <
typename Q>
1304 for (
const auto& [key, node] : other.
coeffs) {
1316 template<
typename Q,
typename R>
1336 template<
typename Q,
typename R>
1348 template<
typename Q,
typename R>
1365 const double beta,
const implT&
g,
const bool fence);
1368 template <
typename Q,
typename R>
1377 const keyT& key = it->first;
1383 template <
typename Archive>
1396 template <
typename Q,
typename R>
1409 template <
typename Archive>
1427 template <
typename Archive>
1486 std::shared_ptr<FunctionFunctorInterface<T,NDIM> >
get_functor();
1488 std::shared_ptr<FunctionFunctorInterface<T,NDIM> >
get_functor()
const;
1540 void truncate(
double tol,
bool fence);
1644 const int xaxis,
const int yaxis,
const coordT el2);
1666 template<
size_t FDIM>
1667 typename std::enable_if<NDIM==FDIM>::type
1686 const size_t npt = qx.
dim(0);
1703 double x,y,z,
x1,
y1,
z1,val;
1718 const double h = std::pow(0.5,
double(n));
1725 for (
size_t i=0; i<npt; ++i) {
1726 c[0] =
cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
1727 for (
size_t j=0; j<npt; ++j) {
1728 c[1] =
cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
1729 for (
size_t k=0;
k<npt; ++
k) {
1730 c[2] =
cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
1734 std::istringstream(
gline) >> x >> y >> z >> val;
1754 const bool has_children=
false;
1756 nodeT node(coeff,has_children);
1773 template<
size_t FDIM>
1774 typename std::enable_if<NDIM==FDIM>::type
1788 const size_t npt = qx.
dim(0);
1819 const double h = std::pow(0.5,
double(n));
1826 for (
int i=0; i<npt; ++i) {
1827 c[0] =
cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
1828 for (
int j=0; j<npt; ++j) {
1829 c[1] =
cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
1830 for (
int k=0;
k<npt; ++
k) {
1831 c[2] =
cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
1835 std::istringstream(
gline) >>
x1 >>
y1 >>
z1 >> val;
1851 const bool has_children=
false;
1853 nodeT node(coeff,has_children);
1930 const coeffT& coeff)
const;
1936 template <
typename Q>
1952 template <
typename Q>
1954 const bool s_only)
const {
1988 template <
typename Q>
2006 for (std::size_t
d=0;
d<
NDIM; ++
d) {
2037 template <
typename Q>
2062 template <
typename Q>
2069 template <
typename Q>
2076 template <
typename Q>
2090 template <
typename Q>
2097 MADNESS_EXCEPTION(
"FunctionImpl: fcube_for_mul: child-parent relationship bad?",0);
2101 for (std::size_t
d=0;
d<
NDIM; ++
d) {
2118 template <
typename Q>
2125 MADNESS_EXCEPTION(
"FunctionImpl: fcube_for_mul: child-parent relationship bad?",0);
2129 for (
size_t d=0;
d<
NDIM;
d++) {
2140 template <
typename L,
typename R>
2165 template<
typename R>
2167 const int npt,
const keyT& key)
const {
2174 c11(this->cdata.
s0)=c1;
2175 c22(this->cdata.
s0)=c2;
2187 return copy(result(this->cdata.
s0));
2192 template <
typename L,
typename R,
typename opT>
2215 template <
typename L,
typename R>
2225 const keyT& key = it->first;
2233 const keyT& key = it->first;
2243 template <
typename opT>
2247 const keyT& parent = it->first;
2248 nodeT& node = it->second;
2264 template <
typename opT>
2268 const keyT& parent = it->first;
2269 nodeT& node = it->second;
2281 template<std::
size_t LDIM>
2300 const long maxk=
f->get_k();
2308 for (
long i=0; i<rank; ++i) {
2326 template<std::
size_t LDIM>
2331 const keyT& key = it->first;
2345 f->trickle_down(
true);
2355 template <
typename opT>
2365 template <
typename opT>
2390 const keyT& key = it->first;
2391 nodeT& node = it->second;
2396 const double error=
d.normf();
2415 nodeT& node = it->second;
2431 nodeT& node = it->second;
2450 nodeT& node = it->second;
2477 nodeT& node = it->second;
2497 if constexpr(
NDIM==6) {
2498 const keyT& key = it->first;
2502 if (
fnode.has_children())
return 0.0;
2507 std::vector<long> map(
NDIM);
2508 map[0]=3; map[1]=4; map[2]=5;
2509 map[3]=0; map[4]=1; map[5]=2;
2533 norm=(c1-c2).normf();
2569 template<
typename Q,
typename R>
2581 const keyT& key = it->first;
2582 const nodeT& node = it->second;
2598 template<
typename Q,
typename R>
2611 const keyT& key = it->first;
2646 const keyT& key = it->first;
2647 const nodeT& node = it->second;
2676 const keyT& key = it->first;
2677 const nodeT& node = it->second;
2682 for (std::size_t i=0; i<
NDIM; ++i) {
2689 std::vector<Slice> s(
___);
2692 for (
size_t i=0; i<
NDIM; ++i) {
2693 std::size_t
kmax=
c.dim(i);
2695 for (
size_t k=1;
k<
kmax;
k+=2) {
2727 const keyT& key = it->first;
2728 const nodeT& node = it->second;
2736 for (std::size_t i=0; i<
NDIM; ++i)
l1[
map[i]] = l[i];
2745 for (std::size_t i=0; i<
NDIM; ++i) {
2746 if (
mirror[i]==-1)
l1[i]= lmax - l[i];
2752 std::vector<Slice> s(
___);
2755 for (
size_t i=0; i<
NDIM; ++i) {
2756 std::size_t
kmax=
c.dim(i);
2758 for (
size_t k=1;
k<
kmax;
k+=2) {
2792 const keyT& key = it->first;
2796 if (
fnode.has_coeff()) {
2830 nodeT& node = it->second;
2851 it->second.consolidate_buffer(
targs);
2859 template <
typename opT>
2866 const keyT& key = it->first;
2867 nodeT& node = it->second;
2886 template <
typename Q,
typename R>
2894 std::vector<unsigned int> ind(
vleft.size());
2895 for (
unsigned int i=0; i<
vleft.size(); ++i) {
2898 for (
unsigned int i=0; i<
vleft.size(); ++i) {
2900 std::swap(ind[i],ind[j]);
2903 for (
const auto& [key,
rnode] : right->coeffs) {
2904 if (
rnode.has_coeff()) {
2909 for (
unsigned int j=0; j<
vleft.size(); ++j) {
2910 unsigned int i = ind[j];
2937 const std::vector<tensorT>&
c,
2944 template <
typename opT>
2946 std::vector<tensorT>
c(
v.size());
2947 for (
unsigned int i=0; i<
v.size(); i++) {
2950 c[i]=
cc.full_tensor();
2961 template <
typename opT>
2964 for (std::size_t i=1; i<
v.size(); ++i) {
2965 if (
v[i]
and v[i-1]) {
2971 const keyT& key = it->first;
2972 if (it->second.has_coeff())
2986 template <
typename opT>
2988 const std::vector<implT*>&
vin, std::vector<implT*>&
vout) {
2989 std::vector<tensorT>
c(
vin.size());
2990 for (
unsigned int i=0; i<
vin.size(); i++) {
2993 c[i]=
cc.full_tensor();
2996 std::vector<tensorT> r =
op(key,
c);
2998 for (std::size_t i=0; i<
vout.size(); ++i) {
3009 template <
typename opT>
3011 std::vector<implT*>&
vout,
const bool fence=
true) {
3013 for (std::size_t i=1; i<
vin.size(); ++i) {
3020 const keyT& key = it->first;
3021 if (it->second.has_coeff())
3038 template <
typename Q,
typename R>
3044 for (
unsigned int j=0; j<
vright.size(); ++j) {
3053 template <
typename opT>
3073 template <
typename L,
typename R>
3089 if (
lc.size() == 0) {
3094 lnorm =
lit->second.get_norm_tree();
3106 std::vector<FunctionImpl<T,NDIM>*>
vresult;
3107 std::vector<const FunctionImpl<R,NDIM>*>
vright;
3108 std::vector< Tensor<R> >
vrc;
3124 for (
unsigned int i=0; i<
vrightin.size(); ++i) {
3130 if (
rc.size() == 0) {
3133 rnorm =
rit->second.get_norm_tree();
3167 for (
unsigned int i=0; i<
vresult.size(); ++i) {
3172 if (
vrc[i].
size() || !
rit->second.has_children()) {
3182 const keyT& child =
kit.key();
3190 std::vector< Tensor<R> > vv(
vresult.size());
3191 for (
unsigned int i=0; i<
vresult.size(); ++i) {
3210 template <
typename L,
typename R>
3221 if (
lc.size() == 0) {
3224 lnorm = it->second.get_norm_tree();
3225 if (it->second.has_coeff())
3226 lc = it->second.coeff().reconstruct_tensor();
3230 if (
rc.size() == 0) {
3233 rnorm = it->second.get_norm_tree();
3234 if (it->second.has_coeff())
3235 rc = it->second.coeff().reconstruct_tensor();
3239 if (
rc.size() &&
lc.size()) {
3273 const keyT& child =
kit.key();
3296 template <
typename L,
typename R,
typename opT>
3305 if (
lc.size() == 0) {
3308 if (it->second.has_coeff())
3309 lc = it->second.coeff().reconstruct_tensor();
3313 if (
rc.size() == 0) {
3316 if (it->second.has_coeff())
3317 rc = it->second.coeff().reconstruct_tensor();
3320 if (
rc.size() &&
lc.size()) {
3343 const keyT& child =
kit.key();
3355 template <
typename Q,
typename opT>
3374 template <
typename Archive>
3388 template <
typename Q,
typename opT>
3393 const Tensor<Q> fc =
func->coeffs.find(key).get()->second.coeff().reconstruct_tensor();
3395 if (fc.
size() == 0) {
3399 const keyT& child =
kit.key();
3413 template <
typename L,
typename R>
3427 template <
typename L,
typename R,
typename opT>
3429 const opT&
op,
bool fence) {
3441 template <
typename Q,
typename opT>
3454 template <
typename Q,
typename opT>
3470 template <
typename L,
typename R>
3476 std::vector< Tensor<R> >
vr(
vright.size());
3556 const std::vector<long>& npt,
3579 std::vector<std::pair<bool,T>>
3660 template<
size_t LDIM>
3720 if (key.
level()<2) is_leaf=
false;
3739 return std::pair<bool,coeffT> (is_leaf,
hcoeff);
3790 if (
not is_leaf)
return std::pair<bool,coeffT> (is_leaf,
coeffT());
3797 return std::pair<bool,coeffT> (is_leaf,
hcoeff);
3830 template<
size_t LDIM>
3852 template<
size_t LDIM,
typename leaf_opT>
3880 if (
not is_leaf)
return std::pair<bool,coeffT> (is_leaf,
coeffT());
3890 return std::pair<bool,coeffT>(is_leaf,coeff);
3924 template<
typename coeff_opT,
typename apply_opT>
3938 template<
typename coeff_opT,
typename apply_opT>
3942 typedef typename std::pair<bool,coeffT> argT;
3944 apply_op.operator()(key,
arg.second,
arg.first);
3946 const bool has_children=(
not arg.first);
3968 template<std::
size_t LDIM,
typename leaf_opT>
3972 MADNESS_CHECK_THROW(p1.size()==p2.size(),
"hartree_product: p1 and p2 must have the same size");
3973 for (
auto&
p : p1)
MADNESS_CHECK(
p->is_nonstandard()
or p->is_nonstandard_with_leaves());
3974 for (
auto&
p : p2)
MADNESS_CHECK(
p->is_nonstandard()
or p->is_nonstandard_with_leaves());
3978 for (std::size_t i=0; i<p1.size(); ++i) {
4005 template <
typename opT,
typename R>
4010 const double cnorm =
c.normf();
4024 double Rnorm = r.
normf();
4030 if (s <= 1 || r.
normf()*cnorm > tol) {
4034 if (result.
normf() > tol*0.3) {
4056 template <
typename opT,
typename R>
4065 for (
fiterT it=
f->coeffs.begin(); it!=end; ++it) {
4066 const fnodeT& node = it->second;
4067 if (node.has_coeff()) {
4068 const keyT& key = it->first;
4069 const Tensor<R>&
c = node.coeff().full_tensor_copy();
4080 const std::pair<keyT,coeffT>& left,
4081 const std::pair<keyT,coeffT>& center,
4082 const std::pair<keyT,coeffT>& right);
4087 const std::pair<keyT,coeffT>& left,
4088 const std::pair<keyT,coeffT>& center,
4089 const std::pair<keyT,coeffT>& right);
4138 template<std::
size_t LDIM>
4259 template<
typename opT,
size_t LDIM>
4300 if(
leaf_op.do_pre_screening()){
4302 if(
leaf_op.pre_screening(key)){
4306 return std::pair<bool,coeffT> (
true,
coeffT());
4331 return std::pair<bool,coeffT> (
true,
coeffT());
4337 return std::pair<bool,coeffT> (
true,
coeffT());
4375 return std::pair<bool,coeffT> (
true,
coeffT());
4433 double dnorm=
d.normf();
4538 template<
typename opT>
4541 constexpr size_t LDIM=
NDIM/2;
4548 std::shared_ptr< FunctionFunctorInterface<T,NDIM> >
func2(this->
get_functor());
4556 if (fence)
func->make_redundant(
true);
4560 for (
auto& ket :
func->impl_ket_vector) {
4569 for (std::size_t i=0; i<
func->impl_p1_vector.size(); ++i) {
4599 template<
typename opT, std::
size_t LDIM>
4604 const bool fence=
true) {
4632 void mapdim(
const implT&
f,
const std::vector<long>& map,
bool fence);
4642 const std::vector<long>&
mirror,
bool fence);
4675 auto& node=it->second;
4676 node.recompute_snorm_and_dnorm(
cdata);
4746 template <
typename opT>
4761 const keyT& child =
kit.key();
4771 template <
typename opT>
4784 template <
typename opT>
4797 void broaden_op(
const keyT& key,
const std::vector< Future <bool> >&
v);
4834 typedef std::pair<coeffT, std::pair<double,double> >
compressT;
4904 const keyT& key = it->first;
4905 nodeT& node = it->second;
4926 template<
size_t OPDIM>
4935 template <
class Archive>
4946 template <
typename opT,
typename R,
size_t OPDIM>
4974 template <
typename opT,
typename R,
size_t OPDIM>
5012 template <
typename opT,
typename R,
size_t OPDIM>
5054 template <
typename opT,
typename R>
5066 typedef typename opT::keyT
opkeyT;
5067 constexpr auto opdim = opT::opdim;
5086 double radius = 1.5 + 0.33 * std::max(0.0, 2 - std::log10(
thresh) -
5092 double cnorm =
c.normf();
5099 (
op->particle() == 1)
5101 op->func_domain_is_periodic())
5103 op->func_domain_is_periodic());
5145 const auto &probing_displacements =
displacements.probing_displacements();
5146 for (std::size_t
d = 0;
d != opdim; ++
d) {
5147 if (!probing_displacements[
d])
continue;
5150 if (cnorm *
opnorm <= tol / fac)
5166 if (
op->particle() == 1)
5198 if (cnorm *
opnorm > tol / fac) {
5201 if (result.
normf() > 0.3 * tol / fac) {
5221 const std::vector<opkeyT> &disp =
op->get_disp(key.
level());
5227 if (
op->range_restricted() && key.
level() >= 1) {
5229 std::array<std::optional<std::int64_t>, opdim> box_radius;
5230 std::array<std::optional<std::int64_t>, opdim> surface_thickness;
5231 auto &
range =
op->get_range();
5232 for (
int d = 0;
d != opdim; ++
d) {
5235 surface_thickness[
d] =
range[
d].finite_soft() ? 1 : 0;
5245 std::optional<typename SurfaceRange::Validator>
validator;
5249 std::array<double, opdim> widths;
5250 for (std::size_t
d = 0;
d != opdim; ++
d) widths[
d] = cell_width(
d);
5251 validator.emplace(
op->func_domain_is_periodic(),
op->lattice_summed(),
5259 op->lattice_summed(),
5265 [](
const auto &
displacement) -> std::uint64_t {
return 0; },
5272 template <
typename opT,
typename R>
5276 for (
const auto& [key, node]:
f.coeffs) {
5277 if (node.has_coeff()) {
5278 if (node.coeff().dim(0) !=
k ||
op.doleaves) {
5305 template <
typename opT,
typename R>
5310 typedef typename opT::keyT
opkeyT;
5315 constexpr auto opdim=opT::opdim;
5324 double fac=std::pow(3,
NDIM*0.5);
5325 double cnorm = coeff.
normf();
5339#ifdef HAVE_GENTENSOR
5348 for (
const auto&
d: disp) {
5349 const int shell=
d.distsq_bc(
op->lattice_summed());
5367 bool screened=
false;
5368 typename std::list<opkeyT>::const_iterator
it2;
5370 if (
d.is_farther_out_than(*
it2)) {
5380 if (cnorm*
opnorm> tol/fac) {
5394 if (2*opdim==
NDIM) {
5403 }
else if (shell >= 12) {
5414 template <
typename opT,
typename R>
5423 const keyT& key = it->first;
5424 const coeffT& coeff = it->second.coeff();
5455 template<
typename opT, std::
size_t LDIM>
5482 template<
typename opT, std::
size_t LDIM>
5543 return std::pair<bool,coeffT> (is_leaf,
coeffT());
5549 const coeffT& coeff)
const {
5552 if (key.
level()<2) is_leaf=
false;
5553 return std::pair<bool,coeffT> (is_leaf,coeff);
5589 template<
typename opT>
5613 template<
typename opT>
5619 typedef std::pair<bool,coeffT>
argT;
5657 const bool is_leaf=
true;
5667 if (key.
level()<2) is_leaf=
false;
5668 return argT(is_leaf,coeff);
5702 template <
typename opT>
5707 std::vector<long> vq(
NDIM);
5708 for (std::size_t i=0; i<
NDIM; ++i)
5728 double err =
fval.normf();
5732 template <
typename opT>
5751 const keyT& key = it->first;
5752 const nodeT& node = it->second;
5763 template <
typename Archive>
5770 template <
typename opT>
5774 const int npt =
cdata.npt + 1;
5795 const nodeT& node = it->second;
5825 template<
typename R>
5836 const keyT& key=it->first;
5838 if (
fnode.has_coeff()) {
5841 if (
gnode.has_coeff()) {
5842 if (
gnode.coeff().dim(0) !=
fnode.coeff().dim(0)) {
5844 MADNESS_EXCEPTION(
"functions have different k or compress/reconstruct error", 0);
5871 template <
typename R>
5886 template<
typename R>
5898 constexpr std::size_t LDIM=std::max(
NDIM/2,std::size_t(1));
5900 const keyT& key=it->first;
5902 if (
not fnode.has_coeff())
return resultT(0.0);
5906 MADNESS_CHECK(impl->get_coeffs().owner(key)==impl->world.rank());
5907 if (impl->get_coeffs().probe(key))
return key;
5915 auto impl=
v_impl.front();
5921 typename decltype(impl->coeffs)::accessor
acc;
5928 typedef typename std::decay_t<
decltype(
v_impl)>::value_type::element_type::typeT S;
5936 return std::vector<std::decay_t<
decltype(
arg)>>(1,
arg);
5947 "only one ket function supported in inner_on_demand");
5949 "only one p1 function supported in inner_on_demand");
5951 "only one p2 function supported in inner_on_demand");
5984 if (
func->impl_eri) {
5994 result=
coeff_bra.full_tensor_copy().trace_conj(
v1v2ket.full_tensor_copy());
6011 template <
typename R>
6023 template<
typename R>
6034 const keyT& key=it->first;
6036 if (
fnode.has_coeff()) {
6039 if (
gnode.has_coeff()) {
6040 if (
gnode.coeff().dim(0) !=
fnode.coeff().dim(0)) {
6042 MADNESS_EXCEPTION(
"functions have different k or compress/reconstruct error", 0);
6046 sum +=
fnode.coeff().full_tensor().trace(
gnode.coeff().full_tensor());
6049 sum +=
fnode.coeff().full_tensor().trace(
gnode.coeff().full_tensor());
6069 template <
typename R>
6083 typedef std::vector< std::pair<int,const coeffT*> >
mapvecT;
6093 const keyT& key = it->first;
6097 acc->second.push_back(std::make_pair(index,&(node.
coeff())));
6110 for (
unsigned int i=0; i<
v.size(); i++) {
6114 if (
v.size())
v[0]->world.taskq.fence();
6120 template <
typename R>
6139 const int i =
leftv[
iv].first;
6146 if (!
sym || (
sym && i<=j))
6147 r(i,j) += iptr->trace_conj(*jptr);
6157 template <
typename R>
6175 unsigned int size =
leftv[0].second->size();
6186 const int i =
leftv[
iv].first;
6189 if (!
sym || (
sym && i<=j)) result(i,j) += r(
iv,
jv);
6200 template <
typename R,
typename = std::enable_if_t<std::is_
floating_po
int_v<R>>>
6220 const int i =
leftv[
iv].first;
6227 if (!
sym || (
sym && i <= j))
6228 r(i, j) += iptr->trace_conj(*jptr);
6238 template <
typename R>
6256 unsigned int size =
leftv[0].second->size();
6266 const int i =
leftv[
iv].first;
6269 if (!
sym || (
sym && i <= j)) result(i, j) += r(
iv,
jv);
6278 template <
typename Real>
6279 static std::enable_if_t<std::is_floating_point_v<Real>, Real>
conj(
const Real x) {
6283 template <
typename Real>
6284 static std::complex<Real>
conj(
const std::complex<Real>& x) {
6285 return std::conj(x);
6288 template <
typename R>
6314 size_t chunk = (
lmap.size()-1)/(3*4*5)+1;
6322 advance(
lend,chunk);
6326 left[0]->world.taskq.fence();
6329 for (
long i=0; i<r.
dim(0); i++) {
6330 for (
long j=0; j<i; j++) {
6340 template <
typename R>
6366 size_t chunk = (
lmap.size() - 1) / (3 * 4 * 5) + 1;
6374 advance(
lend, chunk);
6378 left[0]->world.taskq.fence();
6382 for (
long i = 0; i < r.
dim(0); i++) {
6383 for (
long j = 0; j < i; j++) {
6393 template <
typename R>
6396 static_assert(!std::is_same<R, int>::value &&
6397 std::is_same<R, int>::value,
6398 "Compilation failed because you wanted to know the type; see below:");
6408 template<
typename Q, std::size_t LDIM,
typename R, std::size_t
KDIM,
6411 const std::array<int, CDIM>
v1,
const std::array<int, CDIM>
v2) {
6413 typedef std::multimap<Key<NDIM>, std::list<Key<CDIM>>>
contractionmapT;
6428 for (std::size_t n=0; n<nmax; ++n) {
6466 it->second.splice(it->second.end(),
it2->second);
6477 elem.second.unique();
6496 const std::list<Key<CDIM>>& list=
key_list.second;
6510 template<std::
size_t CDIM>
6511 std::tuple<std::set<Key<NDIM>>, std::map<Key<CDIM>,
double>>
6516 if (coeff.has_no_data())
return false;
6517 return (coeff.dim(0)==2*
cdata.k);
6522 std::map<Key<CDIM>,
double>
j_list;
6567 const std::array<int,CDIM>&
v_this,
6568 const std::array<int,CDIM>&
v_other,
6613 if (continue_recursion) {
6634 if (
d.dim(0)==
cdata.vk[0]) {
6676 template<
typename Q, std::size_t LDIM,
typename R, std::size_t
KDIM,
6679 const std::array<int, CDIM>
v1,
const std::array<int, CDIM>
v2,
6690 constexpr std::size_t
VDIM = std::tuple_size<std::decay_t<
decltype(
v)>>::value;
6691 constexpr std::size_t
VCDIM = std::tuple_size<std::decay_t<
decltype(
vc)>>::value;
6692 std::array<int, VCDIM> result;
6693 for (std::size_t i = 0; i <
VCDIM; i++) result[i] = (
v.back() + i + 1) % (
VDIM +
VCDIM);
6697 constexpr std::size_t
IDIM = std::decay_t<
decltype(
i_key)>::static_size;
6698 constexpr std::size_t
JDIM = std::decay_t<
decltype(
j_key)>::static_size;
6699 static_assert(
JDIM == std::tuple_size<std::decay_t<
decltype(
v)>>::value);
6702 for (std::size_t i = 0; i <
v.size(); ++i) l[
v[i]] =
j_key.translation()[i];
6703 std::array<int, IDIM>
vc1;
6705 for (std::size_t i = 0; i <
vc.size(); ++i) l[
vc[i]] =
i_key.translation()[i];
6718 if (
gcoeff.dim(0) ==
g->get_cdata().k) {
6724 if (
hcoeff.dim(0) ==
g->get_cdata().k) {
6733 for (std::size_t i = 0; i <
CDIM - 1; ++i) {
6766 if (key.
level() > 0) {
6797 if (key.
level() > 0) {
6869 return c.trace_conj(fc);
6893 if (
coeffs.
find(key).get()->second.has_children()) {
6899 const keyT& child = it.key();
6904 }
else if (leaf_refine) {
6921 const keyT& child = it.key();
6941 const keyT& child = it.key();
6951 const std::shared_ptr< FunctionFunctorInterface<T, NDIM> >
fref;
6957 const implT * impl,
const bool leaf_refine,
const bool do_leaves)
6958 : fref(
f), impl(impl), leaf_refine(leaf_refine), do_leaves(do_leaves) {};
6961 if (do_leaves
and it->second.is_leaf()) {
6962 tensorT cc = it->second.coeff().full_tensor();
6965 tensorT cc = it->second.coeff().full_tensor();
7012 const bool leaf_refine, T
old_inner=T(0))
const {
7029 const keyT& child = it.key();
7038 const keyT& child = it.key();
7062 template <
typename L>
7086 template <
typename L>
7102 const keyT& child = it.key();
7112 if (
lc.size() == 0) {
7115 if (it->second.has_coeff())
7116 lc = it->second.coeff().reconstruct_tensor();
7120 if (
c.size() == 0) {
7141 const keyT& child = it.key();
7153 double dnorm =
d.normf();
7164 const keyT& child = it.key();
7173 template <
typename L>
7189 template<
size_t LDIM>
7191 const int dim,
const bool fence) {
7215 template<
size_t LDIM>
7222 typedef std::pair<bool,coeffT>
argT;
7265 const int k_ldim=std::pow(
k,LDIM);
7266 std::vector<long>
shape(LDIM,
k);
7268 if (
fcoeff.is_full_tensor()) {
7274 }
else if (
fcoeff.is_svd_tensor()) {
7288 final =
final.reshape(
shape);
7335 template<
size_t LDIM>
7338 typedef std::pair< keyT,coeffT > pairT;
7344 for (
fiterator it=
f->get_coeffs().begin(); it!=end; ++it) {
7363 }
else if (dim==1) {
7393 template<
size_t LDIM>
7395 const Key<NDIM>& dest,
const int dim)
const {
7410 std::vector<Slice> s(
fcoeff.config().dim_per_vector()+1,
_);
7413 for (
int r=0; r<
fcoeff.rank(); ++r) {
7418 const double fac=
ovlp *
fcoeff.config().weights(r);
7449 std::size_t
size()
const;
7455 std::size_t
nCoeff()
const;
7470 template <
typename Q,
typename F>
7474 typename fdcT::const_iterator end =
f.coeffs.
end();
7475 for (
typename fdcT::const_iterator it=
f.coeffs.begin(); it!=end; ++it) {
7476 const keyT& key = it->first;
7477 const fnodeT& node = it->second;
7483 nodeT scaled(
c, node.get_norm_tree(), node.get_dnorm_tree(),
7484 node.get_snorm(), node.get_dnorm(), node.has_children());
7512 template <
class Archive,
class T, std::
size_t NDIM>
7524 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use a locally uninitialized object",0);
7527 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use an unregistered object",0);
7534 template <
class Archive,
class T, std::
size_t NDIM>
7537 bool exists=(ptr) ?
true :
false;
7539 if (exists) ar & ptr->
id();
7543 template <
class Archive,
class T, std::
size_t NDIM>
7555 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use a locally uninitialized object",0);
7560 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use an unregistered object",0);
7568 template <
class Archive,
class T, std::
size_t NDIM>
7571 bool exists=(ptr) ?
true :
false;
7573 if (exists) ar & ptr->
id();
7578 template <
class Archive,
class T, std::
size_t NDIM>
7587 template <
class Archive,
class T, std::
size_t NDIM>
7594 template <
class Archive,
class T, std::
size_t NDIM>
7603 template <
class Archive,
class T, std::
size_t NDIM>
double w(double t, double eps)
Definition DKops.h:22
double q(double t)
Definition DKops.h:18
This header should include pretty much everything needed for the parallel runtime.
An integer with atomic set, get, read+increment, read+decrement, and decrement+test operations.
Definition atomicint.h:126
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
Definition displacements.h:551
a class to track where relevant (parent) coeffs are
Definition funcimpl.h:826
const keyT & key() const
const reference to the key
Definition funcimpl.h:876
CoeffTracker(const CoeffTracker &other, const datumT &datum)
ctor with a pair<keyT,nodeT>
Definition funcimpl.h:856
const LeafStatus & is_leaf() const
const reference to is_leaf flag
Definition funcimpl.h:900
const implT * impl
the funcimpl that has the coeffs
Definition funcimpl.h:835
CoeffTracker & operator=(const CoeffTracker &other)=default
LeafStatus
Definition funcimpl.h:832
@ yes
Definition funcimpl.h:832
@ no
Definition funcimpl.h:832
@ unknown
Definition funcimpl.h:832
CoeffTracker(const CoeffTracker &other)
copy ctor
Definition funcimpl.h:864
double dnorm(const keyT &key) const
return the s and dnorm belonging to the passed-in key
Definition funcimpl.h:893
coeffT coeff_
the coefficients belonging to key
Definition funcimpl.h:841
const implT * get_impl() const
const reference to impl
Definition funcimpl.h:870
const coeffT & coeff() const
const reference to the coeffs
Definition funcimpl.h:873
keyT key_
the current key, which must exists in impl
Definition funcimpl.h:837
double dnorm_
norm of d coefficients corresponding to key
Definition funcimpl.h:843
CoeffTracker(const implT *impl)
the initial ctor making the root key
Definition funcimpl.h:851
void serialize(const Archive &ar)
serialization
Definition funcimpl.h:952
Future< CoeffTracker > activate() const
find the coefficients
Definition funcimpl.h:929
CoeffTracker()
default ctor
Definition funcimpl.h:848
GenTensor< T > coeffT
Definition funcimpl.h:830
CoeffTracker make_child(const keyT &child) const
make a child of this, ignoring the coeffs
Definition funcimpl.h:903
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:828
std::pair< Key< NDIM >, ShallowNode< T, NDIM > > datumT
Definition funcimpl.h:831
CoeffTracker forward_ctor(const CoeffTracker &other, const datumT &datum) const
taskq-compatible forwarding to the ctor
Definition funcimpl.h:946
LeafStatus is_leaf_
flag if key is a leaf node
Definition funcimpl.h:839
coeffT coeff(const keyT &key) const
return the coefficients belonging to the passed-in key
Definition funcimpl.h:884
Key< NDIM > keyT
Definition funcimpl.h:829
CompositeFunctorInterface implements a wrapper of holding several functions and functors.
Definition function_interface.h:172
Definition worldhashmap.h:396
std::pair< iterator, bool > insert(const datumT &datum)
Definition worldhashmap.h:468
Hash_private::HashIterator< hashT > iterator
Definition worldhashmap.h:402
Tri-diagonal operator traversing tree primarily for derivative operator.
Definition derivative.h:73
FunctionCommonData holds all Function data common for given k.
Definition function_common_data.h:52
std::vector< long > vk
(k,...) used to initialize Tensors
Definition function_common_data.h:93
std::vector< Slice > s0
s[0] in each dimension to get scaling coeff
Definition function_common_data.h:91
static const FunctionCommonData< T, NDIM > & get(int k)
Definition function_common_data.h:111
static void _init_quadrature(int k, int npt, Tensor< double > &quad_x, Tensor< double > &quad_w, Tensor< double > &quad_phi, Tensor< double > &quad_phiw, Tensor< double > &quad_phit)
Initialize the quadrature information.
Definition mraimpl.h:93
collect common functionality does not need to be member function of funcimpl
Definition function_common_data.h:135
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 int get_max_refine_level()
Gets the default maximum adaptive refinement level.
Definition funcdefaults.h:220
static const Tensor< double > & get_cell_width()
Returns the width of each user cell dimension.
Definition funcdefaults.h:390
static bool get_apply_randomize()
Gets the random load balancing for integral operators flag.
Definition funcdefaults.h:294
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
bool _fence
Definition function_factory.h:103
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
Definition funcimpl.h:5733
double operator()(double a, double b) const
Definition funcimpl.h:5759
const opT * func
Definition funcimpl.h:5735
Tensor< double > qx
Definition funcimpl.h:5737
double operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:5750
void serialize(const Archive &ar)
Definition funcimpl.h:5764
do_err_box(const implT *impl, const opT *func, int npt, const Tensor< double > &qx, const Tensor< double > &quad_phit, const Tensor< double > &quad_phiw)
Definition funcimpl.h:5743
int npt
Definition funcimpl.h:5736
Tensor< double > quad_phiw
Definition funcimpl.h:5739
const implT * impl
Definition funcimpl.h:5734
Tensor< double > quad_phit
Definition funcimpl.h:5738
do_err_box(const do_err_box &e)
Definition funcimpl.h:5747
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:982
std::tuple< std::set< Key< NDIM > >, std::map< Key< CDIM >, double > > get_contraction_node_lists(const std::size_t n, const std::array< int, CDIM > &v) const
for contraction two functions f(x,z) = \int g(x,y) h(y,z) dy
Definition funcimpl.h:6512
void copy_coeffs(const FunctionImpl< Q, NDIM > &other, bool fence)
Copy coeffs from other into self.
Definition funcimpl.h:1240
bool is_nonstandard() const
Definition mraimpl.h:275
void insert_serialized_coeffs(std::vector< unsigned char > &v)
insert coeffs from vector archive into this
Definition funcimpl.h:1296
T eval_cube(Level n, coordT &x, const tensorT &c) const
Definition mraimpl.h:2096
void partial_inner_contract(const FunctionImpl< Q, LDIM > *g, const FunctionImpl< R, KDIM > *h, const std::array< int, CDIM > v1, const std::array< int, CDIM > v2, const Key< NDIM > &key, const std::list< Key< CDIM > > &j_key_list)
tensor contraction part of partial_inner
Definition funcimpl.h:6678
AtomicInt large
Definition funcimpl.h:1097
Timer timer_target_driven
Definition funcimpl.h:1095
void binaryXX(const FunctionImpl< L, NDIM > *left, const FunctionImpl< R, NDIM > *right, const opT &op, bool fence)
Definition funcimpl.h:3428
void do_apply(const opT *op, const keyT &key, const Tensor< R > &c)
apply an operator on the coeffs c (at node key)
Definition funcimpl.h:5055
void do_print_tree_graphviz(const keyT &key, std::ostream &os, Level maxlevel) const
Functor for the do_print_tree method (using GraphViz)
Definition mraimpl.h:2850
void add_keys_to_map(mapT *map, int index) const
Adds keys to union of local keys with specified index.
Definition funcimpl.h:6089
void change_tensor_type1(const TensorArgs &targs, bool fence)
change the tensor type of the coefficients in the FunctionNode
Definition mraimpl.h:1131
void gaxpy_ext_recursive(const keyT &key, const FunctionImpl< L, NDIM > *left, Tensor< L > lcin, tensorT c, T(*f)(const coordT &), T alpha, T beta, double tol, bool below_leaf)
Definition funcimpl.h:7087
int initial_level
Initial level for refinement.
Definition funcimpl.h:1011
int max_refine_level
Do not refine below this level.
Definition funcimpl.h:1015
double do_apply_kernel3(const opT *op, const GenTensor< R > &coeff, const do_op_args< OPDIM > &args, const TensorArgs &apply_targs)
same as do_apply_kernel2, but use low rank tensors as input and low rank tensors as output
Definition funcimpl.h:5013
void hartree_product(const std::vector< std::shared_ptr< FunctionImpl< T, LDIM > > > p1, const std::vector< std::shared_ptr< FunctionImpl< T, LDIM > > > p2, const leaf_opT &leaf_op, bool fence)
given two functions of LDIM, perform the Hartree/Kronecker/outer product
Definition funcimpl.h:3969
void traverse_tree(const coeff_opT &coeff_op, const apply_opT &apply_op, const keyT &key) const
traverse a non-existing tree
Definition funcimpl.h:3939
void do_square_inplace(const keyT &key)
int special_level
Minimium level for refinement on special points.
Definition funcimpl.h:1012
void do_apply_kernel(const opT *op, const Tensor< R > &c, const do_op_args< OPDIM > &args)
for fine-grain parallelism: call the apply method of an operator in a separate task
Definition funcimpl.h:4947
compressT compress_op(const keyT &key, const std::vector< Future< compressT > > &v, bool nonstandard)
calculate the wavelet coefficients using the sum coefficients of all child nodes
Definition mraimpl.h:1708
double errsq_local(const opT &func) const
Returns the sum of squares of errors from local info ... no comms.
Definition funcimpl.h:5771
WorldContainer< keyT, nodeT > dcT
Type of container holding the coefficients.
Definition funcimpl.h:994
void evaldepthpt(const Vector< double, NDIM > &xin, const keyT &keyin, const typename Future< Level >::remote_refT &ref)
Get the depth of the tree at a point in simulation coordinates.
Definition mraimpl.h:3121
void scale_inplace(const T q, bool fence)
In-place scale by a constant.
Definition mraimpl.h:3293
void gaxpy_oop_reconstructed(const double alpha, const implT &f, const double beta, const implT &g, const bool fence)
perform: this= alpha*f + beta*g, invoked by result
Definition mraimpl.h:225
void unary_op_coeff_inplace(const opT &op, bool fence)
Definition funcimpl.h:2244
World & world
Definition funcimpl.h:1001
void apply_1d_realspace_push_op(const archive::archive_ptr< const opT > &pop, int axis, const keyT &key, const Tensor< R > &c)
Definition funcimpl.h:4007
bool is_redundant() const
Returns true if the function is redundant.
Definition mraimpl.h:264
FunctionNode< T, NDIM > nodeT
Type of node.
Definition funcimpl.h:992
std::size_t nCoeff_local() const
Returns the number of coefficients in the function for this MPI rank.
Definition mraimpl.h:1981
void print_size(const std::string name) const
print tree size and size
Definition mraimpl.h:2000
FunctionImpl(const FunctionImpl< T, NDIM > &p)
void print_info() const
Prints summary of data distribution.
Definition mraimpl.h:851
void abs_inplace(bool fence)
Definition mraimpl.h:3305
void binaryXXa(const keyT &key, const FunctionImpl< L, NDIM > *left, const Tensor< L > &lcin, const FunctionImpl< R, NDIM > *right, const Tensor< R > &rcin, const opT &op)
Definition funcimpl.h:3297
void print_timer() const
Definition mraimpl.h:369
void evalR(const Vector< double, NDIM > &xin, const keyT &keyin, const typename Future< long >::remote_refT &ref)
Get the rank of leaf box of the tree at a point in simulation coordinates.
Definition mraimpl.h:3163
const FunctionCommonData< T, NDIM > & cdata
Definition funcimpl.h:1021
void do_print_grid(const std::string filename, const std::vector< keyT > &keys) const
print the grid in xyz format
Definition mraimpl.h:596
void mulXXa(const keyT &key, const FunctionImpl< L, NDIM > *left, const Tensor< L > &lcin, const FunctionImpl< R, NDIM > *right, const Tensor< R > &rcin, double tol)
Definition funcimpl.h:3211
bool has_coefficients_on_leaves_only() const
Returns true if only the leaves of this tree carry its coefficients.
Definition mraimpl.h:290
int get_truncate_mode() const
Definition funcimpl.h:1881
const std::vector< Vector< double, NDIM > > & get_special_points() const
Definition funcimpl.h:1006
Future< compressT > compress_spawn(const keyT &key, bool nonstandard, bool keepleaves, bool redundant1)
Invoked on node where key is local.
Definition mraimpl.h:3452
std::size_t nCoeff() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:1991
double vol_nsphere(int n, double R)
Definition funcimpl.h:5043
keyT neighbor_in_volume(const keyT &key, const keyT &disp) const
Returns key of general neighbor that resides in-volume.
Definition mraimpl.h:3424
void compress(const TreeState newstate, bool fence)
compress the wave function
Definition mraimpl.h:1541
void do_dirac_convolution(FunctionImpl< T, LDIM > *f, bool fence) const
Definition funcimpl.h:2327
Future< bool > truncate_spawn(const keyT &key, double tol)
Returns true if after truncation this node has coefficients.
Definition mraimpl.h:2695
void print_type_in_compilation_error(R &&)
Definition funcimpl.h:6394
Future< double > norm_tree_spawn(const keyT &key)
Definition mraimpl.h:1611
std::vector< keyT > local_leaf_keys() const
return the keys of the local leaf boxes
Definition mraimpl.h:570
MADNESS_ASSERT(this->is_redundant()==g.is_redundant())
void do_print_tree(const keyT &key, std::ostream &os, Level maxlevel) const
Functor for the do_print_tree method.
Definition mraimpl.h:2768
void vtransform(const std::vector< std::shared_ptr< FunctionImpl< R, NDIM > > > &vright, const Tensor< Q > &c, const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > &vleft, double tol, bool fence)
Definition funcimpl.h:3039
void unset_functor()
Definition mraimpl.h:324
void refine_spawn(const opT &op, const keyT &key)
Definition funcimpl.h:4772
void apply_1d_realspace_push(const opT &op, const FunctionImpl< R, NDIM > *f, int axis, bool fence)
Definition funcimpl.h:4058
void set_truncate_mode(int mode)
Definition funcimpl.h:1882
void do_print_plane(const std::string filename, std::vector< Tensor< double > > plotinfo, const int xaxis, const int yaxis, const coordT el2)
print the MRA structure
Definition mraimpl.h:511
std::pair< Key< NDIM >, ShallowNode< T, NDIM > > find_datum(keyT key) const
return the a std::pair<key, node>, which MUST exist
Definition mraimpl.h:997
void set_functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor1)
Definition mraimpl.h:305
std::enable_if< NDIM==FDIM >::type read_grid2(const std::string gridfile, std::shared_ptr< FunctionFunctorInterface< double, NDIM > > vnuc_functor)
read data from a grid
Definition funcimpl.h:1775
bool verify_tree_state_local() const
check that the tree state and the coeffs are consistent
Definition mraimpl.h:171
const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap() const
Definition mraimpl.h:209
Tensor< Q > fcube_for_mul(const keyT &child, const keyT &parent, const Tensor< Q > &coeff) const
Compute the function values for multiplication.
Definition funcimpl.h:2091
Timer timer_filter
Definition funcimpl.h:1093
void sock_it_to_me(const keyT &key, const RemoteReference< FutureImpl< std::pair< keyT, coeffT > > > &ref) const
Walk up the tree returning pair(key,node) for first node with coefficients.
Definition mraimpl.h:2908
void recursive_apply(opT &apply_op, const implT *fimpl, implT *rimpl, const bool fence)
traverse an existing tree and apply an operator
Definition funcimpl.h:5590
double get_thresh() const
Definition mraimpl.h:340
void trickle_down(bool fence)
sum all the contributions from all scales after applying an operator in mod-NS form
Definition mraimpl.h:1388
bool autorefine
If true, autorefine where appropriate.
Definition funcimpl.h:1017
bool halo_enabled() const
Is a neighbor halo staged on this function?
Definition funcimpl.h:1044
void set_autorefine(bool value)
Definition mraimpl.h:349
tensorT filter(const tensorT &s) const
Transform sum coefficients at level n to sums+differences at level n-1.
Definition mraimpl.h:1184
void chop_at_level(const int n, const bool fence=true)
remove all nodes with level higher than n
Definition mraimpl.h:1147
void unaryXXvalues(const FunctionImpl< Q, NDIM > *func, const opT &op, bool fence)
Definition funcimpl.h:3455
void partial_inner(const FunctionImpl< Q, LDIM > &g, const FunctionImpl< R, KDIM > &h, const std::array< int, CDIM > v1, const std::array< int, CDIM > v2)
invoked by result
Definition funcimpl.h:6410
TreeState tree_state
Definition funcimpl.h:1024
void print_tree_json(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2788
coeffT parent_to_child_NS(const keyT &child, const keyT &parent, const coeffT &coeff) const
Directly project parent NS coeffs to child NS coeffs.
Definition mraimpl.h:725
void copy_coeffs_different_world(const FunctionImpl< Q, NDIM > &other)
Copy coefficients from other funcimpl with possibly different world and on a different node.
Definition funcimpl.h:1250
void mapdim(const implT &f, const std::vector< long > &map, bool fence)
Permute the dimensions of f according to map, result on this.
Definition mraimpl.h:1089
bool is_compressed() const
Returns true if the function is compressed.
Definition mraimpl.h:252
void receive_halo(const std::vector< std::pair< keyT, coeffT > > &buf) const
Insert pushed neighbor nodes into the halo; runs as a task, concurrently with other pushes.
Definition funcimpl.h:1064
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition funcimpl.h:996
void apply(opT &op, const FunctionImpl< R, NDIM > &f, bool fence)
apply an operator on f to return this
Definition funcimpl.h:5273
Tensor< T > tensorT
Type of tensor for anything but to hold coeffs.
Definition funcimpl.h:989
void mirror(const implT &f, const std::vector< long > &mirror, bool fence)
mirror the dimensions of f according to map, result on this
Definition mraimpl.h:1098
T inner_adaptive_recursive(keyT key, const tensorT &c, const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine, T old_inner=T(0)) const
Definition funcimpl.h:7010
void store(Archive &ar)
Definition funcimpl.h:1428
void do_binary_op(const keyT &key, const Tensor< L > &left, const std::pair< keyT, Tensor< R > > &arg, const opT &op)
Functor for the binary_op method.
Definition funcimpl.h:2193
void gaxpy_ext(const FunctionImpl< L, NDIM > *left, T(*f)(const coordT &), T alpha, T beta, double tol, bool fence)
Definition funcimpl.h:7174
void accumulate_trees(FunctionImpl< Q, NDIM > &result, const R alpha, const bool fence=true) const
merge the trees of this and other, while multiplying them with the alpha or beta, resp
Definition funcimpl.h:1349
void print_stats() const
print the number of configurations per node
Definition mraimpl.h:2040
void broaden(const array_of_bools< NDIM > &is_periodic, bool fence)
Definition mraimpl.h:1337
coeffT truncate_reconstructed_op(const keyT &key, const std::vector< Future< coeffT > > &v, const double tol)
given the sum coefficients of all children, truncate or not
Definition mraimpl.h:1658
void refine_op(const opT &op, const keyT &key)
Definition funcimpl.h:4747
static Tensor< TENSOR_RESULT_TYPE(T, R) > inner_local(const std::vector< const FunctionImpl< T, NDIM > * > &left, const std::vector< const FunctionImpl< R, NDIM > * > &right, bool sym)
Definition funcimpl.h:6290
void fcube(const keyT &key, const FunctionFunctorInterface< T, NDIM > &f, const Tensor< double > &qx, tensorT &fval) const
Evaluate function at quadrature points in the specified box.
Definition mraimpl.h:2530
Timer timer_change_tensor_type
Definition funcimpl.h:1091
void forward_do_diff1(const DerivativeBase< T, NDIM > *D, const implT *f, const keyT &key, const std::pair< keyT, coeffT > &left, const std::pair< keyT, coeffT > ¢er, const std::pair< keyT, coeffT > &right)
Definition mraimpl.h:950
std::vector< Slice > child_patch(const keyT &child) const
Returns patch referring to coeffs of child in parent box.
Definition mraimpl.h:714
void print_tree_graphviz(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2841
void set_tree_state(const TreeState &state)
Definition funcimpl.h:1478
std::size_t min_nodes() const
Returns the min number of nodes on a processor.
Definition mraimpl.h:1932
void copy_coeffs_same_world(const FunctionImpl< Q, NDIM > &other, bool fence)
Copy coeffs from other into self.
Definition funcimpl.h:1303
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor
Definition funcimpl.h:1023
Timer timer_compress_svd
Definition funcimpl.h:1094
Tensor< TENSOR_RESULT_TYPE(T, R)> mul(const Tensor< T > &c1, const Tensor< R > &c2, const int npt, const keyT &key) const
multiply the values of two coefficient tensors using a custom number of grid points
Definition funcimpl.h:2166
void make_redundant(const bool fence)
convert this to redundant, i.e. have sum coefficients on all levels
Definition mraimpl.h:1569
void load(Archive &ar)
Definition funcimpl.h:1410
std::size_t max_nodes() const
Returns the max number of nodes on a processor.
Definition mraimpl.h:1923
T inner_ext_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine) const
Definition funcimpl.h:6985
coeffT upsample(const keyT &key, const coeffT &coeff) const
upsample the sum coefficients of level 1 to sum coeffs on level n+1
Definition mraimpl.h:1263
TensorArgs targs
type of tensor to be used in the FunctionNodes
Definition funcimpl.h:1019
void flo_unary_op_node_inplace(const opT &op, bool fence)
Definition funcimpl.h:2356
std::size_t size_local() const
Returns the number of coefficients in the function for each rank.
Definition mraimpl.h:1950
GenTensor< Q > values2coeffs(const keyT &key, const GenTensor< Q > &values) const
Definition funcimpl.h:2070
void plot_cube_kernel(archive::archive_ptr< Tensor< T > > ptr, const keyT &key, const coordT &plotlo, const coordT &plothi, const std::vector< long > &npt, bool eval_refine) const
Definition mraimpl.h:3527
T trace_local() const
Returns int(f(x),x) in local volume.
Definition mraimpl.h:3347
void print_grid(const std::string filename) const
Definition mraimpl.h:554
void replicate_on_hosts(bool fence=true)
Definition funcimpl.h:1219
bool get_autorefine() const
Definition mraimpl.h:346
int k
Wavelet order.
Definition funcimpl.h:1009
void vtransform_doit(const std::shared_ptr< FunctionImpl< R, NDIM > > &right, const Tensor< Q > &c, const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > &vleft, double tol)
Definition funcimpl.h:2888
MADNESS_CHECK(this->is_reconstructed())
void phi_for_mul(Level np, Translation lp, Level nc, Translation lc, Tensor< double > &phi) const
Compute the Legendre scaling functions for multiplication.
Definition mraimpl.h:3315
Future< std::pair< keyT, coeffT > > find_me(const keyT &key) const
find_me. Called by diff_bdry to get coefficients of boundary function
Definition mraimpl.h:3439
TensorType get_tensor_type() const
Definition mraimpl.h:331
void do_project_out(const coeffT &fcoeff, const std::pair< keyT, coeffT > gpair, const keyT &gkey, const Key< NDIM > &dest, const int dim) const
compute the inner product of two nodes of only some dimensions and accumulate on result
Definition funcimpl.h:7394
void remove_leaf_coefficients(const bool fence)
Definition mraimpl.h:1563
void insert_zero_down_to_initial_level(const keyT &key)
Initialize nodes to zero function at initial_level of refinement.
Definition mraimpl.h:2664
void do_diff1(const DerivativeBase< T, NDIM > *D, const implT *f, const keyT &key, const std::pair< keyT, coeffT > &left, const std::pair< keyT, coeffT > ¢er, const std::pair< keyT, coeffT > &right)
Definition mraimpl.h:961
typedef TENSOR_RESULT_TYPE(T, R) resultT
void unary_op_node_inplace(const opT &op, bool fence)
Definition funcimpl.h:2265
T inner_adaptive_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine) const
Definition funcimpl.h:6996
void do_print_tree_json(const keyT &key, std::multimap< Level, std::tuple< tranT, std::string > > &data, Level maxlevel) const
Functor for the do_print_tree_json method.
Definition mraimpl.h:2819
std::multimap< Key< FDIM >, std::list< Key< CDIM > > > recur_down_for_contraction_map(const keyT &key, const nodeT &node, const std::array< int, CDIM > &v_this, const std::array< int, CDIM > &v_other, const std::set< Key< ODIM > > &ij_other_list, const std::map< Key< CDIM >, double > &j_other_list, bool this_first, const double thresh)
make a map of all nodes that will contribute to a partial inner product
Definition funcimpl.h:6565
std::shared_ptr< FunctionImpl< T, NDIM > > pimplT
pointer to this class
Definition funcimpl.h:988
TENSOR_RESULT_TYPE(T, R) dot_local(const FunctionImpl< R
Returns the dot product ASSUMING same distribution.
void finalize_sum()
after summing up we need to do some cleanup;
Definition mraimpl.h:1878
std::enable_if< NDIM==FDIM >::type read_grid(const std::string keyfile, const std::string gridfile, std::shared_ptr< FunctionFunctorInterface< double, NDIM > > vnuc_functor)
read data from a grid
Definition funcimpl.h:1668
dcT coeffs
The coefficients.
Definition funcimpl.h:1026
bool exists_and_is_leaf(const keyT &key) const
Definition mraimpl.h:1307
static std::complex< Real > conj(const std::complex< Real > &x)
Definition funcimpl.h:6284
void make_Vphi(const opT &leaf_op, const bool fence=true)
assemble the function V*phi using V and phi given from the functor
Definition funcimpl.h:4539
void unaryXX(const FunctionImpl< Q, NDIM > *func, const opT &op, bool fence)
Definition funcimpl.h:3442
std::vector< std::pair< int, const coeffT * > > mapvecT
Type of the entry in the map returned by make_key_vec_map.
Definition funcimpl.h:6083
void project_out(FunctionImpl< T, NDIM-LDIM > *result, const FunctionImpl< T, LDIM > *gimpl, const int dim, const bool fence)
project the low-dim function g on the hi-dim function f: result(x) = <this(x,y) | g(y)>
Definition funcimpl.h:7190
void verify_tree() const
Verify tree is properly constructed ... global synchronization involved.
Definition mraimpl.h:113
void do_square_inplace2(const keyT &parent, const keyT &child, const tensorT &parent_coeff)
void gaxpy_inplace_reconstructed(const T &alpha, const FunctionImpl< Q, NDIM > &g, const R &beta, const bool fence)
Definition funcimpl.h:1317
void undo_replicate(bool fence=true)
Definition funcimpl.h:1224
void set_tensor_args(const TensorArgs &t)
Definition mraimpl.h:337
GenTensor< Q > fcube_for_mul(const keyT &child, const keyT &parent, const GenTensor< Q > &coeff) const
Compute the function values for multiplication.
Definition funcimpl.h:2119
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:5874
std::size_t real_size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:1968
bool exists_and_has_children(const keyT &key) const
Definition mraimpl.h:1302
void sum_down_spawn(const keyT &key, const coeffT &s)
is this the same as trickle_down() ?
Definition mraimpl.h:894
void multi_to_multi_op_values(const opT &op, const std::vector< implT * > &vin, std::vector< implT * > &vout, const bool fence=true)
Inplace operate on many functions (impl's) with an operator within a certain box.
Definition funcimpl.h:3010
long box_interior[1000]
Definition funcimpl.h:3487
std::atomic< ConcurrentHashMap< keyT, coeffT > * > neighbor_halo_
Neighbor coefficients pushed here by whoever owns them; null until something stages.
Definition funcimpl.h:1037
keyT neighbor(const keyT &key, const keyT &disp, const array_of_bools< NDIM > &is_periodic) const
Returns key of general neighbor enforcing BC.
Definition mraimpl.h:3409
GenTensor< Q > NS_fcube_for_mul(const keyT &child, const keyT &parent, const GenTensor< Q > &coeff, const bool s_only) const
Compute the function values for multiplication.
Definition funcimpl.h:1989
rangeT range(coeffs.begin(), coeffs.end())
void norm_tree(bool fence)
compute for each FunctionNode the norm of the function inside that node
Definition mraimpl.h:1588
void gaxpy_inplace(const T &alpha, const FunctionImpl< Q, NDIM > &other, const R &beta, bool fence)
Inplace general bilinear operation.
Definition funcimpl.h:1397
const Tensor< double > cell
the size of the root cell in each dimension, unchangeable
Definition funcimpl.h:1014
bool has_leaves() const
Definition mraimpl.h:300
bool verify_parents_and_children() const
check that parents and children are consistent
Definition mraimpl.h:121
void apply_source_driven(opT &op, const FunctionImpl< R, NDIM > &f, bool fence)
similar to apply, but for low rank coeffs
Definition funcimpl.h:5415
std::size_t halo_size() const
How many neighbor nodes are staged on this rank; zero if no halo.
Definition funcimpl.h:1056
void distribute(std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > newmap) const
Definition funcimpl.h:1231
int get_special_level() const
Definition funcimpl.h:1005
void reconstruct_op(const keyT &key, const coeffT &s, const bool accumulate_NS=true)
Definition mraimpl.h:2163
tensorT gaxpy_ext_node(keyT key, Tensor< L > lc, T(*f)(const coordT &), T alpha, T beta) const
Definition funcimpl.h:7063
const coeffT parent_to_child(const coeffT &s, const keyT &parent, const keyT &child) const
Directly project parent coeffs to child coeffs.
Definition mraimpl.h:3330
WorldObject< FunctionImpl< T, NDIM > > woT
Base class world object type.
Definition funcimpl.h:984
void undo_redundant(const bool fence)
convert this from redundant to standard reconstructed form
Definition mraimpl.h:1579
GenTensor< T > coeffT
Type of tensor used to hold coeffs.
Definition funcimpl.h:993
const keyT & key0() const
Returns cdata.key0.
Definition mraimpl.h:406
double finalize_apply()
after apply we need to do some cleanup;
Definition mraimpl.h:1835
bool leaves_only
Definition funcimpl.h:5879
friend hashT hash_value(const FunctionImpl< T, NDIM > *pimpl)
Hash a pointer to FunctionImpl.
Definition funcimpl.h:7496
const dcT & get_coeffs() const
Definition mraimpl.h:355
FunctionImpl(World &world, const FunctionImpl< Q, NDIM > &other, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool dozero)
Copy constructor.
Definition funcimpl.h:1180
compressT make_redundant_op(const keyT &key, const std::vector< Future< compressT > > &v)
similar to compress_op, but insert only the sum coefficients in the tree
Definition mraimpl.h:1780
T inner_ext_node(keyT key, tensorT c, const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f) const
Return the inner product with an external function on a specified function node.
Definition funcimpl.h:6862
double norm2sq_local() const
Returns the square of the local norm ... no comms.
Definition mraimpl.h:1887
const FunctionCommonData< T, NDIM > & get_cdata() const
Definition mraimpl.h:361
void sum_down(bool fence)
After 1d push operator must sum coeffs down the tree to restore correct scaling function coefficients...
Definition mraimpl.h:940
T inner_ext_recursive(keyT key, tensorT c, const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine, T old_inner=T(0)) const
Definition funcimpl.h:6879
bool noautorefine(const keyT &key, const tensorT &t) const
Always returns false (for when autorefine is not wanted)
Definition mraimpl.h:877
double truncate_tol(double tol, const keyT &key) const
Returns the truncation threshold according to truncate_method.
Definition mraimpl.h:667
void flo_unary_op_node_inplace(const opT &op, bool fence) const
Definition funcimpl.h:2366
bool autorefine_square_test(const keyT &key, const nodeT &t) const
Returns true if this block of coeffs needs autorefining.
Definition mraimpl.h:883
void erase(const Level &max_level)
truncate tree at a certain level
Definition mraimpl.h:757
void mulXX(const FunctionImpl< L, NDIM > *left, const FunctionImpl< R, NDIM > *right, double tol, bool fence)
Definition funcimpl.h:3414
std::pair< coeffT, std::pair< double, double > > compressT
s coefficients plus the (snorm_tree, dnorm_tree) pair propagated up by compress
Definition funcimpl.h:4834
void reconstruct(bool fence)
reconstruct this tree – respects fence
Definition mraimpl.h:1509
void multiply(const implT *f, const FunctionImpl< T, LDIM > *g, const int particle)
multiply f (a pair function of NDIM) with an orbital g (LDIM=NDIM/2)
Definition funcimpl.h:3831
coeffT assemble_coefficients(const keyT &key, const coeffT &coeff_ket, const coeffT &vpotential1, const coeffT &vpotential2, const tensorT &veri) const
given several coefficient tensors, assemble a result tensor
Definition mraimpl.h:1045
static void tnorm(const tensorT &t, double *lo, double *hi)
Computes norm of low/high-order polyn. coeffs for autorefinement test.
Definition mraimpl.h:3206
std::pair< bool, T > eval_local_only(const Vector< double, NDIM > &xin, Level maxlevel)
Evaluate function only if point is local returning (true,value); otherwise return (false,...
Definition mraimpl.h:3001
bool halo_probe(const keyT &key, coeffT &out) const
Look up a staged neighbor; on a hit copy its coefficients, which are empty for an interior node.
Definition funcimpl.h:1082
std::size_t max_depth() const
Returns the maximum depth of the tree ... collective ... global sum/broadcast.
Definition mraimpl.h:1915
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:1960
void reduce_rank(const double thresh, bool fence)
reduce the rank of the coefficients tensors
Definition mraimpl.h:1139
TreeState get_tree_state() const
Definition funcimpl.h:1482
void merge_trees(const T alpha, const FunctionImpl< Q, NDIM > &other, const R beta, const bool fence=true)
merge the trees of this and other, while multiplying them with the alpha or beta, resp
Definition funcimpl.h:1337
const Tensor< double > & get_cell() const
return the simulation cell
Definition funcimpl.h:1501
void halo_clear() const
Discard the neighbor halo, freeing the staged coefficients.
Definition funcimpl.h:1051
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor()
Definition mraimpl.h:312
double do_apply_directed_screening(const opT *op, const keyT &key, const coeffT &coeff, const bool &do_kernel)
apply an operator on the coeffs c (at node key)
Definition funcimpl.h:5306
tensorT unfilter(const tensorT &s) const
Transform sums+differences at level n to sum coefficients at level n+1.
Definition mraimpl.h:1213
int get_initial_level() const
getter
Definition funcimpl.h:1004
Tensor< T > eval_plot_cube(const coordT &plotlo, const coordT &plothi, const std::vector< long > &npt, const bool eval_refine=false) const
Definition mraimpl.h:3619
virtual ~FunctionImpl()
Definition funcimpl.h:1211
Vector< Translation, NDIM > tranT
Type of array holding translation.
Definition funcimpl.h:990
void change_tree_state(const TreeState finalstate, bool fence=true)
change the tree state of this function, might or might not respect fence!
Definition mraimpl.h:1441
Future< coeffT > truncate_reconstructed_spawn(const keyT &key, const double tol)
truncate using a tree in reconstructed form
Definition mraimpl.h:1634
GenTensor< Q > coeffs2values(const keyT &key, const GenTensor< Q > &coeff) const
Definition funcimpl.h:1937
FunctionImpl(const FunctionFactory< T, NDIM > &factory)
Initialize function impl from data in factory.
Definition funcimpl.h:1100
void map_and_mirror(const implT &f, const std::vector< long > &map, const std::vector< long > &mirror, bool fence)
map and mirror the translation index and the coefficients, result on this
Definition mraimpl.h:1108
Timer timer_lr_result
Definition funcimpl.h:1092
void gaxpy(T alpha, const FunctionImpl< L, NDIM > &left, T beta, const FunctionImpl< R, NDIM > &right, bool fence)
Invoked by result to perform result += alpha*left+beta*right in wavelet basis.
Definition funcimpl.h:2216
void truncate(double tol, bool fence)
Truncate according to the threshold with optional global fence.
Definition mraimpl.h:390
void do_mul(const keyT &key, const Tensor< L > &left, const std::pair< keyT, Tensor< R > > &arg)
Functor for the mul method.
Definition funcimpl.h:2141
void copy_remote_coeffs_from_pid(const ProcessID pid, const FunctionImpl< Q, NDIM > &other)
Definition funcimpl.h:1276
void project_out2(const FunctionImpl< T, LDIM+NDIM > *f, const FunctionImpl< T, LDIM > *g, const int dim)
project the low-dim function g on the hi-dim function f: this(x) = <f(x,y) | g(y)>
Definition funcimpl.h:7336
double do_apply_kernel2(const opT *op, const Tensor< R > &c, const do_op_args< OPDIM > &args, const TensorArgs &apply_targs)
same as do_apply_kernel, but use full rank tensors as input and low rank tensors as output
Definition funcimpl.h:4975
static Tensor< TENSOR_RESULT_TYPE(T, R)> dot_local(const std::vector< const FunctionImpl< T, NDIM > * > &left, const std::vector< const FunctionImpl< R, NDIM > * > &right, bool sym)
Definition funcimpl.h:6342
Tensor< Q > coeffs2values(const keyT &key, const Tensor< Q > &coeff) const
Definition funcimpl.h:2063
Tensor< Q > values2coeffs(const keyT &key, const Tensor< Q > &values) const
Definition funcimpl.h:2077
void multi_to_multi_op_values_doit(const keyT &key, const opT &op, const std::vector< implT * > &vin, std::vector< implT * > &vout)
Inplace operate on many functions (impl's) with an operator within a certain box.
Definition funcimpl.h:2987
bool is_reconstructed() const
Returns true if the function is compressed.
Definition mraimpl.h:258
void replicate(bool fence=true)
Definition funcimpl.h:1215
double norm_tree_op(const keyT &key, const std::vector< Future< double > > &v)
Definition mraimpl.h:1596
void reset_timer()
Definition mraimpl.h:378
void refine_to_common_level(const std::vector< FunctionImpl< T, NDIM > * > &v, const std::vector< tensorT > &c, const keyT key)
Refine multiple functions down to the same finest level.
Definition mraimpl.h:787
int get_k() const
Definition mraimpl.h:352
void dirac_convolution_op(const keyT &key, const nodeT &node, FunctionImpl< T, LDIM > *f) const
The operator.
Definition funcimpl.h:2282
FunctionImpl< T, NDIM > implT
Type of this class (implementation)
Definition funcimpl.h:987
void eval(const Vector< double, NDIM > &xin, const keyT &keyin, const typename Future< T >::remote_refT &ref)
Evaluate the function at a point in simulation coordinates.
Definition mraimpl.h:2957
bool truncate_op(const keyT &key, double tol, const std::vector< Future< bool > > &v)
Definition mraimpl.h:2731
void zero_norm_tree()
Definition mraimpl.h:1325
std::size_t max_local_depth() const
Returns the maximum local depth of the tree ... no communications.
Definition mraimpl.h:1901
tensorT project(const keyT &key) const
Definition mraimpl.h:2876
double thresh
Screening threshold.
Definition funcimpl.h:1010
double check_symmetry_local() const
Returns some asymmetry measure ... no comms.
Definition mraimpl.h:773
Future< double > get_norm_tree_recursive(const keyT &key) const
Definition mraimpl.h:2897
bool is_redundant_after_merge() const
Returns true if the function is redundant_after_merge.
Definition mraimpl.h:270
void mulXXvec(const FunctionImpl< L, NDIM > *left, const std::vector< const FunctionImpl< R, NDIM > * > &vright, const std::vector< FunctionImpl< T, NDIM > * > &vresult, double tol, bool fence)
Definition funcimpl.h:3471
Key< NDIM > keyT
Type of key.
Definition funcimpl.h:991
friend hashT hash_value(const std::shared_ptr< FunctionImpl< T, NDIM > > impl)
Hash a shared_ptr to FunctionImpl.
Definition funcimpl.h:7506
std::vector< Vector< double, NDIM > > special_points
special points for further refinement (needed for composite functions or multiplication)
Definition funcimpl.h:1013
bool truncate_on_project
If true projection inserts at level n-1 not n.
Definition funcimpl.h:1018
AtomicInt small
Definition funcimpl.h:1096
static void do_dot_localX(const typename mapT::iterator lstart, const typename mapT::iterator lend, typename FunctionImpl< R, NDIM >::mapT *rmap_ptr, const bool sym, Tensor< TENSOR_RESULT_TYPE(T, R)> *result_ptr, Mutex *mutex)
Definition funcimpl.h:6239
bool is_on_demand() const
Definition mraimpl.h:285
double err_box(const keyT &key, const nodeT &node, const opT &func, int npt, const Tensor< double > &qx, const Tensor< double > &quad_phit, const Tensor< double > &quad_phiw) const
Returns the square of the error norm in the box labeled by key.
Definition funcimpl.h:5703
void accumulate_timer(const double time) const
Definition mraimpl.h:364
void trickle_down_op(const keyT &key, const coeffT &s)
sum all the contributions from all scales after applying an operator in mod-NS form
Definition mraimpl.h:1399
static void do_inner_localX(const typename mapT::iterator lstart, const typename mapT::iterator lend, typename FunctionImpl< R, NDIM >::mapT *rmap_ptr, const bool sym, Tensor< TENSOR_RESULT_TYPE(T, R) > *result_ptr, Mutex *mutex)
Definition funcimpl.h:6158
void mulXXveca(const keyT &key, const FunctionImpl< L, NDIM > *left, const Tensor< L > &lcin, const std::vector< const FunctionImpl< R, NDIM > * > vrightin, const std::vector< Tensor< R > > &vrcin, const std::vector< FunctionImpl< T, NDIM > * > vresultin, double tol)
Definition funcimpl.h:3074
void set_thresh(double value)
Definition mraimpl.h:343
Tensor< double > print_plane_local(const int xaxis, const int yaxis, const coordT &el2)
collect the data for a plot of the MRA structure locally on each node
Definition mraimpl.h:435
void sock_it_to_me_too(const keyT &key, const RemoteReference< FutureImpl< std::pair< keyT, coeffT > > > &ref) const
Definition mraimpl.h:2935
void broaden_op(const keyT &key, const std::vector< Future< bool > > &v)
Definition mraimpl.h:1313
void print_plane(const std::string filename, const int xaxis, const int yaxis, const coordT &el2)
Print a plane ("xy", "xz", or "yz") containing the point x to file.
Definition mraimpl.h:415
void print_tree(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2759
bool has_summable_coefficients() const
Returns true if summing over the local nodes yields the function.
Definition mraimpl.h:295
void project_refine_op(const keyT &key, bool do_refine, const std::vector< Vector< double, NDIM > > &specialpts)
Definition mraimpl.h:2542
void scale_oop(const Q q, const FunctionImpl< F, NDIM > &f, bool fence)
Out-of-place scale by a constant.
Definition funcimpl.h:7471
T typeT
Definition funcimpl.h:986
std::size_t tree_size() const
Returns the size of the tree structure of the function ... collective global sum.
Definition mraimpl.h:1941
ConcurrentHashMap< keyT, mapvecT > mapT
Type of the map returned by make_key_vec_map.
Definition funcimpl.h:6086
void add_scalar_inplace(T t, bool fence)
Adds a constant to the function. Local operation, optional fence.
Definition mraimpl.h:2623
void forward_traverse(const coeff_opT &coeff_op, const apply_opT &apply_op, const keyT &key) const
traverse a non-existing tree
Definition funcimpl.h:3925
tensorT downsample(const keyT &key, const std::vector< Future< coeffT > > &v) const
downsample the sum coefficients of level n+1 to sum coeffs on level n
Definition mraimpl.h:1233
void abs_square_inplace(bool fence)
Definition mraimpl.h:3310
FunctionImpl(const FunctionImpl< Q, NDIM > &other, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool dozero)
Copy constructor.
Definition funcimpl.h:1166
void refine(const opT &op, bool fence)
Definition funcimpl.h:4785
static mapT make_key_vec_map(const std::vector< const FunctionImpl< T, NDIM > * > &v)
Returns map of union of local keys to vector of indexes of functions containing that key.
Definition funcimpl.h:6107
void put_in_box(ProcessID from, long nl, long ni) const
Definition mraimpl.h:842
void unary_op_value_inplace(const opT &op, bool fence)
Definition funcimpl.h:3054
std::pair< const keyT, nodeT > datumT
Type of entry in container.
Definition funcimpl.h:995
Timer timer_accumulate
Definition funcimpl.h:1090
TensorArgs get_tensor_args() const
Definition mraimpl.h:334
void unaryXXa(const keyT &key, const FunctionImpl< Q, NDIM > *func, const opT &op)
Definition funcimpl.h:3389
void make_Vphi_only(const opT &leaf_op, FunctionImpl< T, NDIM > *ket, FunctionImpl< T, LDIM > *v1, FunctionImpl< T, LDIM > *v2, FunctionImpl< T, LDIM > *p1, FunctionImpl< T, LDIM > *p2, FunctionImpl< T, NDIM > *eri, const bool fence=true)
assemble the function V*phi using V and phi given from the functor
Definition funcimpl.h:4600
void average(const implT &rhs)
take the average of two functions, similar to: this=0.5*(this+rhs)
Definition mraimpl.h:1120
void recursive_apply(opT &apply_op, const FunctionImpl< T, LDIM > *fimpl, const FunctionImpl< T, LDIM > *gimpl, const bool fence)
traverse a non-existing tree, make its coeffs and apply an operator
Definition funcimpl.h:5456
void diff(const DerivativeBase< T, NDIM > *D, const implT *f, bool fence)
Definition mraimpl.h:973
void square_inplace(bool fence)
Pointwise squaring of function with optional global fence.
Definition mraimpl.h:3299
void remove_internal_coefficients(const bool fence)
Definition mraimpl.h:1558
void compute_snorm_and_dnorm(bool fence=true)
compute norm of s and d coefficients for all nodes
Definition mraimpl.h:1163
std::vector< unsigned char > serialize_remote_coeffs()
invoked by copy_remote_coeffs_from_pid to serialize local coeffs
Definition funcimpl.h:1288
long box_leaf[1000]
Definition funcimpl.h:3486
void standard(bool fence)
Changes non-standard compressed form to standard compressed form.
Definition mraimpl.h:1822
void multiop_values_doit(const keyT &key, const opT &op, const std::vector< implT * > &v)
Definition funcimpl.h:2945
bool is_nonstandard_with_leaves() const
Definition mraimpl.h:280
GenTensor< Q > values2NScoeffs(const keyT &key, const GenTensor< Q > &values) const
convert function values of the a child generation directly to NS coeffs
Definition funcimpl.h:2038
int truncate_mode
0=default=(|d|<thresh), 1=(|d|<thresh/2^n), 2=(|d|<thresh/4^n);
Definition funcimpl.h:1016
void multiop_values(const opT &op, const std::vector< implT * > &v)
Definition funcimpl.h:2962
GenTensor< Q > NScoeffs2values(const keyT &key, const GenTensor< Q > &coeff, const bool s_only) const
convert S or NS coeffs to values on a 2k grid of the children
Definition funcimpl.h:1953
static std::enable_if_t< std::is_floating_point_v< Real >, Real > conj(const Real x)
Definition funcimpl.h:6279
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition funcimpl.h:136
FunctionNode< Q, NDIM > convert() const
Copy with possible type conversion of coefficients, copying all other state.
Definition funcimpl.h:204
GenTensor< T > coeffT
Definition funcimpl.h:138
bool has_coeff() const
Returns true if there are coefficients in this node.
Definition funcimpl.h:210
void recompute_snorm_and_dnorm(const FunctionCommonData< T, NDIM > &cdata)
Definition funcimpl.h:367
FunctionNode(const coeffT &coeff, bool has_children=false)
Constructor from given coefficients with optional children.
Definition funcimpl.h:166
FunctionNode()
Default constructor makes node without coeff or children.
Definition funcimpl.h:156
void serialize(Archive &ar)
Definition funcimpl.h:490
double _dnorm_tree
norm of the difference coefficients summed up the tree
Definition funcimpl.h:147
void consolidate_buffer(const TensorArgs &args)
Definition funcimpl.h:476
double get_dnorm() const
return the precomputed norm of the (virtual) d coefficients
Definition funcimpl.h:336
size_t size() const
Returns the number of coefficients in this node.
Definition funcimpl.h:252
void set_has_children_recursive(const typename FunctionNode< T, NDIM >::dcT &c, const Key< NDIM > &key)
Sets has_children attribute to true recurring up to ensure connected.
Definition funcimpl.h:269
FunctionNode< T, NDIM > & operator=(const FunctionNode< T, NDIM > &other)
Definition funcimpl.h:186
FunctionNode(const coeffT &coeff, double norm_tree, double dnorm_tree, double snorm, double dnorm, bool has_children)
Definition funcimpl.h:176
double snorm
norm of the s coefficients
Definition funcimpl.h:151
void clear_coeff()
Clears the coefficients (has_coeff() will subsequently return false)
Definition funcimpl.h:305
Tensor< T > tensorT
Definition funcimpl.h:139
coeffT buffer
The coefficients, if any.
Definition funcimpl.h:149
T trace_conj(const FunctionNode< T, NDIM > &rhs) const
Definition funcimpl.h:485
void scale(Q a)
Scale the coefficients of this node.
Definition funcimpl.h:311
bool is_leaf() const
Returns true if this does not have children.
Definition funcimpl.h:223
void set_has_children(bool flag)
Sets has_children attribute to value of flag.
Definition funcimpl.h:264
void scale_norms(const double a)
Multiply the stored norms by a, for coefficients scaled by some q with |q| = a.
Definition funcimpl.h:360
void accumulate(const coeffT &t, const typename FunctionNode< T, NDIM >::dcT &c, const Key< NDIM > &key, const TensorArgs &args)
Accumulate inplace and if necessary connect node to parent.
Definition funcimpl.h:448
double get_norm_tree() const
Gets the value of norm_tree.
Definition funcimpl.h:326
bool _has_children
True if there are children.
Definition funcimpl.h:148
void set_snorm(const double sn)
set the precomputed norm of the (virtual) s coefficients
Definition funcimpl.h:341
coeffT _coeffs
The coefficients, if any.
Definition funcimpl.h:145
void accumulate2(const tensorT &t, const typename FunctionNode< T, NDIM >::dcT &c, const Key< NDIM > &key)
Accumulate inplace and if necessary connect node to parent.
Definition funcimpl.h:415
void reduceRank(const double &eps)
reduces the rank of the coefficients (if applicable)
Definition funcimpl.h:259
WorldContainer< Key< NDIM >, FunctionNode< T, NDIM > > dcT
Definition funcimpl.h:154
void gaxpy_inplace(const T &alpha, const FunctionNode< Q, NDIM > &other, const R &beta)
General bi-linear operation — this = this*alpha + other*beta.
Definition funcimpl.h:397
double get_dnorm_tree() const
Gets the value of dnorm_tree.
Definition funcimpl.h:331
double _norm_tree
After norm_tree will contain norm of sum coefficients summed up tree.
Definition funcimpl.h:146
void set_is_leaf(bool flag)
Sets has_children attribute to value of !flag.
Definition funcimpl.h:290
void print_json(std::ostream &s) const
Definition funcimpl.h:499
double get_snorm() const
get the precomputed norm of the (virtual) s coefficients
Definition funcimpl.h:351
void set_dnorm_tree(double dnorm_tree)
Sets the value of dnorm_tree.
Definition funcimpl.h:321
const coeffT & coeff() const
Returns a const reference to the tensor containing the coeffs.
Definition funcimpl.h:247
FunctionNode(const coeffT &coeff, double norm_tree, bool has_children)
Definition funcimpl.h:171
bool has_children() const
Returns true if this node has children.
Definition funcimpl.h:217
void set_coeff(const coeffT &coeffs)
Takes a shallow copy of the coeff — same as this->coeff()=coeff.
Definition funcimpl.h:295
void set_dnorm(const double dn)
set the precomputed norm of the (virtual) d coefficients
Definition funcimpl.h:346
double dnorm
norm of the d coefficients, also defined if there are no d coefficients
Definition funcimpl.h:150
bool is_invalid() const
Returns true if this node is invalid (no coeffs and no children)
Definition funcimpl.h:229
FunctionNode(const FunctionNode< T, NDIM > &other)
Definition funcimpl.h:180
coeffT & coeff()
Returns a non-const reference to the tensor containing the coeffs.
Definition funcimpl.h:237
void set_norm_tree(double norm_tree)
Sets the value of norm_tree.
Definition funcimpl.h:316
Implements the functionality of futures.
Definition future.h:75
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
Definition lowranktensor.h:59
bool is_of_tensortype(const TensorType &tt) const
Definition gentensor.h:225
GenTensor convert(const TensorArgs &) const
Definition gentensor.h:198
long dim(const int i) const
return the number of entries in dimension i
Definition lowranktensor.h:391
Tensor< T > full_tensor_copy() const
Definition gentensor.h:206
long ndim() const
Definition lowranktensor.h:386
constexpr bool is_full_tensor() const
Definition gentensor.h:224
void add_SVD(const GenTensor< T > &rhs, const double &)
Definition gentensor.h:235
void reduce_rank(const double &)
Definition gentensor.h:217
void normalize()
Definition gentensor.h:218
GenTensor< T > & emul(const GenTensor< T > &other)
Inplace multiply by corresponding elements of argument Tensor.
Definition lowranktensor.h:637
float_scalar_type normf() const
Definition lowranktensor.h:406
double svd_normf() const
Definition gentensor.h:213
long rank() const
Definition gentensor.h:212
const Tensor< T > & full_tensor() const
Definition gentensor.h:200
long size() const
Definition lowranktensor.h:488
SVDTensor< T > & get_svdtensor()
Definition gentensor.h:228
TensorType tensor_type() const
Definition gentensor.h:221
bool has_data() const
Definition gentensor.h:210
Tensor< T > reconstruct_tensor() const
Definition gentensor.h:199
GenTensor & gaxpy(const T alpha, const GenTensor &other, const T beta)
Definition lowranktensor.h:586
bool is_assigned() const
Definition gentensor.h:209
IsSupported< TensorTypeData< Q >, GenTensor< T > & >::type scale(Q fac)
Inplace multiplication by scalar of supported type (legacy name)
Definition lowranktensor.h:426
constexpr bool is_svd_tensor() const
Definition gentensor.h:222
Definition worldhashmap.h:330
iterator for hash
Definition worldhashmap.h:188
Iterates in lexical order thru all children of a key.
Definition key.h:548
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
Key< NDIM+LDIM > merge_with(const Key< LDIM > &rhs) const
merge with other key (ie concatenate), use level of rhs, not of this
Definition key.h:487
Level level() const
Definition key.h:169
bool is_valid() const
Checks if a key is valid.
Definition key.h:124
hashT hash() const
Definition key.h:158
Key< NDIM-VDIM > extract_complement_key(const std::array< int, VDIM > &v) const
extract a new key with the Translations complementary to the ones indicated in the v array
Definition key.h:473
Key< VDIM > extract_key(const std::array< int, VDIM > &v) const
extract a new key with the Translations indicated in the v array
Definition key.h:465
Key parent(int generation=1) const
Returns the key of the parent.
Definition key.h:290
const Vector< Translation, NDIM > & translation() const
Definition key.h:174
bool is_child_of(const Key &key) const
Definition key.h:301
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:424
A pmap that locates children on odd levels with their even level parents.
Definition funcimpl.h:105
LevelPmap(World &world)
Definition funcimpl.h:111
const int nproc
Definition funcimpl.h:107
LevelPmap()
Definition funcimpl.h:109
ProcessID owner(const keyT &key) const
Find the owner of a given key.
Definition funcimpl.h:114
Mutex using pthread mutex operations.
Definition worldmutex.h:150
void unlock() const
Free a mutex owned by this thread.
Definition worldmutex.h:184
void lock() const
Acquire the mutex waiting if necessary.
Definition worldmutex.h:174
Range, vaguely a la Intel TBB, to encapsulate a random-access, STL-like start and end iterator with c...
Definition range.h:64
iteratorT iterator
Alias for the iterator type.
Definition range.h:71
Simple structure used to manage references/pointers to remote instances.
Definition worldref.h:394
Definition SVDTensor.h:42
A simple process map.
Definition funcimpl.h:86
SimplePmap(World &world)
Definition funcimpl.h:92
const int nproc
Definition funcimpl.h:88
const ProcessID me
Definition funcimpl.h:89
ProcessID owner(const keyT &key) const
Maps key to processor.
Definition funcimpl.h:95
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
static TaskAttributes hipri()
Definition thread.h:457
Traits class to specify support of numeric types.
Definition type_data.h:56
A tensor is a multidimensional array.
Definition tensor.h:318
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition tensor.h:1727
Tensor< T > & gaxpy(T alpha, const Tensor< T > &other, T beta)
Inplace generalized saxpy ... this = this*alpha + other*beta.
Definition tensor.h:1806
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition tensor.h:1385
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1841
Tensor< T > mapdim(const std::vector< long > &map)
Returns new view/tensor permuting the dimensions.
Definition tensor.h:1625
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type scale(Q x)
Inplace multiplication by scalar of supported type (legacy name)
Definition tensor.h:687
Tensor< T > & emul(const Tensor< T > &t)
Inplace multiply by corresponding elements of argument Tensor.
Definition tensor.h:1800
Tensor< T > fusedim(long i)
Returns new view/tensor fusing contiguous dimensions i and i+1.
Definition tensor.h:1588
Tensor< T > flat()
Returns new view/tensor rehshaping to flat (1-d) tensor.
Definition tensor.h:1556
Definition function_common_data.h:169
void accumulate(const double time) const
accumulate timer
Definition function_common_data.h:183
A simple, fixed dimension vector.
Definition vector.h:64
Iterator for distributed container wraps the local iterator.
Definition worlddc.h:414
Makes a distributed container with specified attributes.
Definition worlddc.h:1299
void process_pending()
Process pending messages.
Definition worlddc.h:1645
bool find(accessor &acc, const keyT &key)
Write access to LOCAL value by key. Returns true if found, false otherwise (always false for remote).
Definition worlddc.h:1466
bool probe(const keyT &key) const
Returns true if local data is immediately available (no communication)
Definition worlddc.h:1503
iterator begin()
Returns an iterator to the beginning of the local data (no communication)
Definition worlddc.h:1549
bool is_replicated() const
Definition worlddc.h:1399
ProcessID owner(const keyT &key) const
Returns processor that logically owns key (no communication)
Definition worlddc.h:1513
void replicate(bool fence=true)
Definition worlddc.h:1424
void erase(const keyT &key)
Erases entry from container (non-blocking comm if remote)
Definition worlddc.h:1584
void replace(const pairT &datum)
Inserts/replaces key+value pair (non-blocking communication if key not local)
Definition worlddc.h:1453
iterator end()
Returns an iterator past the end of the local data (no communication)
Definition worlddc.h:1563
const std::shared_ptr< WorldDCPmapInterface< keyT > > & get_pmap() const
Returns shared pointer to the process mapping.
Definition worlddc.h:1621
bool insert(accessor &acc, const keyT &key)
Write access to LOCAL value by key. Returns true if inserted, false if already exists (throws if remo...
Definition worlddc.h:1480
bool is_distributed() const
Definition worlddc.h:1395
std::size_t size() const
Returns the number of local entries (no communication)
Definition worlddc.h:1614
Future< REMFUTURE(MEMFUN_RETURNT(memfunT))> task(const keyT &key, memfunT memfun, const TaskAttributes &attr=TaskAttributes())
Adds task "resultT memfun()" in process owning item (non-blocking comm if remote)
Definition worlddc.h:1905
bool is_local(const keyT &key) const
Returns true if the key maps to the local processor (no communication)
Definition worlddc.h:1520
bool is_host_replicated() const
Definition worlddc.h:1403
Future< MEMFUN_RETURNT(memfunT)> send(const keyT &key, memfunT memfun)
Sends message "resultT memfun()" to item (non-blocking comm if remote)
Definition worlddc.h:1662
void replicate_on_hosts(bool fence=true)
replicates this WorldContainer on all hosts (one PID per host)
Definition worlddc.h:1430
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
Implements most parts of a globally addressable object (via unique ID).
Definition world_object.h:491
void process_pending()
To be called from derived constructor to process pending messages.
Definition world_object.h:787
ProcessID me
Rank of self.
Definition world_object.h:514
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn) const
Definition world_object.h:858
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)().
Definition world_object.h:1132
Future< bool > for_each(const rangeT &range, const opT &op)
Apply op(item) on all items in range.
Definition world_task_queue.h:572
void add(TaskInterface *t)
Add a new local task, taking ownership of the pointer.
Definition world_task_queue.h:466
Future< resultT > reduce(const rangeT &range, const opT &op)
Reduce op(item) for all items in range using op(sum,op(item)).
Definition world_task_queue.h:527
A parallel world class.
Definition world.h:134
static World * world_from_id(std::uint64_t id)
Convert a World ID to a World pointer.
Definition world.h:516
WorldTaskQueue & taskq
Task queue.
Definition world.h:215
std::vector< uniqueidT > get_object_ids() const
Returns a vector of all unique IDs in this World.
Definition world.h:492
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
static std::vector< unsigned long > get_world_ids()
return a vector containing all world ids
Definition world.h:500
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:354
unsigned long id() const
Definition world.h:324
WorldGopInterface & gop
Global operations.
Definition world.h:216
std::optional< T * > ptr_from_id(uniqueidT id) const
Look up a local pointer from a world-wide unique ID.
Definition world.h:440
ProcessID random_proc()
Returns a random process number; that is, an integer in [0,world.size()).
Definition world.h:615
Wraps an archive around an STL vector for output.
Definition vector_archive.h:55
Wrapper for an opaque pointer for serialization purposes.
Definition archive.h:851
syntactic sugar for std::array<bool, N>
Definition array_of_bools.h:19
Class for unique global IDs.
Definition uniqueid.h:53
unsigned long get_obj_id() const
Access the object ID.
Definition uniqueid.h:97
unsigned long get_world_id() const
Access the World ID.
Definition uniqueid.h:90
static const double R
Definition csqrt.cc:46
double(* f1)(const coord_3d &)
Definition derivatives.cc:55
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
static double lo
Definition dirac-hatom.cc:23
@ upper
Definition dirac-hatom.cc:15
Provides FunctionDefaults and utilities for coordinate transformation.
archive_array< unsigned char > wrap_opaque(const T *, unsigned int)
Factory function to wrap a pointer to contiguous data as an opaque (uchar) archive_array.
Definition archive.h:926
Tensor< typename Tensor< T >::scalar_type > arg(const Tensor< T > &t)
Return a new tensor holding the argument of each element of t (complex types only)
Definition tensor.h:2757
Tensor< TENSOR_RESULT_TYPE(T, Q) > & fast_transform(const Tensor< T > &t, const Tensor< Q > &c, Tensor< TENSOR_RESULT_TYPE(T, Q) > &result, Tensor< TENSOR_RESULT_TYPE(T, Q) > &workspace)
Restricted but heavily optimized form of transform()
Definition tensor.h:2460
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.
static double pow(const double *a, const double *b)
Definition lda.h:74
#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.
constexpr double pi
Mathematical constant .
Definition constants.h:48
MemFuncWrapper< objT *, memfnT, typename result_of< memfnT >::type > wrap_mem_fn(objT &obj, memfnT memfn)
Create a member function wrapper (MemFuncWrapper) from an object and a member function pointer.
Definition mem_func_wrapper.h:251
void combine_hash(hashT &seed, hashT hash)
Internal use only.
Definition worldhash.h:249
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
std::ostream & operator<<(std::ostream &os, const particle< PDIM > &p)
Definition lowrankfunction.h:401
static const char * filename
Definition legendre.cc:96
static const std::vector< Slice > ___
Entire dimension.
Definition slice.h:124
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition timers.h:128
GenTensor< TENSOR_RESULT_TYPE(R, Q)> general_transform(const GenTensor< R > &t, const Tensor< Q > c[])
Definition gentensor.h:274
void finalize()
Call this once at the very end of your main program instead of MPI_Finalize().
Definition world.cc:246
void norm_tree(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Makes the norm tree for all functions in a vector.
Definition vmra.h:1345
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition vmra.h:758
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
@ redundant
s coeffs everywhere
Definition funcdefaults.h:66
static Tensor< double > weights[max_npt+1]
Definition legendre.cc:99
int64_t Translation
Definition key.h:58
Key< NDIM > displacement(const Key< NDIM > &source, const Key< NDIM > &target)
given a source and a target, return the displacement in translation
Definition key.h:533
static const Slice _(0,-1, 1)
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
int Level
Definition key.h:59
std::enable_if< std::is_base_of< ProjectorBase, projT >::value, OuterProjector< projT, projQ > >::type outer(const projT &p0, const projQ &p1)
Definition projector.h:457
static constexpr double NORM_TREE_UNCOMPUTED
Definition funcimpl.h:127
int RandomValue< int >()
Random int.
Definition ran.cc:250
bool has_data(const PropertyResults &p)
Definition Results.h:413
static constexpr double MUL_SCREENING_SAFETY
Definition funcimpl.h:132
static double pop(std::vector< double > &v)
Definition SCF.cc:117
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition mraimpl.h:2217
TensorType
low rank representations of tensors (see gentensor.h)
Definition gentensor.h:120
@ TT_2D
Definition gentensor.h:120
@ TT_FULL
Definition gentensor.h:120
NDIM & f
Definition mra.h:2668
void error(const char *msg)
Definition world.cc:147
NDIM const Function< R, NDIM > & g
Definition mra.h:2668
std::size_t hashT
The hash value type.
Definition worldhash.h:146
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
void change_tensor_type(GenTensor< T > &, const TensorArgs &targs)
change representation to targ.tt
Definition gentensor.h:284
static const int kmax
Definition twoscale.cc:52
GenTensor< TENSOR_RESULT_TYPE(R, Q)> transform_dir(const GenTensor< R > &t, const Tensor< Q > &c, const int axis)
Definition lowranktensor.h:1106
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
void scale(World &world, std::vector< Function< T, NDIM > > &v, const std::vector< Q > &factors, bool fence=true)
Scales inplace a vector of functions by distinct values.
Definition vmra.h:874
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
void mxmT(long dimi, long dimj, long dimk, T *MADNESS_RESTRICT c, const T *a, const T *b)
Matrix += Matrix * matrix transpose ... MKL interface version.
Definition mxm.h:191
bool same_displacement_shell(double a, double b)
Definition displacements.h:60
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 int MAXK
The maximum wavelet order presently supported.
Definition funcdefaults.h:55
static long abs(long a)
Definition tensor.h:219
const double cc
Definition navstokes_cosines.cc:107
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
Defines simple templates for printing to std::cout "a la Python".
double Q(double a)
Definition relops.cc:20
static const double c
Definition relops.cc:10
static const double L
Definition rk.cc:46
static const double thresh
Definition rk.cc:45
Definition test_ar.cc:204
Key parent() const
Definition test_tree.cc:68
hashT hash() const
Definition test_dc.cc:54
Definition test_ccpairfunction.cc:22
given a ket and the 1- and 2-electron potentials, construct the function V phi
Definition funcimpl.h:4260
implT * result
where to construct Vphi, no need to track parents
Definition funcimpl.h:4268
bool have_v2() const
Definition funcimpl.h:4277
ctL iav1
Definition funcimpl.h:4272
Vphi_op_NS(implT *result, const opT &leaf_op, const ctT &iaket, const ctL &iap1, const ctL &iap2, const ctL &iav1, const ctL &iav2, const implT *eri)
Definition funcimpl.h:4286
ctL iap1
Definition funcimpl.h:4271
bool have_v1() const
Definition funcimpl.h:4276
std::pair< bool, coeffT > continue_recursion(const std::vector< bool > child_is_leaf, const tensorT &coeffs, const keyT &key) const
loop over all children and either insert their sum coeffs or continue the recursion
Definition funcimpl.h:4352
opT leaf_op
deciding if a given FunctionNode will be a leaf node
Definition funcimpl.h:4269
std::pair< coeffT, double > make_sum_coeffs(const keyT &key) const
make the sum coeffs for key
Definition funcimpl.h:4445
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:4265
ctL iap2
the particles 1 and 2 (exclusive with ket)
Definition funcimpl.h:4271
bool have_ket() const
Definition funcimpl.h:4275
const implT * eri
2-particle potential, must be on-demand
Definition funcimpl.h:4273
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:4266
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
make and insert the coefficients into result's tree
Definition funcimpl.h:4297
void serialize(const Archive &ar)
serialize this (needed for use in recursive_op)
Definition funcimpl.h:4526
Vphi_op_NS< opT, LDIM > this_type
Definition funcimpl.h:4264
ctT iaket
the ket of a pair function (exclusive with p1, p2)
Definition funcimpl.h:4270
double compute_error_from_inaccurate_refinement(const keyT &key, const tensorT &ceri) const
the error is computed from the d coefficients of the constituent functions
Definition funcimpl.h:4398
void accumulate_into_result(const Key< NDIM > &key, const coeffT &coeff) const
Definition funcimpl.h:4280
this_type make_child(const keyT &child) const
Definition funcimpl.h:4497
tensorT eri_coeffs(const keyT &key) const
Definition funcimpl.h:4378
ctL iav2
potentials for particles 1 and 2
Definition funcimpl.h:4272
bool have_eri() const
Definition funcimpl.h:4278
this_type forward_ctor(implT *result1, const opT &leaf_op, const ctT &iaket1, const ctL &iap11, const ctL &iap21, const ctL &iav11, const ctL &iav21, const implT *eri1)
Definition funcimpl.h:4519
Vphi_op_NS()
Definition funcimpl.h:4285
Future< this_type > activate() const
Definition funcimpl.h:4508
bool randomize() const
Definition funcimpl.h:4262
add two functions f and g: result=alpha * f + beta * g
Definition funcimpl.h:3770
bool randomize() const
Definition funcimpl.h:3775
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition funcimpl.h:3805
add_op(const ctT &f, const ctT &g, const double alpha, const double beta)
Definition funcimpl.h:3783
ctT f
tracking coeffs of first and second addend
Definition funcimpl.h:3778
double alpha
prefactor for f, g
Definition funcimpl.h:3780
add_op this_type
Definition funcimpl.h:3773
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:3772
void serialize(const Archive &ar)
Definition funcimpl.h:3817
ctT g
Definition funcimpl.h:3778
std::pair< bool, coeffT > operator()(const keyT &key) const
if we are at the bottom of the trees, return the sum of the coeffs
Definition funcimpl.h:3787
double beta
Definition funcimpl.h:3780
this_type make_child(const keyT &child) const
Definition funcimpl.h:3800
this_type forward_ctor(const ctT &f1, const ctT &g1, const double alpha, const double beta)
taskq-compatible ctor
Definition funcimpl.h:3813
Definition funcimpl.h:3356
opT op
Definition funcimpl.h:3359
opT::resultT resultT
Definition funcimpl.h:3357
Tensor< resultT > operator()(const Key< NDIM > &key, const Tensor< Q > &t) const
Definition funcimpl.h:3366
coeff_value_adaptor(const FunctionImpl< Q, NDIM > *impl_func, const opT &op)
Definition funcimpl.h:3362
const FunctionImpl< Q, NDIM > * impl_func
Definition funcimpl.h:3358
coeff_value_adaptor()=default
void serialize(Archive &ar)
Definition funcimpl.h:3375
merge the coefficent boxes of this into result's tree
Definition funcimpl.h:2570
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:2571
do_accumulate_trees()=default
void serialize(const Archive &ar)
Definition funcimpl.h:2588
FunctionImpl< Q, NDIM > * result
Definition funcimpl.h:2572
do_accumulate_trees(FunctionImpl< Q, NDIM > &result, const T alpha)
Definition funcimpl.h:2575
T alpha
Definition funcimpl.h:2573
bool operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition funcimpl.h:2579
"put" this on g
Definition funcimpl.h:2781
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:2782
void serialize(const Archive &ar)
Definition funcimpl.h:2810
implT * g
Definition funcimpl.h:2784
do_average()
Definition funcimpl.h:2786
bool operator()(typename rangeT::iterator &it) const
iterator it points to this
Definition funcimpl.h:2790
do_average(implT &g)
Definition funcimpl.h:2787
change representation of nodes' coeffs to low rank, optional fence
Definition funcimpl.h:2814
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2815
void serialize(const Archive &ar)
Definition funcimpl.h:2838
TensorArgs targs
Definition funcimpl.h:2818
do_change_tensor_type(const TensorArgs &targs, implT &g)
Definition funcimpl.h:2824
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2827
implT * f
Definition funcimpl.h:2819
do_change_tensor_type()=default
check symmetry wrt particle exchange
Definition funcimpl.h:2487
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:2488
double operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition funcimpl.h:2494
do_check_symmetry_local()
Definition funcimpl.h:2490
void serialize(const Archive &ar)
Definition funcimpl.h:2557
double operator()(double a, double b) const
Definition funcimpl.h:2553
do_check_symmetry_local(const implT &f)
Definition funcimpl.h:2491
const implT * f
Definition funcimpl.h:2489
compute the norm of the wavelet coefficients
Definition funcimpl.h:4667
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:4668
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:4674
do_compute_snorm_and_dnorm(const FunctionCommonData< T, NDIM > &cdata)
Definition funcimpl.h:4671
const FunctionCommonData< T, NDIM > & cdata
Definition funcimpl.h:4670
Definition funcimpl.h:2841
TensorArgs targs
Definition funcimpl.h:2845
do_consolidate_buffer()=default
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2850
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2842
do_consolidate_buffer(const TensorArgs &targs)
Definition funcimpl.h:2849
void serialize(const Archive &ar)
Definition funcimpl.h:2854
Definition funcimpl.h:1600
double operator()(double val) const
Definition funcimpl.h:1606
double limit
Definition funcimpl.h:1601
do_convert_to_color(const double limit, const bool log)
Definition funcimpl.h:1605
bool log
Definition funcimpl.h:1602
do_convert_to_color()=default
static double lower()
Definition funcimpl.h:1603
compute the inner product of this range with other
Definition funcimpl.h:6024
do_dot_local(const FunctionImpl< R, NDIM > *other, const bool leaves_only)
Definition funcimpl.h:6029
bool leaves_only
Definition funcimpl.h:6026
typedef TENSOR_RESULT_TYPE(T, R) resultT
resultT operator()(resultT a, resultT b) const
Definition funcimpl.h:6057
const FunctionImpl< R, NDIM > * other
Definition funcimpl.h:6025
void serialize(const Archive &ar)
Definition funcimpl.h:6061
resultT operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:6031
functor for the gaxpy_inplace method
Definition funcimpl.h:1369
FunctionImpl< T, NDIM > * f
prefactor for current function impl
Definition funcimpl.h:1371
do_gaxpy_inplace(FunctionImpl< T, NDIM > *f, T alpha, R beta)
Definition funcimpl.h:1375
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:1376
R beta
prefactor for other function impl
Definition funcimpl.h:1373
void serialize(Archive &ar)
Definition funcimpl.h:1384
Range< typename FunctionImpl< Q, NDIM >::dcT::const_iterator > rangeT
Definition funcimpl.h:1370
T alpha
the current function impl
Definition funcimpl.h:1372
do_gaxpy_inplace()=default
Definition funcimpl.h:6950
const bool do_leaves
start with leaf nodes instead of initial_level
Definition funcimpl.h:6954
T operator()(T a, T b) const
Definition funcimpl.h:6972
do_inner_ext_local_ffi(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const implT *impl, const bool leaf_refine, const bool do_leaves)
Definition funcimpl.h:6956
void serialize(const Archive &ar)
Definition funcimpl.h:6976
const bool leaf_refine
Definition funcimpl.h:6953
const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > fref
Definition funcimpl.h:6951
T operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:6960
const implT * impl
Definition funcimpl.h:6952
compute the inner product of this range with other
Definition funcimpl.h:5887
const FunctionImpl< T, NDIM > * bra
Definition funcimpl.h:5888
void serialize(const Archive &ar)
Definition funcimpl.h:6003
const FunctionImpl< R, NDIM > * ket
Definition funcimpl.h:5889
typedef TENSOR_RESULT_TYPE(T, R) resultT
bool leaves_only
Definition funcimpl.h:5890
do_inner_local_on_demand(const FunctionImpl< T, NDIM > *bra, const FunctionImpl< R, NDIM > *ket, const bool leaves_only=true)
Definition funcimpl.h:5893
resultT operator()(resultT a, resultT b) const
Definition funcimpl.h:5999
resultT operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:5896
compute the inner product of this range with other
Definition funcimpl.h:5826
resultT operator()(resultT a, resultT b) const
Definition funcimpl.h:5859
bool leaves_only
Definition funcimpl.h:5828
void serialize(const Archive &ar)
Definition funcimpl.h:5863
do_inner_local(const FunctionImpl< R, NDIM > *other, const bool leaves_only)
Definition funcimpl.h:5831
const FunctionImpl< R, NDIM > * other
Definition funcimpl.h:5827
resultT operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:5833
typedef TENSOR_RESULT_TYPE(T, R) resultT
keep only the sum coefficients in each node
Definition funcimpl.h:2441
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2442
do_keep_sum_coeffs(implT *impl)
constructor need impl for cdata
Definition funcimpl.h:2446
implT * impl
Definition funcimpl.h:2443
void serialize(const Archive &ar)
Definition funcimpl.h:2455
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2448
mirror dimensions of this, write result on f
Definition funcimpl.h:2715
do_map_and_mirror()=default
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2725
implT * f
Definition funcimpl.h:2719
std::vector< long > mirror
Definition funcimpl.h:2718
void serialize(const Archive &ar)
Definition funcimpl.h:2772
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2716
std::vector< long > map
Definition funcimpl.h:2718
do_map_and_mirror(const std::vector< long > map, const std::vector< long > mirror, implT &f)
Definition funcimpl.h:2722
map this on f
Definition funcimpl.h:2635
do_mapdim(const std::vector< long > map, implT &f)
Definition funcimpl.h:2642
void serialize(const Archive &ar)
Definition funcimpl.h:2658
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2636
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2644
std::vector< long > map
Definition funcimpl.h:2638
do_mapdim()
Definition funcimpl.h:2641
implT * f
Definition funcimpl.h:2639
merge the coefficient boxes of this into other's tree
Definition funcimpl.h:2599
bool operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition funcimpl.h:2609
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:2600
FunctionImpl< Q, NDIM > * other
Definition funcimpl.h:2601
do_merge_trees(const T alpha, const R beta, FunctionImpl< Q, NDIM > &other)
Definition funcimpl.h:2605
T alpha
Definition funcimpl.h:2602
do_merge_trees()
Definition funcimpl.h:2604
R beta
Definition funcimpl.h:2603
void serialize(const Archive &ar)
Definition funcimpl.h:2628
mirror dimensions of this, write result on f
Definition funcimpl.h:2665
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2674
implT * f
Definition funcimpl.h:2669
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2666
do_mirror()
Definition funcimpl.h:2671
do_mirror(const std::vector< long > mirror, implT &f)
Definition funcimpl.h:2672
void serialize(const Archive &ar)
Definition funcimpl.h:2708
std::vector< long > mirror
Definition funcimpl.h:2668
Definition funcimpl.h:5787
do_norm2sq_local()=default
double operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:5794
bool leaves_only
skip the internal nodes, cf. has_coefficients_on_leaves_only()
Definition funcimpl.h:5789
do_norm2sq_local(bool leaves_only)
Definition funcimpl.h:5792
void serialize(const Archive &ar)
Definition funcimpl.h:5810
double operator()(double a, double b) const
Definition funcimpl.h:5806
laziness
Definition funcimpl.h:4927
void serialize(Archive &ar)
Definition funcimpl.h:4936
Key< OPDIM > d
Definition funcimpl.h:4928
Key< OPDIM > key
Definition funcimpl.h:4928
keyT dest
Definition funcimpl.h:4929
double fac
Definition funcimpl.h:4930
do_op_args(const Key< OPDIM > &key, const Key< OPDIM > &d, const keyT &dest, double tol, double fac, double cnorm)
Definition funcimpl.h:4933
double cnorm
Definition funcimpl.h:4930
double tol
Definition funcimpl.h:4930
reduce the rank of the nodes, optional fence
Definition funcimpl.h:2461
do_reduce_rank(const TensorArgs &targs)
Definition funcimpl.h:2469
TensorArgs args
Definition funcimpl.h:2465
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2475
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2462
do_reduce_rank(const double &thresh)
Definition funcimpl.h:2470
void serialize(const Archive &ar)
Definition funcimpl.h:2481
Changes non-standard compressed form to standard compressed form.
Definition funcimpl.h:4891
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:4902
do_standard(implT *impl)
Definition funcimpl.h:4899
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:4892
void serialize(const Archive &ar)
Definition funcimpl.h:4919
implT * impl
Definition funcimpl.h:4895
given an NS tree resulting from a convolution, truncate leafs if appropriate
Definition funcimpl.h:2382
void serialize(const Archive &ar)
Definition funcimpl.h:2402
const implT * f
Definition funcimpl.h:2384
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2388
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2383
do_truncate_NS_leafs(const implT *f)
Definition funcimpl.h:2386
Definition funcimpl.h:2860
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2861
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2865
implT * impl
Definition funcimpl.h:2862
void serialize(const Archive &ar)
Definition funcimpl.h:2883
opT op
Definition funcimpl.h:2863
do_unary_op_value_inplace(implT *impl, const opT &op)
Definition funcimpl.h:2864
Hartree product of two LDIM functions to yield a NDIM = 2*LDIM function.
Definition funcimpl.h:3853
this_type forward_ctor(implT *result1, const ctL &p11, const ctL &p22, const leaf_opT &leaf_op)
Definition funcimpl.h:3909
bool randomize() const
Definition funcimpl.h:3854
void serialize(const Archive &ar)
Definition funcimpl.h:3913
hartree_op(implT *result, const ctL &p11, const ctL &p22, const leaf_opT &leaf_op)
Definition funcimpl.h:3865
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:3857
ctL p2
tracking coeffs of the two lo-dim functions
Definition funcimpl.h:3860
leaf_opT leaf_op
determine if a given node will be a leaf node
Definition funcimpl.h:3861
hartree_op()
Definition funcimpl.h:3864
implT * result
where to construct the pair function
Definition funcimpl.h:3859
hartree_op< LDIM, leaf_opT > this_type
Definition funcimpl.h:3856
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
Definition funcimpl.h:3870
ctL p1
Definition funcimpl.h:3860
this_type make_child(const keyT &child) const
Definition funcimpl.h:3893
Future< this_type > activate() const
Definition funcimpl.h:3902
perform this multiplication: h(1,2) = f(1,2) * g(1)
Definition funcimpl.h:3661
multiply_op()
Definition funcimpl.h:3673
ctL g
Definition funcimpl.h:3670
Future< this_type > activate() const
Definition funcimpl.h:3752
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:3665
implT * h
the result function h(1,2) = f(1,2) * g(1)
Definition funcimpl.h:3668
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:3664
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
apply this on a FunctionNode of f and g of Key key
Definition funcimpl.h:3700
this_type forward_ctor(implT *h1, const ctT &f1, const ctL &g1, const int particle)
Definition funcimpl.h:3759
static bool randomize()
Definition funcimpl.h:3663
int particle
if g is g(1) or g(2)
Definition funcimpl.h:3671
ctT f
Definition funcimpl.h:3669
multiply_op< LDIM > this_type
Definition funcimpl.h:3666
multiply_op(implT *h1, const ctT &f1, const ctL &g1, const int particle1)
Definition funcimpl.h:3675
bool screen(const coeffT &fcoeff, const coeffT &gcoeff, const keyT &key) const
return true if this will be a leaf node
Definition funcimpl.h:3681
this_type make_child(const keyT &child) const
Definition funcimpl.h:3742
void serialize(const Archive &ar)
Definition funcimpl.h:3763
Definition funcimpl.h:4139
coeffT val_lhs
Definition funcimpl.h:4140
double lo
Definition funcimpl.h:4143
double lo1
Definition funcimpl.h:4143
long oversampling
Definition funcimpl.h:4141
pointwise_multiplier()=default
double error
Definition funcimpl.h:4142
tensorT operator()(const Key< NDIM > key, const tensorT &coeff_rhs)
multiply values of rhs and lhs, result on rhs, rhs and lhs are of the same dimensions
Definition funcimpl.h:4158
coeffT coeff_lhs
Definition funcimpl.h:4140
void serialize(const Archive &ar)
Definition funcimpl.h:4246
double lo2
Definition funcimpl.h:4143
double hi1
Definition funcimpl.h:4143
pointwise_multiplier(const Key< NDIM > key, const coeffT &clhs)
Definition funcimpl.h:4146
coeffT operator()(const Key< NDIM > key, const tensorT &coeff_rhs, const int particle)
multiply values of rhs and lhs, result on rhs, rhs and lhs are of differnet dimensions
Definition funcimpl.h:4203
double hi2
Definition funcimpl.h:4143
double hi
Definition funcimpl.h:4143
project the low-dim function g on the hi-dim function f: result(x) = <f(x,y) | g(y)>
Definition funcimpl.h:7216
project_out_op(const implT *fimpl, implL1 *result, const ctL &iag, const int dim)
Definition funcimpl.h:7231
ctL iag
the low dim function g
Definition funcimpl.h:7226
FunctionImpl< T, NDIM-LDIM > implL1
Definition funcimpl.h:7221
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition funcimpl.h:7310
std::pair< bool, coeffT > argT
Definition funcimpl.h:7222
const implT * fimpl
the hi dim function f
Definition funcimpl.h:7224
this_type forward_ctor(const implT *fimpl1, implL1 *result1, const ctL &iag1, const int dim1)
taskq-compatible ctor
Definition funcimpl.h:7317
this_type make_child(const keyT &child) const
Definition funcimpl.h:7301
project_out_op< LDIM > this_type
Definition funcimpl.h:7219
implL1 * result
the low dim result function
Definition funcimpl.h:7225
Future< argT > operator()(const Key< NDIM > &key) const
do the actual contraction
Definition funcimpl.h:7238
void serialize(const Archive &ar)
Definition funcimpl.h:7321
project_out_op(const project_out_op &other)
Definition funcimpl.h:7233
int dim
0: project 0..LDIM-1, 1: project LDIM..NDIM-1
Definition funcimpl.h:7227
bool randomize() const
Definition funcimpl.h:7217
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:7220
recursive part of recursive_apply
Definition funcimpl.h:5614
ctT iaf
Definition funcimpl.h:5622
recursive_apply_op2< opT > this_type
Definition funcimpl.h:5617
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition funcimpl.h:5677
const opT * apply_op
need this for randomization
Definition funcimpl.h:5623
bool randomize() const
Definition funcimpl.h:5615
recursive_apply_op2(const recursive_apply_op2 &other)
Definition funcimpl.h:5630
void serialize(const Archive &ar)
Definition funcimpl.h:5693
argT finalize(const double kernel_norm, const keyT &key, const coeffT &coeff, const implT *r) const
sole purpose is to wait for the kernel norm, wrap it and send it back to caller
Definition funcimpl.h:5663
this_type make_child(const keyT &child) const
Definition funcimpl.h:5672
recursive_apply_op2()=default
recursive_apply_op2(implT *result, const ctT &iaf, const opT *apply_op)
Definition funcimpl.h:5627
std::pair< bool, coeffT > argT
Definition funcimpl.h:5619
implT * result
Definition funcimpl.h:5621
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:5618
argT operator()(const Key< NDIM > &key) const
send off the application of the operator
Definition funcimpl.h:5639
this_type forward_ctor(implT *result1, const ctT &iaf1, const opT *apply_op1)
taskq-compatible ctor
Definition funcimpl.h:5689
recursive part of recursive_apply
Definition funcimpl.h:5483
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
make the NS-coefficients and send off the application of the operator
Definition funcimpl.h:5508
this_type forward_ctor(implT *r, const CoeffTracker< T, LDIM > &f1, const CoeffTracker< T, LDIM > &g1, const opT *apply_op1)
Definition funcimpl.h:5573
opT * apply_op
Definition funcimpl.h:5491
recursive_apply_op(const recursive_apply_op &other)
Definition funcimpl.h:5501
recursive_apply_op< opT, LDIM > this_type
Definition funcimpl.h:5486
Future< this_type > activate() const
Definition funcimpl.h:5566
bool randomize() const
Definition funcimpl.h:5484
implT * result
Definition funcimpl.h:5488
CoeffTracker< T, LDIM > iaf
Definition funcimpl.h:5489
void serialize(const Archive &ar)
Definition funcimpl.h:5578
recursive_apply_op()=default
std::pair< bool, coeffT > finalize(const double kernel_norm, const keyT &key, const coeffT &coeff) const
sole purpose is to wait for the kernel norm, wrap it and send it back to caller
Definition funcimpl.h:5548
recursive_apply_op(implT *result, const CoeffTracker< T, LDIM > &iaf, const CoeffTracker< T, LDIM > &iag, const opT *apply_op)
Definition funcimpl.h:5495
this_type make_child(const keyT &child) const
Definition funcimpl.h:5557
CoeffTracker< T, LDIM > iag
Definition funcimpl.h:5490
remove all coefficients of internal nodes
Definition funcimpl.h:2407
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2408
remove_internal_coeffs()=default
constructor need impl for cdata
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2413
void serialize(const Archive &ar)
Definition funcimpl.h:2419
remove all coefficients of leaf nodes
Definition funcimpl.h:2424
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2430
remove_leaf_coeffs()=default
constructor need impl for cdata
void serialize(const Archive &ar)
Definition funcimpl.h:2435
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2425
Definition funcimpl.h:4739
void serialize(Archive &ar)
Definition funcimpl.h:4743
bool operator()(const implT *f, const keyT &key, const nodeT &t) const
Definition funcimpl.h:4740
shallow-copy, pared-down version of FunctionNode, for special purpose only
Definition funcimpl.h:784
coeffT & coeff()
Definition funcimpl.h:798
GenTensor< T > coeffT
Definition funcimpl.h:785
bool is_leaf() const
Definition funcimpl.h:800
void serialize(Archive &ar)
Definition funcimpl.h:802
ShallowNode(const ShallowNode< T, NDIM > &node)
Definition funcimpl.h:793
ShallowNode(const FunctionNode< T, NDIM > &node)
Definition funcimpl.h:790
bool has_children() const
Definition funcimpl.h:799
ShallowNode()
Definition funcimpl.h:789
bool _has_children
Definition funcimpl.h:787
double dnorm
Definition funcimpl.h:788
const coeffT & coeff() const
Definition funcimpl.h:797
coeffT _coeffs
Definition funcimpl.h:786
Definition displacements.h:390
TensorArgs holds the arguments for creating a LowRankTensor.
Definition gentensor.h:134
double thresh
Definition gentensor.h:135
TensorType tt
Definition gentensor.h:136
const uniqueidT & id() const
Returns the globally unique object ID.
Definition world_object.h:424
inserts/accumulates coefficients into impl's tree
Definition funcimpl.h:751
FunctionImpl< T, NDIM > * impl
Definition funcimpl.h:755
FunctionNode< T, NDIM > nodeT
Definition funcimpl.h:753
accumulate_op(const accumulate_op &other)=default
void operator()(const Key< NDIM > &key, const coeffT &coeff, const bool &is_leaf) const
Definition funcimpl.h:759
void serialize(Archive &ar)
Definition funcimpl.h:763
GenTensor< T > coeffT
Definition funcimpl.h:752
accumulate_op(FunctionImpl< T, NDIM > *f)
Definition funcimpl.h:757
static void load(const Archive &ar, FunctionImpl< T, NDIM > *&ptr)
Definition funcimpl.h:7545
static void load(const Archive &ar, const FunctionImpl< T, NDIM > *&ptr)
Definition funcimpl.h:7514
static void load(const Archive &ar, std::shared_ptr< FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:7596
static void load(const Archive &ar, std::shared_ptr< const FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:7580
Default load of an object via serialize(ar, t).
Definition archive.h:667
static void load(const A &ar, const U &t)
Load an object.
Definition archive.h:679
static void store(const Archive &ar, FunctionImpl< T, NDIM > *const &ptr)
Definition funcimpl.h:7570
static void store(const Archive &ar, const FunctionImpl< T, NDIM > *const &ptr)
Definition funcimpl.h:7536
static void store(const Archive &ar, const std::shared_ptr< FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:7605
static void store(const Archive &ar, const std::shared_ptr< const FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:7589
Default store of an object via serialize(ar, t).
Definition archive.h:612
static std::enable_if_t< is_output_archive_v< A > &&!std::is_function< U >::value &&(has_member_serialize_v< U, A >||has_nonmember_serialize_v< U, A >||has_freestanding_serialize_v< U, A >||has_freestanding_default_serialize_v< U, A >), void > store(const A &ar, const U &t)
Definition archive.h:622
Definition funcimpl.h:645
void serialize(Archive &ar)
Definition funcimpl.h:709
const opT * op
Definition funcimpl.h:652
hartree_convolute_leaf_op(const implT *f, const implL *g, const opT *op)
Definition funcimpl.h:656
bool operator()(const Key< NDIM > &key) const
no pre-determination
Definition funcimpl.h:660
hartree_convolute_leaf_op()=default
bool operator()(const Key< NDIM > &key, const Tensor< T > &fcoeff, const Tensor< T > &gcoeff) const
post-determination: true if f is a leaf and the result is well-represented
Definition funcimpl.h:673
const implL * g
Definition funcimpl.h:651
const FunctionImpl< T, NDIM > * f
Definition funcimpl.h:650
FunctionImpl< T, LDIM > implL
Definition funcimpl.h:648
bool do_error_leaf_op() const
Definition funcimpl.h:653
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:647
bool operator()(const Key< NDIM > &key, const GenTensor< T > &coeff) const
no post-determination
Definition funcimpl.h:663
returns true if the result of a hartree_product is a leaf node (compute norm & error)
Definition funcimpl.h:535
hartree_leaf_op()=default
bool do_error_leaf_op() const
Definition funcimpl.h:540
const FunctionImpl< T, NDIM > * f
Definition funcimpl.h:538
hartree_leaf_op(const implT *f, const long &k)
Definition funcimpl.h:543
long k
Definition funcimpl.h:539
void serialize(Archive &ar)
Definition funcimpl.h:591
bool operator()(const Key< NDIM > &key, const GenTensor< T > &coeff) const
no post-determination
Definition funcimpl.h:549
bool operator()(const Key< NDIM > &key, const Tensor< T > &fcoeff, const Tensor< T > &gcoeff) const
post-determination: true if f is a leaf and the result is well-represented
Definition funcimpl.h:559
bool operator()(const Key< NDIM > &key) const
no pre-determination
Definition funcimpl.h:546
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:537
insert/replaces the coefficients into the function
Definition funcimpl.h:727
insert_op()
Definition funcimpl.h:734
implT * impl
Definition funcimpl.h:733
void operator()(const keyT &key, const coeffT &coeff, const bool &is_leaf) const
Definition funcimpl.h:737
FunctionNode< T, NDIM > nodeT
Definition funcimpl.h:731
Key< NDIM > keyT
Definition funcimpl.h:729
insert_op(const insert_op &other)
Definition funcimpl.h:736
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:728
GenTensor< T > coeffT
Definition funcimpl.h:730
insert_op(implT *f)
Definition funcimpl.h:735
void serialize(Archive &ar)
Definition funcimpl.h:741
Definition funcimpl.h:715
bool operator()(const Key< NDIM > &key, const GenTensor< T > &fcoeff, const GenTensor< T > &gcoeff) const
Definition funcimpl.h:717
void serialize(Archive &ar)
Definition funcimpl.h:721
void operator()(const Key< NDIM > &key, const GenTensor< T > &coeff, const bool &is_leaf) const
Definition funcimpl.h:716
Definition funcimpl.h:599
bool operator()(const Key< NDIM > &key, const double &cnorm) const
post-determination: return true if operator and coefficient norms are small
Definition funcimpl.h:620
void serialize(Archive &ar)
Definition funcimpl.h:635
const implT * f
the source or result function, needed for truncate_tol
Definition funcimpl.h:603
op_leaf_op(const opT *op, const implT *f)
Definition funcimpl.h:607
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:600
const opT * op
the convolution operator
Definition funcimpl.h:602
bool do_error_leaf_op() const
Definition funcimpl.h:604
bool operator()(const Key< NDIM > &key) const
pre-determination: we can't know if this will be a leaf node before we got the final coeffs
Definition funcimpl.h:610
bool operator()(const Key< NDIM > &key, const GenTensor< T > &coeff) const
post-determination: return true if operator and coefficient norms are small
Definition funcimpl.h:613
Definition lowrankfunction.h:336
Definition funcimpl.h:771
void serialize(Archive &ar)
Definition funcimpl.h:778
bool operator()(const Key< NDIM > &key, const T &t, const R &r) const
Definition funcimpl.h:777
bool operator()(const Key< NDIM > &key, const T &t) const
Definition funcimpl.h:774
int np
Definition tdse1d.cc:165
static const double s0
Definition tdse4.cc:83
Defines and implements most of Tensor.
#define ITERATOR(t, exp)
Definition tensor_macros.h:249
#define IND
Definition tensor_macros.h:204
#define TERNARY_OPTIMIZED_ITERATOR(X, x, Y, y, Z, z, exp)
Definition tensor_macros.h:719
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 double g1(const Vector< double, D > &r)
Definition test_state_archive_hdf5.cpp:34
static const double alpha
Definition testcosine.cc:10
const double offset
Definition testfuns.cc:143
constexpr std::size_t NDIM
Definition testgconv.cc:54
double h(const coord_1d &r)
Definition testgconv.cc:175
std::size_t axis
Definition testpdiff.cc:59
double source(const coordT &r)
Definition testperiodic.cc:48
#define TENSOR_RESULT_TYPE(L, R)
This macro simplifies access to TensorResultType.
Definition type_data.h:205
#define PROFILE_MEMBER_FUNC(classname)
Definition worldprofile.h:210
#define PROFILE_BLOCK(name)
Definition worldprofile.h:208
int ProcessID
Used to clearly identify process number/rank.
Definition worldtypes.h:43