32#ifndef MADNESS_MRA_MRAIMPL_H__INCLUDED
33#define MADNESS_MRA_MRAIMPL_H__INCLUDED
36#error "mraimpl.h should ONLY be included in one of the mraX.cc files (x=1..6)"
53 bool isnan(
const std::complex<T>&
v) {
69 template <
typename T, std::
size_t NDIM>
71 if (!
two_scale_hg(
k, &hg))
throw "failed to get twoscale coefficients";
89 template <
typename T, std::
size_t NDIM>
99 for (
int mu=0;
mu<npt; ++
mu) {
102 for (
int j=0; j<
k; ++j) {
103 quad_phi(
mu,j) = phi[j];
104 quad_phiw(
mu,j) = quad_w(
mu)*phi[j];
110 template <
typename T, std::
size_t NDIM>
118 template <
typename T, std::
size_t NDIM>
122 for (
const auto& [key, node] : coeffs) {
124 if (key.level() > 0) {
127 if (pit == coeffs.end()) {
128 print(world.rank(),
"FunctionImpl: verify: MISSING PARENT",key,parent);
133 const nodeT&
pnode = pit->second;
134 if (!
pnode.has_children()) {
135 print(world.rank(),
"FunctionImpl: verify: PARENT THINKS IT HAS NO CHILDREN",key,parent);
143 typename dcT::const_iterator
cit = coeffs.find(
kit.key()).get();
144 if (
cit == coeffs.end()) {
145 if (node.has_children()) {
146 print(world.rank(),
"FunctionImpl: verify: MISSING CHILD",key,
kit.key());
153 if (! node.has_children()) {
154 print(world.rank(),
"FunctionImpl: verify: UNEXPECTED CHILD",key,
kit.key());
168 template<
typename T, std::
size_t NDIM>
176 return c.dim(0)==2*
k;
193 for (
const auto& [key, node] : coeffs) {
194 const auto&
c=node.coeff();
196 const bool is_leaf=
not node.has_children();
200 print(
"incorrect size of coefficients for key",key,
"state",state,
c.dim(0));;
206 template <
typename T, std::
size_t NDIM>
208 return coeffs.get_pmap();
222 template <
typename T, std::
size_t NDIM>
224 const double beta,
const implT&
g,
const bool fence) {
229 ProcessID owner = coeffs.owner(cdata.key0);
230 if (world.rank() == owner) {
245 if (fence) world.gop.fence();
249 template <
typename T, std::
size_t NDIM>
255 template <
typename T, std::
size_t NDIM>
261 template <
typename T, std::
size_t NDIM>
267 template <
typename T, std::
size_t NDIM>
272 template <
typename T, std::
size_t NDIM>
277 template <
typename T, std::
size_t NDIM>
282 template <
typename T, std::
size_t NDIM>
287 template <
typename T, std::
size_t NDIM>
292 template <
typename T, std::
size_t NDIM>
299 template <
typename T, std::
size_t NDIM>
305 template <
typename T, std::
size_t NDIM>
311 template <
typename T, std::
size_t NDIM>
318 template <
typename T, std::
size_t NDIM>
321 template <
typename T, std::
size_t NDIM>
324 template <
typename T, std::
size_t NDIM>
327 template <
typename T, std::
size_t NDIM>
330 template <
typename T, std::
size_t NDIM>
333 template <
typename T, std::
size_t NDIM>
336 template <
typename T, std::
size_t NDIM>
339 template <
typename T, std::
size_t NDIM>
342 template <
typename T, std::
size_t NDIM>
345 template <
typename T, std::
size_t NDIM>
348 template <
typename T, std::
size_t NDIM>
351 template <
typename T, std::
size_t NDIM>
353 timer_accumulate.accumulate(
time);
356 template <
typename T, std::
size_t NDIM>
358 if (world.rank()==0) {
359 timer_accumulate.print(
"accumulate");
360 timer_target_driven.print(
"target_driven");
361 timer_lr_result.print(
"result2low_rank");
365 template <
typename T, std::
size_t NDIM>
367 if (world.rank()==0) {
368 timer_accumulate.reset();
369 timer_target_driven.reset();
370 timer_lr_result.reset();
377 template <
typename T, std::
size_t NDIM>
382 if (world.rank() == coeffs.owner(cdata.key0)) {
383 if (is_compressed()) {
384 truncate_spawn(cdata.key0,tol);
386 truncate_reconstructed_spawn(cdata.key0,tol);
393 template <
typename T, std::
size_t NDIM>
402 template <
typename T, std::
size_t NDIM>
422 template <
typename T, std::
size_t NDIM>
435 const keyT& key = it->first;
436 const nodeT& node = it->second;
444 double scale=std::pow(0.5,
double(n));
465 const double maxrank=40;
471 const int npt = cdata.npt + 1;
498 template <
typename T, std::
size_t NDIM>
500 const int xaxis,
const int yaxis,
const coordT el2) {
512 fprintf(
pFile,
"\\begin{pspicture}(%4.2f,%4.2f)(%4.2f,%4.2f)\n",
522 for (
long i=0; i<
localinfo.dim(0); ++i) {
528 "(%12.8f,%12.8f)(%12.8f,%12.8f)\n",
541 template <
typename T, std::
size_t NDIM>
545 std::vector<keyT>
local_keys=local_leaf_keys();
557 template <
typename T, std::
size_t NDIM>
561 std::vector<keyT>
keys(coeffs.size());
568 const keyT& key = it->first;
569 const nodeT& node = it->second;
583 template <
typename T, std::
size_t NDIM>
590 const size_t npt = qx.
dim(0);
605 typename std::vector<keyT>::const_iterator
key_it=
keys.begin();
616 const double h = std::pow(0.5,
double(n));
623 for (
size_t i=0; i<npt; ++i) {
624 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
625 for (
size_t j=0; j<npt; ++j) {
626 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
627 for (
size_t k=0;
k<npt; ++
k) {
628 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
648 template <
typename T, std::
size_t NDIM>
683 const static double fac=1.0/std::pow(2,
NDIM*0.5);
695 template <
typename T, std::
size_t NDIM>
697 std::vector<Slice> s(
NDIM);
699 for (std::size_t i=0; i<
NDIM; ++i)
700 s[i] = cdata.s[l[i]&1];
706 template <
typename T, std::
size_t NDIM>
708 const keyT& child,
const keyT& parent,
const coeffT& coeff)
const {
718 if (coeff.
dim(0)==2*
f->get_k()) result=coeff;
719 else if (coeff.
dim(0)==
f->get_k()) {
720 result(
f->cdata.s0)+=coeff;
738 template <
typename T, std::
size_t NDIM>
743 for (
typename dcT::iterator it= coeffs.begin(); it!=end; ++it) {
745 nodeT& node=it->second;
749 this->undo_redundant(
true);
754 template <
typename T, std::
size_t NDIM>
768 template <
typename T, std::
size_t NDIM>
770 const std::vector<tensorT>&
c,
772 if (key == cdata.key0 && coeffs.owner(key)!=world.rank())
return;
775 std::unique_ptr<typename dcT::accessor[]>
acc(
new typename dcT::accessor[
v.size()]);
776 for (
unsigned int i=0; i<
c.size(); i++) {
779 bool exists = !
v[i]->coeffs.insert(
acc[i],key);
791 for (
unsigned int i=0; i<
v.size(); i++) {
792 done &=
acc[i]->second.has_coeff();
797 std::vector<tensorT>
d(
v.size());
798 for (
unsigned int i=0; i<
v.size(); i++) {
802 s(cdata.s0) =
acc[i]->second.coeff().full_tensor();
803 acc[i]->second.clear_coeff();
805 acc[i]->second.set_has_children(
true);
812 std::vector<Slice> cp = child_patch(child);
813 std::vector<tensorT>
childc(
v.size());
814 for (
unsigned int i=0; i<
v.size(); i++) {
817 woT::task(coeffs.owner(child), &implT::refine_to_common_level,
v,
childc, child);
823 template <
typename T, std::
size_t NDIM>
825 if (world.size()> 1000)
832 template <
typename T, std::
size_t NDIM>
834 if (world.size() >= 1000)
836 for (
int i=0; i<world.size(); ++i)
837 box_leaf[i] = box_interior[i] == 0;
842 const nodeT& node = it->second;
848 this->send(0, &implT::put_in_box, world.rank(),
nleaf,
ninterior);
850 if (world.rank() == 0) {
851 for (
int i=0; i<world.size(); ++i) {
852 printf(
"load: %5d %8ld %8ld\n", i, box_leaf[i], box_interior[i]);
858 template <
typename T, std::
size_t NDIM>
864 template <
typename T, std::
size_t NDIM>
868 double test = 2*
lo*hi + hi*hi;
875 template <
typename T, std::
size_t NDIM>
878 coeffs.insert(
acc,key);
902 if (
d.size() > 0)
ss =
copy(
d(child_patch(child)));
904 woT::task(coeffs.owner(child), &implT::sum_down_spawn, child,
ss);
909 if (
c.size() <= 0)
c =
coeffT(cdata.vk,targs);
921 template <
typename T, std::
size_t NDIM>
923 if (get_tensor_type()!=
TT_FULL && world.rank()==0)
924 print(
"WARNING: sum_down is numerically unstable for tensor type",get_tensor_type());
926 if (world.rank() == coeffs.owner(cdata.key0)) sum_down_spawn(cdata.key0,
coeffT());
927 if (fence) world.gop.fence();
931 template <
typename T, std::
size_t NDIM>
935 const std::pair<keyT,coeffT>& left,
936 const std::pair<keyT,coeffT>& center,
937 const std::pair<keyT,coeffT>& right) {
938 D->forward_do_diff1(
f,
this,key,left,center,right);
942 template <
typename T, std::
size_t NDIM>
946 const std::pair<keyT,coeffT>& left,
947 const std::pair<keyT,coeffT>& center,
948 const std::pair<keyT,coeffT>& right) {
949 D->do_diff1(
f,
this,key,left,center,right);
954 template <
typename T, std::
size_t NDIM>
956 typedef std::pair<keyT,coeffT> argT;
957 if (
D->parallel_submit_) {
958 D->submit_diff_tasks(
f,
this);
959 if (fence) world.gop.fence();
962 for (
const auto& [key, node]:
f->coeffs) {
963 if (node.has_coeff()) {
965 argT center(key,node.coeff());
973 if (fence) world.gop.fence();
978 template <
typename T, std::
size_t NDIM>
991 template <
typename T, std::
size_t NDIM>
999 std::vector<long>
vkhalf=std::vector<long>(
NDIM/2,cdata.vk[0]);
1026 template <
typename T, std::
size_t NDIM>
1050 if (
veri.has_data()) {
1070 template <
typename T, std::
size_t NDIM>
1074 const_cast<implT*
>(&
f)->flo_unary_op_node_inplace(
do_mapdim(map,*
this),fence);
1079 template <
typename T, std::
size_t NDIM>
1082 const_cast<implT*
>(&
f)->flo_unary_op_node_inplace(
do_mirror(mirrormap,*
this),fence);
1089 template <
typename T, std::
size_t NDIM>
1091 const std::vector<long>&
mirror,
bool fence) {
1101 template <
typename T, std::
size_t NDIM>
1105 this->scale_inplace(0.5,
true);
1112 template <
typename T, std::
size_t NDIM>
1120 template <
typename T, std::
size_t NDIM>
1128 template <
typename T, std::
size_t NDIM>
1131 for (
auto it=coeffs.begin(); it!=coeffs.end(); ++it) {
1132 const keyT& key=it->first;
1133 nodeT& node=it->second;
1144 template <
typename T, std::
size_t NDIM>
1147 flo_unary_op_node_inplace(
1165 template <
typename T, std::
size_t NDIM>
1173 template <
typename T, std::
size_t NDIM>
1194 template <
typename T, std::
size_t NDIM>
1202 template <
typename T, std::
size_t NDIM>
1214 template <
typename T, std::
size_t NDIM>
1220 const tensorT h[2] = {cdata.h0T, cdata.h1T};
1244 template <
typename T, std::
size_t NDIM>
1249 const tensorT h[2] = {cdata.h0, cdata.h1};
1262 template <
typename T, std::
size_t NDIM>
1264 long kmin = std::min(cdata.k,
old.cdata.k);
1268 const keyT& key = it->first;
1269 const nodeT& node = it->second;
1273 coeffs.replace(key,
nodeT(
c,
false));
1283 template <
typename T, std::
size_t NDIM>
1285 return coeffs.probe(key) && coeffs.find(key).get()->second.has_children();
1288 template <
typename T, std::
size_t NDIM>
1290 return coeffs.probe(key) && (
not coeffs.find(key).get()->second.has_children());
1294 template <
typename T, std::
size_t NDIM>
1296 for (
unsigned int i=0; i<
v.size(); ++i) {
1305 template <
typename T, std::
size_t NDIM>
1308 for (
typename dcT::iterator it=coeffs.begin(); it!=end; ++it) {
1309 it->second.set_norm_tree(0.0);
1310 it->second.set_snorm(0.0);
1311 it->second.set_dnorm(0.0);
1316 template <
typename T, std::
size_t NDIM>
1319 for (
typename dcT::iterator it=coeffs.begin(); it!=end; ++it) {
1320 const keyT& key = it->first;
1322 const auto found = coeffs.find(
acc,key);
1332 int ndir =
static_cast<int>(std::pow(
static_cast<double>(3),
static_cast<int>(
NDIM)));
1338 for (std::size_t
d=0;
d<
NDIM; ++
d) {
1348 if (
neigh.is_valid()) {
1349 v[i++] = this->
task(coeffs.owner(
neigh), &implT::exists_and_has_children,
neigh);
1355 woT::task(world.rank(), &implT::broaden_op, key,
v);
1367 template <
typename T, std::
size_t NDIM>
1370 if (world.rank() == coeffs.owner(cdata.key0))
1371 woT::task(world.rank(), &implT::trickle_down_op, cdata.key0,
coeffT());
1372 if (fence) world.gop.fence();
1378 template <
typename T, std::
size_t NDIM>
1389 if (it == coeffs.end()) {
1391 it = coeffs.find(key).get();
1393 nodeT& node = it->second;
1403 if (key.
level() > 0)
d += s;
1406 const keyT& child =
kit.key();
1410 woT::task(coeffs.owner(child), &implT::trickle_down_op, child,
ss);
1420 template <
typename T, std::
size_t NDIM>
1435 remove_internal_coefficients(fence);
1439 remove_internal_coefficients(fence);
1456 remove_leaf_coefficients(fence);
1479 "must reconstruct first and therefore fences, despite fence=false");
1488 template <
typename T, std::
size_t NDIM>
1491 if (is_reconstructed())
return;
1493 if (is_redundant()
or is_nonstandard_with_leaves()) {
1495 this->remove_internal_coefficients(fence);
1499 if (world.rank() == coeffs.owner(cdata.key0))
1500 woT::task(world.rank(), &implT::reconstruct_op, cdata.key0,
coeffT(),
true);
1501 }
else if (is_nonstandard()) {
1504 if (world.rank() == coeffs.owner(cdata.key0))
1505 woT::task(world.rank(), &implT::reconstruct_op, cdata.key0,
coeffT(),
false);
1509 if (fence) world.gop.fence();
1520 template <
typename T, std::
size_t NDIM>
1529 if (world.rank() == coeffs.owner(cdata.key0)) {
1537 template <
typename T, std::
size_t NDIM>
1542 template <
typename T, std::
size_t NDIM>
1548 template <
typename T, std::
size_t NDIM>
1552 if (is_redundant())
return;
1558 template <
typename T, std::
size_t NDIM>
1567 template <
typename T, std::
size_t NDIM>
1569 if (world.rank() == coeffs.owner(cdata.key0))
1570 norm_tree_spawn(cdata.key0);
1575 template <
typename T, std::
size_t NDIM>
1581 double value =
v[i].get();
1585 coeffs.task(key, &nodeT::set_norm_tree,
sum);
1590 template <
typename T, std::
size_t NDIM>
1592 nodeT& node = coeffs.find(key).get()->second;
1597 v[i] = woT::task(coeffs.owner(
kit.key()), &implT::norm_tree_spawn,
kit.key());
1599 return woT::task(world.rank(),&implT::norm_tree_op, key,
v);
1613 template <
typename T, std::
size_t NDIM>
1616 nodeT& node = coeffs.find(key).get()->second;
1637 template <
typename T, std::
size_t NDIM>
1644 for (
size_t i=0; i<
v.size(); ++i)
if (
v[i].get().has_no_data())
return coeffT();
1651 const auto found = coeffs.find(
acc, key);
1657 d(child_patch(
kit.key())) +=
v[i].get().full_tensor();
1663 const double error=
d.normf();
1665 nodeT& node = coeffs.find(key).get()->second;
1667 if (
error < truncate_tol(tol,key)) {
1670 coeffs.erase(
kit.key());
1674 acc->second.set_coeff(
ss);
1687 template <
typename T, std::
size_t NDIM>
1700 d(child_patch(
kit.key())) +=
v[i].get().first.full_tensor();
1701 norm_tree2+=
v[i].get().second.first*
v[i].get().second.first;
1702 dnorm_tree2+=
v[i].get().second.second*
v[i].get().second.second;
1707 timer_filter.accumulate(
cpu1-
cpu0);
1711 const auto found = coeffs.find(
acc, key);
1721 double snorm=
ss.normf();
1726 double dnorm=
dd.normf();
1731 acc->second.set_snorm(snorm);
1732 acc->second.set_dnorm(dnorm);
1736 acc->second.set_coeff(
dd);
1738 timer_compress_svd.accumulate(
cpu1-
cpu0);
1750 template <
typename T, std::
size_t NDIM>
1758 d(child_patch(
kit.key())) +=
v[i].get().first.full_tensor();
1759 norm_tree2+=
v[i].get().second.first*
v[i].get().second.first;
1760 dnorm_tree2+=
v[i].get().second.second*
v[i].get().second.second;
1772 double dnorm=
d.normf();
1773 double snorm=s.normf();
1776 const auto found = coeffs.find(
acc, key);
1782 acc->second.set_coeff(s);
1783 acc->second.set_dnorm(dnorm);
1784 acc->second.set_snorm(snorm);
1793 template <
typename T, std::
size_t NDIM>
1796 if (is_compressed())
return;
1798 flo_unary_op_node_inplace(
do_standard(
this),fence);
1806 template <
typename T, std::
size_t NDIM>
1828 flo_unary_op_node_inplace(do_change_tensor_type(targs,*
this),
true);
1834 flo_unary_op_node_inplace(do_truncate_NS_leafs(
this),
true);
1849 template <
typename T, std::
size_t NDIM>
1852 flo_unary_op_node_inplace(do_consolidate_buffer(get_tensor_args()),
true);
1858 template <
typename T, std::
size_t NDIM>
1870 template <
typename T, std::
size_t NDIM>
1875 std::size_t
N = (std::size_t) it->first.level();
1884 template <
typename T, std::
size_t NDIM>
1892 template <
typename T, std::
size_t NDIM>
1901 template <
typename T, std::
size_t NDIM>
1910 template <
typename T, std::
size_t NDIM>
1912 std::size_t
sum = 0;
1913 sum = coeffs.size();
1919 template <
typename T, std::
size_t NDIM>
1921 std::size_t
sum = 0;
1922 for (
const auto& [key,node] : coeffs) {
1929 template <
typename T, std::
size_t NDIM>
1931 std::size_t
sum = size_local();
1937 template <
typename T, std::
size_t NDIM>
1939 std::size_t
sum = coeffs.size() * (
sizeof(
keyT) +
sizeof(
nodeT));
1942 const nodeT& node = it->second;
1950 template <
typename T, std::
size_t NDIM>
1953 for (
auto& [key,node] : coeffs) {
1960 template <
typename T, std::
size_t NDIM>
1962 std::size_t
sum = nCoeff_local();
1969 template <
typename T, std::
size_t NDIM>
1971 const size_t tsize=this->tree_size();
1973 const size_t ncoeff=this->nCoeff();
1975 const double d=
sizeof(T);
1976 const double fac=1024*1024*1024;
1980 double local = norm2sq_local();
1981 this->world.gop.sum(local);
1982 this->world.gop.fence();
1986 if (this->world.rank()==0) {
1988 constexpr std::size_t
bufsize=128;
1990 snprintf(buf,
bufsize,
"%40s at time %.1fs: norm/tree/#coeff/size: %7.5f %zu, %6.3f m, %6.3f GByte",
1992 print(std::string(buf));
1997 template <
typename T, std::
size_t NDIM>
1999 if (this->targs.tt==
TT_FULL)
return;
2002 if (is_compressed())
k0=2*
k;
2007 if (world.rank()==0)
print(
"n.size(),k0,dim",n.
size(),
k0,dim);
2010 const nodeT& node = it->second;
2026 if (world.rank()==0) {
2027 print(
"configurations number of nodes");
2029 for (
unsigned int i=0; i<n.
size(); i++) {
2030 print(
" ",i,
" ",n[i]);
2037 for (
unsigned int i=0; i<std::min(3l,n.
size()); i++)
nlog[0]+=n[i];
2038 for (
unsigned int i=3; i<std::min(10l,n.
size()); i++)
nlog[1]+=n[i];
2039 for (
unsigned int i=10; i<std::min(30l,n.
size()); i++)
nlog[2]+=n[i];
2040 for (
unsigned int i=30; i<std::min(100l,n.
size()); i++)
nlog[3]+=n[i];
2041 for (
unsigned int i=100; i<std::min(300l,n.
size()); i++)
nlog[4]+=n[i];
2042 for (
unsigned int i=300; i<std::min(1000l,n.
size()); i++)
nlog[5]+=n[i];
2044 std::vector<std::string>
slog={
"3",
"10",
"30",
"100",
"300",
"1000"};
2045 for (
unsigned int i=0; i<
nlog.size(); i++) {
2053 template <
typename T, std::
size_t NDIM>
2056 const int k = cdata.k;
2073 if constexpr (
NDIM <= 2) {
2078 if constexpr (
NDIM == 1) {
2079 const T* cp =
c.ptr();
2080 for (
int p=0;
p<
k; ++
p)
sum += cp[
p]*px[0][
p];
2083 for (
int p=0;
p<
k; ++
p) {
2084 const double a = px[0][
p];
2085 const T*
cq = &
c(
p,0);
2087 for (
int q=0;
q<
k; ++
q)
s2 +=
cq[
q]*px[1][
q];
2094 thread_local int phi_k = -1;
2099 for (std::size_t i=0; i<
NDIM; ++i)
2104 auto [
ws,
res] = madness::detail::eval_scratch<evalR>(
c.size());
2120 template <
typename T, std::
size_t NDIM>
2132 if (it == coeffs.end()) {
2134 it = coeffs.find(key).get();
2136 nodeT& node = it->second;
2147 if (!
d.has_data())
d =
coeffT(cdata.v2k,targs);
2149 if (
d.dim(0)==2*get_k()) {
2154 const keyT& child =
kit.key();
2158 woT::task(coeffs.owner(child), &implT::reconstruct_op, child,
ss,
accumulate_NS);
2168 if (s.has_no_data())
ss=
coeffT(cdata.vk,targs);
2174 template <
typename T, std::
size_t NDIM>
2177 std::vector<long> npt(
NDIM,qx.
dim(0));
2183 template <
typename T, std::
size_t NDIM>
2186 std::vector<long> npt(
NDIM,qx.
dim(0));
2192 template <
typename T, std::
size_t NDIM>
2201 const double h = std::pow(0.5,
double(n));
2203 const int npt = qx.
dim(0);
2210 for (std::size_t i = 0; i <
NDIM; i++) {
2211 c1[i] = cell(i,0) +
h*cell_width[i]*(l[i] + qx((
long)0));
2212 c2[i] = cell(i,0) +
h*cell_width[i]*(l[i] + qx(npt-1));
2214 if (
f.screened(c1, c2)) {
2224 double*
x1 =
new double[npt];
2226 for (
int i=0; i<npt; ++i, ++
idx) {
2227 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2234 else if (
NDIM == 2) {
2235 double*
x1 =
new double[npt*npt];
2236 double*
x2 =
new double[npt*npt];
2238 for (
int i=0; i<npt; ++i) {
2239 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2240 for (
int j=0; j<npt; ++j, ++
idx) {
2241 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2251 else if (
NDIM == 3) {
2252 double*
x1 =
new double[npt*npt*npt];
2253 double*
x2 =
new double[npt*npt*npt];
2254 double*
x3 =
new double[npt*npt*npt];
2256 for (
int i=0; i<npt; ++i) {
2257 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2258 for (
int j=0; j<npt; ++j) {
2259 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2260 for (
int k=0;
k<npt; ++
k, ++
idx) {
2261 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2274 else if (
NDIM == 4) {
2275 double*
x1 =
new double[npt*npt*npt*npt];
2276 double*
x2 =
new double[npt*npt*npt*npt];
2277 double*
x3 =
new double[npt*npt*npt*npt];
2278 double*
x4 =
new double[npt*npt*npt*npt];
2280 for (
int i=0; i<npt; ++i) {
2281 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2282 for (
int j=0; j<npt; ++j) {
2283 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2284 for (
int k=0;
k<npt; ++
k) {
2285 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2286 for (
int m=0;
m<npt; ++
m, ++
idx) {
2287 c[3] = cell(3,0) +
h*cell_width[3]*(l[3] + qx(
m));
2303 else if (
NDIM == 5) {
2304 double*
x1 =
new double[npt*npt*npt*npt*npt];
2305 double*
x2 =
new double[npt*npt*npt*npt*npt];
2306 double*
x3 =
new double[npt*npt*npt*npt*npt];
2307 double*
x4 =
new double[npt*npt*npt*npt*npt];
2308 double*
x5 =
new double[npt*npt*npt*npt*npt];
2310 for (
int i=0; i<npt; ++i) {
2311 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2312 for (
int j=0; j<npt; ++j) {
2313 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2314 for (
int k=0;
k<npt; ++
k) {
2315 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2316 for (
int m=0;
m<npt; ++
m) {
2317 c[3] = cell(3,0) +
h*cell_width[3]*(l[3] + qx(
m));
2318 for (
int n=0; n<npt; ++n, ++
idx) {
2319 c[4] = cell(4,0) +
h*cell_width[4]*(l[4] + qx(n));
2338 else if (
NDIM == 6) {
2339 double*
x1 =
new double[npt*npt*npt*npt*npt*npt];
2340 double*
x2 =
new double[npt*npt*npt*npt*npt*npt];
2341 double*
x3 =
new double[npt*npt*npt*npt*npt*npt];
2342 double*
x4 =
new double[npt*npt*npt*npt*npt*npt];
2343 double*
x5 =
new double[npt*npt*npt*npt*npt*npt];
2344 double*
x6 =
new double[npt*npt*npt*npt*npt*npt];
2346 for (
int i=0; i<npt; ++i) {
2347 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2348 for (
int j=0; j<npt; ++j) {
2349 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2350 for (
int k=0;
k<npt; ++
k) {
2351 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2352 for (
int m=0;
m<npt; ++
m) {
2353 c[3] = cell(3,0) +
h*cell_width[3]*(l[3] + qx(
m));
2354 for (
int n=0; n<npt; ++n) {
2355 c[4] = cell(4,0) +
h*cell_width[4]*(l[4] + qx(n));
2356 for (
int p=0;
p<npt; ++
p, ++
idx) {
2357 c[5] = cell(5,0) +
h*cell_width[5]*(l[5] + qx(
p));
2389 for (
int i=0; i<npt; ++i) {
2390 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2395 else if (
NDIM == 2) {
2396 for (
int i=0; i<npt; ++i) {
2397 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2398 for (
int j=0; j<npt; ++j) {
2399 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2405 else if (
NDIM == 3) {
2406 for (
int i=0; i<npt; ++i) {
2407 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2408 for (
int j=0; j<npt; ++j) {
2409 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2410 for (
int k=0;
k<npt; ++
k) {
2411 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2418 else if (
NDIM == 4) {
2419 for (
int i=0; i<npt; ++i) {
2420 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2421 for (
int j=0; j<npt; ++j) {
2422 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2423 for (
int k=0;
k<npt; ++
k) {
2424 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2425 for (
int m=0;
m<npt; ++
m) {
2426 c[3] = cell(3,0) +
h*cell_width[3]*(l[3] + qx(
m));
2434 else if (
NDIM == 5) {
2435 for (
int i=0; i<npt; ++i) {
2436 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2437 for (
int j=0; j<npt; ++j) {
2438 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2439 for (
int k=0;
k<npt; ++
k) {
2440 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2441 for (
int m=0;
m<npt; ++
m) {
2442 c[3] = cell(3,0) +
h*cell_width[3]*(l[3] + qx(
m));
2443 for (
int n=0; n<npt; ++n) {
2444 c[4] = cell(4,0) +
h*cell_width[4]*(l[4] + qx(n));
2453 else if (
NDIM == 6) {
2454 for (
int i=0; i<npt; ++i) {
2455 c[0] = cell(0,0) +
h*cell_width[0]*(l[0] + qx(i));
2456 for (
int j=0; j<npt; ++j) {
2457 c[1] = cell(1,0) +
h*cell_width[1]*(l[1] + qx(j));
2458 for (
int k=0;
k<npt; ++
k) {
2459 c[2] = cell(2,0) +
h*cell_width[2]*(l[2] + qx(
k));
2460 for (
int m=0;
m<npt; ++
m) {
2461 c[3] = cell(3,0) +
h*cell_width[3]*(l[3] + qx(
m));
2462 for (
int n=0; n<npt; ++n) {
2463 c[4] = cell(4,0) +
h*cell_width[4]*(l[4] + qx(n));
2464 for (
int p=0;
p<npt; ++
p) {
2465 c[5] = cell(5,0) +
h*cell_width[5]*(l[5] + qx(
p));
2481 template <
typename T, std::
size_t NDIM>
2487 template <
typename T, std::
size_t NDIM>
2499 template <
typename T, std::
size_t NDIM>
2508 if (key.
level() < special_level && specialpts.size() > 0) {
2510 const auto bperiodic = bc.is_periodic();
2511 for (
unsigned int i = 0; i < specialpts.size(); ++i) {
2533 const keyT& child = it.key();
2534 r(child_patch(child)) =
project(child);
2538 if (truncate_on_project)
s0 =
copy(
d(cdata.s0));
2548 const keyT& child = it.key();
2551 p = world.random_proc();
2554 p = coeffs.owner(child);
2561 if (truncate_on_project) {
2563 coeffs.replace(key,
nodeT(s,
false));
2568 const keyT& child = it.key();
2570 coeffs.replace(child,
nodeT(s,
false));
2580 template <
typename T, std::
size_t NDIM>
2582 std::vector<long>
v0(
NDIM,0
L);
2583 std::vector<long>
v1(
NDIM,1L);
2586 if (is_compressed()) {
2587 if (world.rank() == coeffs.owner(cdata.key0)) {
2590 nodeT& node = it->second;
2601 for (
typename dcT::iterator it=coeffs.begin(); it!=coeffs.end(); ++it) {
2602 Level n = it->first.level();
2603 nodeT& node = it->second;
2611 node.
coeff()(s) += tt;
2618 if (fence) world.gop.fence();
2621 template <
typename T, std::
size_t NDIM>
2624 if (is_compressed()) initial_level = std::max(initial_level,1);
2625 if (coeffs.is_local(key)) {
2626 if (is_compressed()) {
2627 if (key.
level() == initial_level) {
2631 coeffs.replace(key,
nodeT(
coeffT(cdata.v2k,targs),
true));
2635 if (key.
level()<initial_level) {
2639 coeffs.replace(key,
nodeT(
coeffT(cdata.vk,targs),
false));
2643 if (key.
level() < initial_level) {
2645 insert_zero_down_to_initial_level(
kit.key());
2652 template <
typename T, std::
size_t NDIM>
2656 if (it == coeffs.end()) {
2660 coeffs.replace(key,
nodeT());
2661 it = coeffs.find(key).get();
2663 nodeT& node = it->second;
2670 return woT::task(world.rank(),&implT::truncate_op, key, tol,
v);
2679 if (dnorm < truncate_tol(tol,key)) {
2688 template <
typename T, std::
size_t NDIM>
2692 for (
int i=0; i<(1<<
NDIM); ++i)
if (
v[i].get())
return true;
2693 nodeT& node = coeffs.find(key).get()->second;
2700 if (key.
level() > 1) {
2702 if (dnorm < truncate_tol(tol,key)) {
2707 coeffs.erase(
kit.key());
2716 template <
typename T, std::
size_t NDIM>
2718 if (world.rank() == 0) do_print_tree(cdata.key0, os,
maxlevel);
2720 if (world.rank() == 0) os.flush();
2725 template <
typename T, std::
size_t NDIM>
2728 if (it == coeffs.end()) {
2730 for (
int i=0; i<key.
level(); ++i) os <<
" ";
2731 os << key <<
" missing --> " << coeffs.owner(key) <<
"\n";
2734 const nodeT& node = it->second;
2735 for (
int i=0; i<key.
level(); ++i) os <<
" ";
2736 os << key <<
" " << node <<
" --> " << coeffs.owner(key) <<
"\n";
2745 template <
typename T, std::
size_t NDIM>
2747 std::multimap<Level, std::tuple<tranT, std::string>>
data;
2748 if (world.rank() == 0) do_print_tree_json(cdata.key0,
data,
maxlevel);
2750 if (world.rank() == 0) {
2752 if (
data.count(level) == 0)
2757 os <<
"\"" << level <<
"\":{";
2758 os <<
"\"level\": " << level <<
",";
2759 os <<
"\"nodes\":{";
2760 auto range =
data.equal_range(level);
2761 for (
auto it = range.first; it != range.second; ++it) {
2762 os <<
"\"" << std::get<0>(it->second) <<
"\":"
2763 << std::get<1>(it->second);
2764 if (std::next(it) != range.second)
2776 template <
typename T, std::
size_t NDIM>
2779 if (it == coeffs.end()) {
2783 const nodeT& node = it->second;
2784 std::ostringstream
oss;
2787 oss <<
",\"owner\": " << coeffs.owner(key) <<
"}";
2798 template <
typename T, std::
size_t NDIM>
2801 if (world.rank() == 0) do_print_tree_graphviz(cdata.key0, os,
maxlevel);
2803 if (world.rank() == 0) os.flush();
2807 template <
typename T, std::
size_t NDIM>
2814 result += (1 << j*
NDIM);
2822 if (it != coeffs.end()) {
2823 const nodeT& node = it->second;
2826 os << uniqhash::value(key) <<
" -> " << uniqhash::value(
kit.key()) <<
"\n";
2833 template <
typename T, std::
size_t NDIM>
2840 if (functor->provides_coeff())
return functor->coeff(key).full_tensor_copy();
2854 template <
typename T, std::
size_t NDIM>
2856 if (coeffs.probe(key)) {
2857 return Future<double>(coeffs.find(key).get()->second.get_norm_tree());
2861 return woT::task(coeffs.owner(parent), &implT::get_norm_tree_recursive, parent,
TaskAttributes::hipri());
2865 template <
typename T, std::
size_t NDIM>
2869 if (coeffs.probe(key)) {
2870 const nodeT& node = coeffs.find(key).get()->second;
2874 result.
set(std::pair<keyT,coeffT>(key,node.
coeff()));
2878 result.
set(std::pair<keyT,coeffT>(key,
coeffT()));
2885 if (coeffs.is_local(parent))
2893 template <
typename T, std::
size_t NDIM>
2897 if (coeffs.probe(key)) {
2898 const nodeT& node = coeffs.find(key).get()->second;
2901 result.
set(std::pair<keyT,coeffT>(key,node.
coeff()));
2915 template <
typename T, std::
size_t NDIM>
2937 nodeT& node = it->second;
2943 for (std::size_t i=0; i<
NDIM; ++i) {
2944 double xi = x[i]*2.0;
2946 if (
li == 2)
li = 1;
2958 template <
typename T, std::
size_t NDIM>
2966 if (coeffs.owner(key) ==
me) {
2969 if (it != coeffs.end()) {
2970 nodeT& node = it->second;
2976 for (std::size_t i=0; i<
NDIM; ++i) {
2977 double xi = x[i]*2.0;
2979 if (
li == 2)
li = 1;
2985 return std::pair<bool,T>(
false,0.0);
2988 template <
typename T, std::
size_t NDIM>
2992 std::pair<bool,T>* results) {
3012 for (std::size_t
ip=0;
ip<npt; ++
ip) {
3013 results[
ip] = std::pair<bool,T>(
false, T(0));
3018 for (std::size_t i=0; i<
NDIM; ++i) l[i] = 0;
3021 for (std::size_t i=0; i<
NDIM; ++i) {
3022 double xi = x[i]*2.0;
3024 if (
li == 2)
li = 1;
3031 for (std::size_t i=0; i<
NDIM; ++i)
same =
same && (l[i] ==
lc[i]);
3033 results[
ip] = std::pair<bool,T>(
true, eval_cube(nl, x,
cached_c));
3044 if (coeffs.owner(key) ==
me) {
3047 if (it != coeffs.end()) {
3048 nodeT& node = it->second;
3053 results[
ip] = std::pair<bool,T>(
true,
3059 for (std::size_t i=0; i<
NDIM; ++i) {
3060 double xi = x[i]*2.0;
3062 if (
li == 2)
li = 1;
3071 template <
typename T, std::
size_t NDIM>
3072 std::vector<std::pair<bool,T>>
3074 std::vector<std::pair<bool,T>> results(
xin.size(), std::pair<bool,T>(
false,T(0)));
3075 eval_local_only(
xin.data(),
xin.size(),
maxlevel, results.data());
3079 template <
typename T, std::
size_t NDIM>
3101 nodeT& node = it->second;
3107 for (std::size_t i=0; i<
NDIM; ++i) {
3108 double xi = x[i]*2.0;
3110 if (
li == 2)
li = 1;
3121 template <
typename T, std::
size_t NDIM>
3143 nodeT& node = it->second;
3149 for (std::size_t i=0; i<
NDIM; ++i) {
3150 double xi = x[i]*2.0;
3152 if (
li == 2)
li = 1;
3164 template <
typename T, std::
size_t NDIM>
3175 template <
typename T, std::
size_t NDIM>
3185 template <
typename T, std::
size_t NDIM>
3191 if (t.
rank()==0)
return;
3193 for (
long i=0; i<t.
rank(); ++i) {
3196 tnorm(
c, &lo1, &hi1);
3204 template <
typename A,
typename B>
3211 template <
typename T, std::
size_t NDIM>
3228 template <
typename T, std::
size_t NDIM>
3236 template <
typename T, std::
size_t NDIM>
3242 template <
typename T, std::
size_t NDIM>
3250template <
typename T, std::
size_t NDIM>
3256 template <
typename T, std::
size_t NDIM>
3262 template <
typename T, std::
size_t NDIM>
3267 template <
typename T, std::
size_t NDIM>
3272 template <
typename T, std::
size_t NDIM>
3277 for (
int mu=0;
mu<cdata.npt; ++
mu) {
3281 for (
int i=0; i<
k; ++i) phi(i,
mu) =
p[i];
3286 template <
typename T, std::
size_t NDIM>
3298 result =
transform(result,cdata.quad_phiw);
3304 template <
typename T, std::
size_t NDIM>
3307 std::vector<long>
v0(
NDIM,0);
3309 if (is_compressed()) {
3310 if (world.rank() == coeffs.owner(cdata.key0)) {
3312 if (it != coeffs.end()) {
3313 const nodeT& node = it->second;
3320 const keyT& key = it->first;
3321 const nodeT& node = it->second;
3341 }
else if (l >=
two2n) {
3345 }
while (l >=
two2n);
3354 return l >= 0 && l <
two2n;
3360 template <
typename T, std::
size_t NDIM>
3369 return keyT::invalid();
3375 template <
typename T, std::
size_t NDIM>
3383 return keyT::invalid();
3389 template <
typename T, std::
size_t NDIM>
3393 typedef std::pair< Key<NDIM>,
coeffT > argT;
3403 template <
typename T, std::
size_t NDIM>
3406 if (!coeffs.probe(key))
print(
"missing node",key);
3410 nodeT& node = coeffs.find(key).get()->second;
3419 v[i] = woT::task(coeffs.owner(
kit.key()), &implT::compress_spawn,
kit.key(),
3422 if (
redundant1)
return woT::task(world.rank(),&implT::make_redundant_op, key,
v);
3423 return woT::task(world.rank(),&implT::compress_op, key,
v,
nonstandard1);
3430 if (key.
level()==0) {
3442 coeffT result(node.
coeff());
3443 coeffT
sdcoeff(cdata.v2k,
this->get_tensor_type());
3469 template <
typename T, std::
size_t NDIM>
3478 for (std::size_t i=0; i<
NDIM; ++i) {
3490 const double twon =
pow(2.0,
double(n));
3491 const tensorT& coeff = coeffs.find(key).get()->second.coeff().full_tensor();
3497 double fac =
pow(0.5,
double(key.
level()));
3499 for (std::size_t
d=0;
d<
NDIM; ++
d) {
3510 else if (npt[
d] == 1) {
3534 for (IndexIterator it(
boxnpt); it; ++it) {
3537 x[
d] = twon*
xd - l[
d];
3551 T
tmp = eval_cube(n, x, coeff);
3561 template <
typename T, std::
size_t NDIM>
3564 const std::vector<long>& npt,
3572 const keyT& key = it->first;
3573 const nodeT& node = it->second;
3575 woT::task(world.rank(), &implT::plot_cube_kernel,
3582 world.taskq.fence();
3583 world.gop.sum(r.
ptr(), r.
size());
3594 fprintf(
f,
"%.6e %.6e\n", t.real(), t.imag());
3597 template <
typename T, std::
size_t NDIM>
3601 const std::vector<long>& npt,
3611 "plotdx: plot cell must be an (NDIM x 2) [lo,hi] tensor "
3612 "(got an empty or ill-shaped cell)");
3613 const char*
element[6] = {
"lines",
"quads",
"cubes",
"cubes4D",
"cubes5D",
"cubes6D"};
3618 if (world.
rank() == 0) {
3622 fprintf(
f,
"object 1 class gridpositions counts ");
3630 for (std::size_t
d=0;
d<
NDIM; ++
d) {
3634 if (npt[
d]>1)
h = (cell(
d,1)-cell(
d,0))/(npt[
d]-1);
3641 fprintf(
f,
"object 2 class gridconnections counts ");
3645 fprintf(
f,
"attribute \"ref\" string \"positions\"\n");
3651 if (TensorTypeData<T>::iscomplex)
iscomplex =
"category complex";
3654 fprintf(
f,
"object 3 class array type double %s rank 0 items %d %s data follows\n",
3661 if (world.
rank() == 0) {
3665 fwrite((
void *) r.ptr(),
sizeof(T), r.size(),
f);
3669 for (IndexIterator it(npt); it; ++it) {
3677 fprintf(
f,
"component \"positions\" value 1\n");
3678 fprintf(
f,
"component \"connections\" value 2\n");
3679 fprintf(
f,
"component \"data\" value 3\n");
3686 template <std::
size_t NDIM>
3692 max_refine_level = 30;
3697 truncate_on_project =
true;
3698 apply_randomize =
false;
3699 project_randomize =
false;
3702 cell = make_default_cell();
3703 recompute_cell_info();
3704 set_default_pmap(world);
3707 template <std::
size_t NDIM>
3710 return std::make_shared<LevelPmap< Key<NDIM> >>(world);
3714 template <std::
size_t NDIM>
3716 pmap = make_default_pmap(world);
3717 pmap_nproc = world.
nproc();
3721 template <std::
size_t NDIM>
3723 std::cout <<
"Function Defaults:" << std::endl;
3724 std::cout <<
" Dimension " <<
": " <<
NDIM << std::endl;
3725 std::cout <<
" k" <<
": " <<
k << std::endl;
3726 std::cout <<
" thresh" <<
": " <<
thresh << std::endl;
3727 std::cout <<
" initial_level" <<
": " << initial_level << std::endl;
3728 std::cout <<
" special_level" <<
": " << special_level << std::endl;
3729 std::cout <<
" max_refine_level" <<
": " << max_refine_level << std::endl;
3730 std::cout <<
" truncate_mode" <<
": " <<
truncate_mode << std::endl;
3731 std::cout <<
" refine" <<
": " <<
refine << std::endl;
3732 std::cout <<
" autorefine" <<
": " << autorefine << std::endl;
3733 std::cout <<
" debug" <<
": " <<
debug << std::endl;
3734 std::cout <<
" truncate_on_project" <<
": " << truncate_on_project << std::endl;
3735 std::cout <<
" apply_randomize" <<
": " << apply_randomize << std::endl;
3736 std::cout <<
" project_randomize" <<
": " << project_randomize << std::endl;
3737 std::cout <<
" bc" <<
": " << get_bc() << std::endl;
3738 std::cout <<
" tt" <<
": " << tt << std::endl;
3739 std::cout <<
" cell" <<
": " << cell << std::endl;
3742 template <
typename T, std::
size_t NDIM>
3743 const FunctionCommonData<T,NDIM>*
FunctionCommonData<T,NDIM>::data[
MAXK] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
double w(double t, double eps)
Definition DKops.h:22
double q(double t)
Definition DKops.h:18
std::complex< double > double_complex
Definition cfft.h:14
Definition test_ar.cc:118
Definition test_ar.cc:141
Definition test_tree.cc:78
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
This class is used to specify boundary conditions for all operators.
Definition bc.h:72
a class to track where relevant (parent) coeffs are
Definition funcimpl.h:814
Tri-diagonal operator traversing tree primarily for derivative operator.
Definition derivative.h:73
ElementaryInterface (formerly FunctorInterfaceWrapper) interfaces a c-function.
Definition function_interface.h:275
FunctionCommonData holds all Function data common for given k.
Definition function_common_data.h:52
static const FunctionCommonData< T, NDIM > & get(int k)
Definition function_common_data.h:111
static void _init_quadrature(int k, int npt, Tensor< double > &quad_x, Tensor< double > &quad_w, Tensor< double > &quad_phi, Tensor< double > &quad_phiw, Tensor< double > &quad_phit)
Initialize the quadrature information.
Definition mraimpl.h:91
void _init_twoscale()
Private. Initialize the twoscale coefficients.
Definition mraimpl.h:70
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:100
static Tensor< double > make_default_cell_width()
Definition funcdefaults.h:136
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > make_default_pmap(World &world)
Makes a default process map for the given world.
Definition mraimpl.h:3708
static bool truncate_on_project
If true initial projection inserts at n-1 not n.
Definition funcdefaults.h:114
static bool apply_randomize
If true use randomization for load balancing in apply integral operator.
Definition funcdefaults.h:115
static double cell_volume
Volume of simulation cell.
Definition funcdefaults.h:121
static int k
Wavelet order.
Definition funcdefaults.h:105
static double get_cell_volume()
Returns the volume of the user cell.
Definition funcdefaults.h:394
static int truncate_mode
Truncation method.
Definition funcdefaults.h:110
static void set_default_pmap(World &world)
Definition mraimpl.h:3715
static int pmap_nproc
Number of processes assumed by pmap, -1 indicates uninitialized pmap.
Definition funcdefaults.h:125
static Tensor< double > cell_width
Width of simulation cell in each dimension.
Definition funcdefaults.h:119
static double thresh
Truncation threshold.
Definition funcdefaults.h:106
static bool debug
Controls output of debug info.
Definition funcdefaults.h:113
static int special_level
Minimum level for fine scale projection of special boxes.
Definition funcdefaults.h:108
static double cell_min_width
Size of smallest dimension.
Definition funcdefaults.h:122
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > pmap
Default mapping of keys to processes.
Definition funcdefaults.h:124
static const Tensor< double > & get_cell_width()
Returns the width of each user cell dimension.
Definition funcdefaults.h:379
static const BoundaryConditions< NDIM > & get_bc()
Returns the default boundary conditions.
Definition funcdefaults.h:309
static Tensor< double > cell
cell[NDIM][2] Simulation cell, cell(0,0)=xlo, cell(0,1)=xhi, ...
Definition funcdefaults.h:118
static int initial_level
Initial level for fine scale projection.
Definition funcdefaults.h:107
static bool autorefine
Whether to autorefine in multiplication, etc.
Definition funcdefaults.h:112
static Tensor< double > make_default_cell()
Definition funcdefaults.h:127
static std::optional< BoundaryConditions< NDIM > > bc
Default boundary conditions, not initialized by default and must be set explicitly before use.
Definition funcdefaults.h:117
static void print()
Definition mraimpl.h:3722
static Tensor< double > rcell_width
Reciprocal of width.
Definition funcdefaults.h:120
static double get_cell_min_width()
Returns the minimum width of any user cell dimension.
Definition funcdefaults.h:389
static bool project_randomize
If true use randomization for load balancing in project/refine.
Definition funcdefaults.h:116
static const Tensor< double > & get_cell()
Gets the user cell for the simulation.
Definition funcdefaults.h:346
static void set_defaults(World &world)
Definition mraimpl.h:3687
static int max_refine_level
Level at which to stop refinement.
Definition funcdefaults.h:109
static TensorType tt
structure of the tensor in FunctionNode
Definition funcdefaults.h:123
static bool refine
Whether to refine new functions.
Definition funcdefaults.h:111
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
Definition funcimpl.h:5669
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:968
bool is_nonstandard() const
Definition mraimpl.h:273
T eval_cube(Level n, coordT &x, const tensorT &c) const
Definition mraimpl.h:2054
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:2808
void change_tensor_type1(const TensorArgs &targs, bool fence)
change the tensor type of the coefficients in the FunctionNode
Definition mraimpl.h:1113
compressT compress_op(const keyT &key, const std::vector< Future< compressT > > &v, bool nonstandard)
calculate the wavelet coefficients using the sum coefficients of all child nodes
Definition mraimpl.h:1688
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:3080
void scale_inplace(const T q, bool fence)
In-place scale by a constant.
Definition mraimpl.h:3251
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:223
bool is_redundant() const
Returns true if the function is redundant.
Definition mraimpl.h:262
std::size_t nCoeff_local() const
Returns the number of coefficients in the function for this MPI rank.
Definition mraimpl.h:1951
void print_size(const std::string name) const
print tree size and size
Definition mraimpl.h:1970
void print_info() const
Prints summary of data distribution.
Definition mraimpl.h:833
void abs_inplace(bool fence)
Definition mraimpl.h:3263
void print_timer() const
Definition mraimpl.h:357
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:3122
void do_print_grid(const std::string filename, const std::vector< keyT > &keys) const
print the grid in xyz format
Definition mraimpl.h:584
Future< compressT > compress_spawn(const keyT &key, bool nonstandard, bool keepleaves, bool redundant1)
Invoked on node where key is local.
Definition mraimpl.h:3404
std::size_t nCoeff() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:1961
keyT neighbor_in_volume(const keyT &key, const keyT &disp) const
Returns key of general neighbor that resides in-volume.
Definition mraimpl.h:3376
void compress(const TreeState newstate, bool fence)
compress the wave function
Definition mraimpl.h:1521
Future< bool > truncate_spawn(const keyT &key, double tol)
Returns true if after truncation this node has coefficients.
Definition mraimpl.h:2653
Future< double > norm_tree_spawn(const keyT &key)
Definition mraimpl.h:1591
std::vector< keyT > local_leaf_keys() const
return the keys of the local leaf boxes
Definition mraimpl.h:558
void do_print_tree(const keyT &key, std::ostream &os, Level maxlevel) const
Functor for the do_print_tree method.
Definition mraimpl.h:2726
void unset_functor()
Definition mraimpl.h:312
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:499
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:979
void set_functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor1)
Definition mraimpl.h:293
bool verify_tree_state_local() const
check that the tree state and the coeffs are consistent
Definition mraimpl.h:169
const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap() const
Definition mraimpl.h:207
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:2866
double get_thresh() const
Definition mraimpl.h:328
void trickle_down(bool fence)
sum all the contributions from all scales after applying an operator in mod-NS form
Definition mraimpl.h:1368
void set_autorefine(bool value)
Definition mraimpl.h:337
tensorT filter(const tensorT &s) const
Transform sum coefficients at level n to sums+differences at level n-1.
Definition mraimpl.h:1166
void chop_at_level(const int n, const bool fence=true)
remove all nodes with level higher than n
Definition mraimpl.h:1129
void print_tree_json(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2746
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:707
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:1071
bool is_compressed() const
Returns true if the function is compressed.
Definition mraimpl.h:250
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:1080
void print_stats() const
print the number of configurations per node
Definition mraimpl.h:1998
void broaden(const array_of_bools< NDIM > &is_periodic, bool fence)
Definition mraimpl.h:1317
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:1638
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:2488
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:932
std::vector< Slice > child_patch(const keyT &child) const
Returns patch referring to coeffs of child in parent box.
Definition mraimpl.h:696
void print_tree_graphviz(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2799
std::size_t min_nodes() const
Returns the min number of nodes on a processor.
Definition mraimpl.h:1902
void make_redundant(const bool fence)
convert this to redundant, i.e. have sum coefficients on all levels
Definition mraimpl.h:1549
std::size_t max_nodes() const
Returns the max number of nodes on a processor.
Definition mraimpl.h:1893
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:1245
void flo_unary_op_node_inplace(const opT &op, bool fence)
Definition funcimpl.h:2313
std::size_t size_local() const
Returns the number of coefficients in the function for each rank.
Definition mraimpl.h:1920
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:3470
T trace_local() const
Returns int(f(x),x) in local volume.
Definition mraimpl.h:3305
void print_grid(const std::string filename) const
Definition mraimpl.h:542
bool get_autorefine() const
Definition mraimpl.h:334
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:3273
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:3391
TensorType get_tensor_type() const
Definition mraimpl.h:319
void remove_leaf_coefficients(const bool fence)
Definition mraimpl.h:1543
void insert_zero_down_to_initial_level(const keyT &key)
Initialize nodes to zero function at initial_level of refinement.
Definition mraimpl.h:2622
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:943
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:2777
void finalize_sum()
after summing up we need to do some cleanup;
Definition mraimpl.h:1850
bool exists_and_is_leaf(const keyT &key) const
Definition mraimpl.h:1289
void verify_tree() const
Verify tree is properly constructed ... global synchronization involved.
Definition mraimpl.h:111
void set_tensor_args(const TensorArgs &t)
Definition mraimpl.h:325
std::size_t real_size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:1938
bool exists_and_has_children(const keyT &key) const
Definition mraimpl.h:1284
void sum_down_spawn(const keyT &key, const coeffT &s)
is this the same as trickle_down() ?
Definition mraimpl.h:876
keyT neighbor(const keyT &key, const keyT &disp, const array_of_bools< NDIM > &is_periodic) const
Returns key of general neighbor enforcing BC.
Definition mraimpl.h:3361
void norm_tree(bool fence)
compute for each FunctionNode the norm of the function inside that node
Definition mraimpl.h:1568
bool has_leaves() const
Definition mraimpl.h:288
bool verify_parents_and_children() const
check that parents and children are consistent
Definition mraimpl.h:119
void reconstruct_op(const keyT &key, const coeffT &s, const bool accumulate_NS=true)
Definition mraimpl.h:2121
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:3288
void undo_redundant(const bool fence)
convert this from redundant to standard reconstructed form
Definition mraimpl.h:1559
const keyT & key0() const
Returns cdata.key0.
Definition mraimpl.h:394
double finalize_apply()
after apply we need to do some cleanup;
Definition mraimpl.h:1807
const dcT & get_coeffs() const
Definition mraimpl.h:343
compressT make_redundant_op(const keyT &key, const std::vector< Future< compressT > > &v)
similar to compress_op, but insert only the sum coefficients in the tree
Definition mraimpl.h:1752
double norm2sq_local() const
Returns the square of the local norm ... no comms.
Definition mraimpl.h:1859
const FunctionCommonData< T, NDIM > & get_cdata() const
Definition mraimpl.h:349
void sum_down(bool fence)
After 1d push operator must sum coeffs down the tree to restore correct scaling function coefficients...
Definition mraimpl.h:922
bool noautorefine(const keyT &key, const tensorT &t) const
Always returns false (for when autorefine is not wanted)
Definition mraimpl.h:859
double truncate_tol(double tol, const keyT &key) const
Returns the truncation threshold according to truncate_method.
Definition mraimpl.h:649
bool autorefine_square_test(const keyT &key, const nodeT &t) const
Returns true if this block of coeffs needs autorefining.
Definition mraimpl.h:865
void erase(const Level &max_level)
truncate tree at a certain level
Definition mraimpl.h:739
std::pair< coeffT, std::pair< double, double > > compressT
s coefficients plus the (snorm_tree, dnorm_tree) pair propagated up by compress
Definition funcimpl.h:4788
void reconstruct(bool fence)
reconstruct this tree – respects fence
Definition mraimpl.h:1489
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:3786
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:1027
static void tnorm(const tensorT &t, double *lo, double *hi)
Computes norm of low/high-order polyn. coeffs for autorefinement test.
Definition mraimpl.h:3165
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:2960
std::size_t max_depth() const
Returns the maximum depth of the tree ... collective ... global sum/broadcast.
Definition mraimpl.h:1885
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mraimpl.h:1930
void reduce_rank(const double thresh, bool fence)
reduce the rank of the coefficients tensors
Definition mraimpl.h:1121
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor()
Definition mraimpl.h:300
tensorT unfilter(const tensorT &s) const
Transform sums+differences at level n to sum coefficients at level n+1.
Definition mraimpl.h:1195
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:3562
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:1421
Future< coeffT > truncate_reconstructed_spawn(const keyT &key, const double tol)
truncate using a tree in reconstructed form
Definition mraimpl.h:1614
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:1090
void truncate(double tol, bool fence)
Truncate according to the threshold with optional global fence.
Definition mraimpl.h:378
bool is_reconstructed() const
Returns true if the function is compressed.
Definition mraimpl.h:256
double norm_tree_op(const keyT &key, const std::vector< Future< double > > &v)
Definition mraimpl.h:1576
void reset_timer()
Definition mraimpl.h:366
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:769
int get_k() const
Definition mraimpl.h:340
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:2916
bool truncate_op(const keyT &key, double tol, const std::vector< Future< bool > > &v)
Definition mraimpl.h:2689
void zero_norm_tree()
Definition mraimpl.h:1306
std::size_t max_local_depth() const
Returns the maximum local depth of the tree ... no communications.
Definition mraimpl.h:1871
tensorT project(const keyT &key) const
Definition mraimpl.h:2834
double check_symmetry_local() const
Returns some asymmetry measure ... no comms.
Definition mraimpl.h:755
Future< double > get_norm_tree_recursive(const keyT &key) const
Definition mraimpl.h:2855
bool is_redundant_after_merge() const
Returns true if the function is redundant_after_merge.
Definition mraimpl.h:268
bool is_on_demand() const
Definition mraimpl.h:283
void accumulate_timer(const double time) const
Definition mraimpl.h:352
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:1379
void set_thresh(double value)
Definition mraimpl.h:331
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:423
void sock_it_to_me_too(const keyT &key, const RemoteReference< FutureImpl< std::pair< keyT, coeffT > > > &ref) const
Definition mraimpl.h:2894
void broaden_op(const keyT &key, const std::vector< Future< bool > > &v)
Definition mraimpl.h:1295
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:403
void print_tree(std::ostream &os=std::cout, Level maxlevel=10000) const
Definition mraimpl.h:2717
void project_refine_op(const keyT &key, bool do_refine, const std::vector< Vector< double, NDIM > > &specialpts)
Definition mraimpl.h:2500
std::size_t tree_size() const
Returns the size of the tree structure of the function ... collective global sum.
Definition mraimpl.h:1911
void add_scalar_inplace(T t, bool fence)
Adds a constant to the function. Local operation, optional fence.
Definition mraimpl.h:2581
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:1215
void abs_square_inplace(bool fence)
Definition mraimpl.h:3268
void put_in_box(ProcessID from, long nl, long ni) const
Definition mraimpl.h:824
TensorArgs get_tensor_args() const
Definition mraimpl.h:322
void average(const implT &rhs)
take the average of two functions, similar to: this=0.5*(this+rhs)
Definition mraimpl.h:1102
void diff(const DerivativeBase< T, NDIM > *D, const implT *f, bool fence)
Definition mraimpl.h:955
void square_inplace(bool fence)
Pointwise squaring of function with optional global fence.
Definition mraimpl.h:3257
void remove_internal_coefficients(const bool fence)
Definition mraimpl.h:1538
void compute_snorm_and_dnorm(bool fence=true)
compute norm of s and d coefficients for all nodes
Definition mraimpl.h:1145
void standard(bool fence)
Changes non-standard compressed form to standard compressed form.
Definition mraimpl.h:1794
bool is_nonstandard_with_leaves() const
Definition mraimpl.h:278
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition funcimpl.h:136
bool has_coeff() const
Returns true if there are coefficients in this node.
Definition funcimpl.h:210
size_t size() const
Returns the number of coefficients in this node.
Definition funcimpl.h:252
void clear_coeff()
Clears the coefficients (has_coeff() will subsequently return false)
Definition funcimpl.h:305
bool is_leaf() const
Returns true if this does not have children.
Definition funcimpl.h:223
void set_has_children(bool flag)
Sets has_children attribute to value of flag.
Definition funcimpl.h:264
double get_norm_tree() const
Gets the value of norm_tree.
Definition funcimpl.h:326
void set_snorm(const double sn)
set the precomputed norm of the (virtual) s coefficients
Definition funcimpl.h:341
void set_is_leaf(bool flag)
Sets has_children attribute to value of !flag.
Definition funcimpl.h:290
void print_json(std::ostream &s) const
Definition funcimpl.h:487
void set_dnorm_tree(double dnorm_tree)
Sets the value of dnorm_tree.
Definition funcimpl.h:321
bool has_children() const
Returns true if this node has children.
Definition funcimpl.h:217
void set_coeff(const coeffT &coeffs)
Takes a shallow copy of the coeff — same as this->coeff()=coeff.
Definition funcimpl.h:295
void set_dnorm(const double dn)
set the precomputed norm of the (virtual) d coefficients
Definition funcimpl.h:346
coeffT & coeff()
Returns a non-const reference to the tensor containing the coeffs.
Definition funcimpl.h:237
void set_norm_tree(double norm_tree)
Sets the value of norm_tree.
Definition funcimpl.h:316
A multiresolution adaptive numerical function.
Definition mra.h:144
Implements the functionality of futures.
Definition future.h:75
A future is a possibly yet unevaluated value.
Definition future.h:370
T & get(bool dowork=true) &
Gets the value, waiting if necessary.
Definition future.h:571
remote_refT remote_ref(World &world) const
Returns a structure used to pass references to another process.
Definition future.h:672
void set(const Future< T > &other)
A.set(B), where A and B are futures ensures A has/will have the same value as B.
Definition future.h:505
Definition lowranktensor.h:59
GenTensor convert(const TensorArgs &targs) const
Definition gentensor.h:198
long dim(const int i) const
return the number of entries in dimension i
Definition lowranktensor.h:391
bool has_no_data() const
Definition gentensor.h:211
size_t real_size() const
Definition gentensor.h:214
GenTensor< T > & emul(const GenTensor< T > &other)
Inplace multiply by corresponding elements of argument Tensor.
Definition lowranktensor.h:637
float_scalar_type normf() const
Definition lowranktensor.h:406
void reduce_rank(const double &eps)
Definition gentensor.h:217
long rank() const
Definition gentensor.h:212
const Tensor< T > & full_tensor() const
Definition gentensor.h:200
size_t nCoeff() const
Definition gentensor.h:215
TensorType tensor_type() const
Definition gentensor.h:221
GenTensor & gaxpy(const T alpha, const GenTensor &other, const T beta)
Definition lowranktensor.h:586
IsSupported< TensorTypeData< Q >, GenTensor< T > & >::type scale(Q fac)
Inplace multiplication by scalar of supported type (legacy name)
Definition lowranktensor.h:426
Definition worldhashmap.h:330
Iterates in lexical order thru all children of a key.
Definition key.h:548
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
Level level() const
Definition key.h:169
bool is_neighbor_of(const Key &key, const array_of_bools< NDIM > &bperiodic) const
Assuming keys are at the same level, returns true if displaced by no more than 1 in any direction.
Definition key.h:325
bool thisKeyContains(const Vector< double, NDIM > &x, const unsigned int &dim0, const unsigned int &dim1) const
check if this MultiIndex contains point x, disregarding these two dimensions
Definition key.h:400
bool is_invalid() const
Checks if a key is invalid.
Definition key.h:119
Key parent(int generation=1) const
Returns the key of the parent.
Definition key.h:290
const Vector< Translation, NDIM > & translation() const
Definition key.h:174
Range, vaguely a la Intel TBB, to encapsulate a random-access, STL-like start and end iterator with c...
Definition range.h:64
Simple structure used to manage references/pointers to remote instances.
Definition worldref.h:395
double weights(const unsigned int &i) const
return the weight
Definition srconf.h:671
const Tensor< T > flat_vector(const unsigned int &idim) const
return shallow copy of a slice of one of the vectors, flattened to (r,kVec)
Definition srconf.h:545
Definition SVDTensor.h:42
long rank() const
Definition SVDTensor.h:77
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
static TaskAttributes hipri()
Definition thread.h:456
static TaskAttributes generator()
Definition thread.h:448
A tensor is a multidimensional array.
Definition tensor.h:318
T sum() const
Returns the sum of all elements of the tensor.
Definition tensor.h:1663
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition tensor.h:1385
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1841
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type scale(Q x)
Inplace multiplication by scalar of supported type (legacy name)
Definition tensor.h:687
Tensor< T > & emul(const Tensor< T > &t)
Inplace multiply by corresponding elements of argument Tensor.
Definition tensor.h:1800
Iterator for distributed container wraps the local iterator.
Definition worlddc.h:386
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:176
A parallel world class.
Definition world.h:134
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
WorldGopInterface & gop
Global operations.
Definition world.h:216
ProcessID nproc() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:349
Wrapper for an opaque pointer for serialization purposes.
Definition archive.h:851
syntactic sugar for std::array<bool, N>
Definition array_of_bools.h:19
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
const std::size_t bufsize
Definition derivatives.cc:16
static double lo
Definition dirac-hatom.cc:23
static bool debug
Definition dirac-hatom.cc:16
Provides FunctionCommonData, FunctionImpl and FunctionFactory.
static double function(const coord_3d &r)
Normalized gaussian.
Definition functionio.cc:100
Tensor< TENSOR_RESULT_TYPE(T, Q) > & fast_transform(const Tensor< T > &t, const Tensor< Q > &c, Tensor< TENSOR_RESULT_TYPE(T, Q) > &result, Tensor< TENSOR_RESULT_TYPE(T, Q) > &workspace)
Restricted but heavily optimized form of transform()
Definition tensor.h:2460
Tensor< T > transpose(const Tensor< T > &t)
Returns a new deep copy of the transpose of the input tensor.
Definition tensor.h:2035
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
static double pow(const double *a, const double *b)
Definition lda.h:74
Macros and tools pertaining to the configuration of MADNESS.
#define MADNESS_PRAGMA_CLANG(x)
Definition madness_config.h:200
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
static const bool VERIFY_TREE
Definition mra.h:57
Definition potentialmanager.cc:41
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
bool two_scale_hg(int k, Tensor< double > *hg)
Definition twoscale.cc:151
@ BC_FREE
Definition bc.h:53
void make_redundant(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
change tree_state of a vector of functions to redundant
Definition vmra.h:186
static const char * filename
Definition legendre.cc:96
static const std::vector< Slice > ___
Entire dimension.
Definition slice.h:128
static bool enforce_in_volume(Level n, const Translation &l)
Definition mraimpl.h:3352
double abs(double x)
Definition complexfun.h:48
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition timers.h:128
Vector< double, 3 > coordT
Definition corepotential.cc:54
GenTensor< TENSOR_RESULT_TYPE(R, Q)> general_transform(const GenTensor< R > &t, const Tensor< Q > c[])
Definition gentensor.h:274
void legendre_scaling_functions(double x, long k, double *p)
Evaluate the first k Legendre scaling functions.
Definition legendre.cc:85
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:1252
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:757
static Key< NDIM > simpt2key(const Vector< T, NDIM > &pt, Level n)
Definition funcdefaults.h:462
TreeState
Definition funcdefaults.h:59
@ nonstandard_after_apply
s and d coeffs, state after operator application
Definition funcdefaults.h:64
@ on_demand
no coeffs anywhere, but a functor providing if necessary
Definition funcdefaults.h:67
@ redundant_after_merge
s coeffs everywhere, must be summed up to yield the result
Definition funcdefaults.h:66
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:60
@ nonstandard
s and d coeffs in internal nodes
Definition funcdefaults.h:62
@ unknown
Definition funcdefaults.h:68
@ compressed
d coeffs in internal nodes, s and d coeffs at the root, empty leaves may be present
Definition funcdefaults.h:61
@ redundant
s coeffs everywhere
Definition funcdefaults.h:65
@ nonstandard_with_leaves
like nonstandard, with s coeffs at the leaves
Definition funcdefaults.h:63
static void user_to_sim(const Vector< double, NDIM > &xuser, Vector< double, NDIM > &xsim)
Convert user coords (cell[][]) to simulation coords ([0,1]^ndim)
Definition funcdefaults.h:453
void standard(World &world, std::vector< Function< T, NDIM > > &v, bool fence=true)
Generates standard form of a vector of functions.
Definition vmra.h:243
Tensor< double > tensorT
Definition distpm.cc:21
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions.
Definition vmra.h:149
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:162
int64_t Translation
Definition key.h:58
Tensor< TENSOR_RESULT_TYPE(T, Q)> & general_fast_transform(const Tensor< T > &t, const Tensor< Q > *c, Tensor< TENSOR_RESULT_TYPE(T, Q)> &result, Tensor< TENSOR_RESULT_TYPE(T, Q)> &workspace)
Definition tensor.h:2525
void plotdx(const Function< T, NDIM > &f, const char *filename, const Tensor< double > &cell=FunctionDefaults< NDIM >::get_cell(), const std::vector< long > &npt=std::vector< long >(NDIM, 201L), bool binary=true)
Writes an OpenDX format file with a cube/slice of points on a uniform grid.
Definition mraimpl.h:3598
Function< T, NDIM > mirror(const Function< T, NDIM > &f, const std::vector< long > &mirrormap, bool fence=true)
Generate a new function by mirroring within the dimensions .. optional fence.
Definition mra.h:2474
static void verify_tree(World &world, const std::vector< Function< T, NDIM > > &v)
Definition SCF.cc:74
static const Slice _(0,-1, 1)
void change_tensor_type(GenTensor< T > &t, const TensorArgs &targs)
change representation to targ.tt
Definition gentensor.h:284
int Level
Definition key.h:59
std::enable_if< std::is_base_of< ProjectorBase, projT >::value, OuterProjector< projT, projQ > >::type outer(const projT &p0, const projQ &p1)
Definition projector.h:457
TreeState get_tree_state(const Function< T, NDIM > &f)
get tree state of a function
Definition mra.h:2935
bool gauss_legendre(int n, double xlo, double xhi, double *x, double *w)
Definition legendre.cc:226
static double pop(std::vector< double > &v)
Definition SCF.cc:115
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:227
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition mraimpl.h:2175
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
static void dxprintvalue(FILE *f, const double t)
Definition mraimpl.h:3589
void refine(World &world, const std::vector< Function< T, NDIM > > &vf, bool fence=true)
refine the functions according to the autorefine criteria
Definition vmra.h:196
NDIM & f
Definition mra.h:2622
void error(const char *msg)
Definition world.cc:147
const Function< T, NDIM > & change_tree_state(const Function< T, NDIM > &f, const TreeState finalstate, bool fence=true)
change tree state of a function
Definition mra.h:2948
NDIM const Function< R, NDIM > & g
Definition mra.h:2622
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition timers.cc:48
static bool print_timings
Definition SCF.cc:106
constexpr Vector< T, sizeof...(Ts)+1 > vec(T t, Ts... ts)
Factory function for creating a madness::Vector.
Definition vector.h:750
Function< T, NDIM > multiply(const Function< T, NDIM > f, const Function< T, LDIM > g, const int particle, const bool fence=true)
multiply a high-dimensional function with a low-dimensional function
Definition mra.h:2575
void scale(World &world, std::vector< Function< T, NDIM > > &v, const std::vector< Q > &factors, bool fence=true)
Scales inplace a vector of functions by distinct values.
Definition vmra.h:873
static std::vector< double > ttt
Definition SCF.cc:107
Function< T, NDIM > project(const Function< T, NDIM > &other, int k=FunctionDefaults< NDIM >::get_k(), double thresh=FunctionDefaults< NDIM >::get_thresh(), bool fence=true)
Definition mra.h:2605
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
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:2187
static const int MAXK
The maximum wavelet order presently supported.
Definition funcdefaults.h:54
static bool enforce_bc(bool is_periodic, Level n, Translation &l)
Definition mraimpl.h:3332
bool isnan(const std::complex< T > &v)
Definition mraimpl.h:53
const double mu
Definition navstokes_cosines.cc:95
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
static const double m
Definition relops.cc:9
static const double L
Definition rk.cc:46
static const double thresh
Definition rk.cc:45
static const long k
Definition rk.cc:44
const double xi
Exponent for delta function approx.
Definition siam_example.cc:60
Definition test_ar.cc:204
Definition test_ccpairfunction.cc:22
add two functions f and g: result=alpha * f + beta * g
Definition funcimpl.h:3725
"put" this on g
Definition funcimpl.h:2738
change representation of nodes' coeffs to low rank, optional fence
Definition funcimpl.h:2771
check symmetry wrt particle exchange
Definition funcimpl.h:2444
compute the norm of the wavelet coefficients
Definition funcimpl.h:4622
Definition funcimpl.h:2798
Definition funcimpl.h:1557
mirror dimensions of this, write result on f
Definition funcimpl.h:2672
map this on f
Definition funcimpl.h:2592
mirror dimensions of this, write result on f
Definition funcimpl.h:2622
Definition funcimpl.h:5723
reduce the rank of the nodes, optional fence
Definition funcimpl.h:2418
Changes non-standard compressed form to standard compressed form.
Definition funcimpl.h:4845
remove all coefficients of internal nodes
Definition funcimpl.h:2364
remove all coefficients of leaf nodes
Definition funcimpl.h:2381
Definition funcimpl.h:4694
shallow-copy, pared-down version of FunctionNode, for special purpose only
Definition funcimpl.h:772
TensorArgs holds the arguments for creating a LowRankTensor.
Definition gentensor.h:134
double thresh
Definition gentensor.h:135
Definition mraimpl.h:3237
void operator()(const Key< NDIM > &key, Tensor< T > &t) const
Definition mraimpl.h:3238
void serialize(Archive &ar)
Definition mraimpl.h:3239
Definition mraimpl.h:3243
void operator()(const Key< NDIM > &key, Tensor< T > &t) const
Definition mraimpl.h:3244
void serialize(Archive &ar)
Definition mraimpl.h:3245
Definition mraimpl.h:3205
void operator()(const A &a, const B &b) const
Definition mraimpl.h:3206
void serialize(Archive &ar)
Definition mraimpl.h:3208
Definition mraimpl.h:3212
void operator()(const Key< NDIM > &key, FunctionNode< T, NDIM > &node) const
Definition mraimpl.h:3220
void serialize(Archive &ar)
Definition mraimpl.h:3223
T q
Definition mraimpl.h:3213
scaleinplace()
Definition mraimpl.h:3214
scaleinplace(T q)
Definition mraimpl.h:3216
void operator()(const Key< NDIM > &key, Tensor< T > &t) const
Definition mraimpl.h:3217
Definition mraimpl.h:3229
void serialize(Archive &ar)
Definition mraimpl.h:3233
void operator()(const Key< NDIM > &key, Tensor< T > &t) const
Definition mraimpl.h:3230
insert/replaces the coefficients into the function
Definition funcimpl.h:715
Definition lowrankfunction.h:336
int np
Definition tdse1d.cc:165
static const double s0
Definition tdse4.cc:83
AtomicInt sum
Definition test_atomicint.cc:46
int me
Definition test_binsorter.cc:10
double norm(const T i1)
Definition test_cloud.cc:85
int task(int i)
Definition test_runtime.cpp:4
void e()
Definition test_sig.cc:75
static double g1(const Vector< double, D > &r)
Definition test_state_archive_hdf5.cpp:34
static double g0(const Vector< double, D > &r)
Definition test_state_archive_hdf5.cpp:31
#define N
Definition testconv.cc:37
static const double alpha
Definition testcosine.cc:10
static const int truncate_mode
Definition testcosine.cc:14
double cell_volume()
Definition testgconv.cc:86
constexpr std::size_t NDIM
Definition testgconv.cc:54
double h(const coord_1d &r)
Definition testgconv.cc:175
std::size_t axis
Definition testpdiff.cc:59
double k0
Definition testperiodic.cc:66
#define TENSOR_RESULT_TYPE(L, R)
This macro simplifies access to TensorResultType.
Definition type_data.h:205
Defines and implements WorldObject.
Implements WorldContainer.
Defines and implements a concurrent hashmap.
#define PROFILE_FUNC
Definition worldprofile.h:209
#define PROFILE_MEMBER_FUNC(classname)
Definition worldprofile.h:210
#define PROFILE_BLOCK(name)
Definition worldprofile.h:208
int ProcessID
Used to clearly identify process number/rank.
Definition worldtypes.h:43
Key< D > keyT
Definition writecoeff2.cc:11
void test()
Definition y.cc:696