32 #ifndef MADNESS_MRA_FUNCIMPL_H__INCLUDED
33 #define MADNESS_MRA_FUNCIMPL_H__INCLUDED
39 #include <type_traits>
55 template <
typename T, std::
size_t NDIM>
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>
68 class FunctionFactory;
70 template<
typename T, std::
size_t NDIM, std::
size_t MDIM>
71 class CompositeFunctorInterface;
82 template<
typename keyT>
96 return key.hash() %
nproc;
101 template <
typename keyT>
112 Level n = key.level();
113 if (n == 0)
return 0;
115 if (n <= 3 || (n&0x1)) hash = key.hash();
116 else hash = key.parent().hash();
123 template<
typename T, std::
size_t NDIM>
173 if (
this != &other) {
284 print(
"set_coeff: may have a problem");
285 print(
"set_coeff: coeff.dim[0] =", coeffs.
dim(0),
", 2* MAXK =", 2*
MAXK);
296 template <
typename Q>
335 }
else if (
coeff().dim(0) == cdata.
vk[0]) {
338 }
else if (
coeff().is_full_tensor()) {
344 }
else if (
coeff().is_svd_tensor()) {
360 template <
typename Q,
typename R>
401 if (
c.is_local(parent))
432 if (
c.is_local(parent))
450 return this->_coeffs.trace_conj((rhs.
_coeffs));
453 template <
typename Archive>
463 s <<
"\"has_coeff\":" << this->
has_coeff()
464 <<
",\"has_children\":" << this->
has_children() <<
",\"norm\":";
471 s <<
norm <<
",\"norm_tree\":" << nt <<
",\"snorm\":"
474 if (this->
coeff().is_assigned())
475 s <<
",\"dim\":" << this->
coeff().
dim(0);
480 template <
typename T, std::
size_t NDIM>
487 if (nt == 1e300) nt = 0.0;
495 template<
typename T,
size_t NDIM>
522 if (key.
level()<2)
return false;
524 std::vector<Slice>
s0(
NDIM/2,s);
526 const double tol=
f->get_thresh();
527 const double thresh=
f->truncate_tol(tol, key)*0.3;
529 const double fnorm=fcoeff.
normf();
530 const double gnorm=gcoeff.
normf();
533 const double norm=fnorm*gnorm;
537 const double sfnorm=fcoeff(
s0).
normf();
538 const double sgnorm=gcoeff(
s0).
normf();
542 const double ferror=sqrt(
std::abs(fnorm*fnorm-sfnorm*sfnorm));
543 const double gerror=sqrt(
std::abs(gnorm*gnorm-sgnorm*sgnorm));
546 const double error=fnorm*gerror + ferror*gnorm + ferror*gerror;
552 template <
typename Archive>
void serialize (Archive& ar) {
559 template<
typename T,
size_t NDIM,
typename opT>
575 if (key.
level()<2)
return false;
576 const double cnorm=coeff.
normf();
582 if (key.
level()<2)
return false;
585 const opkeyT
source=
op->get_source_key(key);
588 const std::vector<opkeyT>& disp =
op->get_disp(key.
level());
589 const opkeyT&
d = *disp.begin();
591 const double norm=opnorm*cnorm;
596 template <
typename Archive>
void serialize (Archive& ar) {
605 template<
typename T,
size_t NDIM,
size_t LDIM,
typename opT>
637 if (key.
level()<2)
return false;
639 const double tol=
f->get_thresh();
640 const double thresh=
f->truncate_tol(tol, key);
642 const double fnorm=fcoeff.
normf();
643 const double gnorm=gcoeff.
normf();
650 const double norm=fnorm*gnorm;
654 const double ferror=sqrt(fnorm*fnorm-sfnorm*sfnorm);
655 const double gerror=sqrt(gnorm*gnorm-sgnorm*sgnorm);
658 const double error=fnorm*gerror + ferror*gnorm + ferror*gerror;
662 const std::vector<Key<NDIM> >& disp =
op->get_disp(key.
level());
664 const double opnorm =
op->norm(key.
level(),
d, key);
665 const double final_norm=opnorm*sfnorm*sgnorm;
666 if (final_norm <
thresh)
return true;
670 template <
typename Archive>
void serialize (Archive& ar) {
675 template<
typename T,
size_t NDIM>
682 template <
typename Archive>
void serialize (Archive& ar) {}
687 template<
typename T, std::
size_t NDIM>
702 template <
typename Archive>
void serialize (Archive& ar) {
711 template<
typename T, std::
size_t NDIM>
724 template <
typename Archive>
void serialize (Archive& ar) {
731 template<
size_t NDIM>
737 template<
typename T,
typename R>
739 template <
typename Archive>
void serialize (Archive& ar) {}
744 template<
typename T, std::
size_t NDIM>
753 dnorm(node.get_dnorm()) {}
762 template <
typename Archive>
786 template<
typename T,
size_t NDIM>
911 template <
typename Archive>
void serialize(
const Archive& ar) {
918 template<
typename T, std::
size_t NDIM>
940 template <
typename T, std::
size_t NDIM>
947 typedef std::shared_ptr< FunctionImpl<T,NDIM> >
pimplT;
954 typedef std::pair<const keyT,nodeT>
datumT;
981 std::shared_ptr< FunctionFunctorInterface<T,NDIM> >
functor;
1002 ,
world(factory._world)
1004 ,
thresh(factory._thresh)
1030 bool do_refine = factory.
_refine;
1040 std::vector<coordT> functor_special_points=
functor->special_points();
1041 if (!functor_special_points.empty())
special_points.insert(
special_points.end(), functor_special_points.begin(), functor_special_points.end());
1045 if (it->second.is_leaf())
1066 template <
typename Q>
1098 const std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >&
get_pmap()
const;
1106 currentmap->redistribute(
world,newmap);
1111 template <
typename Q>
1116 const keyT& key = it->first;
1128 template<
typename Q,
typename R>
1147 template<
typename Q,
typename R>
1159 template<
typename Q,
typename R>
1176 const double beta,
const implT&
g,
const bool fence);
1179 template <
typename Q,
typename R>
1188 const keyT& key = it->first;
1191 f->coeffs.send(key, &nodeT:: template gaxpy_inplace<Q,R>,
alpha, other_node,
beta);
1194 template <
typename Archive>
1204 template <
typename Q,
typename R>
1217 template <
typename Archive>
1235 template <
typename Archive>
1272 std::shared_ptr<FunctionFunctorInterface<T,NDIM> >
get_functor();
1274 std::shared_ptr<FunctionFunctorInterface<T,NDIM> >
get_functor()
const;
1323 void truncate(
double tol,
bool fence);
1360 void print_tree(std::ostream& os = std::cout,
Level maxlevel = 10000)
const;
1393 double val2=log10(val) - log10(
lower());
1395 val2=0.7-(0.7/
upper)*val2;
1397 color= std::min(0.7,color);
1399 double hue=0.7-(0.7/
limit)*(val);
1427 const int xaxis,
const int yaxis,
const coordT el2);
1449 template<
size_t FDIM>
1451 read_grid(
const std::string keyfile,
const std::string gridfile,
1454 std::ifstream kfile(keyfile.c_str());
1455 std::ifstream gfile(gridfile.c_str());
1459 if (not (std::getline(kfile,line)))
MADNESS_EXCEPTION(
"failed reading 1st line of key data",0);
1460 if (not (std::istringstream(line) >> ndata))
MADNESS_EXCEPTION(
"failed reading k",0);
1461 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 1st line of grid data",0);
1462 if (not (std::istringstream(line) >> ndata1))
MADNESS_EXCEPTION(
"failed reading k",0);
1464 if (not (std::getline(kfile,line)))
MADNESS_EXCEPTION(
"failed reading 2nd line of key data",0);
1465 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 2nd line of grid data",0);
1469 const size_t npt = qx.
dim(0);
1472 long npoints=power<NDIM>(npt);
1474 long nboxes=ndata/npoints;
1476 print(
"reading ",nboxes,
"boxes from file",gridfile,keyfile);
1482 std::string gline,kline;
1484 while (std::getline(kfile,kline)) {
1486 double x,y,z,x1,y1,z1,val;
1493 std::stringstream(kline) >> nn >> l1 >> l2 >> l3;
1501 const double h =
std::pow(0.5,
double(n));
1508 for (
size_t i=0; i<npt; ++i) {
1509 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
1510 for (
size_t j=0; j<npt; ++j) {
1511 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
1512 for (
size_t k=0;
k<npt; ++
k) {
1513 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
1515 auto& success1 = std::getline(gfile,gline);
MADNESS_CHECK(success1);
1516 auto& success2 = std::getline(kfile,kline);
MADNESS_CHECK(success2);
1517 std::istringstream(gline) >> x >> y >> z >> val;
1518 std::istringstream(kline) >> x1 >> y1 >> z1;
1527 if (vnuc_functor) val-=(*vnuc_functor)(
c);
1537 const bool has_children=
false;
1539 nodeT node(coeff,has_children);
1556 template<
size_t FDIM>
1561 std::ifstream gfile(gridfile.c_str());
1565 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 1st line of grid data",0);
1566 if (not (std::istringstream(line) >> ndata))
MADNESS_EXCEPTION(
"failed reading k",0);
1567 if (not (std::getline(gfile,line)))
MADNESS_EXCEPTION(
"failed reading 2nd line of grid data",0);
1571 const size_t npt = qx.
dim(0);
1574 long npoints=power<NDIM>(npt);
1576 long nboxes=ndata/npoints;
1578 print(
"reading ",nboxes,
"boxes from file",gridfile);
1586 while (std::getline(gfile,gline)) {
1588 double x1,y1,z1,val;
1595 std::stringstream(gline) >> nn >> l1 >> l2 >> l3;
1602 const double h =
std::pow(0.5,
double(n));
1609 for (
int i=0; i<npt; ++i) {
1610 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
1611 for (
int j=0; j<npt; ++j) {
1612 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
1613 for (
int k=0;
k<npt; ++
k) {
1614 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
1616 auto& success = std::getline(gfile,gline);
1618 std::istringstream(gline) >> x1 >> y1 >> z1 >> val;
1624 if (vnuc_functor) val-=(*vnuc_functor)(
c);
1634 const bool has_children=
false;
1636 nodeT node(coeff,has_children);
1710 const coeffT& coeff)
const;
1716 template <
typename Q>
1732 template <
typename Q>
1734 const bool s_only)
const {
1768 template <
typename Q>
1786 for (std::size_t
d=0;
d<
NDIM; ++
d) {
1817 template <
typename Q>
1842 template <
typename Q>
1849 template <
typename Q>
1856 template <
typename Q>
1870 template <
typename Q>
1877 MADNESS_EXCEPTION(
"FunctionImpl: fcube_for_mul: child-parent relationship bad?",0);
1881 for (std::size_t
d=0;
d<
NDIM; ++
d) {
1898 template <
typename Q>
1905 MADNESS_EXCEPTION(
"FunctionImpl: fcube_for_mul: child-parent relationship bad?",0);
1909 for (
size_t d=0;
d<
NDIM;
d++) {
1920 template <
typename L,
typename R>
1945 template<
typename R>
1947 const int npt,
const keyT& key)
const {
1954 c11(this->cdata.
s0)=c1;
1955 c22(this->cdata.
s0)=c2;
1967 return copy(result(this->cdata.
s0));
1972 template <
typename L,
typename R,
typename opT>
1983 op(key, tcube, lcube, rcube);
1995 template <
typename L,
typename R>
2005 const keyT& key = it->first;
2007 coeffs.
send(key, &nodeT:: template gaxpy_inplace<T,L>, 1.0, other_node,
alpha);
2013 const keyT& key = it->first;
2015 coeffs.
send(key, &nodeT:: template gaxpy_inplace<T,R>, 1.0, other_node,
beta);
2023 template <
typename opT>
2027 const keyT& parent = it->first;
2028 nodeT& node = it->second;
2044 template <
typename opT>
2048 const keyT& parent = it->first;
2049 nodeT& node = it->second;
2061 template<std::
size_t LDIM>
2076 coeffT g_values =
g->coeffs2values(key,g_coeff);
2079 const long rank=g_values.
rank();
2080 const long maxk=
f->get_k();
2086 tensorT result(maxk,maxk,maxk);
2088 for (
long i=0; i<rank; ++i) {
2092 double singular_value_i = g_values.
get_svdtensor().weights(i);
2093 result += (singular_value_i*c1);
2097 tensorT f_coeff =
f->values2coeffs(key1,result);
2106 template<std::
size_t LDIM>
2111 const keyT& key = it->first;
2119 woT::task(
p, &implT:: template dirac_convolution_op<LDIM>, key, node,
f);
2125 f->trickle_down(
true);
2135 template <
typename opT>
2145 template <
typename opT>
2170 const keyT& key = it->first;
2171 nodeT& node = it->second;
2176 const double error=
d.normf();
2182 template <
typename Archive>
void serialize(
const Archive& ar) {}
2195 nodeT& node = it->second;
2199 template <
typename Archive>
void serialize(
const Archive& ar) {}
2211 nodeT& node = it->second;
2215 template <
typename Archive>
void serialize(
const Archive& ar) {}
2230 nodeT& node = it->second;
2235 template <
typename Archive>
void serialize(
const Archive& ar) {}
2257 nodeT& node = it->second;
2261 template <
typename Archive>
void serialize(
const Archive& ar) {}
2277 if constexpr(
NDIM==6) {
2278 const keyT& key = it->first;
2279 const nodeT& fnode = it->second;
2287 std::vector<long> map(
NDIM);
2288 map[0]=3; map[1]=4; map[2]=5;
2289 map[3]=0; map[4]=1; map[5]=2;
2309 if (have_c1 and have_c2) {
2313 norm=(c1-c2).normf();
2314 }
else if (have_c1) {
2317 }
else if (have_c2) {
2329 throw "ONLY FOR DIM 6!";
2337 template <
typename Archive>
void serialize(
const Archive& ar) {
2349 template<
typename Q,
typename R>
2361 const keyT& key = it->first;
2362 const nodeT& node = it->second;
2368 template <
typename Archive>
void serialize(
const Archive& ar) {
2378 template<
typename Q,
typename R>
2391 const keyT& key = it->first;
2392 const nodeT& fnode = it->second;
2398 nodeT& gnode=acc->second;
2408 template <
typename Archive>
void serialize(
const Archive& ar) {
2426 const keyT& key = it->first;
2427 const nodeT& node = it->second;
2438 template <
typename Archive>
void serialize(
const Archive& ar) {
2456 const keyT& key = it->first;
2457 const nodeT& node = it->second;
2462 for (std::size_t i=0; i<
NDIM; ++i) {
2469 std::vector<Slice> s(
___);
2472 for (
size_t i=0; i<
NDIM; ++i) {
2473 std::size_t
kmax=
c.dim(i);
2475 for (
size_t k=1;
k<
kmax;
k+=2) {
2488 template <
typename Archive>
void serialize(
const Archive& ar) {
2507 const keyT& key = it->first;
2508 const nodeT& node = it->second;
2516 for (std::size_t i=0; i<
NDIM; ++i) l1[
map[i]] = l[i];
2525 for (std::size_t i=0; i<
NDIM; ++i) {
2526 if (
mirror[i]==-1) l1[i]= lmax - l[i];
2532 std::vector<Slice> s(
___);
2535 for (
size_t i=0; i<
NDIM; ++i) {
2536 std::size_t
kmax=
c.dim(i);
2538 for (
size_t k=1;
k<
kmax;
k+=2) {
2552 template <
typename Archive>
void serialize(
const Archive& ar) {
2572 const keyT& key = it->first;
2573 const nodeT& fnode = it->second;
2581 nodeT& gnode=acc->second;
2590 template <
typename Archive>
void serialize(
const Archive& ar) {}
2610 nodeT& node = it->second;
2618 template <
typename Archive>
void serialize(
const Archive& ar) {}
2631 it->second.consolidate_buffer(
targs);
2634 template <
typename Archive>
void serialize(
const Archive& ar) {}
2639 template <
typename opT>
2646 const keyT& key = it->first;
2647 nodeT& node = it->second;
2663 template <
typename Archive>
void serialize(
const Archive& ar) {}
2666 template <
typename Q,
typename R>
2674 std::vector<unsigned int> ind(vleft.size());
2675 for (
unsigned int i=0; i<vleft.size(); ++i) {
2678 for (
unsigned int i=0; i<vleft.size(); ++i) {
2685 if (it->second.has_coeff()) {
2691 for (
unsigned int j=0; j<vleft.size(); ++j) {
2692 unsigned int i = ind[j];
2694 implT* left = vleft[i].get();
2697 if (newnode && key.
level()>0) {
2705 nodeT& node = acc->second;
2722 const std::vector<tensorT>&
c,
2729 template <
typename opT>
2731 std::vector<tensorT>
c(
v.size());
2732 for (
unsigned int i=0; i<
v.size(); i++) {
2735 c[i]=
cc.full_tensor();
2746 template <
typename opT>
2749 for (std::size_t i=1; i<
v.size(); ++i) {
2750 if (
v[i] and
v[i-1]) {
2756 const keyT& key = it->first;
2757 if (it->second.has_coeff())
2758 world.
taskq.
add(*
this, &implT:: template multiop_values_doit<opT>, key,
op,
v);
2771 template <
typename opT>
2773 const std::vector<implT*>& vin, std::vector<implT*>& vout) {
2774 std::vector<tensorT>
c(vin.size());
2775 for (
unsigned int i=0; i<vin.size(); i++) {
2778 c[i]=
cc.full_tensor();
2781 std::vector<tensorT> r =
op(key,
c);
2783 for (std::size_t i=0; i<vout.size(); ++i) {
2794 template <
typename opT>
2796 std::vector<implT*>& vout,
const bool fence=
true) {
2798 for (std::size_t i=1; i<vin.size(); ++i) {
2799 if (vin[i] and vin[i-1]) {
2805 const keyT& key = it->first;
2806 if (it->second.has_coeff())
2807 world.
taskq.
add(*
this, &implT:: template multi_to_multi_op_values_doit<opT>,
2808 key,
op, vin, vout);
2811 for (
implT* it2 : vout) {
2823 template <
typename Q,
typename R>
2829 for (
unsigned int j=0; j<vright.size(); ++j) {
2830 world.
taskq.
add(*
this, &implT:: template vtransform_doit<Q,R>, vright[j],
copy(
c(j,
_)), vleft, tol);
2838 template <
typename opT>
2858 template <
typename L,
typename R>
2868 double lnorm = 1e99;
2870 if (lc.
size() == 0) {
2873 lnorm = it->second.get_norm_tree();
2874 if (it->second.has_coeff())
2875 lc = it->second.coeff().full_tensor_copy();
2879 std::vector<FunctionImpl<T,NDIM>*> vresult;
2880 std::vector<const FunctionImpl<R,NDIM>*> vright;
2881 std::vector< Tensor<R> > vrc;
2882 vresult.reserve(vrightin.size());
2883 vright.reserve(vrightin.size());
2884 vrc.reserve(vrightin.size());
2886 for (
unsigned int i=0; i<vrightin.size(); ++i) {
2891 if (rc.
size() == 0) {
2894 rnorm = it->second.get_norm_tree();
2895 if (it->second.has_coeff())
2896 rc = it->second.coeff().full_tensor_copy();
2903 result->
task(
world.
rank(), &implT:: template do_mul<L,R>, key, lc, std::make_pair(key,rc));
2905 else if (tol && lnorm*rnorm <
truncate_tol(tol, key)) {
2910 vresult.push_back(result);
2911 vright.push_back(right);
2916 if (vresult.size()) {
2924 std::vector< Tensor<R> > vrss(vresult.size());
2925 for (
unsigned int i=0; i<vresult.size(); ++i) {
2926 if (vrc[i].
size()) {
2929 vrss[i] = vright[i]->unfilter(rd);
2934 const keyT& child = kit.key();
2942 std::vector< Tensor<R> > vv(vresult.size());
2943 for (
unsigned int i=0; i<vresult.size(); ++i) {
2945 vv[i] =
copy(vrss[i](cp));
2948 woT::task(
coeffs.
owner(child), &implT:: template mulXXveca<L,R>, child, left, ll, vright, vv, vresult, tol);
2962 template <
typename L,
typename R>
2970 double lnorm=1e99, rnorm=1e99;
2973 if (lc.
size() == 0) {
2976 lnorm = it->second.get_norm_tree();
2977 if (it->second.has_coeff())
2978 lc = it->second.coeff().reconstruct_tensor();
2982 if (rc.
size() == 0) {
2985 rnorm = it->second.get_norm_tree();
2986 if (it->second.has_coeff())
2987 rc = it->second.coeff().reconstruct_tensor();
2992 do_mul<L,R>(key, lc, std::make_pair(key,rc));
3025 const keyT& child = kit.key();
3033 woT::task(
coeffs.
owner(child), &implT:: template mulXXa<L,R>, child, left, ll, right, rr, tol);
3048 template <
typename L,
typename R,
typename opT>
3057 if (lc.
size() == 0) {
3060 if (it->second.has_coeff())
3061 lc = it->second.coeff().reconstruct_tensor();
3065 if (rc.
size() == 0) {
3068 if (it->second.has_coeff())
3069 rc = it->second.coeff().reconstruct_tensor();
3073 do_binary_op<L,R>(key, lc, std::make_pair(key,rc),
op);
3095 const keyT& child = kit.key();
3107 template <
typename Q,
typename opT>
3126 template <
typename Archive>
3140 template <
typename Q,
typename opT>
3145 const Tensor<Q> fc =
func->coeffs.find(key).get()->second.coeff().reconstruct_tensor();
3147 if (fc.
size() == 0) {
3151 const keyT& child = kit.key();
3165 template <
typename L,
typename R>
3179 template <
typename L,
typename R,
typename opT>
3181 const opT&
op,
bool fence) {
3193 template <
typename Q,
typename opT>
3206 template <
typename Q,
typename opT>
3222 template <
typename L,
typename R>
3228 std::vector< Tensor<R> > vr(vright.size());
3284 const coordT& plotlo,
const coordT& plothi,
const std::vector<long>& npt,
3285 bool eval_refine)
const;
3295 const std::vector<long>& npt,
3296 const bool eval_refine =
false)
const;
3383 template<
size_t LDIM>
3410 double glo=0.0, ghi=0.0, flo=0.0, fhi=0.0;
3414 double total_hi=glo*fhi + ghi*flo + fhi*ghi;
3442 bool is_leaf=
screen(coeff1_2D,coeff2,key);
3443 if (key.
level()<2) is_leaf=
false;
3462 return std::pair<bool,coeffT> (is_leaf,hcoeff);
3486 template <
typename Archive>
void serialize(
const Archive& ar) {
3513 if (not is_leaf)
return std::pair<bool,coeffT> (is_leaf,
coeffT());
3520 return std::pair<bool,coeffT> (is_leaf,hcoeff);
3540 template <
typename Archive>
void serialize(
const Archive& ar) {
3553 template<
size_t LDIM>
3560 coeff_opT coeff_op(
this,ff,gg,
particle);
3563 apply_opT apply_op(
this);
3568 woT::task(
p, &implT:: template forward_traverse<coeff_opT,apply_opT>, coeff_op, apply_op,
key0);
3575 template<
size_t LDIM,
typename leaf_opT>
3603 if (not is_leaf)
return std::pair<bool,coeffT> (is_leaf,
coeffT());
3613 return std::pair<bool,coeffT>(is_leaf,coeff);
3636 template <
typename Archive>
void serialize(
const Archive& ar) {
3647 template<
typename coeff_opT,
typename apply_opT>
3651 woT::task(
world.
rank(), &implT:: template traverse_tree<coeff_opT,apply_opT>, active_coeff, apply_op, key);
3661 template<
typename coeff_opT,
typename apply_opT>
3665 typedef typename std::pair<bool,coeffT> argT;
3666 const argT
arg=coeff_op(key);
3667 apply_op.operator()(key,
arg.second,
arg.first);
3669 const bool has_children=(not
arg.first);
3672 const keyT& child=kit.key();
3673 coeff_opT child_op=coeff_op.make_child(child);
3677 void (
implT::*ft)(
const coeff_opT&,
const apply_opT&,
const keyT&)
const = &implT::forward_traverse<coeff_opT,apply_opT>;
3691 template<std::
size_t LDIM,
typename leaf_opT>
3694 const leaf_opT&
leaf_op,
bool fence) {
3695 MADNESS_CHECK_THROW(p1.size()==p2.size(),
"hartree_product: p1 and p2 must have the same size");
3696 for (
auto&
p : p1)
MADNESS_CHECK(
p->is_nonstandard() or
p->is_nonstandard_with_leaves());
3697 for (
auto&
p : p2)
MADNESS_CHECK(
p->is_nonstandard() or
p->is_nonstandard_with_leaves());
3701 for (std::size_t i=0; i<p1.size(); ++i) {
3710 coeff_opT coeff_op(
this,iap1,iap2,
leaf_op);
3715 apply_opT apply_op(
this);
3718 coeff_op, apply_op,
cdata.key0);
3728 template <
typename opT,
typename R>
3731 const opT*
op =
pop.ptr;
3733 const double cnorm =
c.normf();
3742 int maxdir = s ? 1 : -1;
3743 for (
int direction=-1; direction<=maxdir; direction+=2) {
3744 lnew[
axis] = lold + direction*s;
3745 if (lnew[
axis] >= 0 && lnew[
axis] < maxs) {
3747 double Rnorm = r.
normf();
3753 if (s <= 1 || r.
normf()*cnorm > tol) {
3757 if (result.
normf() > tol*0.3) {
3779 template <
typename opT,
typename R>
3786 fiterT end =
f->coeffs.end();
3788 for (fiterT it=
f->coeffs.begin(); it!=end; ++it) {
3789 const fnodeT& node = it->second;
3790 if (node.has_coeff()) {
3791 const keyT& key = it->first;
3792 const Tensor<R>&
c = node.coeff().full_tensor_copy();
3793 woT::task(
me, &implT:: template apply_1d_realspace_push_op<opT,R>,
3803 const std::pair<keyT,coeffT>& left,
3804 const std::pair<keyT,coeffT>& center,
3805 const std::pair<keyT,coeffT>& right);
3810 const std::pair<keyT,coeffT>& left,
3811 const std::pair<keyT,coeffT>& center,
3812 const std::pair<keyT,coeffT>& right);
3856 template<std::
size_t LDIM>
3882 bool use_tnorm=
false;
3887 tensorT val_rhs=fcf.coeffs2values(key, coeff_rhs);
3889 return fcf.values2coeffs(key,val_rhs);
3898 coeff1(
cdata.s0)=coeff_rhs;
3902 tensorT coeff_lhs_k1(cdata_npt.vk);
3907 val_lhs_k1.
emul(val_rhs_k1);
3914 result1(
cdata.s0)=0.0;
3924 const long k=coeff_rhs.
dim(0);
3938 coeff_rhs_npt1(fcf_lo.
cdata.s0)=coeff_rhs;
3952 val_lhs_npt.
emul(val_rhs);
3959 result1(
cdata.s0)=0.0;
3964 template <
typename Archive>
void serialize(
const Archive& ar) {
3977 template<
typename opT,
size_t LDIM>
4018 if(
leaf_op.do_pre_screening()){
4020 if(
leaf_op.pre_screening(key)){
4024 return std::pair<bool,coeffT> (
true,
coeffT());
4035 if(key.
level()<
int(il)){
4047 if(
leaf_op.post_screening(key,sum_coeff)){
4049 return std::pair<bool,coeffT> (
true,
coeffT());
4055 return std::pair<bool,coeffT> (
true,
coeffT());
4059 std::vector<bool> child_is_leaf(1<<
NDIM,
false);
4074 keyT child=kit.key();
4075 bool is_leaf=child_is_leaf[i];
4093 return std::pair<bool,coeffT> (
true,
coeffT());
4123 double dnorm_ket, snorm_ket;
4133 dnorm_ket=s1*d2 + s2*d1 + d1*d2;
4139 error+=snorm*dnorm_ket + dnorm*snorm_ket + dnorm*dnorm_ket;
4144 error+=snorm*dnorm_ket + dnorm*snorm_ket + dnorm*dnorm_ket;
4148 double snorm=s_coeffs.
normf();
4151 double dnorm=
d.normf();
4152 error+=snorm*dnorm_ket + dnorm*snorm_ket + dnorm*dnorm_ket;
4184 double error=refine_error;
4212 return std::make_pair(cresult,
error);
4234 iaket1,iap11,iap21,iav11,iav21,
eri);
4238 const ctL& iap11,
const ctL& iap21,
const ctL& iav11,
const ctL& iav21,
4239 const implT* eri1) {
4244 template <
typename Archive>
void serialize(
const Archive& ar) {
4256 template<
typename opT>
4259 constexpr
size_t LDIM=
NDIM/2;
4266 std::shared_ptr< FunctionFunctorInterface<T,NDIM> > func2(this->
get_functor());
4274 if (fence)
func->make_redundant(
true);
4278 for (
auto& ket :
func->impl_ket_vector) {
4287 for (std::size_t i=0; i<
func->impl_p1_vector.size(); ++i) {
4317 template<
typename opT, std::
size_t LDIM>
4322 const bool fence=
true) {
4333 coeff_opT coeff_op(
this,
leaf_op,iaket,iap1,iap2,iav1,iav2,eri);
4341 coeff_op, apply_op,
cdata.key0);
4350 void mapdim(
const implT&
f,
const std::vector<long>& map,
bool fence);
4360 const std::vector<long>&
mirror,
bool fence);
4393 auto& node=it->second;
4394 node.recompute_snorm_and_dnorm(
cdata);
4464 template <
typename opT>
4471 nodeT& node = acc->second;
4479 const keyT& child = kit.key();
4489 template <
typename opT>
4502 template <
typename opT>
4521 void broaden(std::vector<bool> is_periodic,
bool fence);
4619 const keyT& key = it->first;
4620 nodeT& node = it->second;
4634 template <
typename Archive>
void serialize(
const Archive& ar) {
4641 template<
size_t OPDIM>
4649 template <
class Archive>
4660 template <
typename opT,
typename R,
size_t OPDIM>
4688 template <
typename opT,
typename R,
size_t OPDIM>
4726 template <
typename opT,
typename R,
size_t OPDIM>
4731 if (2*OPDIM==
NDIM) result=
op->apply2_lowdim(args.
key, args.
d, coeff,
4733 if (OPDIM==
NDIM) result =
op->apply2(args.
key, args.
d, coeff,
4736 const double result_norm=result.
svd_normf();
4738 if (result_norm> 0.3*args.
tol/args.
fac) {
4768 template <
typename opT,
typename R>
4780 typedef typename opT::keyT opkeyT;
4781 static const size_t opdim=opT::opdim;
4782 const opkeyT
source=
op->get_source_key(key);
4805 double cnorm =
c.normf();
4807 const std::vector<opkeyT>& disp =
op->get_disp(key.
level());
4808 const std::vector<bool> is_periodic(
NDIM,
false);
4811 uint64_t distsq = 99999999999999;
4812 for (
typename std::vector<opkeyT>::const_iterator it=disp.begin(); it != disp.end(); ++it) {
4815 if (
op->particle()==1)
d=it->merge_with(nullkey);
4816 if (
op->particle()==2)
d=nullkey.merge_with(*it);
4818 uint64_t dsq =
d.distsq();
4819 if (dsq != distsq) {
4820 if (nvalid > 0 && nused == 0 && dsq > 1) {
4838 if (cnorm*opnorm> tol/fac) {
4841 if (result.
normf() > 0.3*tol/fac) {
4854 template <
typename opT,
typename R>
4861 const keyT& key = it->first;
4891 template <
typename opT,
typename R>
4893 const bool& do_kernel) {
4896 typedef typename opT::keyT opkeyT;
4899 std::list<opkeyT> blacklist;
4901 static const size_t opdim=opT::opdim;
4905 const opkeyT
source=
op->get_source_key(key);
4911 double cnorm = coeff.
normf();
4915 apply_targs.
thresh=tol/fac*0.03;
4925 #ifdef HAVE_GENTENSOR
4929 const std::vector<opkeyT>& disp =
op->get_disp(key.
level());
4930 const std::vector<bool> is_periodic(
NDIM,
false);
4932 for (
typename std::vector<opkeyT>::const_iterator it=disp.begin(); it != disp.end(); ++it) {
4933 const opkeyT&
d = *it;
4935 const int shell=
d.distsq();
4936 if (do_kernel and (shell>0))
break;
4937 if ((not do_kernel) and (shell==0))
continue;
4941 else if (
op->particle()==2) disp1=nullkey.
merge_with(*it);
4953 bool screened=
false;
4954 typename std::list<opkeyT>::const_iterator it2;
4955 for (it2=blacklist.begin(); it2!=blacklist.end(); it2++) {
4956 if (
d.is_farther_out_than(*it2)) {
4966 if (cnorm*opnorm> tol/fac) {
4968 double cost_ratio=
op->estimate_costs(
source,
d, coeff_SVD, tol/fac/cnorm, tol/fac);
4972 if (cost_ratio>0.0) {
4976 if (cost_ratio<1.0) {
4980 if (2*opdim==
NDIM) {
4989 }
else if (shell >= 12) {
4992 if (
norm<0.3*tol/fac) blacklist.push_back(
d);
5000 template <
typename opT,
typename R>
5009 const keyT& key = it->first;
5010 const coeffT& coeff = it->second.coeff();
5014 woT::task(
p, &implT:: template do_apply_directed_screening<opT,R>, &
op, key, coeff,
true);
5015 woT::task(
p, &implT:: template do_apply_directed_screening<opT,R>, &
op, key, coeff,
false);
5041 template<
typename opT, std::
size_t LDIM>
5054 coeff_opT coeff_op(
this,ff,gg,&apply_op);
5060 woT::task(
p, &implT:: template forward_traverse<coeff_opT,apply_opT>, coeff_op, apply_op,
key0);
5068 template<
typename opT, std::
size_t LDIM>
5109 bool is_leaf=
leaf_op(key,fcoeff,gcoeff);
5123 result->
task(
p,&implT:: template do_apply_directed_screening<opT,T>,
5129 return std::pair<bool,coeffT> (is_leaf,
coeffT());
5135 const coeffT& coeff)
const {
5138 if (key.
level()<2) is_leaf=
false;
5139 return std::pair<bool,coeffT> (is_leaf,coeff);
5160 const opT* apply_op1) {
5164 template <
typename Archive>
void serialize(
const Archive& ar) {
5175 template<
typename opT>
5185 coeff_opT coeff_op(
this,fimpl,&apply_op);
5191 coeff_op, apply_op,
cdata.key0);
5199 template<
typename opT>
5205 typedef std::pair<bool,coeffT>
argT;
5233 result->
task(
p,&implT:: template do_apply_directed_screening<opT,T>,
5243 const bool is_leaf=
true;
5253 if (key.
level()<2) is_leaf=
false;
5254 return argT(is_leaf,coeff);
5276 return this_type(result1,iaf1,apply_op1);
5279 template <
typename Archive>
void serialize(
const Archive& ar) {
5288 template <
typename opT>
5293 std::vector<long> vq(
NDIM);
5294 for (std::size_t i=0; i<
NDIM; ++i)
5296 tensorT fval(vq,
false), work(vq,
false), result(vq,
false);
5314 double err = fval.normf();
5318 template <
typename opT>
5337 const keyT& key = it->first;
5338 const nodeT& node = it->second;
5349 template <
typename Archive>
5356 template <
typename opT>
5360 const int npt =
cdata.npt + 1;
5375 const nodeT& node = it->second;
5389 template <
typename Archive>
void serialize(
const Archive& ar) {
5390 throw "NOT IMPLEMENTED";
5399 template<
typename R>
5410 const keyT& key=it->first;
5411 const nodeT& fnode = it->second;
5418 MADNESS_EXCEPTION(
"functions have different k or compress/reconstruct error", 0);
5437 template <
typename Archive>
void serialize(
const Archive& ar) {
5438 throw "NOT IMPLEMENTED";
5445 template <
typename R>
5460 template<
typename R>
5472 constexpr std::size_t LDIM=
std::max(
NDIM/2,std::size_t(1));
5474 const keyT& key=it->first;
5475 const nodeT& fnode = it->second;
5476 if (not fnode.
has_coeff())
return resultT(0.0);
5479 auto find_valid_parent = [](
auto& key,
auto& impl,
auto&& find_valid_parent) {
5480 MADNESS_CHECK(impl->get_coeffs().owner(key)==impl->world.rank());
5481 if (impl->get_coeffs().probe(key))
return key;
5482 auto parentkey=key.
parent();
5483 return find_valid_parent(parentkey, impl, find_valid_parent);
5487 auto get_coeff = [&find_valid_parent](
const auto& key,
const auto& v_impl) {
5488 if ((v_impl.size()>0) and v_impl.front().get()) {
5489 auto impl=v_impl.front();
5493 auto parentkey = find_valid_parent(key, impl, find_valid_parent);
5495 typename decltype(impl->coeffs)::accessor acc;
5496 impl->get_coeffs().find(acc,parentkey);
5497 auto parentcoeff=acc->second.coeff();
5498 auto coeff=impl->parent_to_child(parentcoeff, parentkey, key);
5502 typedef typename std::decay_t<decltype(v_impl)>::value_type::element_type::typeT S;
5509 auto make_vector = [](
auto&
arg) {
5510 return std::vector<std::decay_t<decltype(
arg)>>(1,
arg);
5521 "only one ket function supported in inner_on_demand");
5523 "only one p1 function supported in inner_on_demand");
5525 "only one p2 function supported in inner_on_demand");
5526 auto coeff_bra=fnode.
coeff();
5527 auto coeff_ket=get_coeff(key,
func->impl_ket_vector);
5528 auto coeff_v1=get_coeff(key1,make_vector(
func->impl_m1));
5529 auto coeff_v2=get_coeff(key2,make_vector(
func->impl_m2));
5530 auto coeff_p1=get_coeff(key1,
func->impl_p1_vector);
5531 auto coeff_p2=get_coeff(key2,
func->impl_p2_vector);
5535 if (coeff_ket.has_data() and coeff_p1.has_data()) {
5539 }
else if (coeff_ket.has_data() or coeff_p1.has_data()) {
5540 coeff_ket = (coeff_ket.has_data()) ? coeff_ket :
outer(coeff_p1,coeff_p2);
5547 if (coeff_v1.has_data()) {
5549 v1v2ket = pm(key,coeff_v1.full_tensor(), 1);
5551 v1v2ket+= pm(key,coeff_v2.full_tensor(), 2);
5554 v1v2ket = coeff_ket;
5558 if (
func->impl_eri) {
5560 coeffT coeff_eri=
func->impl_eri->get_functor()->coeff(key).full_tensor();
5562 tensorT braket=pm(key,coeff_bra.full_tensor_copy().conj());
5568 result=coeff_bra.full_tensor_copy().trace_conj(v1v2ket.
full_tensor_copy());
5577 template <
typename Archive>
void serialize(
const Archive& ar) {
5578 throw "NOT IMPLEMENTED";
5585 template <
typename R>
5597 typedef std::vector< std::pair<int,const coeffT*> >
mapvecT;
5607 const keyT& key = it->first;
5610 [[maybe_unused]]
auto inserted = map->
insert(acc,key);
5611 acc->second.push_back(std::make_pair(index,&(node.
coeff())));
5624 for (
unsigned int i=0; i<
v.size(); i++) {
5628 if (
v.size())
v[0]->world.taskq.fence();
5634 template <
typename R>
5644 const keyT& key = lit->first;
5646 if (rit != rmap_ptr->end()) {
5647 const mapvecT& leftv = lit->second;
5649 const int nleft = leftv.
size();
5650 const int nright= rightv.
size();
5652 for (
int iv=0; iv<nleft; iv++) {
5653 const int i = leftv[iv].first;
5656 for (
int jv=0; jv<nright; jv++) {
5657 const int j = rightv[jv].first;
5660 if (!sym || (sym && i<=j))
5661 r(i,j) += iptr->trace_conj(*jptr);
5671 template <
typename R>
5681 const keyT& key = lit->first;
5683 if (rit != rmap_ptr->end()) {
5684 const mapvecT& leftv = lit->second;
5686 const size_t nleft = leftv.
size();
5687 const size_t nright= rightv.
size();
5689 unsigned int size = leftv[0].second->size();
5693 for(
unsigned int iv = 0; iv < nleft; ++iv) Left(iv,
_) = *(leftv[iv].second);
5694 for(
unsigned int jv = 0; jv < nright; ++jv) Right(jv,
_) = *(rightv[jv].second);
5699 for(
unsigned int iv = 0; iv < nleft; ++iv) {
5700 const int i = leftv[iv].first;
5701 for(
unsigned int jv = 0; jv < nright; ++jv) {
5702 const int j = rightv[jv].first;
5703 if (!sym || (sym && i<=j)) result(i,j) += r(iv,jv);
5716 static std::complex<double>
conj(
const std::complex<double> x) {
5720 template <
typename R>
5746 size_t chunk = (lmap.
size()-1)/(3*4*5)+1;
5752 while (lstart != lmap.
end()) {
5758 left[0]->world.taskq.fence();
5761 for (
long i=0; i<r.
dim(0); i++) {
5762 for (
long j=0; j<i; j++) {
5772 template <
typename R>
5775 static_assert(!std::is_same<R, int>::value &&
5776 std::is_same<R, int>::value,
5777 "Compilation failed because you wanted to know the type; see below:");
5787 template<
typename Q, std::size_t LDIM,
typename R, std::size_t KDIM,
5788 std::size_t CDIM = (KDIM + LDIM -
NDIM) / 2>
5790 const std::array<int, CDIM> v1,
const std::array<int, CDIM> v2) {
5792 typedef std::multimap<Key<NDIM>, std::list<Key<CDIM>>> contractionmapT;
5806 std::list<contractionmapT> all_contraction_maps;
5807 for (std::size_t n=0; n<nmax; ++n) {
5811 auto [g_ijlist, g_jlist] =
g.get_contraction_node_lists(n, v1);
5812 auto [h_ijlist, h_jlist] =
h.get_contraction_node_lists(n, v2);
5813 if ((g_ijlist.size() == 0) and (h_ijlist.size() == 0))
break;
5823 bool this_first =
true;
5827 h_ijlist, h_jlist, this_first,
thresh);
5833 h_nc.
key0(), hnode0, v2, v1,
5834 g_ijlist, g_jlist, this_first,
thresh);
5837 contraction_map.merge(contraction_map1);
5839 auto it = contraction_map.begin();
5840 while (it != contraction_map.end()) {
5841 auto it_end = contraction_map.upper_bound(it->first);
5844 while (it2 != it_end) {
5845 it->second.splice(it->second.end(), it2->second);
5846 it2 = contraction_map.erase(it2);
5854 for (
auto& elem: contraction_map) {
5856 elem.second.unique();
5864 all_contraction_maps.push_back(contraction_map);
5866 long mapsize=contraction_map.
size();
5867 if (mapsize==0)
break;
5872 for (
const auto& contraction_map : all_contraction_maps) {
5873 for (
const auto& key_list : contraction_map) {
5875 const std::list<Key<CDIM>>& list=key_list.second;
5877 &
g,&
h,v1,v2,key,list);
5889 template<std::
size_t CDIM>
5890 std::tuple<std::set<Key<NDIM>>, std::map<Key<CDIM>,
double>>
5894 auto has_d_coeffs = [&
cdata](
const coeffT& coeff) {
5895 if (coeff.has_no_data())
return false;
5896 return (coeff.dim(0)==2*
cdata.k);
5900 std::set<Key<NDIM>> ij_list;
5901 std::map<Key<CDIM>,
double> j_list;
5906 if ((key.
level()==n) and (has_d_coeffs(node.
coeff()))) {
5907 ij_list.insert(key);
5909 for (std::size_t i=0; i<CDIM; ++i) j_trans[i]=key.
translation()[
v[i]];
5911 const double max_d_norm=j_list[jkey];
5914 while (j_list.count(parent_jkey)==0) {
5915 j_list.insert({parent_jkey,1.0});
5916 parent_jkey=parent_jkey.
parent();
5920 return std::make_tuple(ij_list,j_list);
5943 template<std::size_t CDIM, std::size_t ODIM, std::size_t FDIM=
NDIM+ODIM-2*CDIM>
5946 const std::array<int,CDIM>& v_this,
5947 const std::array<int,CDIM>& v_other,
5948 const std::set<
Key<ODIM>>& ij_other_list,
5949 const std::map<
Key<CDIM>,
double>& j_other_list,
5950 bool this_first,
const double thresh) {
5952 std::multimap<Key<FDIM>, std::list<Key<CDIM>>> contraction_map;
5955 if (j_other_list.empty())
return contraction_map;
5962 const double max_d_norm=j_other_list.find(j_this_key)->second;
5968 bool final_scale=key.
level()==ij_other_list.begin()->level();
5969 if (final_scale and sd_norm_product_large) {
5970 for (
auto& other_key : ij_other_list) {
5971 const auto j_other_key=other_key.extract_key(v_other);
5972 if (j_this_key != j_other_key)
continue;
5974 auto k_key=other_key.extract_complement_key(v_other);
5980 contraction_map.insert(std::make_pair(ik_key,std::list<
Key<CDIM>>{j_this_key}));
5982 return contraction_map;
5985 bool continue_recursion = (j_other_list.count(j_this_key)==1);
5986 if (not continue_recursion)
return contraction_map;
5990 continue_recursion = (node.
has_children() or sd_norm_product_large);
5992 if (continue_recursion) {
5994 bool compute_child_s_coeffs=
true;
5999 keyT child=kit.key();
6004 bool need_s_coeffs= childnode_exists ? (acc->second.get_snorm()<=0.0) :
true;
6007 if (need_s_coeffs and compute_child_s_coeffs) {
6008 if (
d.dim(0)==
cdata.vk[0]) {
6015 child_s_coeffs.reduce_rank(
thresh);
6016 compute_child_s_coeffs=
false;
6019 if (not childnode_exists) {
6022 }
else if (childnode_exists and need_s_coeffs) {
6023 acc->second.coeff()=child_s_coeffs;
6027 nodeT& childnode = acc->second;
6031 ij_other_list, j_other_list, this_first,
thresh));
6037 return contraction_map;
6049 template<
typename Q, std::size_t LDIM,
typename R, std::size_t KDIM,
6050 std::size_t CDIM = (KDIM + LDIM -
NDIM) / 2>
6052 const std::array<int, CDIM> v1,
const std::array<int, CDIM> v2,
6055 Key<LDIM - CDIM> i_key;
6056 Key<KDIM - CDIM> k_key;
6060 for (
const auto& j_key: j_key_list) {
6062 auto v_complement = [](
const auto&
v,
const auto& vc) {
6063 constexpr std::size_t VDIM = std::tuple_size<std::decay_t<decltype(
v)>>::value;
6064 constexpr std::size_t VCDIM = std::tuple_size<std::decay_t<decltype(vc)>>::value;
6065 std::array<int, VCDIM> result;
6066 for (std::size_t i = 0; i < VCDIM; i++) result[i] = (
v.back() + i + 1) % (VDIM + VCDIM);
6069 auto make_ij_key = [&v_complement](
const auto i_key,
const auto j_key,
const auto&
v) {
6070 constexpr std::size_t IDIM = std::decay_t<decltype(i_key)>::static_size;
6071 constexpr std::size_t JDIM = std::decay_t<decltype(j_key)>::static_size;
6072 static_assert(JDIM == std::tuple_size<std::decay_t<decltype(
v)>>::value);
6075 for (std::size_t i = 0; i <
v.size(); ++i) l[
v[i]] = j_key.translation()[i];
6076 std::array<int, IDIM> vc1;
6077 auto vc = v_complement(
v, vc1);
6078 for (std::size_t i = 0; i < vc.size(); ++i) l[vc[i]] = i_key.translation()[i];
6083 Key<LDIM> ij_key = make_ij_key(i_key, j_key, v1);
6084 Key<KDIM> jk_key = make_ij_key(k_key, j_key, v2);
6088 const coeffT& gcoeff =
g->get_coeffs().find(ij_key).get()->second.coeff();
6089 const coeffT& hcoeff =
h->get_coeffs().find(jk_key).get()->second.coeff();
6091 if (gcoeff.
dim(0) ==
g->get_cdata().k) {
6092 gcoeff1 =
coeffT(
g->get_cdata().v2k,
g->get_tensor_args());
6093 gcoeff1(
g->get_cdata().s0) += gcoeff;
6097 if (hcoeff.
dim(0) ==
g->get_cdata().k) {
6098 hcoeff1 =
coeffT(
h->get_cdata().v2k,
h->get_tensor_args());
6099 hcoeff1(
h->get_cdata().s0) += hcoeff;
6105 auto fuse = [](
Tensor<T> tensor,
const std::array<int, CDIM>&
v,
int offset) {
6106 for (std::size_t i = 0; i < CDIM - 1; ++i) {
6116 auto contract2 = [](
const auto& svdcoeff,
const auto& tensor,
const int particle) {
6118 const int spectator_particle=(
particle+1)%2;
6119 Tensor<Q> gtensor = svdcoeff.get_svdtensor().make_vector_with_weights(
particle);
6120 gtensor=gtensor.
reshape(svdcoeff.rank(),gtensor.
size()/svdcoeff.rank());
6122 Tensor<Q> gtensor_other = svdcoeff.get_svdtensor().ref_vector(spectator_particle);
6139 if (key.
level() > 0) {
6142 gtensor = fuse(gtensor, v1,
offset);
6143 htensor = fuse(htensor, v2,
offset);
6156 int gparticle= v1[0]==0 ? 0 : 1;
6157 int hparticle= v2[0]==0 ? 0 : 1;
6169 result_tmp.
get_svdtensor().set_vectors_and_weights(
w,tmp2,htensor_other);
6170 if (key.
level() > 0) {
6183 result_coeff1.
get_svdtensor().set_vectors_and_weights(
w,tmp2,htensor_other);
6186 result_coeff+=result_tmp;
6196 int hparticle= v2[0]==0 ? 0 : 1;
6209 int gparticle= v1[0]==0 ? 0 : 1;
6242 return c.trace_conj(fc);
6255 T new_inner, result = 0.0;
6262 if (old_inner ==
T(0)) {
6266 if (
coeffs.
find(key).get()->second.has_children()) {
6272 const keyT& child = it.key();
6276 new_inner = inner_child.
sum();
6277 }
else if (leaf_refine) {
6294 const keyT& child = it.key();
6298 new_inner = inner_child.
sum();
6302 new_inner = old_inner;
6314 const keyT& child = it.key();
6324 const std::shared_ptr< FunctionFunctorInterface<T, NDIM> >
fref;
6330 const implT * impl,
const bool leaf_refine,
const bool do_leaves)
6331 : fref(
f), impl(impl), leaf_refine(leaf_refine), do_leaves(do_leaves) {};
6334 if (do_leaves and it->second.is_leaf()) {
6335 tensorT cc = it->second.coeff().full_tensor();
6337 }
else if ((not do_leaves) and (it->first.level() == impl->
initial_level)) {
6338 tensorT cc = it->second.coeff().full_tensor();
6349 template <
typename Archive>
void serialize(
const Archive& ar) {
6350 throw "NOT IMPLEMENTED";
6385 const bool leaf_refine,
T old_inner=
T(0))
const {
6402 const keyT& child = it.key();
6409 if (leaf_refine and (
std::abs(new_inner - old_inner) > tol)) {
6411 const keyT& child = it.key();
6435 template <
typename L>
6459 template <
typename L>
6468 if (not below_leaf) {
6469 bool left_leaf = left->
coeffs.
find(key).get()->second.is_leaf();
6475 const keyT& child = it.key();
6485 if (lc.
size() == 0) {
6488 if (it->second.has_coeff())
6489 lc = it->second.coeff().reconstruct_tensor();
6493 if (
c.size() == 0) {
6514 const keyT& child = it.key();
6526 double dnorm =
d.normf();
6537 const keyT& child = it.key();
6541 child, left, left_coeff, child_coeff,
f,
alpha,
beta, tol, below_leaf);
6546 template <
typename L>
6562 template<
size_t LDIM>
6564 const int dim,
const bool fence) {
6579 coeff_op, apply_op,
cdata.key0);
6588 template<
size_t LDIM>
6595 typedef std::pair<bool,coeffT>
argT;
6637 const int k=fcoeff.
dim(0);
6639 std::vector<long> shape(LDIM,
k);
6645 final=
inner(gtensor,ftensor,0,
dim).reshape(shape);
6648 if (fcoeff.
rank()>0) {
6651 const int otherdim = (
dim + 1) % 2;
6655 const tensorT gatensor =
inner(gtensor, atensor, 0, 1);
6660 for (
int r = 0; r < fcoeff.
rank(); ++r)
final +=
weights(r) * btensor(r,
_);
6661 final =
final.reshape(shape);
6691 return this_type(fimpl1,result1,iag1,dim1);
6694 template <
typename Archive>
void serialize(
const Archive& ar) {
6708 template<
size_t LDIM>
6711 typedef std::pair< keyT,coeffT > pairT;
6716 fiterator end =
f->get_coeffs().end();
6717 for (fiterator it=
f->get_coeffs().begin(); it!=end; ++it) {
6734 woT::task(
world.
rank(),&implT:: template do_project_out<LDIM>,fcoeff,result,key1,key2,dim);
6736 }
else if (dim==1) {
6744 woT::task(
world.
rank(),&implT:: template do_project_out<LDIM>,fcoeff,result,key2,key1,dim);
6766 template<
size_t LDIM>
6768 const Key<NDIM>& dest,
const int dim)
const {
6781 const int otherdim=(dim+1)%2;
6782 const int k=fcoeff.
dim(0);
6783 std::vector<Slice> s(fcoeff.
config().dim_per_vector()+1,
_);
6786 for (
int r=0; r<fcoeff.
rank(); ++r) {
6788 const tensorT contracted_tensor=fcoeff.
config().ref_vector(dim)(s).reshape(
k,
k,
k);
6789 const tensorT other_tensor=fcoeff.
config().ref_vector(otherdim)(s).reshape(
k,
k,
k);
6790 const double ovlp= gtensor.trace_conj(contracted_tensor);
6791 const double fac=ovlp * fcoeff.
config().weights(r);
6792 result+=fac*other_tensor;
6819 std::size_t
size()
const;
6822 std::size_t
nCoeff()
const;
6837 template <
typename Q,
typename F>
6841 typename fdcT::const_iterator end =
f.coeffs.end();
6842 for (
typename fdcT::const_iterator it=
f.coeffs.begin(); it!=end; ++it) {
6843 const keyT& key = it->first;
6844 const fnodeT& node = it->second;
6846 if (node.has_coeff()) {
6877 template <
class Archive,
class T, std::
size_t NDIM>
6889 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use a locally uninitialized object",0);
6892 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use an unregistered object",0);
6899 template <
class Archive,
class T, std::
size_t NDIM>
6902 bool exists=(ptr) ?
true :
false;
6904 if (exists) ar & ptr->
id();
6908 template <
class Archive,
class T, std::
size_t NDIM>
6920 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use a locally uninitialized object",0);
6923 MADNESS_EXCEPTION(
"FunctionImpl: remote operation attempting to use an unregistered object",0);
6930 template <
class Archive,
class T, std::
size_t NDIM>
6933 bool exists=(ptr) ?
true :
false;
6935 if (exists) ar & ptr->
id();
6940 template <
class Archive,
class T, std::
size_t NDIM>
6949 template <
class Archive,
class T, std::
size_t NDIM>
6956 template <
class Archive,
class T, std::
size_t NDIM>
6965 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
a class to track where relevant (parent) coeffs are
Definition: funcimpl.h:787
CoeffTracker(const CoeffTracker &other, const datumT &datum)
ctor with a pair<keyT,nodeT>
Definition: funcimpl.h:817
Future< CoeffTracker > activate() const
find the coefficients
Definition: funcimpl.h:888
const implT * impl
the funcimpl that has the coeffs
Definition: funcimpl.h:796
LeafStatus
Definition: funcimpl.h:793
@ yes
Definition: funcimpl.h:793
@ no
Definition: funcimpl.h:793
@ unknown
Definition: funcimpl.h:793
CoeffTracker(const CoeffTracker &other)
copy ctor
Definition: funcimpl.h:825
double dnorm(const keyT &key) const
return the s and dnorm belonging to the passed-in key
Definition: funcimpl.h:852
coeffT coeff_
the coefficients belonging to key
Definition: funcimpl.h:802
const implT * get_impl() const
const reference to impl
Definition: funcimpl.h:829
const keyT & key() const
const reference to the key
Definition: funcimpl.h:835
keyT key_
the current key, which must exists in impl
Definition: funcimpl.h:798
const LeafStatus & is_leaf() const
const reference to is_leaf flag
Definition: funcimpl.h:859
double dnorm_
norm of d coefficients corresponding to key
Definition: funcimpl.h:804
CoeffTracker(const implT *impl)
the initial ctor making the root key
Definition: funcimpl.h:812
void serialize(const Archive &ar)
serialization
Definition: funcimpl.h:911
CoeffTracker()
default ctor
Definition: funcimpl.h:809
GenTensor< T > coeffT
Definition: funcimpl.h:791
CoeffTracker make_child(const keyT &child) const
make a child of this, ignoring the coeffs
Definition: funcimpl.h:862
const coeffT & coeff() const
const reference to the coeffs
Definition: funcimpl.h:832
FunctionImpl< T, NDIM > implT
Definition: funcimpl.h:789
std::pair< Key< NDIM >, ShallowNode< T, NDIM > > datumT
Definition: funcimpl.h:792
CoeffTracker forward_ctor(const CoeffTracker &other, const datumT &datum) const
taskq-compatible forwarding to the ctor
Definition: funcimpl.h:905
LeafStatus is_leaf_
flag if key is a leaf node
Definition: funcimpl.h:800
coeffT coeff(const keyT &key) const
return the coefficients belonging to the passed-in key
Definition: funcimpl.h:843
Key< NDIM > keyT
Definition: funcimpl.h:790
CompositeFunctorInterface implements a wrapper of holding several functions and functors.
Definition: function_interface.h:165
Definition: worldhashmap.h:396
size_t size() const
Definition: worldhashmap.h:560
std::pair< iterator, bool > insert(const datumT &datum)
Definition: worldhashmap.h:468
iterator begin()
Definition: worldhashmap.h:571
iterator end()
Definition: worldhashmap.h:583
Hash_private::HashIterator< hashT > iterator
Definition: worldhashmap.h:402
Tri-diagonal operator traversing tree primarily for derivative operator.
Definition: derivative.h:73
FunctionCommonData holds all Function data common for given k.
Definition: function_common_data.h:52
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 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:88
static const FunctionCommonData< T, NDIM > & get(int k)
Definition: function_common_data.h:111
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:204
static const double & get_thresh()
Returns the default threshold.
Definition: funcdefaults.h:279
static int get_max_refine_level()
Gets the default maximum adaptive refinement level.
Definition: funcdefaults.h:316
static const Tensor< double > & get_cell()
Gets the user cell for the simulation.
Definition: funcdefaults.h:446
static const Tensor< double > & get_cell_width()
Returns the width of each user cell dimension.
Definition: funcdefaults.h:468
static bool get_apply_randomize()
Gets the random load balancing for integral operators flag.
Definition: funcdefaults.h:392
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
Definition: funcimpl.h:5319
double operator()(double a, double b) const
Definition: funcimpl.h:5345
do_err_box()
Definition: funcimpl.h:5327
const opT * func
Definition: funcimpl.h:5321
Tensor< double > qx
Definition: funcimpl.h:5323
double operator()(typename dcT::const_iterator &it) const
Definition: funcimpl.h:5336
void serialize(const Archive &ar)
Definition: funcimpl.h:5350
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:5329
int npt
Definition: funcimpl.h:5322
Tensor< double > quad_phiw
Definition: funcimpl.h:5325
const implT * impl
Definition: funcimpl.h:5320
Tensor< double > quad_phit
Definition: funcimpl.h:5324
do_err_box(const do_err_box &e)
Definition: funcimpl.h:5333
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition: funcimpl.h:941
void copy_coeffs(const FunctionImpl< Q, NDIM > &other, bool fence)
Copy coeffs from other into self.
Definition: funcimpl.h:1112
bool is_nonstandard() const
Definition: mraimpl.h:252
T eval_cube(Level n, coordT &x, const tensorT &c) const
Definition: mraimpl.h:2055
AtomicInt large
Definition: funcimpl.h:997
Timer timer_target_driven
Definition: funcimpl.h:995
void binaryXX(const FunctionImpl< L, NDIM > *left, const FunctionImpl< R, NDIM > *right, const opT &op, bool fence)
Definition: funcimpl.h:3180
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:4769
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:2789
void add_keys_to_map(mapT *map, int index) const
Adds keys to union of local keys with specified index.
Definition: funcimpl.h:5603
void change_tensor_type1(const TensorArgs &targs, bool fence)
change the tensor type of the coefficients in the FunctionNode
Definition: mraimpl.h:1078
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:6460
int initial_level
Initial level for refinement.
Definition: funcimpl.h:970
int max_refine_level
Do not refine below this level.
Definition: funcimpl.h:973
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:4727
void traverse_tree(const coeff_opT &coeff_op, const apply_opT &apply_op, const keyT &key) const
traverse a non-existing tree
Definition: funcimpl.h:3662
void do_square_inplace(const keyT &key)
int special_level
Minimium level for refinement on special points.
Definition: funcimpl.h:971
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:4661
double errsq_local(const opT &func) const
Returns the sum of squares of errors from local info ... no comms.
Definition: funcimpl.h:5357
GenTensor< Q > coeffs2values(const keyT &key, const GenTensor< Q > &coeff) const
Definition: funcimpl.h:1717
WorldContainer< keyT, nodeT > dcT
Type of container holding the coefficients.
Definition: funcimpl.h:953
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:2970
void scale_inplace(const T q, bool fence)
In-place scale by a constant.
Definition: mraimpl.h:3141
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:208
void unary_op_coeff_inplace(const opT &op, bool fence)
Definition: funcimpl.h:2024
World & world
Definition: funcimpl.h:960
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:3730
bool is_redundant() const
Returns true if the function is redundant.
Definition: mraimpl.h:247
FunctionNode< T, NDIM > nodeT
Type of node.
Definition: funcimpl.h:951
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:2758
void print_size(const std::string name) const
print tree size and size
Definition: mraimpl.h:1971
FunctionImpl(const FunctionImpl< T, NDIM > &p)
void print_info() const
Prints summary of data distribution.
Definition: mraimpl.h:812
void abs_inplace(bool fence)
Definition: mraimpl.h:3153
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:3049
void print_timer() const
Definition: mraimpl.h:336
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:3012
const FunctionCommonData< T, NDIM > & cdata
Definition: funcimpl.h:979
void do_print_grid(const std::string filename, const std::vector< keyT > &keys) const
print the grid in xyz format
Definition: mraimpl.h:563
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:2963
std::size_t nCoeff() const
Returns the number of coefficients in the function ... collective global sum.
Definition: mraimpl.h:1957
double vol_nsphere(int n, double R)
Definition: funcimpl.h:4757
void compress(const TreeState newstate, bool fence)
compress the wave function
Definition: mraimpl.h:1522
void do_dirac_convolution(FunctionImpl< T, LDIM > *f, bool fence) const
Definition: funcimpl.h:2107
Future< bool > truncate_spawn(const keyT &key, double tol)
Returns true if after truncation this node has coefficients.
Definition: mraimpl.h:2634
void print_type_in_compilation_error(R &&)
Definition: funcimpl.h:5773
Future< double > norm_tree_spawn(const keyT &key)
Definition: mraimpl.h:1592
std::vector< keyT > local_leaf_keys() const
return the keys of the local leaf boxes
Definition: mraimpl.h:537
MADNESS_ASSERT(this->is_redundant()==g.is_redundant())
Tensor< Q > values2coeffs(const keyT &key, const Tensor< Q > &values) const
Definition: funcimpl.h:1857
void do_print_tree(const keyT &key, std::ostream &os, Level maxlevel) const
Functor for the do_print_tree method.
Definition: mraimpl.h:2707
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:2824
void unset_functor()
Definition: mraimpl.h:291
void refine_spawn(const opT &op, const keyT &key)
Definition: funcimpl.h:4490
void apply_1d_realspace_push(const opT &op, const FunctionImpl< R, NDIM > *f, int axis, bool fence)
Definition: funcimpl.h:3781
void partial_inner_contract(const FunctionImpl< Q, LDIM > *g, const FunctionImpl< R, KDIM > *h, const std::array< int, CDIM > v1, const std::array< int, CDIM > v2, const Key< NDIM > &key, const std::list< Key< CDIM >> &j_key_list)
tensor contraction part of partial_inner
Definition: funcimpl.h:6051
static double conj(float x)
Definition: funcimpl.h:5712
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:478
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:944
void set_functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor1)
Definition: mraimpl.h:272
void broaden(std::vector< bool > is_periodic, bool fence)
Definition: mraimpl.h:1282
const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap() const
Definition: mraimpl.h:192
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:1818
Timer timer_filter
Definition: funcimpl.h:993
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:2847
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:5176
static std::complex< double > conj(const std::complex< double > x)
Definition: funcimpl.h:5716
double get_thresh() const
Definition: mraimpl.h:307
void trickle_down(bool fence)
sum all the contributions from all scales after applying an operator in mod-NS form
Definition: mraimpl.h:1333
bool autorefine
If true, autorefine where appropriate.
Definition: funcimpl.h:975
std::pair< coeffT, double > make_redundant_op(const keyT &key, const std::vector< Future< std::pair< coeffT, double > > > &v)
similar to compress_op, but insert only the sum coefficients in the tree
Definition: mraimpl.h:1750
void set_autorefine(bool value)
Definition: mraimpl.h:316
tensorT filter(const tensorT &s) const
Transform sum coefficients at level n to sums+differences at level n-1.
Definition: mraimpl.h:1131
void chop_at_level(const int n, const bool fence=true)
remove all nodes with level higher than n
Definition: mraimpl.h:1094
void unaryXXvalues(const FunctionImpl< Q, NDIM > *func, const opT &op, bool fence)
Definition: funcimpl.h:3207
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:5789
TreeState tree_state
Definition: funcimpl.h:982
void print_tree_json(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition: mraimpl.h:2727
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:686
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:1036
TENSOR_RESULT_TYPE(T, R) inner_local(const FunctionImpl< R
Returns the inner product ASSUMING same distribution.
bool is_compressed() const
Returns true if the function is compressed.
Definition: mraimpl.h:235
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition: funcimpl.h:955
void apply(opT &op, const FunctionImpl< R, NDIM > &f, bool fence)
apply an operator on f to return this
Definition: funcimpl.h:4855
Tensor< T > tensorT
Type of tensor for anything but to hold coeffs.
Definition: funcimpl.h:948
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:1045
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:6383
void store(Archive &ar)
Definition: funcimpl.h:1236
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:1973
void gaxpy_ext(const FunctionImpl< L, NDIM > *left, T(*f)(const coordT &), T alpha, T beta, double tol, bool fence)
Definition: funcimpl.h:6547
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:1160
void print_stats() const
print the number of configurations per node
Definition: mraimpl.h:1999
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:1639
void refine_op(const opT &op, const keyT &key)
Definition: funcimpl.h:4465
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:2472
Timer timer_change_tensor_type
Definition: funcimpl.h:991
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:902
std::vector< Slice > child_patch(const keyT &child) const
Returns patch referring to coeffs of child in parent box.
Definition: mraimpl.h:675
void print_tree_graphviz(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition: mraimpl.h:2780
void set_tree_state(const TreeState &state)
Definition: funcimpl.h:1264
std::size_t min_nodes() const
Returns the min number of nodes on a processor.
Definition: mraimpl.h:1895
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor
Definition: funcimpl.h:981
Timer timer_compress_svd
Definition: funcimpl.h:994
void make_redundant(const bool fence)
convert this to redundant, i.e. have sum coefficients on all levels
Definition: mraimpl.h:1550
void load(Archive &ar)
Definition: funcimpl.h:1218
std::size_t max_nodes() const
Returns the max number of nodes on a processor.
Definition: mraimpl.h:1886
T inner_ext_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine) const
Definition: funcimpl.h:6358
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:1210
TensorArgs targs
type of tensor to be used in the FunctionNodes
Definition: funcimpl.h:977
void flo_unary_op_node_inplace(const opT &op, bool fence)
Definition: funcimpl.h:2136
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:3319
T trace_local() const
Returns int(f(x),x) in local volume.
Definition: mraimpl.h:3195
void print_grid(const std::string filename) const
Definition: mraimpl.h:521
Future< std::pair< coeffT, double > > compress_spawn(const keyT &key, bool nonstandard, bool keepleaves, bool redundant1)
Invoked on node where key is local.
Definition: mraimpl.h:3267
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:3692
bool get_autorefine() const
Definition: mraimpl.h:313
int k
Wavelet order.
Definition: funcimpl.h:968
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:2668
const std::vector< Vector< double, NDIM > > & get_special_points() const
Definition: funcimpl.h:965
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:3163
GenTensor< Q > values2coeffs(const keyT &key, const GenTensor< Q > &values) const
Definition: funcimpl.h:1850
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:3254
TensorType get_tensor_type() const
Definition: mraimpl.h:298
void do_project_out(const coeffT &fcoeff, const std::pair< keyT, coeffT > gpair, const keyT &gkey, const Key< NDIM > &dest, const int dim) const
compute the inner product of two nodes of only some dimensions and accumulate on result
Definition: funcimpl.h:6767
void remove_leaf_coefficients(const bool fence)
Definition: mraimpl.h:1544
void insert_zero_down_to_initial_level(const keyT &key)
Initialize nodes to zero function at initial_level of refinement.
Definition: mraimpl.h:2603
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:913
typedef TENSOR_RESULT_TYPE(T, R) resultT
void unary_op_node_inplace(const opT &op, bool fence)
Definition: funcimpl.h:2045
T inner_adaptive_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine) const
Definition: funcimpl.h:6369
friend hashT hash_value(const std::shared_ptr< FunctionImpl< T, NDIM >> impl)
Hash a shared_ptr to FunctionImpl.
Definition: funcimpl.h:6871
std::shared_ptr< FunctionImpl< T, NDIM > > pimplT
pointer to this class
Definition: funcimpl.h:947
void finalize_sum()
after summing up we need to do some cleanup;
Definition: mraimpl.h:1843
dcT coeffs
The coefficients.
Definition: funcimpl.h:984
bool exists_and_is_leaf(const keyT &key) const
Definition: mraimpl.h:1254
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:4257
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:1558
void unaryXX(const FunctionImpl< Q, NDIM > *func, const opT &op, bool fence)
Definition: funcimpl.h:3194
std::vector< std::pair< int, const coeffT * > > mapvecT
Type of the entry in the map returned by make_key_vec_map.
Definition: funcimpl.h:5597
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:6563
void verify_tree() const
Verify tree is properly constructed ... global synchronization involved.
Definition: mraimpl.h:109
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:1129
void set_tensor_args(const TensorArgs &t)
Definition: mraimpl.h:304
Range< typename dcT::const_iterator > rangeT
Definition: funcimpl.h:5448
std::size_t real_size() const
Returns the number of coefficients in the function ... collective global sum.
Definition: mraimpl.h:1944
bool exists_and_has_children(const keyT &key) const
Definition: mraimpl.h:1249
void sum_down_spawn(const keyT &key, const coeffT &s)
is this the same as trickle_down() ?
Definition: mraimpl.h:855
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:2795
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:1871
long box_interior[1000]
Definition: funcimpl.h:3238
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:1569
void gaxpy_inplace(const T &alpha, const FunctionImpl< Q, NDIM > &other, const R &beta, bool fence)
Definition: funcimpl.h:1205
bool has_leaves() const
Definition: mraimpl.h:267
void apply_source_driven(opT &op, const FunctionImpl< R, NDIM > &f, bool fence)
similar to apply, but for low rank coeffs
Definition: funcimpl.h:5001
void distribute(std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > newmap) const
Definition: funcimpl.h:1104
int get_special_level() const
Definition: funcimpl.h:964
void reconstruct_op(const keyT &key, const coeffT &s, const bool accumulate_NS=true)
Definition: mraimpl.h:2109
tensorT gaxpy_ext_node(keyT key, Tensor< L > lc, T(*f)(const coordT &), T alpha, T beta) const
Definition: funcimpl.h:6436
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:3178
WorldObject< FunctionImpl< T, NDIM > > woT
Base class world object type.
Definition: funcimpl.h:943
void undo_redundant(const bool fence)
convert this from redundant to standard reconstructed form
Definition: mraimpl.h:1560
GenTensor< T > coeffT
Type of tensor used to hold coeffs.
Definition: funcimpl.h:952
const keyT & key0() const
Returns cdata.key0.
Definition: mraimpl.h:373
double finalize_apply()
after apply we need to do some cleanup;
Definition: mraimpl.h:1800
bool leaves_only
Definition: funcimpl.h:5453
friend hashT hash_value(const FunctionImpl< T, NDIM > *pimpl)
Hash a pointer to FunctionImpl.
Definition: funcimpl.h:6861
const dcT & get_coeffs() const
Definition: mraimpl.h:322
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:6235
double norm2sq_local() const
Returns the square of the local norm ... no comms.
Definition: mraimpl.h:1852
const FunctionCommonData< T, NDIM > & get_cdata() const
Definition: mraimpl.h:328
void sum_down(bool fence)
After 1d push operator must sum coeffs down the tree to restore correct scaling function coefficients...
Definition: mraimpl.h:894
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:6252
bool noautorefine(const keyT &key, const tensorT &t) const
Always returns false (for when autorefine is not wanted)
Definition: mraimpl.h:838
double truncate_tol(double tol, const keyT &key) const
Returns the truncation threshold according to truncate_method.
Definition: mraimpl.h:628
void flo_unary_op_node_inplace(const opT &op, bool fence) const
Definition: funcimpl.h:2146
bool autorefine_square_test(const keyT &key, const nodeT &t) const
Returns true if this block of coeffs needs autorefining.
Definition: mraimpl.h:844
void erase(const Level &max_level)
truncate tree at a certain level
Definition: mraimpl.h:718
void mulXX(const FunctionImpl< L, NDIM > *left, const FunctionImpl< R, NDIM > *right, double tol, bool fence)
Definition: funcimpl.h:3166
void reconstruct(bool fence)
reconstruct this tree – respects fence
Definition: mraimpl.h:1490
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:3554
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:992
static void tnorm(const tensorT &t, double *lo, double *hi)
Computes norm of low/high-order polyn. coeffs for autorefinement test.
Definition: mraimpl.h:3055
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:2941
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:1769
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:5891
std::size_t max_depth() const
Returns the maximum depth of the tree ... collective ... global sum/broadcast.
Definition: mraimpl.h:1878
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:5944
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition: mraimpl.h:1913
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:1946
void reduce_rank(const double thresh, bool fence)
reduce the rank of the coefficients tensors
Definition: mraimpl.h:1086
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:1733
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:5722
std::pair< coeffT, double > compress_op(const keyT &key, const std::vector< Future< std::pair< coeffT, double >> > &v, bool nonstandard)
calculate the wavelet coefficients using the sum coefficients of all child nodes
Definition: mraimpl.h:1690
TreeState get_tree_state() const
Definition: funcimpl.h:1268
void merge_trees(const T alpha, const FunctionImpl< Q, NDIM > &other, const R beta, const bool fence=true)
merge the trees of this and other, while multiplying them with the alpha or beta, resp
Definition: funcimpl.h:1148
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor()
Definition: mraimpl.h:279
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:4892
tensorT unfilter(const tensorT &s) const
Transform sums+differences at level n to sum coefficients at level n+1.
Definition: mraimpl.h:1160
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:1899
int get_initial_level() const
getter
Definition: funcimpl.h:963
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:3412
virtual ~FunctionImpl()
Definition: funcimpl.h:1096
Vector< Translation, NDIM > tranT
Type of array holding translation.
Definition: funcimpl.h:949
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:1386
Future< coeffT > truncate_reconstructed_spawn(const keyT &key, const double tol)
truncate using a tree in reconstructed form
Definition: mraimpl.h:1615
FunctionImpl(const FunctionFactory< T, NDIM > &factory)
Initialize function impl from data in factory.
Definition: funcimpl.h:1000
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:1055
Timer timer_lr_result
Definition: funcimpl.h:992
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:1996
void truncate(double tol, bool fence)
Truncate according to the threshold with optional global fence.
Definition: mraimpl.h:357
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:1921
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:6709
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:4689
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:2772
bool is_reconstructed() const
Returns true if the function is compressed.
Definition: mraimpl.h:241
void replicate(bool fence=true)
Definition: funcimpl.h:1100
double norm_tree_op(const keyT &key, const std::vector< Future< double > > &v)
Definition: mraimpl.h:1577
void reset_timer()
Definition: mraimpl.h:345
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:748
int get_k() const
Definition: mraimpl.h:319
void dirac_convolution_op(const keyT &key, const nodeT &node, FunctionImpl< T, LDIM > *f) const
The operator.
Definition: funcimpl.h:2062
FunctionImpl< T, NDIM > implT
Type of this class (implementation)
Definition: funcimpl.h:946
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:2897
bool truncate_op(const keyT &key, double tol, const std::vector< Future< bool > > &v)
Definition: mraimpl.h:2670
void zero_norm_tree()
Definition: mraimpl.h:1271
std::size_t max_local_depth() const
Returns the maximum local depth of the tree ... no communications.
Definition: mraimpl.h:1864
tensorT project(const keyT &key) const
Definition: mraimpl.h:2815
double thresh
Screening threshold.
Definition: funcimpl.h:969
double check_symmetry_local() const
Returns some asymmetry measure ... no comms.
Definition: mraimpl.h:734
Future< double > get_norm_tree_recursive(const keyT &key) const
Definition: mraimpl.h:2836
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:3223
Key< NDIM > keyT
Type of key.
Definition: funcimpl.h:950
std::vector< Vector< double, NDIM > > special_points
special points for further refinement (needed for composite functions or multiplication)
Definition: funcimpl.h:972
bool truncate_on_project
If true projection inserts at level n-1 not n.
Definition: funcimpl.h:976
AtomicInt small
Definition: funcimpl.h:996
bool is_on_demand() const
Definition: mraimpl.h:262
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:5289
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:1451
void accumulate_timer(const double time) const
Definition: mraimpl.h:331
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:1344
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:5672
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:2859
void set_thresh(double value)
Definition: mraimpl.h:310
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:402
void sock_it_to_me_too(const keyT &key, const RemoteReference< FutureImpl< std::pair< keyT, coeffT > > > &ref) const
Definition: mraimpl.h:2875
void broaden_op(const keyT &key, const std::vector< Future< bool > > &v)
Definition: mraimpl.h:1260
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:382
void print_tree(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition: mraimpl.h:2698
void project_refine_op(const keyT &key, bool do_refine, const std::vector< Vector< double, NDIM > > &specialpts)
Definition: mraimpl.h:2484
void scale_oop(const Q q, const FunctionImpl< F, NDIM > &f, bool fence)
Out-of-place scale by a constant.
Definition: funcimpl.h:6838
T typeT
Definition: funcimpl.h:945
std::size_t tree_size() const
Returns the size of the tree structure of the function ... collective global sum.
Definition: mraimpl.h:1904
ConcurrentHashMap< keyT, mapvecT > mapT
Type of the map returned by make_key_vec_map.
Definition: funcimpl.h:5600
void add_scalar_inplace(T t, bool fence)
Adds a constant to the function. Local operation, optional fence.
Definition: mraimpl.h:2562
void forward_traverse(const coeff_opT &coeff_op, const apply_opT &apply_op, const keyT &key) const
traverse a non-existing tree
Definition: funcimpl.h:3648
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:1180
void abs_square_inplace(bool fence)
Definition: mraimpl.h:3158
Tensor< Q > coeffs2values(const keyT &key, const Tensor< Q > &coeff) const
Definition: funcimpl.h:1843
FunctionImpl(const FunctionImpl< Q, NDIM > &other, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool dozero)
Copy constructor.
Definition: funcimpl.h:1067
void refine(const opT &op, bool fence)
Definition: funcimpl.h:4503
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:5621
void put_in_box(ProcessID from, long nl, long ni) const
Definition: mraimpl.h:803
void unary_op_value_inplace(const opT &op, bool fence)
Definition: funcimpl.h:2839
std::pair< const keyT, nodeT > datumT
Type of entry in container.
Definition: funcimpl.h:954
Timer timer_accumulate
Definition: funcimpl.h:990
TensorArgs get_tensor_args() const
Definition: mraimpl.h:301
void unaryXXa(const keyT &key, const FunctionImpl< Q, NDIM > *func, const opT &op)
Definition: funcimpl.h:3141
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:4318
void average(const implT &rhs)
take the average of two functions, similar to: this=0.5*(this+rhs)
Definition: mraimpl.h:1067
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:5042
void diff(const DerivativeBase< T, NDIM > *D, const implT *f, bool fence)
Definition: mraimpl.h:925
keyT neighbor(const keyT &key, const keyT &disp, const std::vector< bool > &is_periodic) const
Returns key of general neighbor enforcing BC.
Definition: mraimpl.h:3237
void square_inplace(bool fence)
Pointwise squaring of function with optional global fence.
Definition: mraimpl.h:3147
void remove_internal_coefficients(const bool fence)
Definition: mraimpl.h:1539
void compute_snorm_and_dnorm(bool fence=true)
compute norm of s and d coefficients for all nodes
Definition: mraimpl.h:1110
long box_leaf[1000]
Definition: funcimpl.h:3237
void standard(bool fence)
Changes non-standard compressed form to standard compressed form.
Definition: mraimpl.h:1787
void multiop_values_doit(const keyT &key, const opT &op, const std::vector< implT * > &v)
Definition: funcimpl.h:2730
bool is_nonstandard_with_leaves() const
Definition: mraimpl.h:257
int truncate_mode
0=default=(|d|<thresh), 1=(|d|<thresh/2^n), 1=(|d|<thresh/4^n);
Definition: funcimpl.h:974
void multiop_values(const opT &op, const std::vector< implT * > &v)
Definition: funcimpl.h:2747
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition: funcimpl.h:124
GenTensor< T > coeffT
Definition: funcimpl.h:126
bool has_coeff() const
Returns true if there are coefficients in this node.
Definition: funcimpl.h:196
void recompute_snorm_and_dnorm(const FunctionCommonData< T, NDIM > &cdata)
Definition: funcimpl.h:331
FunctionNode(const coeffT &coeff, bool has_children=false)
Constructor from given coefficients with optional children.
Definition: funcimpl.h:153
FunctionNode()
Default constructor makes node without coeff or children.
Definition: funcimpl.h:143
void serialize(Archive &ar)
Definition: funcimpl.h:454
void consolidate_buffer(const TensorArgs &args)
Definition: funcimpl.h:440
double get_dnorm() const
return the precomputed norm of the (virtual) d coefficients
Definition: funcimpl.h:312
size_t size() const
Returns the number of coefficients in this node.
Definition: funcimpl.h:238
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:255
double snorm
norm of the s coefficients
Definition: funcimpl.h:138
void clear_coeff()
Clears the coefficients (has_coeff() will subsequently return false)
Definition: funcimpl.h:291
const coeffT & coeff() const
Returns a const reference to the tensor containing the coeffs.
Definition: funcimpl.h:233
Tensor< T > tensorT
Definition: funcimpl.h:127
coeffT buffer
The coefficients, if any.
Definition: funcimpl.h:136
T trace_conj(const FunctionNode< T, NDIM > &rhs) const
Definition: funcimpl.h:449
void scale(Q a)
Scale the coefficients of this node.
Definition: funcimpl.h:297
bool is_leaf() const
Returns true if this does not have children.
Definition: funcimpl.h:209
void set_has_children(bool flag)
Sets has_children attribute to value of flag.
Definition: funcimpl.h:250
coeffT & coeff()
Returns a non-const reference to the tensor containing the coeffs.
Definition: funcimpl.h:223
void accumulate(const coeffT &t, const typename FunctionNode< T, NDIM >::dcT &c, const Key< NDIM > &key, const TensorArgs &args)
Accumulate inplace and if necessary connect node to parent.
Definition: funcimpl.h:412
double get_norm_tree() const
Gets the value of norm_tree.
Definition: funcimpl.h:307
bool _has_children
True if there are children.
Definition: funcimpl.h:135
FunctionNode(const coeffT &coeff, double norm_tree, double snorm, double dnorm, bool has_children)
Definition: funcimpl.h:163
void set_snorm(const double sn)
set the precomputed norm of the (virtual) s coefficients
Definition: funcimpl.h:317
coeffT _coeffs
The coefficients, if any.
Definition: funcimpl.h:133
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:379
void reduceRank(const double &eps)
reduces the rank of the coefficients (if applicable)
Definition: funcimpl.h:245
WorldContainer< Key< NDIM >, FunctionNode< T, NDIM > > dcT
Definition: funcimpl.h:141
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:361
double _norm_tree
After norm_tree will contain norm of coefficients summed up tree.
Definition: funcimpl.h:134
void set_is_leaf(bool flag)
Sets has_children attribute to value of !flag.
Definition: funcimpl.h:276
void print_json(std::ostream &s) const
Definition: funcimpl.h:462
double get_snorm() const
get the precomputed norm of the (virtual) s coefficients
Definition: funcimpl.h:327
FunctionNode(const coeffT &coeff, double norm_tree, bool has_children)
Definition: funcimpl.h:158
bool has_children() const
Returns true if this node has children.
Definition: funcimpl.h:203
void set_coeff(const coeffT &coeffs)
Takes a shallow copy of the coeff — same as this->coeff()=coeff.
Definition: funcimpl.h:281
void set_dnorm(const double dn)
set the precomputed norm of the (virtual) d coefficients
Definition: funcimpl.h:322
FunctionNode< T, NDIM > & operator=(const FunctionNode< T, NDIM > &other)
Definition: funcimpl.h:172
double dnorm
norm of the d coefficients, also defined if there are no d coefficients
Definition: funcimpl.h:137
bool is_invalid() const
Returns true if this node is invalid (no coeffs and no children)
Definition: funcimpl.h:215
FunctionNode(const FunctionNode< T, NDIM > &other)
Definition: funcimpl.h:167
void set_norm_tree(double norm_tree)
Sets the value of norm_tree.
Definition: funcimpl.h:302
FunctionNode< Q, NDIM > convert() const
Copy with possible type conversion of coefficients, copying all other state.
Definition: funcimpl.h:190
Implements the functionality of futures.
Definition: future.h:74
A future is a possibly yet unevaluated value.
Definition: future.h:373
remote_refT remote_ref(World &world) const
Returns a structure used to pass references to another process.
Definition: future.h:675
Definition: lowranktensor.h:59
bool is_of_tensortype(const TensorType &tt) const
Definition: gentensor.h:225
GenTensor< T > & emul(const GenTensor< T > &other)
Inplace multiply by corresponding elements of argument Tensor.
Definition: lowranktensor.h:631
GenTensor convert(const TensorArgs &targs) const
Definition: gentensor.h:198
SRConf< T > config() const
Definition: gentensor.h:237
GenTensor full_tensor() const
Definition: gentensor.h:200
long dim(const int i) const
return the number of entries in dimension i
Definition: lowranktensor.h:391
long ndim() const
Definition: lowranktensor.h:386
void add_SVD(const GenTensor< T > &rhs, const double &eps)
Definition: gentensor.h:235
constexpr bool is_full_tensor() const
Definition: gentensor.h:224
GenTensor get_tensor() const
Definition: gentensor.h:203
IsSupported< TensorTypeData< Q >, GenTensor< T > & >::type scale(Q fac)
Inplace multiplication by scalar of supported type (legacy name)
Definition: lowranktensor.h:426
GenTensor reconstruct_tensor() const
Definition: gentensor.h:199
bool has_no_data() const
Definition: gentensor.h:211
Tensor< T > full_tensor_copy() const
Definition: gentensor.h:206
void normalize()
Definition: gentensor.h:218
float_scalar_type normf() const
Definition: lowranktensor.h:406
double svd_normf() const
Definition: gentensor.h:213
void reduce_rank(const double &eps)
Definition: gentensor.h:217
long rank() const
Definition: gentensor.h:212
GenTensor & gaxpy(const T alpha, const GenTensor &other, const T beta)
Definition: lowranktensor.h:580
long size() const
Definition: lowranktensor.h:482
SVDTensor< T > & get_svdtensor()
Definition: gentensor.h:228
TensorType tensor_type() const
Definition: gentensor.h:221
bool has_data() const
Definition: gentensor.h:210
bool is_assigned() const
Definition: gentensor.h:209
constexpr bool is_svd_tensor() const
Definition: gentensor.h:222
Definition: worldhashmap.h:330
iterator for hash
Definition: worldhashmap.h:188
Iterates in lexical order thru all children of a key.
Definition: key.h:374
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:66
Level level() const
Definition: key.h:159
const Vector< Translation, NDIM > & translation() const
Definition: key.h:164
bool is_valid() const
Checks if a key is valid.
Definition: key.h:114
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:313
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:291
Key parent(int generation=1) const
Returns the key of the parent.
Definition: key.h:187
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:299
bool is_child_of(const Key &key) const
Definition: key.h:198
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition: key.h:269
A pmap that locates children on odd levels with their even level parents.
Definition: funcimpl.h:102
LevelPmap(World &world)
Definition: funcimpl.h:108
const int nproc
Definition: funcimpl.h:104
LevelPmap()
Definition: funcimpl.h:106
ProcessID owner(const keyT &key) const
Find the owner of a given key.
Definition: funcimpl.h:111
Definition: funcimpl.h:74
Mutex using pthread mutex operations.
Definition: worldmutex.h:131
void unlock() const
Free a mutex owned by this thread.
Definition: worldmutex.h:165
void lock() const
Acquire the mutex waiting if necessary.
Definition: worldmutex.h:155
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:395
Definition: SVDTensor.h:42
A simple process map.
Definition: funcimpl.h:83
SimplePmap(World &world)
Definition: funcimpl.h:89
const int nproc
Definition: funcimpl.h:85
const ProcessID me
Definition: funcimpl.h:86
ProcessID owner(const keyT &key) const
Maps key to processor.
Definition: funcimpl.h:92
A slice defines a sub-range or patch of a dimension.
Definition: slice.h:103
static TaskAttributes hipri()
Definition: thread.h:450
Traits class to specify support of numeric types.
Definition: type_data.h:56
A tensor is a multidimension array.
Definition: tensor.h:317
T * ptr()
Returns a pointer to the internal data.
Definition: tensor.h:1824
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition: tensor.h:1726
Tensor< T > fusedim(long i)
Returns new view/tensor fusing contiguous dimensions i and i+1.
Definition: tensor.h:1587
Tensor< T > mapdim(const std::vector< long > &map)
Returns new view/tensor permuting the dimensions.
Definition: tensor.h:1624
T sum() const
Returns the sum of all elements of the tensor.
Definition: tensor.h:1662
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition: tensor.h:1384
Tensor< T > & gaxpy(T alpha, const Tensor< T > &t, T beta)
Inplace generalized saxpy ... this = this*alpha + other*beta.
Definition: tensor.h:1804
Tensor< T > flat()
Returns new view/tensor rehshaping to flat (1-d) tensor.
Definition: tensor.h:1555
Tensor< T > & conj()
Inplace complex conjugate.
Definition: tensor.h:716
T trace(const Tensor< T > &t) const
Return the trace of two tensors (no complex conjugate invoked)
Definition: tensor.h:1776
Tensor< T > & emul(const Tensor< T > &t)
Inplace multiply by corresponding elements of argument Tensor.
Definition: tensor.h:1798
bool has_data() const
Definition: tensor.h:1886
Definition: function_common_data.h:169
void accumulate(const double time) const
accumulate timer
Definition: function_common_data.h:183
Iterator for distributed container wraps the local iterator.
Definition: worlddc.h:244
Makes a distributed container with specified attributes.
Definition: worlddc.h:866
void process_pending()
Process pending messages.
Definition: worlddc.h:1166
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:987
bool probe(const keyT &key) const
Returns true if local data is immediately available (no communication)
Definition: worlddc.h:1024
iterator begin()
Returns an iterator to the beginning of the local data (no communication)
Definition: worlddc.h:1070
ProcessID owner(const keyT &key) const
Returns processor that logically owns key (no communication)
Definition: worlddc.h:1034
void replicate(bool fence=true)
replicates this WorldContainer on all ProcessIDs
Definition: worlddc.h:968
const std::shared_ptr< WorldDCPmapInterface< keyT > > & get_pmap() const
Returns shared pointer to the process mapping.
Definition: worlddc.h:1142
void replace(const pairT &datum)
Inserts/replaces key+value pair (non-blocking communication if key not local)
Definition: worlddc.h:974
iterator end()
Returns an iterator past the end of the local data (no communication)
Definition: worlddc.h:1084
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:1001
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:1426
std::size_t size() const
Returns the number of local entries (no communication)
Definition: worlddc.h:1135
bool is_local(const keyT &key) const
Returns true if the key maps to the local processor (no communication)
Definition: worlddc.h:1041
Future< MEMFUN_RETURNT(memfunT)> send(const keyT &key, memfunT memfun)
Sends message "resultT memfun()" to item (non-blocking comm if remote)
Definition: worlddc.h:1183
Interface to be provided by any process map.
Definition: worlddc.h:82
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition: worldgop.cc:161
Implements most parts of a globally addressable object (via unique ID).
Definition: world_object.h:364
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn) const
Definition: world_object.h:731
const uniqueidT & id() const
Returns the globally unique object ID.
Definition: world_object.h:711
void process_pending()
To be called from derived constructor to process pending messages.
Definition: world_object.h:656
ProcessID me
Rank of self.
Definition: world_object.h:385
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)().
Definition: world_object.h:1005
Future< bool > for_each(const rangeT &range, const opT &op)
Apply op(item) on all items in range.
Definition: world_task_queue.h:572
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
void add(TaskInterface *t)
Add a new local task, taking ownership of the pointer.
Definition: world_task_queue.h:466
A parallel world class.
Definition: world.h:132
static World * world_from_id(std::uint64_t id)
Convert a World ID to a World pointer.
Definition: world.h:474
WorldTaskQueue & taskq
Task queue.
Definition: world.h:204
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition: world.h:318
std::optional< T * > ptr_from_id(uniqueidT id) const
Look up a local pointer from a world-wide unique ID.
Definition: world.h:414
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition: world.h:328
WorldGopInterface & gop
Global operations.
Definition: world.h:205
ProcessID random_proc()
Returns a random process number; that is, an integer in [0,world.size()).
Definition: world.h:573
Wrapper for an opaque pointer for serialization purposes.
Definition: archive.h:850
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.
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
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:925
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:2443
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:2502
const double beta
Definition: gygi_soltion.cc:62
static const double v
Definition: hatom_sf_dirac.cc:20
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
Multidimension Key for MRA tree and associated iterators.
static double pow(const double *a, const double *b)
Definition: lda.h:74
#define max(a, b)
Definition: lda.h:51
#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:210
Header to declare stuff which has not yet found a home.
const 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
double norm(const T &t)
Definition: adquad.h:42
void combine_hash(hashT &seed, hashT hash)
Internal use only.
Definition: worldhash.h:248
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static const char * filename
Definition: legendre.cc:96
static const std::vector< Slice > ___
Entire dimension.
Definition: slice.h:128
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition: timers.h:127
GenTensor< TENSOR_RESULT_TYPE(R, Q)> general_transform(const GenTensor< R > &t, const Tensor< Q > c[])
Definition: gentensor.h:274
response_space scale(response_space a, double b)
Function< T, NDIM > conj(const Function< T, NDIM > &f, bool fence=true)
Return the complex conjugate of the input function with the same distribution and optional fence.
Definition: mra.h:2046
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:1147
GenTensor< TENSOR_RESULT_TYPE(R, Q)> transform_dir(const GenTensor< R > &t, const Tensor< Q > &c, const int axis)
Definition: lowranktensor.h:1099
TreeState
Definition: funcdefaults.h:58
@ nonstandard_after_apply
s and d coeffs, state after operator application
Definition: funcdefaults.h:63
@ redundant_after_merge
s coeffs everywhere, must be summed up to yield the result
Definition: funcdefaults.h:65
@ reconstructed
s coeffs at the leaves only
Definition: funcdefaults.h:59
@ nonstandard
s and d coeffs in internal nodes
Definition: funcdefaults.h:61
@ redundant
s coeffs everywhere
Definition: funcdefaults.h:64
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition: mra.h:2002
static Tensor< double > weights[max_npt+1]
Definition: legendre.cc:99
int64_t Translation
Definition: key.h:54
static const Slice _(0,-1, 1)
std::ostream & operator<<(std::ostream &os, const particle< PDIM > &p)
Definition: lowrankfunction.h:397
void change_tensor_type(GenTensor< T > &t, const TensorArgs &targs)
change representation to targ.tt
Definition: gentensor.h:284
int Level
Definition: key.h:55
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
int RandomValue< int >()
Random int.
Definition: ran.cc:250
static double pop(std::vector< double > &v)
Definition: SCF.cc:113
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition: print.h:225
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition: mraimpl.h:2163
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
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:1421
NDIM & f
Definition: mra.h:2416
void error(const char *msg)
Definition: world.cc:139
NDIM const Function< R, NDIM > & g
Definition: mra.h:2416
std::size_t hashT
The hash value type.
Definition: worldhash.h:145
static const int kmax
Definition: twoscale.cc:52
double inner(response_space &a, response_space &b)
Definition: response_functions.h:442
std::string type(const PairType &n)
Definition: PNOParameters.h:18
std::string name(const FuncType &type, const int ex=-1)
Definition: ccpairfunction.h:28
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition: vmra.h:689
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:225
std::enable_if< std::is_base_of< ProjectorBase, projT >::value, OuterProjector< projT, projQ > >::type outer(const projT &p0, const projQ &p1)
Definition: projector.h:457
void swap(Vector< T, N > &l, Vector< T, N > &r)
Swap the contents of two Vectors.
Definition: vector.h:497
static const int MAXK
The maximum wavelet order presently supported.
Definition: funcdefaults.h:51
void advance(madness::Hash_private::HashIterator< hashT > &it, const distT &dist)
Definition: worldhashmap.h:610
static long abs(long a)
Definition: tensor.h:218
const double cc
Definition: navstokes_cosines.cc:107
static const double b
Definition: nonlinschro.cc:119
static const double a
Definition: nonlinschro.cc:118
Defines simple templates for printing to std::cout "a la Python".
double Q(double a)
Definition: relops.cc:20
static const double c
Definition: relops.cc:10
static const double L
Definition: rk.cc:46
static const double thresh
Definition: rk.cc:45
Definition: test_ar.cc:204
Definition: test_ccpairfunction.cc:22
given a ket and the 1- and 2-electron potentials, construct the function V phi
Definition: funcimpl.h:3978
implT * result
where to construct Vphi, no need to track parents
Definition: funcimpl.h:3986
bool have_v2() const
Definition: funcimpl.h:3995
ctL iav1
Definition: funcimpl.h:3990
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:4004
ctL iap1
Definition: funcimpl.h:3989
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:4070
std::pair< coeffT, double > make_sum_coeffs(const keyT &key) const
make the sum coeffs for key
Definition: funcimpl.h:4163
bool have_v1() const
Definition: funcimpl.h:3994
opT leaf_op
deciding if a given FunctionNode will be a leaf node
Definition: funcimpl.h:3987
Future< this_type > activate() const
Definition: funcimpl.h:4226
CoeffTracker< T, NDIM > ctT
Definition: funcimpl.h:3983
ctL iap2
the particles 1 and 2 (exclusive with ket)
Definition: funcimpl.h:3989
bool have_ket() const
Definition: funcimpl.h:3993
const implT * eri
2-particle potential, must be on-demand
Definition: funcimpl.h:3991
CoeffTracker< T, LDIM > ctL
Definition: funcimpl.h:3984
void serialize(const Archive &ar)
serialize this (needed for use in recursive_op)
Definition: funcimpl.h:4244
Vphi_op_NS< opT, LDIM > this_type
Definition: funcimpl.h:3982
ctT iaket
the ket of a pair function (exclusive with p1, p2)
Definition: funcimpl.h:3988
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:4116
void accumulate_into_result(const Key< NDIM > &key, const coeffT &coeff) const
Definition: funcimpl.h:3998
this_type make_child(const keyT &child) const
Definition: funcimpl.h:4215
tensorT eri_coeffs(const keyT &key) const
Definition: funcimpl.h:4096
ctL iav2
potentials for particles 1 and 2
Definition: funcimpl.h:3990
bool have_eri() const
Definition: funcimpl.h:3996
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:4237
Vphi_op_NS()
Definition: funcimpl.h:4003
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
make and insert the coefficients into result's tree
Definition: funcimpl.h:4015
bool randomize() const
Definition: funcimpl.h:3980
add two functions f and g: result=alpha * f + beta * g
Definition: funcimpl.h:3493
bool randomize() const
Definition: funcimpl.h:3498
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition: funcimpl.h:3528
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:3510
add_op(const ctT &f, const ctT &g, const double alpha, const double beta)
Definition: funcimpl.h:3506
ctT f
tracking coeffs of first and second addend
Definition: funcimpl.h:3501
double alpha
prefactor for f, g
Definition: funcimpl.h:3503
add_op this_type
Definition: funcimpl.h:3496
CoeffTracker< T, NDIM > ctT
Definition: funcimpl.h:3495
void serialize(const Archive &ar)
Definition: funcimpl.h:3540
ctT g
Definition: funcimpl.h:3501
double beta
Definition: funcimpl.h:3503
add_op()
Definition: funcimpl.h:3505
this_type make_child(const keyT &child) const
Definition: funcimpl.h:3523
this_type forward_ctor(const ctT &f1, const ctT &g1, const double alpha, const double beta)
taskq-compatible ctor
Definition: funcimpl.h:3536
Definition: funcimpl.h:3108
opT op
Definition: funcimpl.h:3111
opT::resultT resultT
Definition: funcimpl.h:3109
coeff_value_adaptor(const FunctionImpl< Q, NDIM > *impl_func, const opT &op)
Definition: funcimpl.h:3114
coeff_value_adaptor()
Definition: funcimpl.h:3113
const FunctionImpl< Q, NDIM > * impl_func
Definition: funcimpl.h:3110
Tensor< resultT > operator()(const Key< NDIM > &key, const Tensor< Q > &t) const
Definition: funcimpl.h:3118
void serialize(Archive &ar)
Definition: funcimpl.h:3127
merge the coefficent boxes of this into result's tree
Definition: funcimpl.h:2350
Range< typename dcT::const_iterator > rangeT
Definition: funcimpl.h:2351
do_accumulate_trees()=default
void serialize(const Archive &ar)
Definition: funcimpl.h:2368
FunctionImpl< Q, NDIM > * result
Definition: funcimpl.h:2352
do_accumulate_trees(FunctionImpl< Q, NDIM > &result, const T alpha)
Definition: funcimpl.h:2355
T alpha
Definition: funcimpl.h:2353
bool operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition: funcimpl.h:2359
"put" this on g
Definition: funcimpl.h:2561
Range< typename dcT::const_iterator > rangeT
Definition: funcimpl.h:2562
void serialize(const Archive &ar)
Definition: funcimpl.h:2590
implT * g
Definition: funcimpl.h:2564
do_average()
Definition: funcimpl.h:2566
bool operator()(typename rangeT::iterator &it) const
iterator it points to this
Definition: funcimpl.h:2570
do_average(implT &g)
Definition: funcimpl.h:2567
change representation of nodes' coeffs to low rank, optional fence
Definition: funcimpl.h:2594
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2595
void serialize(const Archive &ar)
Definition: funcimpl.h:2618
TensorArgs targs
Definition: funcimpl.h:2598
do_change_tensor_type(const TensorArgs &targs, implT &g)
Definition: funcimpl.h:2604
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2607
implT * f
Definition: funcimpl.h:2599
do_change_tensor_type()
Definition: funcimpl.h:2602
check symmetry wrt particle exchange
Definition: funcimpl.h:2267
Range< typename dcT::const_iterator > rangeT
Definition: funcimpl.h:2268
double operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition: funcimpl.h:2274
do_check_symmetry_local()
Definition: funcimpl.h:2270
void serialize(const Archive &ar)
Definition: funcimpl.h:2337
double operator()(double a, double b) const
Definition: funcimpl.h:2333
do_check_symmetry_local(const implT &f)
Definition: funcimpl.h:2271
const implT * f
Definition: funcimpl.h:2269
compute the norm of the wavelet coefficients
Definition: funcimpl.h:4385
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:4386
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:4392
do_compute_snorm_and_dnorm(const FunctionCommonData< T, NDIM > &cdata)
Definition: funcimpl.h:4389
const FunctionCommonData< T, NDIM > & cdata
Definition: funcimpl.h:4388
Definition: funcimpl.h:2621
TensorArgs targs
Definition: funcimpl.h:2625
do_consolidate_buffer()
Definition: funcimpl.h:2628
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2630
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2622
do_consolidate_buffer(const TensorArgs &targs)
Definition: funcimpl.h:2629
void serialize(const Archive &ar)
Definition: funcimpl.h:2634
Definition: funcimpl.h:1383
double operator()(double val) const
Definition: funcimpl.h:1389
do_convert_to_color()
Definition: funcimpl.h:1387
double limit
Definition: funcimpl.h:1384
do_convert_to_color(const double limit, const bool log)
Definition: funcimpl.h:1388
bool log
Definition: funcimpl.h:1385
static double lower()
Definition: funcimpl.h:1386
functor for the gaxpy_inplace method
Definition: funcimpl.h:1180
FunctionImpl< T, NDIM > * f
prefactor for current function impl
Definition: funcimpl.h:1182
do_gaxpy_inplace(FunctionImpl< T, NDIM > *f, T alpha, R beta)
Definition: funcimpl.h:1186
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:1187
R beta
prefactor for other function impl
Definition: funcimpl.h:1184
void serialize(Archive &ar)
Definition: funcimpl.h:1195
do_gaxpy_inplace()
Definition: funcimpl.h:1185
Range< typename FunctionImpl< Q, NDIM >::dcT::const_iterator > rangeT
Definition: funcimpl.h:1181
T alpha
the current function impl
Definition: funcimpl.h:1183
Definition: funcimpl.h:6323
const bool do_leaves
start with leaf nodes instead of initial_level
Definition: funcimpl.h:6327
T operator()(T a, T b) const
Definition: funcimpl.h:6345
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:6329
void serialize(const Archive &ar)
Definition: funcimpl.h:6349
const bool leaf_refine
Definition: funcimpl.h:6326
const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > fref
Definition: funcimpl.h:6324
T operator()(typename dcT::const_iterator &it) const
Definition: funcimpl.h:6333
const implT * impl
Definition: funcimpl.h:6325
compute the inner product of this range with other
Definition: funcimpl.h:5461
const FunctionImpl< T, NDIM > * bra
Definition: funcimpl.h:5462
void serialize(const Archive &ar)
Definition: funcimpl.h:5577
const FunctionImpl< R, NDIM > * ket
Definition: funcimpl.h:5463
typedef TENSOR_RESULT_TYPE(T, R) resultT
bool leaves_only
Definition: funcimpl.h:5464
do_inner_local_on_demand(const FunctionImpl< T, NDIM > *bra, const FunctionImpl< R, NDIM > *ket, const bool leaves_only=true)
Definition: funcimpl.h:5467
resultT operator()(resultT a, resultT b) const
Definition: funcimpl.h:5573
resultT operator()(typename dcT::const_iterator &it) const
Definition: funcimpl.h:5470
compute the inner product of this range with other
Definition: funcimpl.h:5400
resultT operator()(resultT a, resultT b) const
Definition: funcimpl.h:5433
bool leaves_only
Definition: funcimpl.h:5402
void serialize(const Archive &ar)
Definition: funcimpl.h:5437
do_inner_local(const FunctionImpl< R, NDIM > *other, const bool leaves_only)
Definition: funcimpl.h:5405
const FunctionImpl< R, NDIM > * other
Definition: funcimpl.h:5401
resultT operator()(typename dcT::const_iterator &it) const
Definition: funcimpl.h:5407
typedef TENSOR_RESULT_TYPE(T, R) resultT
keep only the sum coefficients in each node
Definition: funcimpl.h:2221
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2222
do_keep_sum_coeffs(implT *impl)
constructor need impl for cdata
Definition: funcimpl.h:2226
implT * impl
Definition: funcimpl.h:2223
void serialize(const Archive &ar)
Definition: funcimpl.h:2235
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2228
mirror dimensions of this, write result on f
Definition: funcimpl.h:2495
do_map_and_mirror()=default
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2505
implT * f
Definition: funcimpl.h:2499
std::vector< long > mirror
Definition: funcimpl.h:2498
void serialize(const Archive &ar)
Definition: funcimpl.h:2552
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2496
std::vector< long > map
Definition: funcimpl.h:2498
do_map_and_mirror(const std::vector< long > map, const std::vector< long > mirror, implT &f)
Definition: funcimpl.h:2502
map this on f
Definition: funcimpl.h:2415
do_mapdim(const std::vector< long > map, implT &f)
Definition: funcimpl.h:2422
void serialize(const Archive &ar)
Definition: funcimpl.h:2438
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2416
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2424
std::vector< long > map
Definition: funcimpl.h:2418
do_mapdim()
Definition: funcimpl.h:2421
implT * f
Definition: funcimpl.h:2419
merge the coefficent boxes of this into other's tree
Definition: funcimpl.h:2379
bool operator()(typename rangeT::iterator &it) const
return the norm of the difference of this node and its "mirror" node
Definition: funcimpl.h:2389
Range< typename dcT::const_iterator > rangeT
Definition: funcimpl.h:2380
FunctionImpl< Q, NDIM > * other
Definition: funcimpl.h:2381
do_merge_trees(const T alpha, const R beta, FunctionImpl< Q, NDIM > &other)
Definition: funcimpl.h:2385
T alpha
Definition: funcimpl.h:2382
do_merge_trees()
Definition: funcimpl.h:2384
R beta
Definition: funcimpl.h:2383
void serialize(const Archive &ar)
Definition: funcimpl.h:2408
mirror dimensions of this, write result on f
Definition: funcimpl.h:2445
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2454
implT * f
Definition: funcimpl.h:2449
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2446
do_mirror()
Definition: funcimpl.h:2451
do_mirror(const std::vector< long > mirror, implT &f)
Definition: funcimpl.h:2452
void serialize(const Archive &ar)
Definition: funcimpl.h:2488
std::vector< long > mirror
Definition: funcimpl.h:2448
Definition: funcimpl.h:5373
double operator()(typename dcT::const_iterator &it) const
Definition: funcimpl.h:5374
void serialize(const Archive &ar)
Definition: funcimpl.h:5389
double operator()(double a, double b) const
Definition: funcimpl.h:5385
laziness
Definition: funcimpl.h:4642
void serialize(Archive &ar)
Definition: funcimpl.h:4650
Key< OPDIM > d
Definition: funcimpl.h:4643
Key< OPDIM > key
Definition: funcimpl.h:4643
keyT dest
Definition: funcimpl.h:4644
double fac
Definition: funcimpl.h:4645
do_op_args()
Definition: funcimpl.h:4646
do_op_args(const Key< OPDIM > &key, const Key< OPDIM > &d, const keyT &dest, double tol, double fac, double cnorm)
Definition: funcimpl.h:4647
double cnorm
Definition: funcimpl.h:4645
double tol
Definition: funcimpl.h:4645
reduce the rank of the nodes, optional fence
Definition: funcimpl.h:2241
do_reduce_rank(const TensorArgs &targs)
Definition: funcimpl.h:2249
TensorArgs args
Definition: funcimpl.h:2245
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2255
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2242
do_reduce_rank()
Definition: funcimpl.h:2248
do_reduce_rank(const double &thresh)
Definition: funcimpl.h:2250
void serialize(const Archive &ar)
Definition: funcimpl.h:2261
Changes non-standard compressed form to standard compressed form.
Definition: funcimpl.h:4606
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:4617
do_standard(implT *impl)
Definition: funcimpl.h:4614
do_standard()
Definition: funcimpl.h:4613
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:4607
void serialize(const Archive &ar)
Definition: funcimpl.h:4634
implT * impl
Definition: funcimpl.h:4610
given an NS tree resulting from a convolution, truncate leafs if appropriate
Definition: funcimpl.h:2162
void serialize(const Archive &ar)
Definition: funcimpl.h:2182
const implT * f
Definition: funcimpl.h:2164
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2168
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2163
do_truncate_NS_leafs(const implT *f)
Definition: funcimpl.h:2166
Definition: funcimpl.h:2640
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2641
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2645
implT * impl
Definition: funcimpl.h:2642
void serialize(const Archive &ar)
Definition: funcimpl.h:2663
opT op
Definition: funcimpl.h:2643
do_unary_op_value_inplace(implT *impl, const opT &op)
Definition: funcimpl.h:2644
Hartree product of two LDIM functions to yield a NDIM = 2*LDIM function.
Definition: funcimpl.h:3576
this_type forward_ctor(implT *result1, const ctL &p11, const ctL &p22, const leaf_opT &leaf_op)
Definition: funcimpl.h:3632
bool randomize() const
Definition: funcimpl.h:3577
void serialize(const Archive &ar)
Definition: funcimpl.h:3636
hartree_op(implT *result, const ctL &p11, const ctL &p22, const leaf_opT &leaf_op)
Definition: funcimpl.h:3588
CoeffTracker< T, LDIM > ctL
Definition: funcimpl.h:3580
ctL p2
tracking coeffs of the two lo-dim functions
Definition: funcimpl.h:3583
leaf_opT leaf_op
determine if a given node will be a leaf node
Definition: funcimpl.h:3584
hartree_op()
Definition: funcimpl.h:3587
implT * result
where to construct the pair function
Definition: funcimpl.h:3582
hartree_op< LDIM, leaf_opT > this_type
Definition: funcimpl.h:3579
std::pair< bool, coeffT > operator()(const Key< NDIM > &key) const
Definition: funcimpl.h:3593
Future< this_type > activate() const
Definition: funcimpl.h:3625
ctL p1
Definition: funcimpl.h:3583
this_type make_child(const keyT &child) const
Definition: funcimpl.h:3616
perform this multiplication: h(1,2) = f(1,2) * g(1)
Definition: funcimpl.h:3384
multiply_op()
Definition: funcimpl.h:3396
ctL g
Definition: funcimpl.h:3393
CoeffTracker< T, LDIM > ctL
Definition: funcimpl.h:3388
implT * h
the result function h(1,2) = f(1,2) * g(1)
Definition: funcimpl.h:3391
CoeffTracker< T, NDIM > ctT
Definition: funcimpl.h:3387
this_type forward_ctor(implT *h1, const ctT &f1, const ctL &g1, const int particle)
Definition: funcimpl.h:3482
static bool randomize()
Definition: funcimpl.h:3386
int particle
if g is g(1) or g(2)
Definition: funcimpl.h:3394
ctT f
Definition: funcimpl.h:3392
multiply_op< LDIM > this_type
Definition: funcimpl.h:3389
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:3423
multiply_op(implT *h1, const ctT &f1, const ctL &g1, const int particle1)
Definition: funcimpl.h:3398
Future< this_type > activate() const
Definition: funcimpl.h:3475
bool screen(const coeffT &fcoeff, const coeffT &gcoeff, const keyT &key) const
return true if this will be a leaf node
Definition: funcimpl.h:3404
this_type make_child(const keyT &child) const
Definition: funcimpl.h:3465
void serialize(const Archive &ar)
Definition: funcimpl.h:3486
Definition: funcimpl.h:3857
coeffT val_lhs
Definition: funcimpl.h:3858
double lo
Definition: funcimpl.h:3861
double lo1
Definition: funcimpl.h:3861
long oversampling
Definition: funcimpl.h:3859
double error
Definition: funcimpl.h:3860
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:3876
coeffT coeff_lhs
Definition: funcimpl.h:3858
void serialize(const Archive &ar)
Definition: funcimpl.h:3964
double lo2
Definition: funcimpl.h:3861
double hi1
Definition: funcimpl.h:3861
pointwise_multiplier(const Key< NDIM > key, const coeffT &clhs)
Definition: funcimpl.h:3864
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:3921
double hi2
Definition: funcimpl.h:3861
pointwise_multiplier()
Definition: funcimpl.h:3863
double hi
Definition: funcimpl.h:3861
project the low-dim function g on the hi-dim function f: result(x) = <f(x,y) | g(y)>
Definition: funcimpl.h:6589
project_out_op(const implT *fimpl, implL1 *result, const ctL &iag, const int dim)
Definition: funcimpl.h:6604
ctL iag
the low dim function g
Definition: funcimpl.h:6599
FunctionImpl< T, NDIM-LDIM > implL1
Definition: funcimpl.h:6594
std::pair< bool, coeffT > argT
Definition: funcimpl.h:6595
const implT * fimpl
the hi dim function f
Definition: funcimpl.h:6597
this_type forward_ctor(const implT *fimpl1, implL1 *result1, const ctL &iag1, const int dim1)
taskq-compatible ctor
Definition: funcimpl.h:6690
this_type make_child(const keyT &child) const
Definition: funcimpl.h:6674
project_out_op< LDIM > this_type
Definition: funcimpl.h:6592
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition: funcimpl.h:6683
implL1 * result
the low dim result function
Definition: funcimpl.h:6598
project_out_op()
Definition: funcimpl.h:6603
void serialize(const Archive &ar)
Definition: funcimpl.h:6694
project_out_op(const project_out_op &other)
Definition: funcimpl.h:6606
int dim
0: project 0..LDIM-1, 1: project LDIM..NDIM-1
Definition: funcimpl.h:6600
Future< argT > operator()(const Key< NDIM > &key) const
do the actual contraction
Definition: funcimpl.h:6611
bool randomize() const
Definition: funcimpl.h:6590
CoeffTracker< T, LDIM > ctL
Definition: funcimpl.h:6593
recursive part of recursive_apply
Definition: funcimpl.h:5200
ctT iaf
Definition: funcimpl.h:5208
recursive_apply_op2< opT > this_type
Definition: funcimpl.h:5203
const opT * apply_op
need this for randomization
Definition: funcimpl.h:5209
bool randomize() const
Definition: funcimpl.h:5201
recursive_apply_op2(const recursive_apply_op2 &other)
Definition: funcimpl.h:5216
void serialize(const Archive &ar)
Definition: funcimpl.h:5279
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:5249
this_type make_child(const keyT &child) const
Definition: funcimpl.h:5258
recursive_apply_op2(implT *result, const ctT &iaf, const opT *apply_op)
Definition: funcimpl.h:5213
std::pair< bool, coeffT > argT
Definition: funcimpl.h:5205
recursive_apply_op2()
Definition: funcimpl.h:5212
implT * result
Definition: funcimpl.h:5207
CoeffTracker< T, NDIM > ctT
Definition: funcimpl.h:5204
argT operator()(const Key< NDIM > &key) const
send off the application of the operator
Definition: funcimpl.h:5225
this_type forward_ctor(implT *result1, const ctT &iaf1, const opT *apply_op1)
taskq-compatible ctor
Definition: funcimpl.h:5275
Future< this_type > activate() const
retrieve the coefficients (parent coeffs might be remote)
Definition: funcimpl.h:5263
recursive part of recursive_apply
Definition: funcimpl.h:5069
this_type forward_ctor(implT *r, const CoeffTracker< T, LDIM > &f1, const CoeffTracker< T, LDIM > &g1, const opT *apply_op1)
Definition: funcimpl.h:5159
Future< this_type > activate() const
Definition: funcimpl.h:5152
recursive_apply_op()
Definition: funcimpl.h:5080
opT * apply_op
Definition: funcimpl.h:5077
recursive_apply_op(const recursive_apply_op &other)
Definition: funcimpl.h:5087
recursive_apply_op< opT, LDIM > this_type
Definition: funcimpl.h:5072
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:5094
bool randomize() const
Definition: funcimpl.h:5070
implT * result
Definition: funcimpl.h:5074
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:5134
CoeffTracker< T, LDIM > iaf
Definition: funcimpl.h:5075
void serialize(const Archive &ar)
Definition: funcimpl.h:5164
recursive_apply_op(implT *result, const CoeffTracker< T, LDIM > &iaf, const CoeffTracker< T, LDIM > &iag, const opT *apply_op)
Definition: funcimpl.h:5081
this_type make_child(const keyT &child) const
Definition: funcimpl.h:5143
CoeffTracker< T, LDIM > iag
Definition: funcimpl.h:5076
remove all coefficients of internal nodes
Definition: funcimpl.h:2187
remove_internal_coeffs()
constructor need impl for cdata
Definition: funcimpl.h:2191
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2188
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2193
void serialize(const Archive &ar)
Definition: funcimpl.h:2199
remove all coefficients of leaf nodes
Definition: funcimpl.h:2204
bool operator()(typename rangeT::iterator &it) const
Definition: funcimpl.h:2210
remove_leaf_coeffs()
constructor need impl for cdata
Definition: funcimpl.h:2208
void serialize(const Archive &ar)
Definition: funcimpl.h:2215
Range< typename dcT::iterator > rangeT
Definition: funcimpl.h:2205
Definition: funcimpl.h:4457
void serialize(Archive &ar)
Definition: funcimpl.h:4461
bool operator()(const implT *f, const keyT &key, const nodeT &t) const
Definition: funcimpl.h:4458
shallow-copy, pared-down version of FunctionNode, for special purpose only
Definition: funcimpl.h:745
coeffT & coeff()
Definition: funcimpl.h:759
GenTensor< T > coeffT
Definition: funcimpl.h:746
bool is_leaf() const
Definition: funcimpl.h:761
void serialize(Archive &ar)
Definition: funcimpl.h:763
ShallowNode(const ShallowNode< T, NDIM > &node)
Definition: funcimpl.h:754
ShallowNode(const FunctionNode< T, NDIM > &node)
Definition: funcimpl.h:751
bool has_children() const
Definition: funcimpl.h:760
ShallowNode()
Definition: funcimpl.h:750
bool _has_children
Definition: funcimpl.h:748
double dnorm
Definition: funcimpl.h:749
coeffT _coeffs
Definition: funcimpl.h:747
const coeffT & coeff() const
Definition: funcimpl.h:758
TensorArgs holds the arguments for creating a LowRankTensor.
Definition: gentensor.h:134
double thresh
Definition: gentensor.h:135
TensorType tt
Definition: gentensor.h:136
inserts/accumulates coefficients into impl's tree
Definition: funcimpl.h:712
FunctionImpl< T, NDIM > * impl
Definition: funcimpl.h:716
FunctionNode< T, NDIM > nodeT
Definition: funcimpl.h:714
accumulate_op(const accumulate_op &other)=default
void operator()(const Key< NDIM > &key, const coeffT &coeff, const bool &is_leaf) const
Definition: funcimpl.h:720
void serialize(Archive &ar)
Definition: funcimpl.h:724
GenTensor< T > coeffT
Definition: funcimpl.h:713
accumulate_op(FunctionImpl< T, NDIM > *f)
Definition: funcimpl.h:718
static void load(const Archive &ar, FunctionImpl< T, NDIM > *&ptr)
Definition: funcimpl.h:6910
static void load(const Archive &ar, const FunctionImpl< T, NDIM > *&ptr)
Definition: funcimpl.h:6879
static void load(const Archive &ar, std::shared_ptr< FunctionImpl< T, NDIM > > &ptr)
Definition: funcimpl.h:6958
static void load(const Archive &ar, std::shared_ptr< const FunctionImpl< T, NDIM > > &ptr)
Definition: funcimpl.h:6942
Default load of an object via serialize(ar, t).
Definition: archive.h:666
static void load(const A &ar, const U &t)
Load an object.
Definition: archive.h:678
static void store(const Archive &ar, FunctionImpl< T, NDIM > *const &ptr)
Definition: funcimpl.h:6932
static void store(const Archive &ar, const FunctionImpl< T, NDIM > *const &ptr)
Definition: funcimpl.h:6901
static void store(const Archive &ar, const std::shared_ptr< FunctionImpl< T, NDIM > > &ptr)
Definition: funcimpl.h:6967
static void store(const Archive &ar, const std::shared_ptr< const FunctionImpl< T, NDIM > > &ptr)
Definition: funcimpl.h:6951
Default store of an object via serialize(ar, t).
Definition: archive.h:611
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:621
Definition: funcimpl.h:606
void serialize(Archive &ar)
Definition: funcimpl.h:670
const opT * op
Definition: funcimpl.h:613
hartree_convolute_leaf_op(const implT *f, const implL *g, const opT *op)
Definition: funcimpl.h:617
bool operator()(const Key< NDIM > &key) const
no pre-determination
Definition: funcimpl.h:621
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:634
const implL * g
Definition: funcimpl.h:612
const FunctionImpl< T, NDIM > * f
Definition: funcimpl.h:611
FunctionImpl< T, LDIM > implL
Definition: funcimpl.h:609
bool do_error_leaf_op() const
Definition: funcimpl.h:614
hartree_convolute_leaf_op()
Definition: funcimpl.h:616
FunctionImpl< T, NDIM > implT
Definition: funcimpl.h:608
bool operator()(const Key< NDIM > &key, const GenTensor< T > &coeff) const
no post-determination
Definition: funcimpl.h:624
returns true if the result of a hartree_product is a leaf node (compute norm & error)
Definition: funcimpl.h:496
bool do_error_leaf_op() const
Definition: funcimpl.h:501
const FunctionImpl< T, NDIM > * f
Definition: funcimpl.h:499
hartree_leaf_op(const implT *f, const long &k)
Definition: funcimpl.h:504
long k
Definition: funcimpl.h:500
void serialize(Archive &ar)
Definition: funcimpl.h:552
bool operator()(const Key< NDIM > &key, const GenTensor< T > &coeff) const
no post-determination
Definition: funcimpl.h:510
hartree_leaf_op()
Definition: funcimpl.h:503
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:520
bool operator()(const Key< NDIM > &key) const
no pre-determination
Definition: funcimpl.h:507
FunctionImpl< T, NDIM > implT
Definition: funcimpl.h:498
insert/replaces the coefficients into the function
Definition: funcimpl.h:688
insert_op()
Definition: funcimpl.h:695
implT * impl
Definition: funcimpl.h:694
void operator()(const keyT &key, const coeffT &coeff, const bool &is_leaf) const
Definition: funcimpl.h:698
FunctionNode< T, NDIM > nodeT
Definition: funcimpl.h:692
Key< NDIM > keyT
Definition: funcimpl.h:690
insert_op(const insert_op &other)
Definition: funcimpl.h:697
FunctionImpl< T, NDIM > implT
Definition: funcimpl.h:689
GenTensor< T > coeffT
Definition: funcimpl.h:691
insert_op(implT *f)
Definition: funcimpl.h:696
void serialize(Archive &ar)
Definition: funcimpl.h:702
Definition: funcimpl.h:676
bool operator()(const Key< NDIM > &key, const GenTensor< T > &fcoeff, const GenTensor< T > &gcoeff) const
Definition: funcimpl.h:678
void serialize(Archive &ar)
Definition: funcimpl.h:682
void operator()(const Key< NDIM > &key, const GenTensor< T > &coeff, const bool &is_leaf) const
Definition: funcimpl.h:677
Definition: funcimpl.h:560
bool operator()(const Key< NDIM > &key, const double &cnorm) const
post-determination: return true if operator and coefficient norms are small
Definition: funcimpl.h:581
void serialize(Archive &ar)
Definition: funcimpl.h:596
const implT * f
the source or result function, needed for truncate_tol
Definition: funcimpl.h:564
op_leaf_op(const opT *op, const implT *f)
Definition: funcimpl.h:568
FunctionImpl< T, NDIM > implT
Definition: funcimpl.h:561
const opT * op
the convolution operator
Definition: funcimpl.h:563
bool do_error_leaf_op() const
Definition: funcimpl.h:565
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:571
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:574
op_leaf_op()
Definition: funcimpl.h:567
Definition: lowrankfunction.h:332
Definition: funcimpl.h:732
void serialize(Archive &ar)
Definition: funcimpl.h:739
bool operator()(const Key< NDIM > &key, const T &t, const R &r) const
Definition: funcimpl.h:738
bool operator()(const Key< NDIM > &key, const T &t) const
Definition: funcimpl.h:735
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
const double alpha
Definition: test_coulomb.cc:54
int task(int i)
Definition: test_runtime.cpp:4
void d()
Definition: test_sig.cc:79
void e()
Definition: test_sig.cc:75
const double offset
Definition: testfuns.cc:143
double h(const coord_1d &r)
Definition: testgconv.cc:68
static const std::size_t NDIM
Definition: testpdiff.cc:42
std::size_t axis
Definition: testpdiff.cc:59
double source(const coordT &r)
Definition: testperiodic.cc:48
#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