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>
73 template<
typename T, std::
size_t NDIM, std::
size_t MDIM>
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))
471 if (
c.is_local(parent))
483 }
else if (
buffer.has_data()) {
490 return this->_coeffs.trace_conj((rhs.
_coeffs));
493 template <
typename Archive>
504 s <<
"\"has_coeff\":" << this->
has_coeff()
505 <<
",\"has_children\":" << this->
has_children() <<
",\"norm\":";
512 s <<
norm <<
",\"norm_tree\":" << nt <<
",\"snorm\":"
515 if (this->
coeff().is_assigned())
516 s <<
",\"dim\":" << this->
coeff().
dim(0);
521 template <
typename T, std::
size_t NDIM>
531 s <<
norm <<
", norm_tree = " << nt <<
", dnorm_tree = " << dnt <<
", s/dnorm =" << node.
get_snorm() <<
" " << node.
get_dnorm() <<
"), rank="<< node.
coeff().
rank()<<
")";
538 template<
typename T,
size_t NDIM>
565 if (key.
level()<2)
return false;
567 std::vector<Slice>
s0(
NDIM/2,s);
569 const double tol=
f->get_thresh();
570 const double thresh=
f->truncate_tol(tol, key)*0.3;
572 const double fnorm=fcoeff.
normf();
573 const double gnorm=gcoeff.
normf();
576 const double norm=fnorm*gnorm;
580 const double sfnorm=fcoeff(
s0).
normf();
581 const double sgnorm=gcoeff(
s0).
normf();
585 const double ferror=sqrt(
std::abs(fnorm*fnorm-sfnorm*sfnorm));
586 const double gerror=sqrt(
std::abs(gnorm*gnorm-sgnorm*sgnorm));
589 const double error=fnorm*gerror + ferror*gnorm + ferror*gerror;
595 template <
typename Archive>
void serialize (Archive& ar) {
605 template<
typename T,
size_t NDIM>
625 const std::vector<
Tensor<T>>& gcoeffs)
const {
628 if (key.
level()<2)
return false;
630 std::vector<Slice>
s0(
NDIM/2,s);
632 const double tol=
f->get_thresh();
633 const double thresh=
f->truncate_tol(tol, key)*0.3;
636 double total_norm=0.0;
637 double total_error=0.0;
638 for (
size_t i=0; i<fcoeffs.size(); ++i) {
639 const double fnorm=fcoeffs[i].normf();
640 const double gnorm=gcoeffs[i].normf();
642 total_norm += fnorm*gnorm;
644 const double sfnorm=fcoeffs[i](
s0).normf();
645 const double sgnorm=gcoeffs[i](
s0).normf();
646 const double ferror=sqrt(
std::abs(fnorm*fnorm-sfnorm*sfnorm));
647 const double gerror=sqrt(
std::abs(gnorm*gnorm-sgnorm*sgnorm));
648 total_error += fnorm*gerror + ferror*gnorm + ferror*gerror;
651 if (total_norm <
thresh)
return true;
652 if (total_error <
thresh)
return true;
656 template <
typename Archive>
void serialize (Archive& ar) {
663 template<
typename T,
size_t NDIM,
typename opT>
679 if (key.
level()<2)
return false;
680 const double cnorm=coeff.
normf();
686 if (key.
level()<2)
return false;
689 const opkeyT
source=
op->get_source_key(key);
691 const double thresh=
f->truncate_tol(
f->get_thresh(),key);
693 const double norm=opnorm*cnorm;
698 template <
typename Archive>
void serialize (Archive& ar) {
707 template<
typename T,
size_t NDIM,
size_t LDIM,
typename opT>
739 if (key.
level()<2)
return false;
741 const double tol=
f->get_thresh();
742 const double thresh=
f->truncate_tol(tol, key);
744 const double fnorm=fcoeff.
normf();
745 const double gnorm=gcoeff.
normf();
748 const double sfnorm=fcoeff(
g->get_cdata().s0).
normf();
749 const double sgnorm=gcoeff(
g->get_cdata().s0).
normf();
752 const double norm=fnorm*gnorm;
756 const double ferror=sqrt(fnorm*fnorm-sfnorm*sfnorm);
757 const double gerror=sqrt(gnorm*gnorm-sgnorm*sgnorm);
760 const double error=fnorm*gerror + ferror*gnorm + ferror*gerror;
764 const double opnorm =
op->norm_bound(key.
level(), key);
765 const double final_norm=opnorm*sfnorm*sgnorm;
766 if (final_norm <
thresh)
return true;
770 template <
typename Archive>
void serialize (Archive& ar) {
775 template<
typename T,
size_t NDIM>
782 template <
typename Archive>
void serialize (Archive& ar) {}
787 template<
typename T, std::
size_t NDIM>
800 impl->get_coeffs().replace(key,
nodeT(coeff,not is_leaf));
802 template <
typename Archive>
void serialize (Archive& ar) {
811 template<
typename T, std::
size_t NDIM>
824 template <
typename Archive>
void serialize (Archive& ar) {
837 template<
typename T,
typename R>
839 template <
typename Archive>
void serialize (Archive& ar) {}
844 template<
typename T, std::
size_t NDIM>
853 dnorm(node.get_dnorm()) {}
862 template <
typename Archive>
886 template<
typename T,
size_t NDIM>
947 if (
impl->is_compressed() or
impl->is_nonstandard() or
948 impl->is_nonstandard_with_leaves())
1013 template <
typename Archive>
void serialize(
const Archive& ar) {
1020 template<
typename T, std::
size_t NDIM>
1042 template <
typename T, std::
size_t NDIM>
1049 typedef std::shared_ptr< FunctionImpl<T,NDIM> >
pimplT;
1084 std::shared_ptr< FunctionFunctorInterface<T,NDIM> >
functor;
1106 return neighbor_halo_.load(std::memory_order_acquire) !=
nullptr;
1113 delete neighbor_halo_.exchange(
nullptr, std::memory_order_acq_rel);
1119 return h ?
h->size() : 0;
1129 if (
neighbor_halo_.compare_exchange_strong(
h, fresh, std::memory_order_acq_rel,
1130 std::memory_order_acquire))
1135 for (
const auto& kv : buf) {
1137 (void)
h->insert(acc, kv.first);
1138 acc->second = kv.second;
1145 if (!
h)
return false;
1147 if (
h->find(acc, key)) { out = acc->second;
return true; }
1163 ,
world(factory._world)
1165 ,
thresh(factory._thresh)
1188 bool do_refine = factory.
_refine;
1198 std::vector<coordT> functor_special_points=
functor->special_points();
1199 if (!functor_special_points.empty())
special_points.insert(
special_points.end(), functor_special_points.begin(), functor_special_points.end());
1205 if (it->second.is_leaf())
1215 coeffs.process_pending();
1226 template <
typename Q>
1240 template <
typename Q>
1268 coeffs.process_pending();
1274 const std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >&
get_pmap()
const;
1281 coeffs.replicate_on_hosts(fence);
1286 std::list<keyT> keys;
1287 for (
const auto& [key, node] :
coeffs)
if (not
coeffs.is_local(key)) keys.push_back(key);
1288 for (
const auto& key : keys)
coeffs.erase(key);
1289 if (fence)
world.gop.fence();
1293 auto currentmap=
coeffs.get_pmap();
1294 currentmap->redistribute(
world,newmap);
1300 template <
typename Q>
1306 if (fence)
world.gop.fence();
1310 template<
typename Q>
1318 if (single_owner >= 0) {
1336 template <
typename Q>
1343 auto v=other.
task(pid, &implQ::serialize_remote_coeffs);
1350 std::vector<unsigned char>
v;
1363 template <
typename Q>
1365 for (
const auto& [key, node] : other.
coeffs) {
1377 template<
typename Q,
typename R>
1409 template<
typename Q,
typename R>
1426 const double beta,
const implT&
g,
const bool fence);
1429 template <
typename Q,
typename R>
1438 const keyT& key = it->first;
1444 template <
typename Archive>
1457 template <
typename Q,
typename R>
1462 typedef do_gaxpy_inplace<Q,R> opT;
1470 template <
typename Archive>
1488 template <
typename Archive>
1549 std::shared_ptr<FunctionFunctorInterface<T,NDIM> >
get_functor()
const;
1671 double val2=log10(val) - log10(
lower());
1673 val2=0.7-(0.7/
upper)*val2;
1674 color= std::max(0.0,val2);
1675 color= std::min(0.7,color);
1677 double hue=0.7-(0.7/
limit)*(val);
1678 color= std::max(0.0,hue);
1705 const int xaxis,
const int yaxis,
const coordT el2);
1727 template<
size_t FDIM>
1728 typename std::enable_if<NDIM==FDIM>::type
1729 read_grid(
const std::string keyfile,
const std::string gridfile,
1732 std::ifstream kfile(keyfile.c_str());
1733 std::ifstream gfile(gridfile.c_str());
1737 if (not (std::getline(kfile,line)))
MADNESS_EXCEPTION(
"failed reading 1st line of key data",0);
1738 if (not (std::istringstream(line) >> ndata))
MADNESS_EXCEPTION(
"failed reading k",0);
1739 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 1st line of grid data",0);
1740 if (not (std::istringstream(line) >> ndata1))
MADNESS_EXCEPTION(
"failed reading k",0);
1742 if (not (std::getline(kfile,line)))
MADNESS_EXCEPTION(
"failed reading 2nd line of key data",0);
1743 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 2nd line of grid data",0);
1747 const size_t npt = qx.
dim(0);
1752 long nboxes=ndata/npoints;
1754 print(
"reading ",nboxes,
"boxes from file",gridfile,keyfile);
1760 std::string gline,kline;
1762 while (std::getline(kfile,kline)) {
1764 double x,y,z,x1,y1,z1,val;
1771 std::stringstream(kline) >> nn >> l1 >> l2 >> l3;
1779 const double h = std::pow(0.5,
double(n));
1786 for (
size_t i=0; i<npt; ++i) {
1788 for (
size_t j=0; j<npt; ++j) {
1790 for (
size_t k=0;
k<npt; ++
k) {
1793 auto& success1 = std::getline(gfile,gline);
MADNESS_CHECK(success1);
1794 auto& success2 = std::getline(kfile,kline);
MADNESS_CHECK(success2);
1795 std::istringstream(gline) >> x >> y >> z >> val;
1796 std::istringstream(kline) >> x1 >> y1 >> z1;
1805 if (vnuc_functor) val-=(*vnuc_functor)(
c);
1815 const bool has_children=
false;
1817 nodeT node(coeff,has_children);
1818 coeffs.replace(key,node);
1834 template<
size_t FDIM>
1835 typename std::enable_if<NDIM==FDIM>::type
1839 std::ifstream gfile(gridfile.c_str());
1843 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 1st line of grid data",0);
1844 if (not (std::istringstream(line) >> ndata))
MADNESS_EXCEPTION(
"failed reading k",0);
1845 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 2nd line of grid data",0);
1849 const size_t npt = qx.
dim(0);
1854 long nboxes=ndata/npoints;
1856 print(
"reading ",nboxes,
"boxes from file",gridfile);
1864 while (std::getline(gfile,gline)) {
1866 double x1,y1,z1,val;
1873 std::stringstream(gline) >> nn >> l1 >> l2 >> l3;
1880 const double h = std::pow(0.5,
double(n));
1887 for (
int i=0; i<npt; ++i) {
1889 for (
int j=0; j<npt; ++j) {
1891 for (
int k=0;
k<npt; ++
k) {
1894 auto& success = std::getline(gfile,gline);
1896 std::istringstream(gline) >> x1 >> y1 >> z1 >> val;
1902 if (vnuc_functor) val-=(*vnuc_functor)(
c);
1912 const bool has_children=
false;
1914 nodeT node(coeff,has_children);
1915 coeffs.replace(key,node);
1990 const coeffT& coeff)
const;
1996 template <
typename Q>
2012 template <
typename Q>
2014 const bool s_only)
const {
2048 template <
typename Q>
2066 for (std::size_t
d=0;
d<
NDIM; ++
d) {
2097 template <
typename Q>
2122 template <
typename Q>
2129 template <
typename Q>
2136 template <
typename Q>
2150 template <
typename Q>
2157 MADNESS_EXCEPTION(
"FunctionImpl: fcube_for_mul: child-parent relationship bad?",0);
2161 for (std::size_t
d=0;
d<
NDIM; ++
d) {
2178 template <
typename Q>
2185 MADNESS_EXCEPTION(
"FunctionImpl: fcube_for_mul: child-parent relationship bad?",0);
2189 for (
size_t d=0;
d<
NDIM;
d++) {
2200 template <
typename L,
typename R>
2225 template<
typename R>
2227 const int npt,
const keyT& key)
const {
2234 c11(this->cdata.
s0)=c1;
2235 c22(this->cdata.
s0)=c2;
2247 return copy(result(this->cdata.
s0));
2252 template <
typename L,
typename R,
typename opT>
2263 op(key, tcube, lcube, rcube);
2275 template <
typename L,
typename R>
2285 const keyT& key = it->first;
2293 const keyT& key = it->first;
2303 template <
typename opT>
2307 const keyT& parent = it->first;
2308 nodeT& node = it->second;
2324 template <
typename opT>
2328 const keyT& parent = it->first;
2329 nodeT& node = it->second;
2341 template<std::
size_t LDIM>
2356 coeffT g_values =
g->coeffs2values(key,g_coeff);
2359 const long rank=g_values.
rank();
2360 const long maxk=
f->get_k();
2366 tensorT result(maxk,maxk,maxk);
2368 for (
long i=0; i<rank; ++i) {
2372 double singular_value_i = g_values.
get_svdtensor().weights(i);
2373 result += (singular_value_i*c1);
2377 tensorT f_coeff =
f->values2coeffs(key1,result);
2386 template<std::
size_t LDIM>
2391 const keyT& key = it->first;
2405 f->trickle_down(
true);
2415 template <
typename opT>
2420 if (fence)
world.gop.fence();
2425 template <
typename opT>
2452 const keyT& key = it->first;
2453 nodeT& node = it->second;
2458 const double error=
d.normf();
2459 const double tol=
f->truncate_tol(
thresh,key);
2464 template <
typename Archive>
void serialize(
const Archive& ar) {}
2477 nodeT& node = it->second;
2481 template <
typename Archive>
void serialize(
const Archive& ar) {}
2493 nodeT& node = it->second;
2497 template <
typename Archive>
void serialize(
const Archive& ar) {}
2512 nodeT& node = it->second;
2517 template <
typename Archive>
void serialize(
const Archive& ar) {}
2539 nodeT& node = it->second;
2543 template <
typename Archive>
void serialize(
const Archive& ar) {}
2559 if constexpr(
NDIM==6) {
2560 const keyT& key = it->first;
2561 const nodeT& fnode = it->second;
2566 if (
f->world.size()>1)
return 0.0;
2582 if (
f->get_coeffs().probe(mapkey)) {
2584 const nodeT& mapnode=
f->get_coeffs().find(mapkey).get()->second;
2591 if (have_c1 and have_c2) {
2595 norm=(c1-c2).normf();
2596 }
else if (have_c1) {
2599 }
else if (have_c2) {
2619 template <
typename Archive>
void serialize(
const Archive& ar) {
2631 template<
typename Q,
typename R>
2643 const keyT& key = it->first;
2644 const nodeT& node = it->second;
2650 template <
typename Archive>
void serialize(
const Archive& ar) {
2708 const keyT& key = it->first;
2709 const nodeT& node = it->second;
2720 template <
typename Archive>
void serialize(
const Archive& ar) {
2738 const keyT& key = it->first;
2739 const nodeT& node = it->second;
2744 for (std::size_t i=0; i<
NDIM; ++i) {
2751 std::vector<Slice> s(
___);
2754 for (
size_t i=0; i<
NDIM; ++i) {
2755 std::size_t
kmax=
c.dim(i);
2757 for (
size_t k=1;
k<
kmax;
k+=2) {
2770 template <
typename Archive>
void serialize(
const Archive& ar) {
2789 const keyT& key = it->first;
2790 const nodeT& node = it->second;
2798 for (std::size_t i=0; i<
NDIM; ++i) l1[
map[i]] = l[i];
2807 for (std::size_t i=0; i<
NDIM; ++i) {
2808 if (
mirror[i]==-1) l1[i]= lmax - l[i];
2814 std::vector<Slice> s(
___);
2817 for (
size_t i=0; i<
NDIM; ++i) {
2818 std::size_t
kmax=
c.dim(i);
2820 for (
size_t k=1;
k<
kmax;
k+=2) {
2834 template <
typename Archive>
void serialize(
const Archive& ar) {
2854 const keyT& key = it->first;
2855 const nodeT& fnode = it->second;
2862 if (
g->get_coeffs().find(acc,key)) {
2863 nodeT& gnode=acc->second;
2866 g->get_coeffs().replace(key,fnode);
2872 template <
typename Archive>
void serialize(
const Archive& ar) {}
2892 nodeT& node = it->second;
2895 f->timer_change_tensor_type.accumulate(cpu1-cpu0);
2900 template <
typename Archive>
void serialize(
const Archive& ar) {}
2920 template <
typename Archive>
void serialize(
const Archive& ar) {}
2925 template <
typename opT>
2932 const keyT& key = it->first;
2933 nodeT& node = it->second;
2939 tensorT values =
impl->fcube_for_mul(key, key, t);
2949 template <
typename Archive>
void serialize(
const Archive& ar) {}
2952 template <
typename Q,
typename R>
2960 std::vector<unsigned int> ind(vleft.size());
2961 for (
unsigned int i=0; i<vleft.size(); ++i) {
2964 for (
unsigned int i=0; i<vleft.size(); ++i) {
2966 std::swap(ind[i],ind[j]);
2969 for (
const auto& [key, rnode] : right->coeffs) {
2970 if (rnode.has_coeff()) {
2975 for (
unsigned int j=0; j<vleft.size(); ++j) {
2976 unsigned int i = ind[j];
2978 implT* left = vleft[i].get();
2989 nodeT& node = acc->second;
3003 const std::vector<tensorT>&
c,
3010 template <
typename opT>
3012 std::vector<tensorT>
c(
v.size());
3013 for (
unsigned int i=0; i<
v.size(); i++) {
3016 c[i]=
cc.full_tensor();
3027 template <
typename opT>
3030 for (std::size_t i=1; i<
v.size(); ++i) {
3031 if (
v[i] and
v[i-1]) {
3037 const keyT& key = it->first;
3038 if (it->second.has_coeff())
3052 template <
typename opT>
3054 const std::vector<implT*>& vin, std::vector<implT*>& vout) {
3055 std::vector<tensorT>
c(vin.size());
3056 for (
unsigned int i=0; i<vin.size(); i++) {
3059 c[i]=
cc.full_tensor();
3062 std::vector<tensorT> r =
op(key,
c);
3064 for (std::size_t i=0; i<vout.size(); ++i) {
3075 template <
typename opT>
3077 std::vector<implT*>& vout,
const bool fence=
true) {
3079 for (std::size_t i=1; i<vin.size(); ++i) {
3080 if (vin[i] and vin[i-1]) {
3086 const keyT& key = it->first;
3087 if (it->second.has_coeff())
3089 key,
op, vin, vout);
3092 for (
implT* it2 : vout) {
3097 if (fence)
world.gop.fence();
3104 template <
typename Q,
typename R>
3110 for (
unsigned int j=0; j<vright.size(); ++j) {
3119 template <
typename opT>
3122 typedef do_unary_op_value_inplace<opT> xopT;
3139 template <
typename L,
typename R>
3149 double lnorm = 1e99;
3150 double ldnorm = 1e99;
3151 bool l_is_leaf =
false;
3155 if (lc.
size() == 0) {
3160 lnorm = lit->second.get_norm_tree();
3161 ldnorm = lit->second.get_dnorm_tree();
3163 l_is_leaf = !lit->second.has_children();
3172 std::vector<FunctionImpl<T,NDIM>*> vresult;
3173 std::vector<const FunctionImpl<R,NDIM>*> vright;
3174 std::vector< Tensor<R> > vrc;
3175 vresult.reserve(vrightin.size());
3176 vright.reserve(vrightin.size());
3177 vrc.reserve(vrightin.size());
3181 bool lc_shared_set =
false;
3182 auto left_coeffs = [&]() ->
const Tensor<L>& {
3183 if (!lc_shared_set) {
3184 lc_shared = lc.
size() ? lc : lit->second.coeff().full_tensor_copy();
3185 lc_shared_set =
true;
3190 for (
unsigned int i=0; i<vrightin.size(); ++i) {
3194 double rnorm, rdnorm;
3196 if (rc.
size() == 0) {
3199 rnorm = rit->second.get_norm_tree();
3200 rdnorm = rit->second.get_dnorm_tree();
3209 if (rnorm*ldnorm + lnorm*rdnorm + ldnorm*rdnorm <=
truncate_tol(tol, key)) {
3211 Tensor<R> rc_data = (rc.
size() == 0) ? rit->second.coeff().full_tensor_copy() : rc;
3212 result->
task(
world.rank(), &implT:: template
do_mul<L,R>, key, left_coeffs(), std::make_pair(key,rc_data));
3216 vresult.push_back(result);
3217 vright.push_back(right);
3222 if (vresult.size()) {
3224 if (lc.
size() || l_is_leaf) {
3231 std::vector<char> r_unfiltered(vresult.size(), 0);
3232 std::vector< Tensor<R> > vrss(vresult.size());
3233 for (
unsigned int i=0; i<vresult.size(); ++i) {
3234 riterT rit = vright[i]->coeffs.find(key).get();
3238 if (vrc[i].
size() || !rit->second.has_children()) {
3241 rd(
cdata.s0) = (vrc[i].size() ? vrc[i] : rit->second.coeff().full_tensor_copy())(
___);
3242 vrss[i] = vright[i]->unfilter(rd);
3243 r_unfiltered[i] = 1;
3248 const keyT& child = kit.key();
3253 if (lc.
size() || l_is_leaf)
3256 std::vector< Tensor<R> > vv(vresult.size());
3257 for (
unsigned int i=0; i<vresult.size(); ++i) {
3258 if (r_unfiltered[i])
3259 vv[i] =
copy(vrss[i](cp));
3276 template <
typename L,
typename R>
3284 double lnorm=1e99, rnorm=1e99;
3287 if (lc.
size() == 0) {
3290 lnorm = it->second.get_norm_tree();
3291 if (it->second.has_coeff())
3292 lc = it->second.coeff().reconstruct_tensor();
3296 if (rc.
size() == 0) {
3299 rnorm = it->second.get_norm_tree();
3300 if (it->second.has_coeff())
3301 rc = it->second.coeff().reconstruct_tensor();
3339 const keyT& child = kit.key();
3362 template <
typename L,
typename R,
typename opT>
3371 if (lc.
size() == 0) {
3374 if (it->second.has_coeff())
3375 lc = it->second.coeff().reconstruct_tensor();
3379 if (rc.
size() == 0) {
3382 if (it->second.has_coeff())
3383 rc = it->second.coeff().reconstruct_tensor();
3409 const keyT& child = kit.key();
3421 template <
typename Q,
typename opT>
3437 return impl_func->values2coeffs(key, outvalues);
3440 template <
typename Archive>
3454 template <
typename Q,
typename opT>
3459 const Tensor<Q> fc =
func->coeffs.find(key).get()->second.coeff().reconstruct_tensor();
3461 if (fc.
size() == 0) {
3465 const keyT& child = kit.key();
3479 template <
typename L,
typename R>
3493 template <
typename L,
typename R,
typename opT>
3495 const opT&
op,
bool fence) {
3507 template <
typename Q,
typename opT>
3520 template <
typename Q,
typename opT>
3536 template <
typename L,
typename R>
3542 std::vector< Tensor<R> > vr(vright.size());
3611 const coordT& plotlo,
const coordT& plothi,
const std::vector<long>& npt,
3612 bool eval_refine)
const;
3622 const std::vector<long>& npt,
3623 const bool eval_refine =
false)
const;
3639 Level maxlevel, std::pair<bool,T>* results);
3645 std::vector<std::pair<bool,T>>
3726 template<
size_t LDIM>
3753 double glo=0.0, ghi=0.0, flo=0.0, fhi=0.0;
3754 g.get_impl()->tnorm(gcoeff.
get_tensor(), &glo, &ghi);
3757 double total_hi=glo*fhi + ghi*flo + fhi*ghi;
3777 coeffT coeff1=
f.get_impl()->parent_to_child(
f.coeff(),
f.key(),key);
3779 const coeffT coeff2=
g.get_impl()->parent_to_child(
g.coeff(),
g.key(),gkey);
3785 bool is_leaf=
screen(coeff1_2D,coeff2,key);
3786 if (key.
level()<2) is_leaf=
false;
3792 coeffT hvalues=
f.get_impl()->coeffs2values(key,coeff1_2D);
3793 coeffT gvalues=
g.get_impl()->coeffs2values(gkey,coeff2);
3798 hcoeff=
h->values2coeffs(key,result_val);
3802 hcoeff=hcoeff.
convert(
h->get_tensor_args());
3805 return std::pair<bool,coeffT> (is_leaf,hcoeff);
3829 template <
typename Archive>
void serialize(
const Archive& ar) {
3855 bool is_leaf=(
f.is_leaf() and
g.is_leaf());
3856 if (not is_leaf)
return std::pair<bool,coeffT> (is_leaf,
coeffT());
3858 coeffT fcoeff=
f.get_impl()->parent_to_child(
f.coeff(),
f.key(),key);
3859 coeffT gcoeff=
g.get_impl()->parent_to_child(
g.coeff(),
g.key(),key);
3862 hcoeff.
reduce_rank(
f.get_impl()->get_tensor_args().thresh);
3863 return std::pair<bool,coeffT> (is_leaf,hcoeff);
3883 template <
typename Archive>
void serialize(
const Archive& ar) {
3896 template<
size_t LDIM>
3902 typedef multiply_op<LDIM> coeff_opT;
3903 coeff_opT coeff_op(
this,ff,gg,
particle);
3906 apply_opT apply_op(
this);
3918 template<
size_t LDIM,
typename leaf_opT>
3943 const coeffT fcoeff=
p1.coeff(key1);
3944 const coeffT gcoeff=
p2.coeff(key2);
3946 if (not is_leaf)
return std::pair<bool,coeffT> (is_leaf,
coeffT());
3949 const coeffT s1=fcoeff(
p1.get_impl()->cdata.s0);
3950 const coeffT s2=gcoeff(
p2.get_impl()->cdata.s0);
3956 return std::pair<bool,coeffT>(is_leaf,coeff);
3979 template <
typename Archive>
void serialize(
const Archive& ar) {
3990 template<
typename coeff_opT,
typename apply_opT>
4004 template<
typename coeff_opT,
typename apply_opT>
4008 typedef typename std::pair<bool,coeffT> argT;
4009 const argT
arg=coeff_op(key);
4010 apply_op.operator()(key,
arg.second,
arg.first);
4012 const bool has_children=(not
arg.first);
4015 const keyT& child=kit.key();
4016 coeff_opT child_op=coeff_op.make_child(child);
4034 template<std::
size_t LDIM,
typename leaf_opT>
4037 const leaf_opT&
leaf_op,
bool fence) {
4038 MADNESS_CHECK_THROW(p1.size()==p2.size(),
"hartree_product: p1 and p2 must have the same size");
4039 for (
auto&
p : p1)
MADNESS_CHECK(
p->is_nonstandard() or
p->is_nonstandard_with_leaves());
4040 for (
auto&
p : p2)
MADNESS_CHECK(
p->is_nonstandard() or
p->is_nonstandard_with_leaves());
4044 for (std::size_t i=0; i<p1.size(); ++i) {
4045 if (
world.rank() == this->get_coeffs().owner(
key0)) {
4052 typedef hartree_op<LDIM,leaf_opT> coeff_opT;
4053 coeff_opT coeff_op(
this,iap1,iap2,
leaf_op);
4058 apply_opT apply_op(
this);
4061 coeff_op, apply_op,
cdata.key0);
4067 if (fence)
world.gop.fence();
4071 template <
typename opT,
typename R>
4074 const opT*
op =
pop.ptr;
4076 const double cnorm =
c.normf();
4085 int maxdir = s ? 1 : -1;
4086 for (
int direction=-1; direction<=maxdir; direction+=2) {
4087 lnew[
axis] = lold + direction*s;
4088 if (lnew[
axis] >= 0 && lnew[
axis] < maxs) {
4090 double Rnorm = r.
normf();
4096 if (s <= 1 || r.
normf()*cnorm > tol) {
4100 if (result.
normf() > tol*0.3) {
4122 template <
typename opT,
typename R>
4129 fiterT end =
f->coeffs.end();
4131 for (fiterT it=
f->coeffs.begin(); it!=end; ++it) {
4132 const fnodeT& node = it->second;
4133 if (node.has_coeff()) {
4134 const keyT& key = it->first;
4135 const Tensor<R>&
c = node.coeff().full_tensor_copy();
4140 if (fence)
world.gop.fence();
4146 const std::pair<keyT,coeffT>& left,
4147 const std::pair<keyT,coeffT>& center,
4148 const std::pair<keyT,coeffT>& right);
4153 const std::pair<keyT,coeffT>& left,
4154 const std::pair<keyT,coeffT>& center,
4155 const std::pair<keyT,coeffT>& right);
4204 template<std::
size_t LDIM>
4230 bool use_tnorm=
false;
4235 tensorT val_rhs=fcf.coeffs2values(key, coeff_rhs);
4237 return fcf.values2coeffs(key,val_rhs);
4246 coeff1(
cdata.s0)=coeff_rhs;
4250 tensorT coeff_lhs_k1(cdata_npt.vk);
4255 val_lhs_k1.
emul(val_rhs_k1);
4262 result1(
cdata.s0)=0.0;
4272 const long k=coeff_rhs.
dim(0);
4286 coeff_rhs_npt1(fcf_lo.
cdata.s0)=coeff_rhs;
4300 val_lhs_npt.
emul(val_rhs);
4307 result1(
cdata.s0)=0.0;
4312 template <
typename Archive>
void serialize(
const Archive& ar) {
4325 template<
typename opT,
size_t LDIM>
4366 if(
leaf_op.do_pre_screening()){
4368 if(
leaf_op.pre_screening(key)){
4372 return std::pair<bool,coeffT> (
true,
coeffT());
4381 size_t il =
result->get_initial_level();
4383 if(key.
level()<
int(il)){
4388 if(key.
level()<
result->get_special_level() and
leaf_op.special_refinement_needed(key)){
4395 if(
leaf_op.post_screening(key,sum_coeff)){
4397 return std::pair<bool,coeffT> (
true,
coeffT());
4403 return std::pair<bool,coeffT> (
true,
coeffT());
4407 std::vector<bool> child_is_leaf(1<<
NDIM,
false);
4422 keyT child=kit.key();
4423 bool is_leaf=child_is_leaf[i];
4436 result->task(
p, ft, child_op, no, child);
4441 return std::pair<bool,coeffT> (
true,
coeffT());
4447 if (
eri->get_functor()->provides_coeff()) {
4448 return eri->get_functor()->coeff(key).full_tensor();
4451 eri->fcube(key,*(
eri->get_functor()),
eri->cdata.quad_x,val_eri);
4452 return eri->values2coeffs(key,val_eri);
4471 double dnorm_ket, snorm_ket;
4473 snorm_ket=
iaket.coeff(key).normf();
4474 dnorm_ket=
iaket.dnorm(key);
4476 double s1=
iap1.coeff(key1).normf();
4477 double s2=
iap2.coeff(key2).normf();
4478 double d1=
iap1.dnorm(key1);
4479 double d2=
iap2.dnorm(key2);
4481 dnorm_ket=s1*d2 + s2*d1 + d1*d2;
4485 double snorm=
iav1.coeff(key1).normf();
4486 double dnorm=
iav1.dnorm(key1);
4487 error+=snorm*dnorm_ket + dnorm*snorm_ket + dnorm*dnorm_ket;
4490 double snorm=
iav2.coeff(key2).normf();
4491 double dnorm=
iav2.dnorm(key2);
4492 error+=snorm*dnorm_ket + dnorm*snorm_ket + dnorm*dnorm_ket;
4496 double snorm=s_coeffs.
normf();
4499 double dnorm=
d.normf();
4500 error+=snorm*dnorm_ket + dnorm*snorm_ket + dnorm*dnorm_ket;
4532 double error=refine_error;
4550 result1+=pm(key,
copy(ceri(
result->cdata.s0)));
4560 return std::make_pair(cresult,
error);
4570 iap1.make_child(key1),
iap2.make_child(key2),
4582 iaket1,iap11,iap21,iav11,iav21,
eri);
4586 const ctL& iap11,
const ctL& iap21,
const ctL& iav11,
const ctL& iav21,
4587 const implT* eri1) {
4592 template <
typename Archive>
void serialize(
const Archive& ar) {
4609 template<
typename opT,
size_t LDIM>
4649 const double sn_u =
iau.coeff(key).normf();
4650 const double dn_u =
iau.dnorm(key);
4651 const double sn_i =
have_i() ?
iai.coeff(key1).normf() : 1.0;
4652 const double dn_i =
have_i() ?
iai.dnorm(key1) : 0.0;
4653 const double sn_j =
have_j() ?
iaj.coeff(key2).normf() : 1.0;
4654 const double dn_j =
have_j() ?
iaj.dnorm(key2) : 0.0;
4657 return sn_u*sn_i*dn_j + sn_u*dn_i*sn_j + dn_u*sn_i*sn_j
4658 + sn_u*dn_i*dn_j + dn_u*sn_i*dn_j + dn_u*dn_i*sn_j
4665 if (
eri->get_functor()->provides_coeff()) {
4666 return eri->get_functor()->coeff(key).full_tensor();
4669 eri->fcube(key, *(
eri->get_functor()),
eri->cdata.quad_x, val_eri);
4670 return eri->values2coeffs(key, val_eri);
4706 return {current,
error};
4716 scalar.
flat()(0
L) = contribution;
4727 if (
leaf_op.do_pre_screening()) {
4728 if (
leaf_op.pre_screening(key)) {
4737 const size_t il =
result->get_initial_level();
4742 leaf_op.special_refinement_needed(key))
4747 if (
leaf_op.post_screening(key, coeff) ||
4758 const keyT& key)
const {
4761 const keyT child = kit.key();
4762 if (child_is_leaf[i]) {
4765 result->get_tensor_args()),
true);
4772 result->task(
p, ft, child_op, no, child);
4782 iau.make_child(child),
4783 iai.make_child(key1),
4784 iaj.make_child(key2),
4792 return result->world.taskq.add(
4800 const ctT& iau1,
const ctL& iai1,
const ctL& iaj1,
4801 const implT* eri1,
double target_precision1,
4802 int oversampling1) {
4803 return this_type(result1, leaf_op1, iau1, iai1, iaj1, eri1,
4804 target_precision1, oversampling1);
4807 template<
typename Archive>
void serialize(
const Archive& ar) {
4819 template<
typename opT>
4822 constexpr size_t LDIM=
NDIM/2;
4829 std::shared_ptr< FunctionFunctorInterface<T,NDIM> > func2(this->
get_functor());
4837 if (fence)
func->make_redundant(
true);
4841 for (
auto& ket :
func->impl_ket_vector) {
4850 for (std::size_t i=0; i<
func->impl_p1_vector.size(); ++i) {
4880 template<
typename opT, std::
size_t LDIM>
4885 const bool fence=
true) {
4895 typedef Vphi_op_NS<opT,LDIM> coeff_opT;
4896 coeff_opT coeff_op(
this,
leaf_op,iaket,iap1,iap2,iav1,iav2,eri);
4904 coeff_op, apply_op,
cdata.key0);
4908 if (fence)
world.gop.fence();
4924 template<
typename opT,
size_t LDIM>
4930 double target_precision = 0.0,
4931 int oversampling = 1) {
4937 if (target_precision == 0.0) target_precision =
u->get_thresh();
4939 typedef Vphi_ij_u_op_NS<opT,LDIM> coeff_opT;
4940 coeff_opT coeff_op(
this,
leaf_op, iau, iai, iaj,
nullptr,
4941 target_precision, oversampling);
4949 coeff_op, apply_op,
cdata.key0);
4953 if (fence)
world.gop.fence();
4967 template<
typename opT,
size_t LDIM>
4973 double target_precision=0.0,
4974 int oversampling=1)
const {
4980 implT acc(*
u,
u->get_pmap(),
false);
4981 if (target_precision==0.0) target_precision=acc.
get_thresh()*0.01;
4988 typedef Vphi_ij_u_op_NS<opT,LDIM> coeff_opT;
4989 coeff_opT coeff_op(&acc,
leaf_op, iau, iai, iaj, eri, target_precision, oversampling);
4997 coeff_op, apply_op,
cdata.key0);
5010 inner_val =
a->second.coeff().full_tensor_copy().flat()(0
L);
5012 world.gop.sum(inner_val);
5027 const std::vector<long>&
mirror,
bool fence);
5060 auto& node=it->second;
5061 node.recompute_snorm_and_dnorm(
cdata);
5131 template <
typename opT>
5136 const auto found =
coeffs.find(acc,key);
5138 nodeT& node = acc->second;
5146 const keyT& child = kit.key();
5156 template <
typename opT>
5169 template <
typename opT>
5219 typedef std::pair<coeffT, std::pair<double,double> >
compressT;
5289 const keyT& key = it->first;
5290 nodeT& node = it->second;
5304 template <
typename Archive>
void serialize(
const Archive& ar) {
5311 template<
size_t OPDIM>
5320 template <
class Archive>
5331 template <
typename opT,
typename R,
size_t OPDIM>
5334 tensorT result =
op->apply(args.key, args.d,
c, args.tol/args.fac/args.cnorm);
5339 if (result.
normf()> 0.3*args.tol/args.fac) {
5343 if (args.dest ==
world.rank()) {
5359 template <
typename opT,
typename R,
size_t OPDIM>
5363 tensorT result_full =
op->apply(args.key, args.d,
c, args.tol/args.fac/args.cnorm);
5371 if (
norm > 0.3*args.tol/args.fac) {
5397 template <
typename opT,
typename R,
size_t OPDIM>
5402 if (2*OPDIM==
NDIM) result=
op->apply2_lowdim(args.key, args.d, coeff,
5403 args.tol/args.fac/args.cnorm, args.tol/args.fac);
5404 if (OPDIM==
NDIM) result =
op->apply2(args.key, args.d, coeff,
5405 args.tol/args.fac/args.cnorm, args.tol/args.fac);
5407 const double result_norm=result.
svd_normf();
5409 if (result_norm> 0.3*args.tol/args.fac) {
5439 template <
typename opT,
typename R>
5451 typedef typename opT::keyT opkeyT;
5452 constexpr auto opdim = opT::opdim;
5453 const opkeyT
source =
op->get_source_key(key);
5471 double radius = 1.5 + 0.33 * std::max(0.0, 2 - std::log10(
thresh) -
5477 double cnorm =
c.normf();
5484 (
op->particle() == 1)
5486 op->func_domain_is_periodic())
5488 op->func_domain_is_periodic());
5491 const auto default_real_distance_squared = [&](
const auto &
displacement)
5495 const auto default_lattice_distance_squared = [&](
const auto &
displacement)
5499 const auto default_skip_predicate = [&](
const auto &
displacement)
5503 const auto for_each = [&](
auto &displacements,
5504 const auto &real_distance_squared,
5505 const auto &lattice_distance_squared,
5506 const auto &skip_predicate) -> std::optional<double> {
5522 std::optional<double> real_last_distsq;
5523 std::optional<std::uint64_t> lattice_last_distsq;
5530 bool any_face_survives =
false;
5531 const auto &probing_displacements = displacements.probing_displacements();
5532 for (std::size_t
d = 0;
d != opdim; ++
d) {
5533 if (!probing_displacements[
d])
continue;
5534 const double opnorm =
5536 if (cnorm * opnorm <= tol / fac)
5537 displacements.skip_face(
d);
5539 any_face_survives =
true;
5541 if (!any_face_survives) {
5552 if (
op->particle() == 1)
5562 const auto real_distsq = real_distance_squared(
displacement);
5563 const std::uint64_t lattice_distsq = real_distsq ? 0 : lattice_distance_squared(
displacement);
5564 if (!real_last_distsq.has_value() ||
5565 !
same_displacement_shell(real_distsq, *real_last_distsq) || (*real_last_distsq == 0 && lattice_distsq != *lattice_last_distsq)) {
5566 if (nvalid > 0 && nused == 0 && (real_distsq > 0 || lattice_distsq > 1)) {
5575 real_last_distsq = real_distsq;
5577 lattice_last_distsq = real_distsq ? std::optional<std::uint64_t>{} : lattice_distsq;
5580 keyT dest =
neighbor(key,
d, func_is_treated_by_op_as_periodic);
5585 if (cnorm * opnorm > tol / fac) {
5588 if (result.
normf() > 0.3 * tol / fac) {
5589 if (
coeffs.is_local(dest))
5601 return real_last_distsq;
5608 const auto max_distsq_reached = for_each(
op->get_disp(key.
level()), default_real_distance_squared, default_lattice_distance_squared, default_skip_predicate);
5613 if (
op->range_restricted() && key.
level() >= 1) {
5615 std::array<std::optional<std::int64_t>, opdim> box_radius;
5616 std::array<std::optional<std::int64_t>, opdim> surface_thickness;
5617 auto &
range =
op->get_range();
5618 for (
int d = 0;
d != opdim; ++
d) {
5621 surface_thickness[
d] =
range[
d].finite_soft() ? 1 : 0;
5631 std::optional<typename SurfaceRange::Validator> validator;
5632 if (max_distsq_reached) {
5637 std::array<double, opdim> widths;
5639 validator.emplace(
op->func_domain_is_periodic(),
op->lattice_summed(),
5644 auto opkey =
op->particle() == 1 ? key.template extract_front<opdim>() : key.template extract_back<opdim>();
5645 SurfaceRange range_boundary_face_displacements(opkey, box_radius,
5647 op->lattice_summed(),
5650 range_boundary_face_displacements,
5653 [](
const auto &
displacement) -> std::uint64_t {
return 0; },
5654 default_skip_predicate);
5660 template <
typename opT,
typename R>
5664 for (
const auto& [key, node]:
f.coeffs) {
5665 if (node.has_coeff()) {
5666 if (node.coeff().dim(0) !=
k ||
op.doleaves) {
5693 template <
typename opT,
typename R>
5695 const bool& do_kernel) {
5701 "apply: the rest-of-crystal operator (OperatorInfo::images_only) is supported only where FunctionImpl::do_apply is used (operator and function of the same dimension, NDIM <= 3)");
5703 typedef typename opT::keyT opkeyT;
5706 std::list<opkeyT> blacklist;
5708 constexpr auto opdim=opT::opdim;
5712 const opkeyT
source=
op->get_source_key(key);
5717 double fac=std::pow(3,
NDIM*0.5);
5718 double cnorm = coeff.
normf();
5722 apply_targs.
thresh=tol/fac*0.03;
5732#ifdef ENABLE_GENTENSOR
5741 for (
const auto&
d: disp) {
5742 const int shell=
d.distsq_bc(
op->lattice_summed());
5743 if (do_kernel and (shell>0))
break;
5744 if ((not do_kernel) and (shell==0))
continue;
5747 if (
op->particle()==1) disp1=
d.merge_with(nullkey);
5760 bool screened=
false;
5761 typename std::list<opkeyT>::const_iterator it2;
5762 for (it2=blacklist.begin(); it2!=blacklist.end(); it2++) {
5763 if (
d.is_farther_out_than(*it2)) {
5773 if (cnorm*opnorm> tol/fac) {
5775 double cost_ratio=
op->estimate_costs(
source,
d, coeff_SVD, tol/fac/cnorm, tol/fac);
5779 if (cost_ratio>0.0) {
5781 do_op_args<opdim> args(
source,
d, dest, tol, fac, cnorm);
5783 if (cost_ratio<1.0) {
5787 if (2*opdim==
NDIM) {
5793 maxnorm=std::max(
norm,maxnorm);
5796 }
else if (shell >= 12) {
5799 if (
norm<0.3*tol/fac) blacklist.push_back(
d);
5807 template <
typename opT,
typename R>
5816 const keyT& key = it->first;
5817 const coeffT& coeff = it->second.coeff();
5825 if (fence)
world.gop.fence();
5848 template<
typename opT, std::
size_t LDIM>
5860 typedef recursive_apply_op<opT,LDIM> coeff_opT;
5861 coeff_opT coeff_op(
this,ff,gg,&apply_op);
5870 if (fence)
world.gop.fence();
5875 template<
typename opT, std::
size_t LDIM>
5909 const tensorT fcoeff=
iaf.coeff(key1).full_tensor();
5910 const tensorT gcoeff=
iag.coeff(key2).full_tensor();
5916 bool is_leaf=
leaf_op(key,fcoeff,gcoeff);
5920 const std::vector<Slice>&
s0=
iaf.get_impl()->cdata.s0;
5928 double norm0=
result->do_apply_directed_screening<opT,T>(
apply_op, key, coeff,
true);
5936 return std::pair<bool,coeffT> (is_leaf,
coeffT());
5942 const coeffT& coeff)
const {
5944 bool is_leaf=(kernel_norm<
result->truncate_tol(
thresh,key));
5945 if (key.
level()<2) is_leaf=
false;
5946 return std::pair<bool,coeffT> (is_leaf,coeff);
5967 const opT* apply_op1) {
5971 template <
typename Archive>
void serialize(
const Archive& ar) {
5986 template<
typename opT, std::
size_t LDIM>
5998 std::vector<CoeffTracker<T,LDIM>> ffs, ggs;
5999 for (
size_t i=0; i<fimpls.size(); ++i) {
6004 typedef recursive_apply_op_vec<opT,LDIM> coeff_opT;
6005 coeff_opT coeff_op(
this,ffs,ggs,&apply_op);
6013 if (fence)
world.gop.fence();
6021 template<
typename opT, std::
size_t LDIM>
6036 const std::vector<ctL>&
iafs,
const std::vector<ctL>&
iags,
6057 const size_t npairs=
iafs.size();
6060 std::vector<tensorT> fcoeffs(npairs), gcoeffs(npairs);
6061 for (
size_t i=0; i<npairs; ++i) {
6062 fcoeffs[i]=
iafs[i].coeff(key1).full_tensor();
6063 gcoeffs[i]=
iags[i].coeff(key2).full_tensor();
6068 bool is_leaf=
leaf_op(key,fcoeffs,gcoeffs);
6071 const std::vector<Slice>&
s0=
iafs[0].get_impl()->cdata.s0;
6072 const double reduce_thresh=
result->truncate_tol(
result->get_thresh(), key);
6075 std::list<coeffT> one_term_coeffs;
6076 for (
size_t i=0; i<npairs; ++i)
6077 one_term_coeffs.push_back(
outer(fcoeffs[i],gcoeffs[i],
result->targs));
6082 double norm0=
result->do_apply_directed_screening<opT,T>(
apply_op, key, coeff,
true);
6090 return std::pair<bool,coeffT> (is_leaf,
coeffT());
6096 const coeffT& coeff)
const {
6098 bool is_leaf=(kernel_norm<
result->truncate_tol(
thresh,key));
6099 if (key.
level()<2) is_leaf=
false;
6100 return std::pair<bool,coeffT> (is_leaf,coeff);
6110 std::vector<ctL> child_fs(
iafs.size()), child_gs(
iags.size());
6111 for (
size_t i=0; i<
iafs.size(); ++i) {
6112 child_fs[i]=
iafs[i].make_child(key1);
6113 child_gs[i]=
iags[i].make_child(key2);
6121 const size_t n=
iafs.size();
6122 std::vector<Future<ctL>> f_futures(n), g_futures(n);
6123 for (
size_t i=0; i<n; ++i) {
6124 f_futures[i]=
iafs[i].activate();
6125 g_futures[i]=
iags[i].activate();
6134 const opT* apply_op1) {
6135 std::vector<ctL> new_fs(f_futures.size()), new_gs(g_futures.size());
6136 for (
size_t i=0; i<f_futures.size(); ++i) {
6137 new_fs[i]=
const_cast<std::vector<Future<ctL>
>&>(f_futures)[i].get();
6139 for (
size_t i=0; i<g_futures.size(); ++i) {
6140 new_gs[i]=
const_cast<std::vector<Future<ctL>
>&>(g_futures)[i].get();
6142 return this_type(r,new_fs,new_gs,apply_op1);
6145 template <
typename Archive>
void serialize(
const Archive& ar) {
6156 template<
typename opT>
6165 typedef recursive_apply_op2<opT> coeff_opT;
6166 coeff_opT coeff_op(
this,fimpl,&apply_op);
6172 coeff_op, apply_op,
cdata.key0);
6175 if (fence)
world.gop.fence();
6180 template<
typename opT>
6186 typedef std::pair<bool,coeffT>
argT;
6218 double norm0=
result->do_apply_directed_screening<opT,T>(
apply_op,key,coeff,
true);
6220 if (
iaf.is_leaf())
return argT(
true,coeff);
6224 const bool is_leaf=
true;
6234 if (key.
level()<2) is_leaf=
false;
6235 return argT(is_leaf,coeff);
6257 return this_type(result1,iaf1,apply_op1);
6260 template <
typename Archive>
void serialize(
const Archive& ar) {
6269 template <
typename opT>
6274 std::vector<long> vq(
NDIM);
6275 for (std::size_t i=0; i<
NDIM; ++i)
6277 tensorT fval(vq,
false), work(vq,
false), result(vq,
false);
6295 double err = fval.normf();
6299 template <
typename opT>
6318 const keyT& key = it->first;
6319 const nodeT& node = it->second;
6330 template <
typename Archive>
6337 template <
typename opT>
6341 const int npt =
cdata.npt + 1;
6348 do_err_box<opT>(
this, &
func, npt, qx, quad_phit, quad_phiw));
6362 const nodeT& node = it->second;
6377 template <
typename Archive>
void serialize(
const Archive& ar) {
6392 template<
typename R>
6403 const keyT& key=it->first;
6404 const nodeT& fnode = it->second;
6406 if (
other->coeffs.probe(it->first)) {
6411 MADNESS_EXCEPTION(
"functions have different k or compress/reconstruct error", 0);
6430 template <
typename Archive>
void serialize(
const Archive& ar) {
6438 template <
typename R>
6453 template<
typename R>
6465 constexpr std::size_t LDIM=std::max(
NDIM/2,std::size_t(1));
6467 const keyT& key=it->first;
6468 const nodeT& fnode = it->second;
6469 if (not fnode.
has_coeff())
return resultT(0.0);
6472 auto find_valid_parent = [](
auto& key,
auto& impl,
auto&& find_valid_parent) {
6473 MADNESS_CHECK(impl->get_coeffs().owner(key)==impl->world.rank());
6474 if (impl->get_coeffs().probe(key))
return key;
6475 auto parentkey=key.
parent();
6476 return find_valid_parent(parentkey, impl, find_valid_parent);
6480 auto get_coeff = [&find_valid_parent](
const auto& key,
const auto& v_impl) {
6481 if ((v_impl.size()>0) and v_impl.front().get()) {
6482 auto impl=v_impl.front();
6486 auto parentkey = find_valid_parent(key, impl, find_valid_parent);
6488 typename decltype(impl->coeffs)
::accessor acc;
6489 impl->get_coeffs().
find(acc,parentkey);
6490 auto parentcoeff=acc->second.coeff();
6491 auto coeff=impl->parent_to_child(parentcoeff, parentkey, key);
6495 typedef typename std::decay_t<
decltype(v_impl)>::value_type::element_type::typeT S;
6502 auto make_vector = [](
auto&
arg) {
6503 return std::vector<std::decay_t<
decltype(
arg)>>(1,
arg);
6514 "only one ket function supported in inner_on_demand");
6516 "only one p1 function supported in inner_on_demand");
6518 "only one p2 function supported in inner_on_demand");
6519 auto coeff_bra=fnode.
coeff();
6520 auto coeff_ket=get_coeff(key,
func->impl_ket_vector);
6521 auto coeff_v1=get_coeff(key1,make_vector(
func->impl_m1));
6522 auto coeff_v2=get_coeff(key2,make_vector(
func->impl_m2));
6523 auto coeff_p1=get_coeff(key1,
func->impl_p1_vector);
6524 auto coeff_p2=get_coeff(key2,
func->impl_p2_vector);
6528 if (coeff_ket.has_data() and coeff_p1.has_data()) {
6532 }
else if (coeff_ket.has_data() or coeff_p1.has_data()) {
6533 coeff_ket = (coeff_ket.has_data()) ? coeff_ket :
outer(coeff_p1,coeff_p2);
6540 if (coeff_v1.has_data()) {
6542 v1v2ket = pm(key,coeff_v1.full_tensor(), 1);
6544 v1v2ket+= pm(key,coeff_v2.full_tensor(), 2);
6547 v1v2ket = coeff_ket;
6551 if (
func->impl_eri) {
6553 coeffT coeff_eri=
func->impl_eri->get_functor()->coeff(key).full_tensor();
6555 tensorT braket=pm(key,coeff_bra.full_tensor_copy().conj());
6561 result=coeff_bra.full_tensor_copy().trace_conj(v1v2ket.
full_tensor_copy());
6570 template <
typename Archive>
void serialize(
const Archive& ar) {
6578 template <
typename R>
6586 do_inner_local_on_demand<R>(
this, &gimpl));
6590 template<
typename R>
6601 const keyT& key=it->first;
6602 const nodeT& fnode = it->second;
6604 if (
other->coeffs.probe(it->first)) {
6609 MADNESS_EXCEPTION(
"functions have different k or compress/reconstruct error", 0);
6628 template <
typename Archive>
void serialize(
const Archive& ar) {
6636 template <
typename R>
6650 typedef std::vector< std::pair<int,const coeffT*> >
mapvecT;
6660 const keyT& key = it->first;
6663 [[maybe_unused]]
auto inserted =
map->insert(acc,key);
6664 acc->second.push_back(std::make_pair(index,&(node.
coeff())));
6677 for (
unsigned int i=0; i<
v.size(); i++) {
6681 if (
v.size())
v[0]->world.taskq.fence();
6687 template <
typename R>
6697 const keyT& key = lit->first;
6699 if (rit != rmap_ptr->
end()) {
6700 const mapvecT& leftv = lit->second;
6702 const int nleft = leftv.size();
6703 const int nright= rightv.
size();
6705 for (
int iv=0; iv<nleft; iv++) {
6706 const int i = leftv[iv].first;
6709 for (
int jv=0; jv<nright; jv++) {
6710 const int j = rightv[jv].first;
6713 if (!sym || (sym && i<=j))
6714 r(i,j) += iptr->trace_conj(*jptr);
6724 template <
typename R>
6734 const keyT& key = lit->first;
6736 if (rit != rmap_ptr->
end()) {
6737 const mapvecT& leftv = lit->second;
6739 const size_t nleft = leftv.size();
6740 const size_t nright= rightv.
size();
6742 unsigned int size = leftv[0].second->size();
6746 for(
unsigned int iv = 0; iv < nleft; ++iv) Left(iv,
_) = (*(leftv[iv].second)).full_tensor();
6747 for(
unsigned int jv = 0; jv < nright; ++jv) Right(jv,
_) = (*(rightv[jv].second)).full_tensor();
6752 for(
unsigned int iv = 0; iv < nleft; ++iv) {
6753 const int i = leftv[iv].first;
6754 for(
unsigned int jv = 0; jv < nright; ++jv) {
6755 const int j = rightv[jv].first;
6756 if (!sym || (sym && i<=j)) result(i,j) += r(iv,jv);
6767 template <
typename R,
typename = std::enable_if_t<std::is_
floating_po
int_v<R>>>
6778 const keyT& key = lit->first;
6780 if (rit != rmap_ptr->
end()) {
6781 const mapvecT& leftv = lit->second;
6783 const int nleft = leftv.size();
6784 const int nright = rightv.
size();
6786 for (
int iv = 0; iv < nleft; iv++) {
6787 const int i = leftv[iv].first;
6790 for (
int jv = 0; jv < nright; jv++) {
6791 const int j = rightv[jv].first;
6794 if (!sym || (sym && i <= j))
6795 r(i, j) += iptr->trace_conj(*jptr);
6805 template <
typename R>
6815 const keyT& key = lit->first;
6817 if (rit != rmap_ptr->
end()) {
6818 const mapvecT& leftv = lit->second;
6820 const size_t nleft = leftv.size();
6821 const size_t nright= rightv.
size();
6823 unsigned int size = leftv[0].second->size();
6827 for(
unsigned int iv = 0; iv < nleft; ++iv) Left(iv,
_) = (*(leftv[iv].second)).full_tensor();
6828 for(
unsigned int jv = 0; jv < nright; ++jv) Right(jv,
_) = (*(rightv[jv].second)).full_tensor();
6832 for(
unsigned int iv = 0; iv < nleft; ++iv) {
6833 const int i = leftv[iv].first;
6834 for(
unsigned int jv = 0; jv < nright; ++jv) {
6835 const int j = rightv[jv].first;
6836 if (!sym || (sym && i <= j)) result(i, j) += r(iv, jv);
6845 template <
typename Real>
6846 static std::enable_if_t<std::is_floating_point_v<Real>, Real>
conj(
const Real x) {
6850 template <
typename Real>
6851 static std::complex<Real>
conj(
const std::complex<Real>& x) {
6852 return std::conj(x);
6855 template <
typename R>
6881 size_t chunk = (lmap.
size()-1)/(3*4*5)+1;
6887 while (lstart != lmap.
end()) {
6889 advance(lend,chunk);
6893 left[0]->world.taskq.fence();
6896 for (
long i=0; i<r.
dim(0); i++) {
6897 for (
long j=0; j<i; j++) {
6907 template <
typename R>
6933 size_t chunk = (lmap.
size() - 1) / (3 * 4 * 5) + 1;
6939 while (lstart != lmap.
end()) {
6941 advance(lend, chunk);
6945 left[0]->world.taskq.fence();
6949 for (
long i = 0; i < r.
dim(0); i++) {
6950 for (
long j = 0; j < i; j++) {
6960 template <
typename R>
6963 static_assert(!std::is_same<R, int>::value &&
6964 std::is_same<R, int>::value,
6965 "Compilation failed because you wanted to know the type; see below:");
6975 template<
typename Q, std::size_t LDIM,
typename R, std::size_t KDIM,
6976 std::size_t CDIM = (KDIM + LDIM -
NDIM) / 2>
6978 const std::array<int, CDIM> v1,
const std::array<int, CDIM> v2) {
6980 typedef std::multimap<Key<NDIM>, std::list<Key<CDIM>>> contractionmapT;
6994 std::list<contractionmapT> all_contraction_maps;
6995 for (std::size_t n=0; n<nmax; ++n) {
6999 auto [g_ijlist, g_jlist] =
g.get_contraction_node_lists(n, v1);
7000 auto [h_ijlist, h_jlist] =
h.get_contraction_node_lists(n, v2);
7001 if ((g_ijlist.size() == 0) and (h_ijlist.size() == 0))
break;
7011 bool this_first =
true;
7015 h_ijlist, h_jlist, this_first,
thresh);
7021 h_nc.
key0(), hnode0, v2, v1,
7022 g_ijlist, g_jlist, this_first,
thresh);
7025 contraction_map.merge(contraction_map1);
7027 auto it = contraction_map.begin();
7028 while (it != contraction_map.end()) {
7029 auto it_end = contraction_map.upper_bound(it->first);
7032 while (it2 != it_end) {
7033 it->second.splice(it->second.end(), it2->second);
7034 it2 = contraction_map.erase(it2);
7042 for (
auto& elem: contraction_map) {
7044 elem.second.unique();
7052 all_contraction_maps.push_back(contraction_map);
7054 long mapsize=contraction_map.
size();
7055 if (mapsize==0)
break;
7060 for (
const auto& contraction_map : all_contraction_maps) {
7061 for (
const auto& key_list : contraction_map) {
7063 const std::list<Key<CDIM>>& list=key_list.second;
7065 &
g,&
h,v1,v2,key,list);
7077 template<std::
size_t CDIM>
7078 std::tuple<std::set<Key<NDIM>>, std::map<Key<CDIM>,
double>>
7082 auto has_d_coeffs = [&
cdata](
const coeffT& coeff) {
7083 if (coeff.has_no_data())
return false;
7084 return (coeff.dim(0)==2*
cdata.k);
7088 std::set<Key<NDIM>> ij_list;
7089 std::map<Key<CDIM>,
double> j_list;
7094 if ((key.
level()==
int(n)) and (has_d_coeffs(node.
coeff()))) {
7095 ij_list.insert(key);
7097 for (std::size_t i=0; i<CDIM; ++i) j_trans[i]=key.
translation()[
v[i]];
7099 const double max_d_norm=j_list[jkey];
7100 j_list.insert_or_assign(jkey,std::max(max_d_norm,node.
get_dnorm()));
7104 while (j_list.count(parent_jkey)==0) {
7105 j_list.insert({parent_jkey,1.0});
7106 parent_jkey=parent_jkey.
parent();
7110 return std::make_tuple(ij_list,j_list);
7133 template<std::size_t CDIM, std::size_t ODIM, std::size_t FDIM=
NDIM+ODIM-2*CDIM>
7136 const std::array<int,CDIM>& v_this,
7137 const std::array<int,CDIM>& v_other,
7138 const std::set<
Key<ODIM>>& ij_other_list,
7139 const std::map<
Key<CDIM>,
double>& j_other_list,
7140 bool this_first,
const double thresh) {
7142 std::multimap<Key<FDIM>, std::list<Key<CDIM>>> contraction_map;
7145 if (j_other_list.empty())
return contraction_map;
7152 const double max_d_norm=j_other_list.find(j_this_key)->second;
7158 bool final_scale=key.
level()==ij_other_list.begin()->level();
7159 if (final_scale and sd_norm_product_large) {
7160 for (
auto& other_key : ij_other_list) {
7161 const auto j_other_key=other_key.extract_key(v_other);
7162 if (j_this_key != j_other_key)
continue;
7164 auto k_key=other_key.extract_complement_key(v_other);
7170 contraction_map.insert(std::make_pair(ik_key,std::list<
Key<CDIM>>{j_this_key}));
7172 return contraction_map;
7175 bool continue_recursion = (j_other_list.count(j_this_key)==1);
7176 if (not continue_recursion)
return contraction_map;
7180 continue_recursion = (node.
has_children() or sd_norm_product_large);
7182 if (continue_recursion) {
7184 bool compute_child_s_coeffs=
true;
7189 keyT child=kit.key();
7198 bool need_s_coeffs= childnode_exists ? (acc->second.get_snorm()<=0.0) :
true;
7201 if (need_s_coeffs) {
7202 if (compute_child_s_coeffs) {
7203 if (
d.dim(0)==
cdata.vk[0]) {
7209 compute_child_s_coeffs=
false;
7215 if (not childnode_exists) {
7218 }
else if (childnode_exists and need_s_coeffs) {
7219 acc->second.coeff()=child_s_coeffs;
7223 nodeT& childnode = acc->second;
7227 ij_other_list, j_other_list, this_first,
thresh));
7233 return contraction_map;
7245 template<
typename Q, std::size_t LDIM,
typename R, std::size_t KDIM,
7246 std::size_t CDIM = (KDIM + LDIM -
NDIM) / 2>
7248 const std::array<int, CDIM> v1,
const std::array<int, CDIM> v2,
7251 Key<LDIM - CDIM> i_key;
7252 Key<KDIM - CDIM> k_key;
7256 for (
const auto& j_key: j_key_list) {
7258 auto v_complement = [](
const auto&
v,
const auto& vc) {
7259 constexpr std::size_t VDIM = std::tuple_size<std::decay_t<
decltype(
v)>>
::value;
7260 constexpr std::size_t VCDIM = std::tuple_size<std::decay_t<
decltype(vc)>>
::value;
7261 std::array<int, VCDIM> result;
7262 for (std::size_t i = 0; i < VCDIM; i++) result[i] = (
v.back() + i + 1) % (VDIM + VCDIM);
7265 auto make_ij_key = [&v_complement](
const auto i_key,
const auto j_key,
const auto&
v) {
7266 constexpr std::size_t IDIM = std::decay_t<
decltype(i_key)>::static_size;
7267 constexpr std::size_t JDIM = std::decay_t<
decltype(j_key)>::static_size;
7268 static_assert(JDIM == std::tuple_size<std::decay_t<
decltype(
v)>>
::value);
7271 for (std::size_t i = 0; i <
v.size(); ++i) l[
v[i]] = j_key.translation()[i];
7272 std::array<int, IDIM> vc1;
7273 auto vc = v_complement(
v, vc1);
7274 for (std::size_t i = 0; i < vc.size(); ++i) l[vc[i]] = i_key.translation()[i];
7279 Key<LDIM> ij_key = make_ij_key(i_key, j_key, v1);
7280 Key<KDIM> jk_key = make_ij_key(k_key, j_key, v2);
7284 const coeffT& gcoeff =
g->get_coeffs().find(ij_key).get()->second.coeff();
7285 const coeffT& hcoeff =
h->get_coeffs().find(jk_key).get()->second.coeff();
7287 if (gcoeff.
dim(0) ==
g->get_cdata().k) {
7288 gcoeff1 =
coeffT(
g->get_cdata().v2k,
g->get_tensor_args());
7289 gcoeff1(
g->get_cdata().s0) += gcoeff;
7293 if (hcoeff.
dim(0) ==
g->get_cdata().k) {
7294 hcoeff1 =
coeffT(
h->get_cdata().v2k,
h->get_tensor_args());
7295 hcoeff1(
h->get_cdata().s0) += hcoeff;
7301 auto fuse = [](
Tensor<T> tensor,
const std::array<int, CDIM>&
v,
int offset) {
7302 for (std::size_t i = 0; i < CDIM - 1; ++i) {
7312 auto contract2 = [](
const auto& svdcoeff,
const auto& tensor,
const int particle) {
7313#ifdef ENABLE_GENTENSOR
7314 const int spectator_particle=(
particle+1)%2;
7315 Tensor<Q> gtensor = svdcoeff.get_svdtensor().make_vector_with_weights(
particle);
7316 gtensor=gtensor.
reshape(svdcoeff.rank(),gtensor.
size()/svdcoeff.rank());
7318 Tensor<Q> gtensor_other = svdcoeff.get_svdtensor().ref_vector(spectator_particle);
7335 if (key.
level() > 0) {
7338 gtensor = fuse(gtensor, v1,
offset);
7339 htensor = fuse(htensor, v2,
offset);
7352 int gparticle= v1[0]==0 ? 0 : 1;
7353 int hparticle= v2[0]==0 ? 0 : 1;
7365 result_tmp.
get_svdtensor().set_vectors_and_weights(
w,tmp2,htensor_other);
7366 if (key.
level() > 0) {
7379 result_coeff1.
get_svdtensor().set_vectors_and_weights(
w,tmp2,htensor_other);
7382 result_coeff+=result_tmp;
7392 int hparticle= v2[0]==0 ? 0 : 1;
7405 int gparticle= v1[0]==0 ? 0 : 1;
7419 if (
coeffs.is_local(key))
7438 return c.trace_conj(fc);
7451 T new_inner, result = 0.0;
7458 if (old_inner == T(0)) {
7462 if (
coeffs.find(key).get()->second.has_children()) {
7468 const keyT& child = it.key();
7469 tensorT cc =
coeffs.find(child).get()->second.coeff().full_tensor_copy();
7472 new_inner = inner_child.
sum();
7473 }
else if (leaf_refine) {
7490 const keyT& child = it.key();
7494 new_inner = inner_child.
sum();
7498 new_inner = old_inner;
7510 const keyT& child = it.key();
7520 const std::shared_ptr< FunctionFunctorInterface<T, NDIM> >
fref;
7530 if (
do_leaves and it->second.is_leaf()) {
7531 tensorT cc = it->second.coeff().full_tensor();
7533 }
else if ((not
do_leaves) and (it->first.level() ==
impl->initial_level)) {
7534 tensorT cc = it->second.coeff().full_tensor();
7545 template <
typename Archive>
void serialize(
const Archive& ar) {
7558 do_inner_ext_local_ffi(
f,
this, leaf_refine,
false));
7569 do_inner_ext_local_ffi(
f,
this, leaf_refine,
true));
7581 const bool leaf_refine, T old_inner=T(0))
const {
7598 const keyT& child = it.key();
7605 if (leaf_refine and (
std::abs(new_inner - old_inner) > tol)) {
7607 const keyT& child = it.key();
7631 template <
typename L>
7655 template <
typename L>
7658 T
alpha, T
beta,
double tol,
bool below_leaf) {
7664 if (not below_leaf) {
7665 bool left_leaf = left->
coeffs.
find(key).get()->second.is_leaf();
7671 const keyT& child = it.key();
7681 if (lc.
size() == 0) {
7684 if (it->second.has_coeff())
7685 lc = it->second.coeff().reconstruct_tensor();
7689 if (
c.size() == 0) {
7710 const keyT& child = it.key();
7722 double dnorm =
d.normf();
7733 const keyT& child = it.key();
7737 child, left, left_coeff, child_coeff,
f,
alpha,
beta, tol, below_leaf);
7742 template <
typename L>
7758 template<
size_t LDIM>
7760 const int dim,
const bool fence) {
7767 typedef project_out_op<LDIM> coeff_opT;
7775 coeff_op, apply_op,
cdata.key0);
7778 if (fence)
world.gop.fence();
7784 template<
size_t LDIM>
7791 typedef std::pair<bool,coeffT>
argT;
7815 gcoeff=
iag.get_impl()->parent_to_child(
iag.coeff(),
iag.key(),key1);
7819 gcoeff=
iag.get_impl()->parent_to_child(
iag.coeff(),
iag.key(),key2);
7824 const nodeT& fnode=
fimpl->get_coeffs().find(key).get()->second;
7833 const int k=fcoeff.
dim(0);
7834 const int k_ldim=std::pow(
k,LDIM);
7835 std::vector<long> shape(LDIM,
k);
7841 final=
inner(gtensor,ftensor,0,
dim).reshape(shape);
7844 if (fcoeff.
rank()>0) {
7847 const int otherdim = (
dim + 1) % 2;
7851 const tensorT gatensor =
inner(gtensor, atensor, 0, 1);
7856 for (
int r = 0; r < fcoeff.
rank(); ++r)
final +=
weights(r) * btensor(r,
_);
7857 final =
final.reshape(shape);
7887 return this_type(fimpl1,result1,iag1,dim1);
7890 template <
typename Archive>
void serialize(
const Archive& ar) {
7904 template<
size_t LDIM>
7907 typedef std::pair< keyT,coeffT > pairT;
7912 fiterator end =
f->get_coeffs().end();
7913 for (fiterator it=
f->get_coeffs().begin(); it!=end; ++it) {
7932 }
else if (dim==1) {
7962 template<
size_t LDIM>
7964 const Key<NDIM>& dest,
const int dim)
const {
7977 const int otherdim=(dim+1)%2;
7978 const int k=fcoeff.
dim(0);
7979 std::vector<Slice> s(fcoeff.
config().dim_per_vector()+1,
_);
7982 for (
int r=0; r<fcoeff.
rank(); ++r) {
7984 const tensorT contracted_tensor=fcoeff.
config().ref_vector(dim)(s).reshape(
k,
k,
k);
7985 const tensorT other_tensor=fcoeff.
config().ref_vector(otherdim)(s).reshape(
k,
k,
k);
7986 const double ovlp= gtensor.trace_conj(contracted_tensor);
7987 const double fac=ovlp * fcoeff.
config().weights(r);
7988 result+=fac*other_tensor;
8039 template <
typename Q,
typename F>
8043 typename fdcT::const_iterator end =
f.coeffs.end();
8044 for (
typename fdcT::const_iterator it=
f.coeffs.begin(); it!=end; ++it) {
8045 const keyT& key = it->first;
8046 const fnodeT& node = it->second;
8052 nodeT scaled(
c, node.get_norm_tree(), node.get_dnorm_tree(),
8053 node.get_snorm(), node.get_dnorm(), node.has_children());
8055 coeffs.replace(key,scaled);
8081 template <
class Archive,
class T, std::
size_t NDIM>
8093 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use a locally uninitialized object",0);
8096 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use an unregistered object",0);
8103 template <
class Archive,
class T, std::
size_t NDIM>
8106 bool exists=(ptr) ?
true :
false;
8108 if (exists) ar & ptr->
id();
8112 template <
class Archive,
class T, std::
size_t NDIM>
8124 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use a locally uninitialized object",0);
8129 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use an unregistered object",0);
8137 template <
class Archive,
class T, std::
size_t NDIM>
8140 bool exists=(ptr) ?
true :
false;
8142 if (exists) ar & ptr->
id();
8147 template <
class Archive,
class T, std::
size_t NDIM>
8156 template <
class Archive,
class T, std::
size_t NDIM>
8163 template <
class Archive,
class T, std::
size_t NDIM>
8172 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 ndim() const
Returns the number of dimensions in the tensor.
Definition basetensor.h:144
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
Definition displacements.h:646
a class to track where relevant (parent) coeffs are
Definition funcimpl.h:887
const keyT & key() const
const reference to the key
Definition funcimpl.h:937
CoeffTracker(const CoeffTracker &other, const datumT &datum)
ctor with a pair<keyT,nodeT>
Definition funcimpl.h:917
const LeafStatus & is_leaf() const
const reference to is_leaf flag
Definition funcimpl.h:961
const implT * impl
Definition funcimpl.h:896
CoeffTracker & operator=(const CoeffTracker &other)=default
LeafStatus
Definition funcimpl.h:893
@ yes
Definition funcimpl.h:893
@ no
Definition funcimpl.h:893
@ unknown
Definition funcimpl.h:893
CoeffTracker(const CoeffTracker &other)
copy ctor
Definition funcimpl.h:925
double dnorm(const keyT &key) const
Definition funcimpl.h:954
coeffT coeff_
Definition funcimpl.h:902
const implT * get_impl() const
const reference to impl
Definition funcimpl.h:931
const coeffT & coeff() const
Definition funcimpl.h:934
keyT key_
Definition funcimpl.h:898
double dnorm_
Definition funcimpl.h:904
CoeffTracker(const implT *impl)
the initial ctor making the root key
Definition funcimpl.h:912
void serialize(const Archive &ar)
serialization
Definition funcimpl.h:1013
Future< CoeffTracker > activate() const
find the coefficients
Definition funcimpl.h:990
CoeffTracker()
default ctor
Definition funcimpl.h:909
GenTensor< T > coeffT
Definition funcimpl.h:891
CoeffTracker make_child(const keyT &child) const
make a child of this, ignoring the coeffs
Definition funcimpl.h:964
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:889
std::pair< Key< NDIM >, ShallowNode< T, NDIM > > datumT
Definition funcimpl.h:892
CoeffTracker forward_ctor(const CoeffTracker &other, const datumT &datum) const
taskq-compatible forwarding to the ctor
Definition funcimpl.h:1007
LeafStatus is_leaf_
Definition funcimpl.h:900
coeffT coeff(const keyT &key) const
return the coefficients belonging to the passed-in key
Definition funcimpl.h:945
Key< NDIM > keyT
Definition funcimpl.h:890
CompositeFunctorInterface implements a wrapper of holding several functions and functors.
Definition function_interface.h:172
Definition worldhashmap.h:396
Hash_private::HashAccessor< const hashT, entryT::READLOCK > const_accessor
Definition worldhashmap.h:405
size_t size() const
Definition worldhashmap.h:560
Hash_private::HashAccessor< hashT, entryT::WRITELOCK > accessor
Definition worldhashmap.h:404
iterator begin()
Definition worldhashmap.h:571
iterator end()
Definition worldhashmap.h:583
Hash_private::HashIterator< hashT > iterator
Definition worldhashmap.h:402
iterator find(const keyT &key)
Definition worldhashmap.h:524
Tri-diagonal operator traversing tree primarily for derivative operator.
Definition derivative.h:73
Holds displacements for applying operators to avoid replicating for all operators.
Definition displacements.h:80
const std::vector< Key< NDIM > > & get_disp(Level n, const array_of_bools< NDIM > &kernel_lattice_sum_axes)
Definition displacements.h:352
FunctionCommonData holds all Function data common for given k.
Definition function_common_data.h:52
Tensor< double > quad_phit
transpose of quad_phi
Definition function_common_data.h:102
Tensor< double > quad_phiw
quad_phiw(i,j) = at x[i] value of w[i]*phi[j]
Definition function_common_data.h:103
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
const FunctionCommonData< T, NDIM > & cdata
Definition function_common_data.h:138
GenTensor< T > coeffs2values(const Key< NDIM > &key, const GenTensor< T > &coeff) const
Definition function_common_data.h:142
Tensor< T > values2coeffs(const Key< NDIM > &key, const Tensor< T > &values) const
Definition function_common_data.h:155
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 double get_cell_volume()
Returns the volume of the user cell.
Definition funcdefaults.h:410
static int get_max_refine_level()
Gets the default maximum adaptive refinement level.
Definition funcdefaults.h:220
static bool get_refine()
Gets the default adaptive refinement flag.
Definition funcdefaults.h:248
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 _refine
Definition function_factory.h:99
bool _empty
Definition function_factory.h:100
bool _fence
Definition function_factory.h:103
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
double operator()(double a, double b) const
Definition funcimpl.h:6326
const opT * func
Definition funcimpl.h:6302
Tensor< double > qx
Definition funcimpl.h:6304
double operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:6317
void serialize(const Archive &ar)
Definition funcimpl.h:6331
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:6310
int npt
Definition funcimpl.h:6303
Tensor< double > quad_phiw
Definition funcimpl.h:6306
const implT * impl
Definition funcimpl.h:6301
Tensor< double > quad_phit
Definition funcimpl.h:6305
do_err_box(const do_err_box &e)
Definition funcimpl.h:6314
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:1043
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:7079
void copy_coeffs(const FunctionImpl< Q, NDIM > &other, bool fence)
Copy coeffs from other into self.
Definition funcimpl.h:1301
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:1357
void make_Vphi_ij_u(const opT &leaf_op, const FunctionImpl< T, NDIM > *u, const FunctionImpl< T, LDIM > *i_func=nullptr, const FunctionImpl< T, LDIM > *j_func=nullptr, bool fence=true, double target_precision=0.0, int oversampling=1)
build this = u * [i(1)] * [j(2)] adaptively using Vphi_ij_u_op_NS
Definition funcimpl.h:4925
T eval_cube(Level n, coordT &x, const tensorT &c) const
Definition mraimpl.h:2171
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)
Definition funcimpl.h:7247
AtomicInt large
Definition funcimpl.h:1158
Timer timer_target_driven
Definition funcimpl.h:1156
void binaryXX(const FunctionImpl< L, NDIM > *left, const FunctionImpl< R, NDIM > *right, const opT &op, bool fence)
Definition funcimpl.h:3494
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:5440
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:2925
void add_keys_to_map(mapT *map, int index) const
Adds keys to union of local keys with specified index.
Definition funcimpl.h:6656
void change_tensor_type1(const TensorArgs &targs, bool fence)
change the tensor type of the coefficients in the FunctionNode
Definition mraimpl.h:1206
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:7656
int initial_level
Definition funcimpl.h:1072
int max_refine_level
Definition funcimpl.h:1076
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:5398
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:4035
void traverse_tree(const coeff_opT &coeff_op, const apply_opT &apply_op, const keyT &key) const
Definition funcimpl.h:4005
void do_square_inplace(const keyT &key)
int special_level
Definition funcimpl.h:1073
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:5332
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:1783
double errsq_local(const opT &func) const
Returns the sum of squares of errors from local info ... no comms.
Definition funcimpl.h:6338
WorldContainer< keyT, nodeT > dcT
Definition funcimpl.h:1055
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:3196
void scale_inplace(const T q, bool fence)
In-place scale by a constant.
Definition mraimpl.h:3368
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:2304
World & world
Definition funcimpl.h:1062
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:4073
bool is_redundant() const
Returns true if the function is redundant.
Definition mraimpl.h:264
FunctionNode< T, NDIM > nodeT
Definition funcimpl.h:1053
std::size_t nCoeff_local() const
Returns the number of coefficients in the function for this MPI rank.
Definition mraimpl.h:2056
void print_size(const std::string name) const
print tree size and size
Definition mraimpl.h:2075
FunctionImpl(const FunctionImpl< T, NDIM > &p)
void print_info() const
Prints summary of data distribution.
Definition mraimpl.h:934
void abs_inplace(bool fence)
Definition mraimpl.h:3380
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:3363
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:3238
const FunctionCommonData< T, NDIM > & cdata
Definition funcimpl.h:1082
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:3277
T inner_ij_u_eri(const opT &leaf_op, const FunctionImpl< T, NDIM > *u, const FunctionImpl< T, LDIM > *i_func, const FunctionImpl< T, LDIM > *j_func, const FunctionImpl< T, NDIM > *eri, double target_precision=0.0, int oversampling=1) const
compute <eri(1,2) | u(1,2) * [i(1)] * [j(2)]> adaptively using Vphi_ij_u_op_NS
Definition funcimpl.h:4968
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:1942
const std::vector< Vector< double, NDIM > > & get_special_points() const
Definition funcimpl.h:1067
Future< compressT > compress_spawn(const keyT &key, bool nonstandard, bool keepleaves, bool redundant1)
Invoked on node where key is local.
Definition mraimpl.h:3527
std::size_t nCoeff() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:2066
coeffT unfilter(const coeffT &s) const
Definition mraimpl.h:1296
double vol_nsphere(int n, double R)
Definition funcimpl.h:5428
keyT neighbor_in_volume(const keyT &key, const keyT &disp) const
Returns key of general neighbor that resides in-volume.
Definition mraimpl.h:3499
void compress(const TreeState newstate, bool fence)
compress the wave function
Definition mraimpl.h:1616
void do_dirac_convolution(FunctionImpl< T, LDIM > *f, bool fence) const
Definition funcimpl.h:2387
return world taskq reduce(rangeT(coeffs.begin(), coeffs.end()), do_inner_local< R >(&g, leaves_only))
Future< bool > truncate_spawn(const keyT &key, double tol)
Returns true if after truncation this node has coefficients.
Definition mraimpl.h:2770
void print_type_in_compilation_error(R &&)
Definition funcimpl.h:6961
Future< double > norm_tree_spawn(const keyT &key)
Definition mraimpl.h:1686
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:2843
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:3105
void unset_functor()
Definition mraimpl.h:324
void refine_spawn(const opT &op, const keyT &key)
Definition funcimpl.h:5157
void apply_1d_realspace_push(const opT &op, const FunctionImpl< R, NDIM > *f, int axis, bool fence)
Definition funcimpl.h:4124
void set_truncate_mode(int mode)
Definition funcimpl.h:1943
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:1072
dcT & get_coeffs()
Definition mraimpl.h:358
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:1836
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
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:2151
Timer timer_filter
Definition funcimpl.h:1154
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:2983
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:6157
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:1463
bool autorefine
Definition funcimpl.h:1078
bool halo_enabled() const
Is a neighbor halo staged on this function?
Definition funcimpl.h:1105
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:1259
void chop_at_level(const int n, const bool fence=true)
remove all nodes with level higher than n
Definition mraimpl.h:1222
void unaryXXvalues(const FunctionImpl< Q, NDIM > *func, const opT &op, bool fence)
Definition funcimpl.h:3521
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:6977
TreeState tree_state
Definition funcimpl.h:1085
void print_tree_json(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2863
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:808
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:1311
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:1164
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:1125
Vector< double, NDIM > coordT
Definition funcimpl.h:1057
void apply(opT &op, const FunctionImpl< R, NDIM > &f, bool fence)
apply an operator on f to return this
Definition funcimpl.h:5661
Tensor< T > tensorT
Definition funcimpl.h:1050
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:1173
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:7579
void store(Archive &ar)
Definition funcimpl.h:1489
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:2253
void gaxpy_ext(const FunctionImpl< L, NDIM > *left, T(*f)(const coordT &), T alpha, T beta, double tol, bool fence)
Definition funcimpl.h:7743
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:1410
void print_stats() const
print the number of configurations per node
Definition mraimpl.h:2115
void eval_local_only(const Vector< double, NDIM > *xin, std::size_t npt, Level maxlevel, std::pair< bool, T > *results)
Definition mraimpl.h:3106
void broaden(const array_of_bools< NDIM > &is_periodic, bool fence)
Definition mraimpl.h:1412
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:1733
static void tnorm(const GenTensor< T > &t, double *lo, double *hi)
Definition mraimpl.h:3292
void refine_op(const opT &op, const keyT &key)
Definition funcimpl.h:5132
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:6857
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:2605
Timer timer_change_tensor_type
Definition funcimpl.h:1152
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:1025
std::vector< Slice > child_patch(const keyT &child) const
Returns patch referring to coeffs of child in parent box.
Definition mraimpl.h:797
void print_tree_graphviz(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2916
void project(const implT &old, bool fence)
Projects old function into new basis (only in reconstructed form).
Definition mraimpl.h:1356
void set_tree_state(const TreeState &state)
Definition funcimpl.h:1539
std::size_t min_nodes() const
Returns the min number of nodes on a processor.
Definition mraimpl.h:2007
void copy_coeffs_same_world(const FunctionImpl< Q, NDIM > &other, bool fence)
Copy coeffs from other into self.
Definition funcimpl.h:1364
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor
Definition funcimpl.h:1084
Timer timer_compress_svd
Definition funcimpl.h:1155
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:2226
void make_redundant(const bool fence)
convert this to redundant, i.e. have sum coefficients on all levels
Definition mraimpl.h:1644
void load(Archive &ar)
Definition funcimpl.h:1471
std::size_t max_nodes() const
Returns the max number of nodes on a processor.
Definition mraimpl.h:1998
T inner_ext_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine) const
Definition funcimpl.h:7554
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:1338
TensorArgs targs
Definition funcimpl.h:1080
void flo_unary_op_node_inplace(const opT &op, bool fence)
Definition funcimpl.h:2416
std::size_t size_local() const
Returns the number of coefficients in the function for each rank.
Definition mraimpl.h:2025
GenTensor< Q > values2coeffs(const keyT &key, const GenTensor< Q > &values) const
Definition funcimpl.h:2130
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:3602
T trace_local() const
Returns int(f(x),x) in local volume.
Definition mraimpl.h:3422
void print_grid(const std::string filename) const
Definition mraimpl.h:554
void replicate_on_hosts(bool fence=true)
Definition funcimpl.h:1280
bool get_autorefine() const
Definition mraimpl.h:346
int k
Definition funcimpl.h:1070
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:2954
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:3390
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:3514
TensorType get_tensor_type() const
void do_project_out(const coeffT &fcoeff, const std::pair< keyT, coeffT > gpair, const keyT &gkey, const Key< NDIM > &dest, const int dim) const
Definition funcimpl.h:7963
void remove_leaf_coefficients(const bool fence)
Definition mraimpl.h:1638
void insert_zero_down_to_initial_level(const keyT &key)
Initialize nodes to zero function at initial_level of refinement.
Definition mraimpl.h:2739
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:1036
typedef TENSOR_RESULT_TYPE(T, R) resultT
void unary_op_node_inplace(const opT &op, bool fence)
Definition funcimpl.h:2325
T inner_adaptive_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine) const
Definition funcimpl.h:7565
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:2894
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:7134
std::shared_ptr< FunctionImpl< T, NDIM > > pimplT
Definition funcimpl.h:1049
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:1953
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:1729
dcT coeffs
Definition funcimpl.h:1087
bool exists_and_is_leaf(const keyT &key) const
Definition mraimpl.h:1382
static std::complex< Real > conj(const std::complex< Real > &x)
Definition funcimpl.h:6851
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:4820
void unaryXX(const FunctionImpl< Q, NDIM > *func, const opT &op, bool fence)
Definition funcimpl.h:3508
std::vector< std::pair< int, const coeffT * > > mapvecT
Definition funcimpl.h:6650
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:7759
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:1378
std::vector< std::pair< bool, T > > eval_local_only(const std::vector< Vector< double, NDIM > > &xin, Level maxlevel)
Definition mraimpl.h:3189
void undo_replicate(bool fence=true)
Definition funcimpl.h:1285
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:2179
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:6441
std::size_t real_size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:2043
bool exists_and_has_children(const keyT &key) const
Definition mraimpl.h:1377
void sum_down_spawn(const keyT &key, const coeffT &s)
is this the same as trickle_down() ?
Definition mraimpl.h:977
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:3076
long box_interior[1000]
Definition funcimpl.h:3553
std::atomic< ConcurrentHashMap< keyT, coeffT > * > neighbor_halo_
Definition funcimpl.h:1098
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:3484
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:2049
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:1663
void gaxpy_inplace(const T &alpha, const FunctionImpl< Q, NDIM > &other, const R &beta, bool fence)
Inplace general bilinear operation.
Definition funcimpl.h:1458
friend class FunctionImpl
Definition funcimpl.h:1060
const Tensor< double > cell
Definition funcimpl.h:1075
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:5808
std::size_t halo_size() const
How many neighbor nodes are staged on this rank; zero if no halo.
Definition funcimpl.h:1117
void distribute(std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > newmap) const
Definition funcimpl.h:1292
int get_special_level() const
Definition funcimpl.h:1066
void reconstruct_op(const keyT &key, const coeffT &s, const bool accumulate_NS=true)
Definition mraimpl.h:2238
tensorT gaxpy_ext_node(keyT key, Tensor< L > lc, T(*f)(const coordT &), T alpha, T beta) const
Definition funcimpl.h:7632
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:3405
WorldObject< FunctionImpl< T, NDIM > > woT
Definition funcimpl.h:1045
void undo_redundant(const bool fence)
convert this from redundant to standard reconstructed form
Definition mraimpl.h:1654
GenTensor< T > coeffT
Definition funcimpl.h:1054
const keyT & key0() const
double finalize_apply()
after apply we need to do some cleanup;
Definition mraimpl.h:1910
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor() const
Definition mraimpl.h:318
bool leaves_only
Definition funcimpl.h:6446
friend hashT hash_value(const FunctionImpl< T, NDIM > *pimpl)
Hash a pointer to FunctionImpl.
Definition funcimpl.h:8065
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:1241
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:1855
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:7431
double norm2sq_local() const
Returns the square of the local norm ... no comms.
Definition mraimpl.h:1962
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:1017
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:7448
bool noautorefine(const keyT &key, const tensorT &t) const
Always returns false (for when autorefine is not wanted).
Definition mraimpl.h:960
double truncate_tol(double tol, const keyT &key) const
Returns the truncation threshold according to truncate_method.
Definition mraimpl.h:722
void recursive_apply(opT &apply_op, const std::vector< const FunctionImpl< T, LDIM > * > &fimpls, const std::vector< const FunctionImpl< T, LDIM > * > &gimpls, const bool fence)
traverse a non-existing tree for a sum of hartree products and apply an operator
Definition funcimpl.h:5987
void flo_unary_op_node_inplace(const opT &op, bool fence) const
Definition funcimpl.h:2426
bool autorefine_square_test(const keyT &key, const nodeT &t) const
Returns true if this block of coeffs needs autorefining.
Definition mraimpl.h:966
void erase(const Level &max_level)
truncate tree at a certain level
Definition mraimpl.h:840
void mulXX(const FunctionImpl< L, NDIM > *left, const FunctionImpl< R, NDIM > *right, double tol, bool fence)
Definition funcimpl.h:3480
std::pair< coeffT, std::pair< double, double > > compressT
Definition funcimpl.h:5219
void reconstruct(bool fence)
reconstruct this tree – respects fence
Definition mraimpl.h:1584
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:3897
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:1120
static void tnorm(const tensorT &t, double *lo, double *hi)
Computes norm of low/high-order polyn. coeffs for autorefinement test.
Definition mraimpl.h:3281
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:3076
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:1143
static void tnorm(const SVDTensor< T > &t, double *lo, double *hi, const int particle)
Definition mraimpl.h:3302
std::size_t max_depth() const
Returns the maximum depth of the tree ... collective ... global sum/broadcast.
Definition mraimpl.h:1990
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:2035
void reduce_rank(const double thresh, bool fence)
reduce the rank of the coefficients tensors
Definition mraimpl.h:1214
TreeState get_tree_state() const
Definition funcimpl.h:1543
const Tensor< double > & get_cell() const
Definition funcimpl.h:1562
void halo_clear() const
Discard the neighbor halo, freeing the staged coefficients.
Definition funcimpl.h:1112
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor()
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:5694
tensorT unfilter(const tensorT &s) const
Transform sums+differences at level n to sum coefficients at level n+1.
Definition mraimpl.h:1288
int get_initial_level() const
getter
Definition funcimpl.h:1065
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:3694
virtual ~FunctionImpl()
Definition funcimpl.h:1272
Vector< Translation, NDIM > tranT
Definition funcimpl.h:1051
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:1516
Future< coeffT > truncate_reconstructed_spawn(const keyT &key, const double tol)
truncate using a tree in reconstructed form
Definition mraimpl.h:1709
GenTensor< Q > coeffs2values(const keyT &key, const GenTensor< Q > &coeff) const
Definition funcimpl.h:1997
FunctionImpl(const FunctionFactory< T, NDIM > &factory)
Initialize function impl from data in factory.
Definition funcimpl.h:1161
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:1183
Timer timer_lr_result
Definition funcimpl.h:1153
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:2276
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:2201
void copy_remote_coeffs_from_pid(const ProcessID pid, const FunctionImpl< Q, NDIM > &other)
Definition funcimpl.h:1337
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:7905
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:5360
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:6909
void fcube(const keyT &key, T(*f)(const coordT &), const Tensor< double > &qx, tensorT &fval) const
Evaluate function at quadrature points in the specified box.
Definition mraimpl.h:2599
Tensor< Q > coeffs2values(const keyT &key, const Tensor< Q > &coeff) const
Definition funcimpl.h:2123
Tensor< Q > values2coeffs(const keyT &key, const Tensor< Q > &values) const
Definition funcimpl.h:2137
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:3053
bool is_reconstructed() const
Returns true if the function is compressed.
Definition mraimpl.h:258
void replicate(bool fence=true)
Definition funcimpl.h:1276
double norm_tree_op(const keyT &key, const std::vector< Future< double > > &v)
Definition mraimpl.h:1671
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:870
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:2342
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:1048
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:3032
bool truncate_op(const keyT &key, double tol, const std::vector< Future< bool > > &v)
Definition mraimpl.h:2806
void zero_norm_tree()
Definition mraimpl.h:1400
std::size_t max_local_depth() const
Returns the maximum local depth of the tree ... no communications.
Definition mraimpl.h:1976
tensorT project(const keyT &key) const
Definition mraimpl.h:2951
double thresh
Definition funcimpl.h:1071
double check_symmetry_local() const
Returns some asymmetry measure ... no comms.
Definition mraimpl.h:856
Future< double > get_norm_tree_recursive(const keyT &key) const
Definition mraimpl.h:2972
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:3537
Key< NDIM > keyT
Definition funcimpl.h:1052
friend hashT hash_value(const std::shared_ptr< FunctionImpl< T, NDIM > > impl)
Hash a shared_ptr to FunctionImpl.
Definition funcimpl.h:8075
coeffT multiply(const coeffT &val_ket, const coeffT &val_pot, int particle) const
multiply the ket with a one-electron potential rr(1,2)= f(1,2)*g(1)
Definition mraimpl.h:1085
std::vector< Vector< double, NDIM > > special_points
Definition funcimpl.h:1074
bool truncate_on_project
Definition funcimpl.h:1079
AtomicInt small
Definition funcimpl.h:1157
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:6806
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:6270
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:1474
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:6725
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:3140
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:3010
void broaden_op(const keyT &key, const std::vector< Future< bool > > &v)
Definition mraimpl.h:1388
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:2834
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:2617
void scale_oop(const Q q, const FunctionImpl< F, NDIM > &f, bool fence)
Out-of-place scale by a constant.
Definition funcimpl.h:8040
T typeT
Definition funcimpl.h:1047
std::size_t tree_size() const
Returns the size of the tree structure of the function ... collective global sum.
Definition mraimpl.h:2016
ConcurrentHashMap< keyT, mapvecT > mapT
Definition funcimpl.h:6653
void add_scalar_inplace(T t, bool fence)
Adds a constant to the function. Local operation, optional fence.
Definition mraimpl.h:2698
void forward_traverse(const coeff_opT &coeff_op, const apply_opT &apply_op, const keyT &key) const
Definition funcimpl.h:3991
coeffT filter(const coeffT &s) const
Definition mraimpl.h:1267
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:1308
void abs_square_inplace(bool fence)
Definition mraimpl.h:3385
FunctionImpl(const FunctionImpl< Q, NDIM > &other, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool dozero)
Copy constructor.
Definition funcimpl.h:1227
void refine(const opT &op, bool fence)
Definition funcimpl.h:5170
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:6674
void put_in_box(ProcessID from, long nl, long ni) const
Definition mraimpl.h:925
void unary_op_value_inplace(const opT &op, bool fence)
Definition funcimpl.h:3120
std::pair< const keyT, nodeT > datumT
Definition funcimpl.h:1056
Timer timer_accumulate
Definition funcimpl.h:1151
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:3455
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:4881
void average(const implT &rhs)
take the average of two functions, similar to: this=0.5*(this+rhs)
Definition mraimpl.h:1195
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:5849
void diff(const DerivativeBase< T, NDIM > *D, const implT *f, bool fence)
Definition mraimpl.h:1048
void square_inplace(bool fence)
Pointwise squaring of function with optional global fence.
Definition mraimpl.h:3374
void remove_internal_coefficients(const bool fence)
Definition mraimpl.h:1633
void compute_snorm_and_dnorm(bool fence=true)
compute norm of s and d coefficients for all nodes
Definition mraimpl.h:1238
std::vector< unsigned char > serialize_remote_coeffs()
invoked by copy_remote_coeffs_from_pid to serialize local coeffs
Definition funcimpl.h:1349
long box_leaf[1000]
Definition funcimpl.h:3552
void standard(bool fence)
Changes non-standard compressed form to standard compressed form.
Definition mraimpl.h:1897
void multiop_values_doit(const keyT &key, const opT &op, const std::vector< implT * > &v)
Definition funcimpl.h:3011
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:2098
int truncate_mode
Definition funcimpl.h:1077
void multiop_values(const opT &op, const std::vector< implT * > &v)
Definition funcimpl.h:3028
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:2013
static std::enable_if_t< std::is_floating_point_v< Real >, Real > conj(const Real x)
Definition funcimpl.h:6846
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:494
double _dnorm_tree
norm of the difference coefficients summed up the tree
Definition funcimpl.h:147
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
void accumulate(const coeffT &t, const typename FunctionNode< T, NDIM >::dcT &c, const Key< NDIM > &key, const TensorArgs &args, const bool do_svd_add)
Accumulate inplace and if necessary connect node to parent.
Definition funcimpl.h:448
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:489
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 consolidate_buffer(const TensorArgs &args, const bool do_svd_add)
Definition funcimpl.h:479
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
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:503
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
A multiresolution adaptive numerical function.
Definition mra.h:141
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
RemoteReference< FutureImpl< T > > remote_refT
Definition future.h:395
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
constexpr bool is_full_tensor() const
Definition gentensor.h:224
void add_SVD(const GenTensor< T > &rhs, const double &)
Definition gentensor.h:235
const Tensor< T > & get_tensor() const
Definition gentensor.h:203
void reduce_rank(const double &)
Definition gentensor.h:217
bool has_no_data() const
Definition gentensor.h:211
void normalize()
Definition gentensor.h:218
GenTensor< T > & emul(const GenTensor< T > &other)
Inplace multiply by corresponding elements of argument Tensor.
Definition lowranktensor.h:639
float_scalar_type normf() const
Definition lowranktensor.h:406
double svd_normf() const
Definition gentensor.h:213
SRConf< T > config() const
Definition gentensor.h:237
long rank() const
Definition gentensor.h:212
const Tensor< T > & full_tensor() const
Definition gentensor.h:200
SVDTensor< T > & get_svdtensor()
Definition gentensor.h:228
TensorType tensor_type() const
Definition gentensor.h:221
static double fac_reduce()
return the additional safety for rank reduction
Definition gentensor.h:241
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:588
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:428
constexpr bool is_svd_tensor() const
Definition gentensor.h:222
Iterates in lexical order thru all children of a key.
Definition key.h:624
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:71
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:563
Level level() const
Definition key.h:170
bool is_valid() const
Checks if a key is valid.
Definition key.h:125
hashT hash() const
Definition key.h:159
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:549
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:541
Key parent(int generation=1) const
Returns the key of the parent.
Definition key.h:366
const Vector< Translation, NDIM > & translation() const
Definition key.h:175
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:500
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
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:313
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition tensor.h:1731
Tensor< T > & gaxpy(T alpha, const Tensor< T > &other, T beta)
Inplace generalized saxpy ... this = this*alpha + other*beta.
Definition tensor.h:1810
T sum() const
Returns the sum of all elements of the tensor.
Definition tensor.h:1667
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition tensor.h:1389
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1845
Tensor< T > mapdim(const std::vector< long > &map)
Returns new view/tensor permuting the dimensions.
Definition tensor.h:1629
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type scale(Q x)
Inplace multiplication by scalar of supported type (legacy name).
Definition tensor.h:691
Tensor< T > & emul(const Tensor< T > &t)
Inplace multiply by corresponding elements of argument Tensor.
Definition tensor.h:1804
bool has_data() const
Definition tensor.h:1907
Tensor< T > fusedim(long i)
Returns new view/tensor fusing contiguous dimensions i and i+1.
Definition tensor.h:1592
Tensor< T > flat()
Returns new view/tensor rehshaping to flat (1-d) tensor.
Definition tensor.h:1560
Tensor< T > & conj()
Inplace complex conjugate.
Definition tensor.h:721
Definition function_common_data.h:169
A simple, fixed dimension vector.
Definition vector.h:64
Makes a distributed container with specified attributes.
Definition worlddc.h:1302
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:1469
iterator begin()
Returns an iterator to the beginning of the local data (no communication).
Definition worlddc.h:1552
bool is_replicated() const
Definition worlddc.h:1402
ProcessID owner(const keyT &key) const
Returns processor that logically owns key (no communication).
Definition worlddc.h:1516
implT::const_iterator const_iterator
Definition worlddc.h:1310
void replace(const pairT &datum)
Inserts/replaces key+value pair (non-blocking communication if key not local).
Definition worlddc.h:1456
iterator end()
Returns an iterator past the end of the local data (no communication).
Definition worlddc.h:1566
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:1483
bool is_distributed() const
Definition worlddc.h:1398
implT::iterator iterator
Definition worlddc.h:1309
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:1908
bool is_local(const keyT &key) const
Returns true if the key maps to the local processor (no communication).
Definition worlddc.h:1523
bool is_host_replicated() const
Definition worlddc.h:1406
Future< MEMFUN_RETURNT(memfunT)> send(const keyT &key, memfunT memfun)
Sends message "resultT memfun()" to item (non-blocking comm if remote).
Definition worlddc.h:1665
implT::const_accessor const_accessor
Definition worlddc.h:1312
implT::accessor accessor
Definition worlddc.h:1311
Interface to be provided by any process map.
Definition worlddc.h:128
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:177
Implements most parts of a globally addressable object (via unique ID).
Definition world_object.h:491
WorldObject(const WorldObject &other)
Definition world_object.h:500
void process_pending()
Definition world_object.h:787
ProcessID me
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
Definition world_object.h:1132
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
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
array_of_bools or_front(const array_of_bools< C > &a) const
Definition array_of_bools.h:79
array_of_bools or_back(const array_of_bools< C > &a) const
Definition array_of_bools.h:121
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:2761
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:2464
const double beta
Definition gygi_soltion.cc:62
static const double v
Definition hatom_sf_dirac.cc:20
static double u(double r, double c)
Definition he.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:452
static const char * filename
Definition legendre.cc:96
static const std::vector< Slice > ___
Entire dimension.
Definition slice.h:124
double FunctionDefaults< NDIM >::thresh
Definition mraimpl.h:3879
int power(int base=2)
Definition power.h:43
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
std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > FunctionDefaults< NDIM >::pmap
Definition mraimpl.h:3898
void finalize()
Call this once at the very end of your main program instead of MPI_Finalize().
Definition world.cc:246
Function< Q, NDIM > convert(const Function< T, NDIM > &f, bool fence=true)
Type conversion implies a deep copy. No communication except for optional fence.
Definition mra.h:2286
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:1394
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:807
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:59
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:609
Function< T, NDIM > sum(World &world, const std::vector< Function< T, NDIM > > &f, bool fence=true)
Returns new function — q = sum_i f[i].
Definition vmra.h:1774
static const Slice _(0,-1, 1)
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< double > > > GaussianConvolution1DCache< double >::map
Definition convolution1d.h:1073
int Level
Definition key.h:60
std::enable_if< std::is_base_of< ProjectorBase, projT >::value, OuterProjector< projT, projQ > >::type outer(const projT &p0, const projQ &p1)
Definition projector.h:476
static constexpr double NORM_TREE_UNCOMPUTED
Definition funcimpl.h:127
int RandomValue< int >()
Random int.
Definition ran.cc:250
Tensor< double > FunctionDefaults< NDIM >::cell_width
Definition mraimpl.h:3893
bool has_data(const PropertyResults &p)
Definition Results.h:421
static constexpr double MUL_SCREENING_SAFETY
Definition funcimpl.h:132
static double pop(std::vector< double > &v)
Definition SCF.cc:118
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition mraimpl.h:2292
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:2817
void error(const char *msg)
Definition world.cc:147
NDIM const Function< R, NDIM > & g
Definition mra.h:2817
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
const Future< void > Future< void >::value
Definition future.cc:44
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:1108
Function< T, CCPairFunction< T, NDIM >::LDIM > inner(const CCPairFunction< T, NDIM > &c, const Function< T, CCPairFunction< T, NDIM >::LDIM > &f, const std::tuple< int, int, int > v1, const std::tuple< int, int, int > v2)
Definition ccpairfunction.h:1007
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:923
const FunctionCommonData< T, NDIM > * FunctionCommonData< T, NDIM >::data[MAXK]
Definition mraimpl.h:3875
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:62
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2239
static const int MAXK
The maximum wavelet order presently supported.
Definition funcdefaults.h:55
static long abs(long a)
Definition tensor.h:214
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
Definition test_ar.cc:204
Key parent() const
Definition test_tree.cc:68
hashT hash() const
Definition test_dc.cc:54
Future< this_type > activate() const
Definition funcimpl.h:4788
int oversampling
pointwise_multiplier oversampling (k+oversampling grid)
Definition funcimpl.h:4624
double target_precision
leaf threshold used for the post-screening truncation
Definition funcimpl.h:4623
this_type forward_ctor(implT *result1, const opT &leaf_op1, const ctT &iau1, const ctL &iai1, const ctL &iaj1, const implT *eri1, double target_precision1, int oversampling1)
Definition funcimpl.h:4799
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:4615
Vphi_ij_u_op_NS()
Definition funcimpl.h:4635
void serialize(const Archive &ar)
Definition funcimpl.h:4807
opT leaf_op
Definition funcimpl.h:4618
Vphi_ij_u_op_NS(implT *result, const opT &leaf_op, const ctT &iau, const ctL &iai, const ctL &iaj, const implT *eri, double target_precision, int oversampling=1)
Definition funcimpl.h:4637
const implT * eri
exact ERI g(1,2), on-demand, optional (null → function mode)
Definition funcimpl.h:4622
bool have_j() const
Definition funcimpl.h:4627
bool have_i() const
Definition funcimpl.h:4626
ctL iai
i(1), NS form, optional (null impl → skip particle-1 multiply)
Definition funcimpl.h:4620
ctT iau
u(1,2), NS form, required
Definition funcimpl.h:4619
void leaf_action(const keyT &key, const coeffT &coeff) const
Definition funcimpl.h:4711
double compute_error_from_inaccurate_refinement(const keyT &key, const Key< LDIM > &key1, const Key< LDIM > &key2) const
error from inaccurate refinement: cross terms of (snorm,dnorm) for u*[i]*[j]
Definition funcimpl.h:4646
void accumulate_into_result(const keyT &key, const coeffT &coeff) const
Definition funcimpl.h:4630
this_type make_child(const keyT &child) const
Definition funcimpl.h:4778
ctL iaj
j(2), NS form, optional (null impl → skip particle-2 multiply)
Definition funcimpl.h:4621
std::pair< coeffT, double > make_sum_coeffs(const keyT &key) const
Definition funcimpl.h:4685
implT * result
output function (function mode) or accumulation handle (inner mode)
Definition funcimpl.h:4617
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:4614
std::pair< bool, coeffT > operator()(const keyT &key) const
Definition funcimpl.h:4724
bool have_eri() const
Definition funcimpl.h:4628
std::pair< bool, coeffT > continue_recursion(const std::vector< bool > child_is_leaf, const tensorT &coeffs, const keyT &key) const
Definition funcimpl.h:4756
tensorT eri_coeffs(const keyT &key) const
get ERI coefficients at key (same logic as Vphi_op_NS::eri_coeffs)
Definition funcimpl.h:4663
bool randomize() const
Definition funcimpl.h:4612
Vphi_ij_u_op_NS< opT, LDIM > this_type
Definition funcimpl.h:4613
implT * result
where to construct Vphi, no need to track parents
Definition funcimpl.h:4334
bool have_v2() const
Definition funcimpl.h:4343
ctL iav1
Definition funcimpl.h:4338
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:4352
ctL iap1
Definition funcimpl.h:4337
bool have_v1() const
Definition funcimpl.h:4342
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:4418
opT leaf_op
deciding if a given FunctionNode will be a leaf node
Definition funcimpl.h:4335
std::pair< coeffT, double > make_sum_coeffs(const keyT &key) const
make the sum coeffs for key
Definition funcimpl.h:4511
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:4331
ctL iap2
the particles 1 and 2 (exclusive with ket)
Definition funcimpl.h:4337
bool have_ket() const
Definition funcimpl.h:4341
const implT * eri
2-particle potential, must be on-demand
Definition funcimpl.h:4339
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:4332
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
make and insert the coefficients into result's tree
Definition funcimpl.h:4363
void serialize(const Archive &ar)
serialize this (needed for use in recursive_op)
Definition funcimpl.h:4592
Vphi_op_NS< opT, LDIM > this_type
Definition funcimpl.h:4330
ctT iaket
the ket of a pair function (exclusive with p1, p2)
Definition funcimpl.h:4336
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:4464
void accumulate_into_result(const Key< NDIM > &key, const coeffT &coeff) const
Definition funcimpl.h:4346
this_type make_child(const keyT &child) const
Definition funcimpl.h:4563
tensorT eri_coeffs(const keyT &key) const
Definition funcimpl.h:4444
ctL iav2
potentials for particles 1 and 2
Definition funcimpl.h:4338
bool have_eri() const
Definition funcimpl.h:4344
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:4585
Vphi_op_NS()
Definition funcimpl.h:4351
Future< this_type > activate() const
Definition funcimpl.h:4574
bool randomize() const
Definition funcimpl.h:4328
bool randomize() const
Definition funcimpl.h:3841
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition funcimpl.h:3871
add_op(const ctT &f, const ctT &g, const double alpha, const double beta)
Definition funcimpl.h:3849
ctT f
tracking coeffs of first and second addend
Definition funcimpl.h:3844
double alpha
prefactor for f, g
Definition funcimpl.h:3846
add_op this_type
Definition funcimpl.h:3839
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:3838
void serialize(const Archive &ar)
Definition funcimpl.h:3883
ctT g
Definition funcimpl.h:3844
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:3853
double beta
Definition funcimpl.h:3846
this_type make_child(const keyT &child) const
Definition funcimpl.h:3866
this_type forward_ctor(const ctT &f1, const ctT &g1, const double alpha, const double beta)
taskq-compatible ctor
Definition funcimpl.h:3879
opT op
Definition funcimpl.h:3425
opT::resultT resultT
Definition funcimpl.h:3423
Tensor< resultT > operator()(const Key< NDIM > &key, const Tensor< Q > &t) const
Definition funcimpl.h:3432
coeff_value_adaptor(const FunctionImpl< Q, NDIM > *impl_func, const opT &op)
Definition funcimpl.h:3428
const FunctionImpl< Q, NDIM > * impl_func
Definition funcimpl.h:3424
coeff_value_adaptor()=default
void serialize(Archive &ar)
Definition funcimpl.h:3441
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:2633
do_accumulate_trees()=default
void serialize(const Archive &ar)
Definition funcimpl.h:2650
FunctionImpl< Q, NDIM > * result
Definition funcimpl.h:2634
do_accumulate_trees(FunctionImpl< Q, NDIM > &result, const T alpha)
Definition funcimpl.h:2637
T alpha
Definition funcimpl.h:2635
bool operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition funcimpl.h:2641
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:2844
void serialize(const Archive &ar)
Definition funcimpl.h:2872
implT * g
Definition funcimpl.h:2846
do_average()
Definition funcimpl.h:2848
bool operator()(typename rangeT::iterator &it) const
iterator it points to this
Definition funcimpl.h:2852
do_average(implT &g)
Definition funcimpl.h:2849
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2877
void serialize(const Archive &ar)
Definition funcimpl.h:2900
TensorArgs targs
Definition funcimpl.h:2880
do_change_tensor_type(const TensorArgs &targs, implT &g)
Definition funcimpl.h:2886
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2889
implT * f
Definition funcimpl.h:2881
do_change_tensor_type()=default
Range< typename dcT::const_iterator > rangeT
Definition funcimpl.h:2550
double operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition funcimpl.h:2556
do_check_symmetry_local()
Definition funcimpl.h:2552
void serialize(const Archive &ar)
Definition funcimpl.h:2619
double operator()(double a, double b) const
Definition funcimpl.h:2615
do_check_symmetry_local(const implT &f)
Definition funcimpl.h:2553
const implT * f
Definition funcimpl.h:2551
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:5053
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:5059
do_compute_snorm_and_dnorm(const FunctionCommonData< T, NDIM > &cdata)
Definition funcimpl.h:5056
const FunctionCommonData< T, NDIM > & cdata
Definition funcimpl.h:5055
TensorArgs targs
Definition funcimpl.h:2907
do_consolidate_buffer()=default
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2916
do_consolidate_buffer(const TensorArgs &targs, bool do_svd_add)
Definition funcimpl.h:2914
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2904
bool do_svd_add
Definition funcimpl.h:2910
void serialize(const Archive &ar)
Definition funcimpl.h:2920
double operator()(double val) const
Definition funcimpl.h:1667
double limit
Definition funcimpl.h:1662
do_convert_to_color(const double limit, const bool log)
Definition funcimpl.h:1666
bool log
Definition funcimpl.h:1663
do_convert_to_color()=default
static double lower()
Definition funcimpl.h:1664
do_dot_local(const FunctionImpl< R, NDIM > *other, const bool leaves_only)
Definition funcimpl.h:6596
bool leaves_only
Definition funcimpl.h:6593
typedef TENSOR_RESULT_TYPE(T, R) resultT
resultT operator()(resultT a, resultT b) const
Definition funcimpl.h:6624
const FunctionImpl< R, NDIM > * other
Definition funcimpl.h:6592
void serialize(const Archive &ar)
Definition funcimpl.h:6628
resultT operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:6598
FunctionImpl< T, NDIM > * f
prefactor for current function impl
Definition funcimpl.h:1432
do_gaxpy_inplace(FunctionImpl< T, NDIM > *f, T alpha, R beta)
Definition funcimpl.h:1436
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:1437
R beta
prefactor for other function impl
Definition funcimpl.h:1434
void serialize(Archive &ar)
Definition funcimpl.h:1445
Range< typename FunctionImpl< Q, NDIM >::dcT::const_iterator > rangeT
Definition funcimpl.h:1431
T alpha
the current function impl
Definition funcimpl.h:1433
do_gaxpy_inplace()=default
const bool do_leaves
start with leaf nodes instead of initial_level
Definition funcimpl.h:7523
T operator()(T a, T b) const
Definition funcimpl.h:7541
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:7525
void serialize(const Archive &ar)
Definition funcimpl.h:7545
const bool leaf_refine
Definition funcimpl.h:7522
const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > fref
Definition funcimpl.h:7520
T operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:7529
const implT * impl
Definition funcimpl.h:7521
const FunctionImpl< T, NDIM > * bra
Definition funcimpl.h:6455
void serialize(const Archive &ar)
Definition funcimpl.h:6570
const FunctionImpl< R, NDIM > * ket
Definition funcimpl.h:6456
typedef TENSOR_RESULT_TYPE(T, R) resultT
bool leaves_only
Definition funcimpl.h:6457
do_inner_local_on_demand(const FunctionImpl< T, NDIM > *bra, const FunctionImpl< R, NDIM > *ket, const bool leaves_only=true)
Definition funcimpl.h:6460
resultT operator()(resultT a, resultT b) const
Definition funcimpl.h:6566
resultT operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:6463
resultT operator()(resultT a, resultT b) const
Definition funcimpl.h:6426
bool leaves_only
Definition funcimpl.h:6395
void serialize(const Archive &ar)
Definition funcimpl.h:6430
do_inner_local(const FunctionImpl< R, NDIM > *other, const bool leaves_only)
Definition funcimpl.h:6398
const FunctionImpl< R, NDIM > * other
Definition funcimpl.h:6394
resultT operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:6400
typedef TENSOR_RESULT_TYPE(T, R) resultT
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2504
do_keep_sum_coeffs(implT *impl)
constructor need impl for cdata
Definition funcimpl.h:2508
implT * impl
Definition funcimpl.h:2505
void serialize(const Archive &ar)
Definition funcimpl.h:2517
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2510
do_map_and_mirror()=default
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2787
implT * f
Definition funcimpl.h:2781
std::vector< long > mirror
Definition funcimpl.h:2780
void serialize(const Archive &ar)
Definition funcimpl.h:2834
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2778
std::vector< long > map
Definition funcimpl.h:2780
do_map_and_mirror(const std::vector< long > map, const std::vector< long > mirror, implT &f)
Definition funcimpl.h:2784
do_mapdim(const std::vector< long > map, implT &f)
Definition funcimpl.h:2704
void serialize(const Archive &ar)
Definition funcimpl.h:2720
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2698
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2706
std::vector< long > map
Definition funcimpl.h:2700
do_mapdim()
Definition funcimpl.h:2703
implT * f
Definition funcimpl.h:2701
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2736
implT * f
Definition funcimpl.h:2731
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2728
do_mirror()
Definition funcimpl.h:2733
do_mirror(const std::vector< long > mirror, implT &f)
Definition funcimpl.h:2734
void serialize(const Archive &ar)
Definition funcimpl.h:2770
std::vector< long > mirror
Definition funcimpl.h:2730
do_norm2sq_local()=default
double operator()(typename dcT::const_iterator &it) const
Definition funcimpl.h:6361
bool leaves_only
skip the internal nodes, cf. has_coefficients_on_leaves_only()
Definition funcimpl.h:6356
do_norm2sq_local(bool leaves_only)
Definition funcimpl.h:6359
void serialize(const Archive &ar)
Definition funcimpl.h:6377
double operator()(double a, double b) const
Definition funcimpl.h:6373
void serialize(Archive &ar)
Definition funcimpl.h:5321
Key< OPDIM > d
Definition funcimpl.h:5313
Key< OPDIM > key
Definition funcimpl.h:5313
keyT dest
Definition funcimpl.h:5314
double fac
Definition funcimpl.h:5315
do_op_args(const Key< OPDIM > &key, const Key< OPDIM > &d, const keyT &dest, double tol, double fac, double cnorm)
Definition funcimpl.h:5318
double cnorm
Definition funcimpl.h:5315
double tol
Definition funcimpl.h:5315
do_reduce_rank(const TensorArgs &targs)
Definition funcimpl.h:2531
TensorArgs args
Definition funcimpl.h:2527
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2537
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2524
do_reduce_rank(const double &thresh)
Definition funcimpl.h:2532
void serialize(const Archive &ar)
Definition funcimpl.h:2543
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:5287
do_standard(implT *impl)
Definition funcimpl.h:5284
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:5277
void serialize(const Archive &ar)
Definition funcimpl.h:5304
implT * impl
Definition funcimpl.h:5280
void serialize(const Archive &ar)
Definition funcimpl.h:2464
const implT * f
Definition funcimpl.h:2444
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2450
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2443
double thresh
Definition funcimpl.h:2445
do_truncate_NS_leafs(const implT *f)
Definition funcimpl.h:2447
do_truncate_NS_leafs(const implT *f, const double thresh)
Definition funcimpl.h:2448
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2927
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2931
implT * impl
Definition funcimpl.h:2928
void serialize(const Archive &ar)
Definition funcimpl.h:2949
opT op
Definition funcimpl.h:2929
do_unary_op_value_inplace(implT *impl, const opT &op)
Definition funcimpl.h:2930
this_type forward_ctor(implT *result1, const ctL &p11, const ctL &p22, const leaf_opT &leaf_op)
Definition funcimpl.h:3975
bool randomize() const
Definition funcimpl.h:3920
void serialize(const Archive &ar)
Definition funcimpl.h:3979
hartree_op(implT *result, const ctL &p11, const ctL &p22, const leaf_opT &leaf_op)
Definition funcimpl.h:3931
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:3923
ctL p2
tracking coeffs of the two lo-dim functions
Definition funcimpl.h:3926
leaf_opT leaf_op
determine if a given node will be a leaf node
Definition funcimpl.h:3927
hartree_op()
Definition funcimpl.h:3930
implT * result
where to construct the pair function
Definition funcimpl.h:3925
hartree_op< LDIM, leaf_opT > this_type
Definition funcimpl.h:3922
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
Definition funcimpl.h:3936
ctL p1
Definition funcimpl.h:3926
this_type make_child(const keyT &child) const
Definition funcimpl.h:3959
Future< this_type > activate() const
Definition funcimpl.h:3968
multiply_op()
Definition funcimpl.h:3739
ctL g
Definition funcimpl.h:3736
Future< this_type > activate() const
Definition funcimpl.h:3818
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:3731
implT * h
the result function h(1,2) = f(1,2) * g(1)
Definition funcimpl.h:3734
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:3730
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:3766
this_type forward_ctor(implT *h1, const ctT &f1, const ctL &g1, const int particle)
Definition funcimpl.h:3825
static bool randomize()
Definition funcimpl.h:3729
int particle
if g is g(1) or g(2)
Definition funcimpl.h:3737
ctT f
Definition funcimpl.h:3735
multiply_op< LDIM > this_type
Definition funcimpl.h:3732
multiply_op(implT *h1, const ctT &f1, const ctL &g1, const int particle1)
Definition funcimpl.h:3741
bool screen(const coeffT &fcoeff, const coeffT &gcoeff, const keyT &key) const
return true if this will be a leaf node
Definition funcimpl.h:3747
this_type make_child(const keyT &child) const
Definition funcimpl.h:3808
void serialize(const Archive &ar)
Definition funcimpl.h:3829
Definition funcimpl.h:4205
coeffT val_lhs
Definition funcimpl.h:4206
double lo
Definition funcimpl.h:4209
double lo1
Definition funcimpl.h:4209
long oversampling
Definition funcimpl.h:4207
pointwise_multiplier()=default
double error
Definition funcimpl.h:4208
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:4224
coeffT coeff_lhs
Definition funcimpl.h:4206
void serialize(const Archive &ar)
Definition funcimpl.h:4312
double lo2
Definition funcimpl.h:4209
double hi1
Definition funcimpl.h:4209
pointwise_multiplier(const Key< NDIM > key, const coeffT &clhs)
Definition funcimpl.h:4212
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:4269
double hi2
Definition funcimpl.h:4209
double hi
Definition funcimpl.h:4209
project_out_op(const implT *fimpl, implL1 *result, const ctL &iag, const int dim)
Definition funcimpl.h:7800
ctL iag
the low dim function g
Definition funcimpl.h:7795
FunctionImpl< T, NDIM-LDIM > implL1
Definition funcimpl.h:7790
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition funcimpl.h:7879
std::pair< bool, coeffT > argT
Definition funcimpl.h:7791
const implT * fimpl
the hi dim function f
Definition funcimpl.h:7793
this_type forward_ctor(const implT *fimpl1, implL1 *result1, const ctL &iag1, const int dim1)
taskq-compatible ctor
Definition funcimpl.h:7886
this_type make_child(const keyT &child) const
Definition funcimpl.h:7870
project_out_op< LDIM > this_type
Definition funcimpl.h:7788
implL1 * result
the low dim result function
Definition funcimpl.h:7794
Future< argT > operator()(const Key< NDIM > &key) const
do the actual contraction
Definition funcimpl.h:7807
void serialize(const Archive &ar)
Definition funcimpl.h:7890
project_out_op(const project_out_op &other)
Definition funcimpl.h:7802
int dim
0: project 0..LDIM-1, 1: project LDIM..NDIM-1
Definition funcimpl.h:7796
bool randomize() const
Definition funcimpl.h:7786
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:7789
ctT iaf
Definition funcimpl.h:6189
recursive_apply_op2< opT > this_type
Definition funcimpl.h:6184
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition funcimpl.h:6244
const opT * apply_op
need this for randomization
Definition funcimpl.h:6190
bool randomize() const
Definition funcimpl.h:6182
recursive_apply_op2(const recursive_apply_op2 &other)
Definition funcimpl.h:6197
void serialize(const Archive &ar)
Definition funcimpl.h:6260
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:6230
this_type make_child(const keyT &child) const
Definition funcimpl.h:6239
recursive_apply_op2()=default
recursive_apply_op2(implT *result, const ctT &iaf, const opT *apply_op)
Definition funcimpl.h:6194
std::pair< bool, coeffT > argT
Definition funcimpl.h:6186
implT * result
Definition funcimpl.h:6188
CoeffTracker< T, NDIM > ctT
Definition funcimpl.h:6185
argT operator()(const Key< NDIM > &key) const
send off the application of the operator
Definition funcimpl.h:6206
this_type forward_ctor(implT *result1, const ctT &iaf1, const opT *apply_op1)
taskq-compatible ctor
Definition funcimpl.h:6256
this_type forward_ctor(implT *r, const std::vector< Future< ctL > > &f_futures, const std::vector< Future< ctL > > &g_futures, const opT *apply_op1)
Definition funcimpl.h:6131
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
make the summed NS-coefficients and send off the application of the operator
Definition funcimpl.h:6051
recursive_apply_op_vec(implT *result, const std::vector< ctL > &iafs, const std::vector< ctL > &iags, const opT *apply_op)
Definition funcimpl.h:6035
implT * result
Definition funcimpl.h:6028
bool randomize() const
Definition funcimpl.h:6023
recursive_apply_op_vec< opT, LDIM > this_type
Definition funcimpl.h:6025
Future< this_type > activate() const
Definition funcimpl.h:6120
void serialize(const Archive &ar)
Definition funcimpl.h:6145
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:6095
recursive_apply_op_vec()=default
recursive_apply_op_vec(const recursive_apply_op_vec &other)
Definition funcimpl.h:6043
std::vector< ctL > iags
Definition funcimpl.h:6030
opT * apply_op
Definition funcimpl.h:6031
std::vector< ctL > iafs
Definition funcimpl.h:6029
this_type make_child(const keyT &child) const
Definition funcimpl.h:6104
CoeffTracker< T, LDIM > ctL
Definition funcimpl.h:6026
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:5901
this_type forward_ctor(implT *r, const CoeffTracker< T, LDIM > &f1, const CoeffTracker< T, LDIM > &g1, const opT *apply_op1)
Definition funcimpl.h:5966
opT * apply_op
Definition funcimpl.h:5884
recursive_apply_op(const recursive_apply_op &other)
Definition funcimpl.h:5894
recursive_apply_op< opT, LDIM > this_type
Definition funcimpl.h:5879
Future< this_type > activate() const
Definition funcimpl.h:5959
bool randomize() const
Definition funcimpl.h:5877
implT * result
Definition funcimpl.h:5881
CoeffTracker< T, LDIM > iaf
Definition funcimpl.h:5882
void serialize(const Archive &ar)
Definition funcimpl.h:5971
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:5941
recursive_apply_op(implT *result, const CoeffTracker< T, LDIM > &iaf, const CoeffTracker< T, LDIM > &iag, const opT *apply_op)
Definition funcimpl.h:5888
this_type make_child(const keyT &child) const
Definition funcimpl.h:5950
CoeffTracker< T, LDIM > iag
Definition funcimpl.h:5883
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2470
remove_internal_coeffs()=default
constructor need impl for cdata
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2475
void serialize(const Archive &ar)
Definition funcimpl.h:2481
bool operator()(typename rangeT::iterator &it) const
Definition funcimpl.h:2492
remove_leaf_coeffs()=default
constructor need impl for cdata
void serialize(const Archive &ar)
Definition funcimpl.h:2497
Range< typename dcT::iterator > rangeT
Definition funcimpl.h:2487
Definition funcimpl.h:5124
void serialize(Archive &ar)
Definition funcimpl.h:5128
bool operator()(const implT *f, const keyT &key, const nodeT &t) const
Definition funcimpl.h:5125
shallow-copy, pared-down version of FunctionNode, for special purpose only
Definition funcimpl.h:845
coeffT & coeff()
Definition funcimpl.h:859
GenTensor< T > coeffT
Definition funcimpl.h:846
bool is_leaf() const
Definition funcimpl.h:861
void serialize(Archive &ar)
Definition funcimpl.h:863
ShallowNode(const ShallowNode< T, NDIM > &node)
Definition funcimpl.h:854
ShallowNode(const FunctionNode< T, NDIM > &node)
Definition funcimpl.h:851
bool has_children() const
Definition funcimpl.h:860
ShallowNode()
Definition funcimpl.h:850
bool _has_children
Definition funcimpl.h:848
double dnorm
Definition funcimpl.h:849
const coeffT & coeff() const
Definition funcimpl.h:858
coeffT _coeffs
Definition funcimpl.h:847
Definition displacements.h:483
TensorArgs holds the arguments for creating a LowRankTensor.
Definition gentensor.h:134
double thresh
Definition gentensor.h:135
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:812
FunctionImpl< T, NDIM > * impl
Definition funcimpl.h:816
FunctionNode< T, NDIM > nodeT
Definition funcimpl.h:814
accumulate_op(const accumulate_op &other)=default
void operator()(const Key< NDIM > &key, const coeffT &coeff, const bool &is_leaf) const
Definition funcimpl.h:820
void serialize(Archive &ar)
Definition funcimpl.h:824
GenTensor< T > coeffT
Definition funcimpl.h:813
accumulate_op(FunctionImpl< T, NDIM > *f)
Definition funcimpl.h:818
static void load(const Archive &ar, FunctionImpl< T, NDIM > *&ptr)
Definition funcimpl.h:8114
static void load(const Archive &ar, const FunctionImpl< T, NDIM > *&ptr)
Definition funcimpl.h:8083
static void load(const Archive &ar, std::shared_ptr< FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:8165
static void load(const Archive &ar, std::shared_ptr< const FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:8149
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:8139
static void store(const Archive &ar, const FunctionImpl< T, NDIM > *const &ptr)
Definition funcimpl.h:8105
static void store(const Archive &ar, const std::shared_ptr< FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:8174
static void store(const Archive &ar, const std::shared_ptr< const FunctionImpl< T, NDIM > > &ptr)
Definition funcimpl.h:8158
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
void serialize(Archive &ar)
Definition funcimpl.h:770
const opT * op
Definition funcimpl.h:715
hartree_convolute_leaf_op(const implT *f, const implL *g, const opT *op)
Definition funcimpl.h:719
bool operator()(const Key< NDIM > &key) const
no pre-determination
Definition funcimpl.h:723
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:736
const implL * g
Definition funcimpl.h:714
const FunctionImpl< T, NDIM > * f
Definition funcimpl.h:713
FunctionImpl< T, LDIM > implL
Definition funcimpl.h:711
bool do_error_leaf_op() const
Definition funcimpl.h:716
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:710
bool operator()(const Key< NDIM > &key, const GenTensor< T > &coeff) const
no post-determination
Definition funcimpl.h:726
returns true if the sum of hartree products is a leaf node (compute combined norm & error)
Definition funcimpl.h:606
bool operator()(const Key< NDIM > &key) const
no pre-determination
Definition funcimpl.h:617
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:608
bool operator()(const Key< NDIM > &key, const std::vector< Tensor< T > > &fcoeffs, const std::vector< Tensor< T > > &gcoeffs) const
post-determination for vector of pairs: true if well-represented
Definition funcimpl.h:624
hartree_leaf_op_vec()=default
long k
Definition funcimpl.h:610
void serialize(Archive &ar)
Definition funcimpl.h:656
hartree_leaf_op_vec(const implT *f, const long &k)
Definition funcimpl.h:614
const FunctionImpl< T, NDIM > * f
Definition funcimpl.h:609
bool do_error_leaf_op() const
Definition funcimpl.h:611
returns true if the result of a hartree_product is a leaf node (compute norm & error)
Definition funcimpl.h:539
hartree_leaf_op()=default
bool do_error_leaf_op() const
Definition funcimpl.h:544
const FunctionImpl< T, NDIM > * f
Definition funcimpl.h:542
hartree_leaf_op(const implT *f, const long &k)
Definition funcimpl.h:547
long k
Definition funcimpl.h:543
void serialize(Archive &ar)
Definition funcimpl.h:595
bool operator()(const Key< NDIM > &key, const GenTensor< T > &coeff) const
no post-determination
Definition funcimpl.h:553
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:563
bool operator()(const Key< NDIM > &key) const
no pre-determination
Definition funcimpl.h:550
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:541
insert/replaces the coefficients into the function
Definition funcimpl.h:788
insert_op()
Definition funcimpl.h:795
implT * impl
Definition funcimpl.h:794
void operator()(const keyT &key, const coeffT &coeff, const bool &is_leaf) const
Definition funcimpl.h:798
FunctionNode< T, NDIM > nodeT
Definition funcimpl.h:792
Key< NDIM > keyT
Definition funcimpl.h:790
insert_op(const insert_op &other)
Definition funcimpl.h:797
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:789
GenTensor< T > coeffT
Definition funcimpl.h:791
insert_op(implT *f)
Definition funcimpl.h:796
void serialize(Archive &ar)
Definition funcimpl.h:802
Definition funcimpl.h:776
bool operator()(const Key< NDIM > &key, const GenTensor< T > &fcoeff, const GenTensor< T > &gcoeff) const
Definition funcimpl.h:778
void serialize(Archive &ar)
Definition funcimpl.h:782
void operator()(const Key< NDIM > &key, const GenTensor< T > &coeff, const bool &is_leaf) const
Definition funcimpl.h:777
bool operator()(const Key< NDIM > &key, const double &cnorm) const
post-determination: return true if operator and coefficient norms are small
Definition funcimpl.h:685
void serialize(Archive &ar)
Definition funcimpl.h:698
const implT * f
the source or result function, needed for truncate_tol
Definition funcimpl.h:668
op_leaf_op(const opT *op, const implT *f)
Definition funcimpl.h:672
FunctionImpl< T, NDIM > implT
Definition funcimpl.h:665
const opT * op
the convolution operator
Definition funcimpl.h:667
bool do_error_leaf_op() const
Definition funcimpl.h:669
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:675
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:678
Definition lowrankfunction.h:387
Definition funcimpl.h:832
void serialize(Archive &ar)
Definition funcimpl.h:839
bool operator()(const Key< NDIM > &key, const T &t, const R &r) const
Definition funcimpl.h:838
bool operator()(const Key< NDIM > &key, const T &t) const
Definition funcimpl.h:835
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
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
Key< D > keyT
Definition writecoeff2.cc:11