33#ifndef MADNESS_MRA_VMRA_H__INCLUDED
34#define MADNESS_MRA_VMRA_H__INCLUDED
133 template <
typename T, std::
size_t NDIM>
137 if (std::any_of(
v.begin(),
v.end(), [](
const Function<T,NDIM>&
f) {return not f.is_initialized();})) {
140 TreeState state=
v[0].get_impl()->get_tree_state();
141 for (
const auto&
f :
v) {
148 template <
typename T, std::
size_t NDIM>
161 template <
typename T, std::
size_t NDIM>
170 template <
typename T, std::
size_t NDIM>
176 template <
typename T, std::
size_t NDIM>
185 template <
typename T, std::
size_t NDIM>
195 template <
typename T, std::
size_t NDIM>
198 for (
const auto&
f :
vf)
f.refine(
false);
205 template <
typename T, std::
size_t NDIM>
211 std::vector<FunctionImpl<T,NDIM>*>
v_ptr;
214 for (
unsigned int i=0; i<
vf.size(); ++i) {
220 typename std::vector<FunctionImpl<T, NDIM>*>::iterator it;
224 std::vector< Tensor<T> >
c(
v_ptr.size());
226 if (fence)
v_ptr[0]->world.gop.fence();
232 template <
typename T, std::
size_t NDIM>
242 template <
typename T, std::
size_t NDIM>
255 template <
typename T, std::
size_t NDIM>
258 const bool fence=
true) {
260 if (
v.size()==0)
return v;
265 for (
const auto&
f :
v)
266 if (
f.is_initialized()) {
270 if (
not dummy.is_initialized())
return v;
315 template<
typename T, std::
size_t NDIM>
327 print(
"ensure_tree_state_respecting_fence failed");
328 throw std::runtime_error(
"ensure_tree_state_respecting_fence failed");
334 template <
typename T, std::
size_t NDIM>
346 vv.truncate(tol,
false);
355 template <
typename T, std::
size_t NDIM>
357 double tol=0.0,
bool fence=
true) {
358 if (
v.size()>0)
truncate(
v[0].world(),
v,tol,fence);
365 template <
typename T, std::
size_t NDIM>
367 double thresh=0.0,
bool fence=
true) {
368 if (
v.size()==0)
return v;
369 for (
auto& vv :
v) vv.reduce_rank(
thresh,
false);
370 if (fence)
v[0].world().gop.fence();
380 template <
typename T, std::
size_t NDIM>
387 for (
const auto&
D :
grad)
388 for (
const auto&
f :
v)
D->stage_halo(
f.get_impl().get(),
false);
395 template <
typename T, std::
size_t NDIM>
398 for (
const auto&
f :
v)
f.get_impl()->halo_clear();
402 template <
typename T, std::
size_t NDIM>
403 std::vector< Function<T,NDIM> >
410 std::vector< Function<T,NDIM> > df(
v.size());
411 for (
unsigned int i=0; i<
v.size(); ++i) {
412 df[i] =
D(
v[i],
false);
419 template <
typename T, std::
size_t NDIM>
420 std::vector< Function<T,NDIM> >
422 std::vector< Function<T,NDIM> > r(n);
423 for (
int i=0; i<n; ++i) {
429 print(
"zero_functions_tree_state: unknown tree state");
430 throw std::runtime_error(
"zero_functions_tree_state: unknown tree state");
440 template <
typename T, std::
size_t NDIM>
441 std::vector< Function<T,NDIM> >
447 template <
typename T, std::
size_t NDIM>
448 std::vector< Function<T,NDIM> >
454 template <
typename T, std::
size_t NDIM>
455 std::vector< Function<T,NDIM> >
464 template<
typename T, std::
size_t NDIM>
466 if (
vf_in.size()==0)
return std::vector<Function<T,NDIM>>();
475 for (
int i=0; i<s.dim(0); ++i)
Q(i,i) += 1.5;
482 for (
int i=0; i<
Q.dim(0); ++i)
483 for (
int j=0; j<i; ++j)
499 template <
typename T, std::
size_t NDIM>
504 if(
v.empty())
return v;
506 World& world =
v.front().world();
507 const size_t n =
v.
size();
512 lindep *= s(s.size() - 1);
516 for(
size_t i = 0; i < n; ++i) {
517 const auto s_i = s(i);
525 if (world.
rank() == 0)
526 print(
"WARNING: linear dependencies detected in ",
nlindep,
527 " functions, rank = ", rank);
533 for(
size_t i = 0; i < n; ++i){
534 for(
size_t j = 0; j < n; ++j){
535 U(i, j) = U(i, j) * s(j);
547 template <
typename T, std::
size_t NDIM>
550 if(
v.empty())
return v;
561 template <
typename T, std::
size_t NDIM>
566 if(
v.empty())
return v;
568 World& world =
v.front().world();
569 const size_t n =
v.
size();
574 lindep *= s(s.size() - 1);
578 for(
size_t i = 0; i < n; ++i) {
579 const auto s_i = s(i);
591 if (world.
rank() == 0)
592 print(
"Linear dependencies detected: removed ",
nlindep,
593 " functions, rank = ", rank);
599 for(
size_t i = 0; i < n; ++i){
600 for(
size_t j = 0; j < rank; ++j){
601 U(i, j) = U(i, j) * s(j);
611 template <
typename T, std::
size_t NDIM>
614 if(
v.empty())
return v;
624 template <
typename T, std::
size_t NDIM>
629 if (
v.empty())
return v;
637 World& world=
v.front().world();
645 template <
typename T, std::
size_t NDIM>
647 if(
v.empty())
return v;
649 World& world=
v.front().world();
661 template <
typename T, std::
size_t NDIM>
676 std::vector<Function<T,NDIM> >
pv(rank);
686 World& world=
v.front().world();
694 template <
typename T, std::
size_t NDIM>
704 template <
typename T, std::
size_t NDIM>
710 World& world=
v.front().world();
716 template <
typename T, std::
size_t NDIM>
718 std::vector<Function<T,NDIM> >
v=
lhs;
719 for (std::size_t i = 0; i <
rhs.size(); ++i)
v.push_back(
rhs[i]);
723 template <
typename T, std::
size_t NDIM>
725 std::vector<Function<T,NDIM> >result;
726 for(
const auto& x:vv) result=
append(result,x);
730 template<
typename T, std::
size_t NDIM>
732 std::vector<std::shared_ptr<FunctionImpl<T,NDIM>>> result;
733 for (
auto&
f :
v) result.push_back(
f.get_impl());
737 template<
typename T, std::
size_t NDIM>
740 for (std::size_t i=0; i<vimpl.size(); ++i)
v[i].
set_impl(vimpl[i]);
743 template<
typename T, std::
size_t NDIM>
745 std::vector<Function<T,NDIM>>
v(vimpl.size());
746 for (std::size_t i=0; i<vimpl.size(); ++i)
v[i].
set_impl(vimpl[i]);
755 template <
typename T,
typename R, std::
size_t NDIM>
771 for (
int i=0; i<
m; ++i) {
772 for (
int j=0; j<n; ++j) {
773 if (
c(j,i) !=
R(0.0))
vc[i].gaxpy(resultT(1.0),
v[j],resultT(
c(j,i)),
false);
784 template <
typename T,
typename R, std::
size_t NDIM>
800 vv.get_impl()->get_tree_state()==
reconstructed,
"trees have to be reconstructed in transform_reconstructed");
804 for (
int i=0; i<
m; ++i) {
806 for (
int j=0; j<n; ++j) {
807 if (
c(j,i) !=
R(0.0))
v[j].get_impl()->accumulate_trees(*(result[i].
get_impl()),resultT(
c(j,i)),
true);
815 for (
auto& r : result) r.get_impl()->finalize_sum();
823 template <
typename L,
typename R, std::
size_t NDIM>
826 const Tensor<R>&
c,
double tol,
bool fence=
true) {
838 template <
typename T,
typename R, std::
size_t NDIM>
854 c.copy_to_replicated(
tmp);
860 for (
int i=0; i<
m; ++i) {
861 for (
int j=0; j<n; ++j) {
862 if (
tmp(j,i) !=
R(0.0))
vc[i].gaxpy(1.0,
v[j],
tmp(j,i),
false);
872 template <
typename T,
typename Q, std::
size_t NDIM>
878 for (
unsigned int i=0; i<
v.size(); ++i)
v[i].
scale(
factors[i],
false);
883 template <
typename T,
typename Q, std::
size_t NDIM>
889 for (
unsigned int i=0; i<
v.size(); ++i)
v[i].
scale(factor,
false);
894 template <
typename T, std::
size_t NDIM>
898 std::vector<double>
norms(
v.size());
900 for (
unsigned int i=0; i<
v.size(); ++i)
norms[i] =
v[i].norm2sq_local();
907 template <
typename T, std::
size_t NDIM>
912 for (
unsigned int i = 0; i <
v.size(); ++i)
norms[i] =
v[i].norm2sq_local();
920 template <
typename T, std::
size_t NDIM>
923 if (
v.size()==0)
return 0.0;
925 std::vector<double>
norms(
v.size());
926 for (
unsigned int i=0; i<
v.size(); ++i)
norms[i] =
v[i].norm2sq_local();
928 for (
unsigned int i=1; i<
v.size(); ++i)
norms[0] +=
norms[i];
976 template <
typename T, std::
size_t NDIM>
993 std::vector< Function<T,NDIM> >
ivec(
f.begin()+ilo,
f.begin()+ihi);
996 std::vector< Function<T,NDIM> >
jvec(
g.begin()+jlo,
g.begin()+jhi);
999 A.copy_from_replicated_patch(ilo, ihi - 1, jlo, jhi - 1,
P);
1010 template <
typename T,
typename R, std::
size_t NDIM>
1017 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1018 return v.front().get_impl()->get_tensor_type();
1024 std::vector<const FunctionImpl<T,NDIM>*> left(
f.size());
1025 std::vector<const FunctionImpl<R,NDIM>*> right(
g.size());
1026 for (
unsigned int i=0; i<
f.size(); i++) left[i] =
f[i].
get_impl().get();
1027 for (
unsigned int i=0; i<
g.size(); i++) right[i]=
g[i].
get_impl().get();
1042 template <
typename T,
typename R, std::
size_t NDIM>
1048 long n=
f.size(),
m=
g.size();
1054 if ((
void*)(&
f) != (
void*)(&
g))
compress(world,
g);
1056 for (
long i=0; i<n; ++i) {
1059 for (
long j=0; j<
jtop; ++j) {
1060 r(i,j) =
f[i].inner_local(
g[j]);
1061 if (
sym) r(j,i) =
conj(r(i,j));
1086 template <
typename T,
typename R, std::
size_t NDIM>
1091 long n=
f.size(),
m=
g.size();
1096 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1097 return v.front().get_impl()->get_tensor_type();
1103 for (
long i=0; i<n; ++i) r(i) =
f[i].inner_local(
g[i]);
1115 template <
typename T,
typename R, std::
size_t NDIM>
1123 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1124 return v.front().get_impl()->get_tensor_type();
1127 f.change_tree_state(operating_state,
false);
1131 for (
long i=0; i<n; ++i) {
1132 r(i) =
f.inner_local(
g[i]);
1143 template <
typename T,
typename R, std::
size_t NDIM>
1147 if(
f.empty())
return 0.0;
1148 else return inner(
f[0].world(),
f,
g).sum();
1153 template <
typename T,
typename R, std::
size_t NDIM>
1161 a.make_redundant(
false);
1185 template <
typename T,
typename R, std::
size_t NDIM>
1196 a.make_redundant(
false);
1198 }
else if (!
v.empty()) {
1200 "mul_sparse: left input must be redundant when do_make_redundant=false");
1202 "mul_sparse: right inputs must be redundant when do_make_redundant=false");
1221 template <
typename T,
typename R, std::
size_t NDIM>
1228 bool symm =
false) {
1235 std::vector<std::vector<Function<R,NDIM> > >result(
f.size());
1236 std::vector<Function<R,NDIM>>
g_i;
1237 for (
int64_t i=
f.size()-1; i>=0; --i) {
1239 result[i]=
vmulXX(
f[i],
g, tol,
false);
1251 template <
typename T, std::
size_t NDIM>
1257 for (
unsigned int i=0; i<
v.size(); ++i) {
1258 v[i].norm_tree(
false);
1266 template <
typename T,
typename R, std::
size_t NDIM>
1283 for (
unsigned int i=0; i<
a.size(); ++i) {
1284 q[i] =
mul(
a[i],
b[i],
false,
false, tol);
1297 template<
typename T, std::
size_t NDIM, std::
size_t LDIM>
1302 std::vector<Function<T,NDIM> > result(
g.size());
1303 for (
auto& r : result) r.set_impl(
f,
false);
1311 for (std::size_t i=0; i<result.size(); ++i) {
1318 for (
auto&
ig :
g)
ig.get_impl()->undo_redundant(
false);
1323 template<
typename T, std::
size_t NDIM, std::
size_t LDIM>
1325 const std::tuple<int,int,int>
v) {
1331 template <
typename T, std::
size_t NDIM>
1332 std::vector< Function<T,NDIM> >
1347 template <
typename T, std::
size_t NDIM>
1348 std::vector< Function<typename Tensor<T>::scalar_type,
NDIM> >
1354 std::vector<Function<scalartype,NDIM> > result(
v.size());
1355 for (
size_t i=0; i<
v.size(); ++i) result[i]=
abs_square(
v[i],
false);
1362 template <
typename T, std::
size_t NDIM>
1364 for (
unsigned int j=0; j<
v.size(); ++j) {
1365 v[j].set_thresh(
thresh,
false);
1371 template <
typename T, std::
size_t NDIM>
1372 std::vector< Function<T,NDIM> >
1377 std::vector< Function<T,NDIM> > r =
copy(world,
v);
1378 for (
unsigned int i=0; i<
v.size(); ++i) {
1386 template <
typename T,
typename R, std::
size_t NDIM>
1390 std::vector< Function<R,NDIM> > r(
v.size());
1391 for (
unsigned int i=0; i<
v.size(); ++i) {
1400 template <
typename T, std::
size_t NDIM>
1401 std::vector< Function<T,NDIM> >
1406 std::vector< Function<T,NDIM> > r(
v.size());
1407 for (
unsigned int i=0; i<
v.size(); ++i) {
1408 r[i] =
copy(
v[i],
false);
1416 template <
typename T, std::
size_t NDIM>
1417 std::vector< Function<T,NDIM> >
1420 std::vector< Function<T,NDIM> > r(
v.size());
1421 if (
v.size()>0) r=
copy(
v.front().world(),
v,fence);
1426 template <
typename T, std::
size_t NDIM>
1427 std::vector< Function<T,NDIM> >
1430 const unsigned int n,
1433 std::vector< Function<T,NDIM> > r(n);
1434 for (
unsigned int i=0; i<n; ++i) {
1435 r[i] =
copy(
v,
false);
1450 template <
typename T, std::
size_t NDIM>
1454 bool fence =
true) {
1456 std::vector<Function<T, NDIM>> r(
v.size());
1457 for (
unsigned int i = 0; i <
v.size(); ++i) {
1458 r[i] =
copy(
v[i], pmap,
false);
1465 template <
typename T,
typename R, std::
size_t NDIM>
1477 for (
unsigned int i=0; i<
a.size(); ++i) {
1478 r[i] =
add(
a[i],
b[i],
false);
1485 template <
typename T,
typename R, std::
size_t NDIM>
1496 for (
unsigned int i=0; i<
b.size(); ++i) {
1497 r[i] =
add(
a,
b[i],
false);
1502 template <
typename T,
typename R, std::
size_t NDIM>
1508 return add(world,
a,
b, fence);
1512 template <
typename T,
typename R, std::
size_t NDIM>
1524 for (
unsigned int i=0; i<
a.size(); ++i) {
1525 r[i] =
sub(
a[i],
b[i],
false);
1532 template <
typename T, std::
size_t NDIM>
1539 for (
unsigned int i=0; i<
f.size(); ++i) r.
gaxpy(1.0,
f[i],1.0,
false);
1544 template <
typename T, std::
size_t NDIM>
1561 std::vector<Function<T, NDIM>>
ivec(
f.begin() + ilo,
f.begin() + ihi);
1564 std::vector<Function<T, NDIM>>
jvec(
g.begin() + jlo,
g.begin() + jhi);
1567 A.copy_from_replicated_patch(ilo, ihi - 1, jlo, jhi - 1,
P);
1578 template <
typename T,
typename R, std::
size_t NDIM>
1589 std::vector<const FunctionImpl<T, NDIM>*> left(
f.size());
1590 std::vector<const FunctionImpl<R, NDIM>*> right(
g.size());
1591 for (
unsigned int i = 0; i <
f.size(); i++) left[i] =
f[i].
get_impl().get();
1592 for (
unsigned int i = 0; i <
g.size(); i++) right[i] =
g[i].
get_impl().get();
1607 template <
typename T,
typename R, std::
size_t NDIM>
1613 long n=
f.size(),
m=
g.size();
1619 if ((
void*)(&
f) != (
void*)(&
g))
compress(world,
g);
1621 for (
long i=0; i<n; ++i) {
1624 for (
long j=0; j<
jtop; ++j) {
1626 r(j,i) =
f[i].dot_local(
g[j]);
1628 r(i,j) =
conj(r(j,i));
1630 r(i,j) =
f[i].dot_local(
g[j]);
1643 template <
typename T,
typename R, std::
size_t NDIM>
1658 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1668 if (
a.size()==0)
return std::vector<Function<resultT,NDIM> >();
1670 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1671 return v.front().get_impl()->get_tensor_type();
1675 World& world=
a[0].world();
1676 std::vector<Function<resultT,NDIM> > result(
a.size());
1683 print(
"could not respect fence in gaxpy");
1700 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1709 if (
a.size()==0)
return std::vector<Function<resultT,NDIM> >();
1711 World& world=
a[0].world();
1717 print(
"could not respect fence in gaxpy_oop");
1721 std::vector<Function<resultT,NDIM> > result(
a.size());
1722 for (
unsigned int i=0; i<
a.size(); ++i) {
1725 if (fence) world.gop.fence();
1731 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1733 if (
a.size() == 0)
return;
1734 World& world=
a.front().world();
1739 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1748 if (
a.empty())
return;
1750 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1751 return v.front().get_impl()->get_tensor_type();
1764 print(
"could not respect fence in gaxpy");
1778 print(
"could not respect fence in gaxpy for a");
1786 print(
"could not respect fence in gaxpy for b");
1793 for (
unsigned int i=0; i<
a.size(); ++i) {
1797 for (
unsigned int i=0; i<
a.size(); ++i)
a[i].
get_impl()->finalize_sum();
1805 template <
typename opT,
typename R, std::
size_t NDIM>
1808 const std::vector< std::shared_ptr<opT> >&
op,
1814 std::vector< Function<R,NDIM> >&
ncf = *
const_cast< std::vector< Function<R,NDIM>
>* >(&
f);
1820 for (
unsigned int i=0; i<
f.size(); ++i) {
1836 template <
typename T,
typename R, std::
size_t NDIM, std::
size_t KDIM>
1845 template <
typename T,
typename R, std::
size_t NDIM, std::
size_t KDIM>
1852 std::vector< Function<R,NDIM> >&
ncf = *
const_cast< std::vector< Function<R,NDIM>
>* >(&
f);
1862 for (
unsigned int i=0; i<
f.size(); ++i) {
1869 if (
op.destructive()) {
1870 for (
auto&
ff :
ncf)
ff.clear(
false);
1878 for (
auto& r : result) r.get_impl()->finalize_apply();
1882 for (
auto& r : result) r.get_impl()->print_timer();
1891 template <
typename T, std::
size_t NDIM>
1894 std::vector<double>
nn =
norm2s(world,
v);
1895 for (
unsigned int i=0; i<
v.size(); ++i)
v[i].
scale(1.0/
nn[i],
false);
1899 template <
typename T, std::
size_t NDIM>
1902 if(world.
rank()==0) std::cout <<
"print_size: " << msg <<
" is empty" << std::endl;
1903 }
else if(
v.size()==1){
1904 v.front().print_size(msg);
1914 template <
typename T, std::
size_t NDIM>
1918 if (x.is_initialized()) size+=x.size_local();
1920 const double d=
sizeof(T);
1921 const double fac=1024*1024*1024;
1926 template <
typename T, std::
size_t NDIM>
1933 template <
typename T, std::
size_t NDIM>
1936 if (
v.empty())
return 0.0;
1938 const double d=
sizeof(T);
1939 const double fac=1024*1024*1024;
1942 for(
unsigned int i=0;i<
v.size();i++){
1943 if (
v[i].is_initialized()) size+=
v[i].size();
1951 template <
typename T, std::
size_t NDIM>
1953 const double d=
sizeof(T);
1954 const double fac=1024*1024*1024;
1955 double size=
f.size();
1964 template <
typename T,
typename opT, std::
size_t NDIM>
1967 const bool fence=
true) {
1974 for (
auto& out :
vout) out.set_impl(
vin[0],
false);
1985 template <
typename T, std::
size_t NDIM>
1993 template <
typename T, std::
size_t NDIM>
2001 template <
typename T, std::
size_t NDIM>
2009 template <
typename T, std::
size_t NDIM>
2017 template <
typename T, std::
size_t NDIM>
2025 template <
typename T, std::
size_t NDIM>
2033 template <
typename T,
typename R, std::
size_t NDIM>
2037 std::vector<Function<T,NDIM> >
tmp=
copy(
rhs[0].world(),
rhs);
2044 template <
typename T,
typename R, std::
size_t NDIM>
2056 template <
typename T,
typename R, std::
size_t NDIM>
2059 if (
v.size()>0)
return mul(
v[0].world(),
a,
v,
true);
2065 template <
typename T,
typename R, std::
size_t NDIM>
2068 if (
v.size()>0)
return mul(
v[0].world(),
a,
v,
true);
2073 template <
typename T, std::
size_t NDIM>
2080 template <
typename T, std::
size_t NDIM>
2089 template <
typename T, std::
size_t NDIM>
2090 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> >
2092 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> > result(
v.size());
2093 for (std::size_t i=0; i<
v.size(); ++i) result[i]=
real(
v[i],
false);
2094 if (fence
and result.size()>0) result[0].world().gop.fence();
2099 template <
typename T, std::
size_t NDIM>
2100 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> >
2102 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> > result(
v.size());
2103 for (std::size_t i=0; i<
v.size(); ++i) result[i]=
imag(
v[i],
false);
2104 if (fence
and result.size()>0) result[0].world().gop.fence();
2115 template <
typename T, std::
size_t NDIM>
2117 bool refine=
false,
bool fence=
true) {
2123 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2126 std::vector<Function<T,NDIM> > result(
NDIM);
2127 for (
size_t i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2133 template <
typename T, std::
size_t NDIM>
2135 bool refine=
false,
bool fence=
true) {
2141 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2145 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_ble1();
2147 std::vector<Function<T,NDIM> > result(
NDIM);
2148 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2154 template <
typename T, std::
size_t NDIM>
2156 bool refine=
false,
bool fence=
true) {
2162 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2166 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_ble2();
2168 std::vector<Function<T,NDIM> > result(
NDIM);
2169 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2175 template <
typename T, std::
size_t NDIM>
2177 bool refine=
false,
bool fence=
true) {
2183 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2187 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_bspline1();
2189 std::vector<Function<T,NDIM> > result(
NDIM);
2190 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2196 template <
typename T, std::
size_t NDIM>
2198 bool refine=
false,
bool fence=
true) {
2204 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2208 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_bspline2();
2210 std::vector<Function<T,NDIM> > result(
NDIM);
2211 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2217 template <
typename T, std::
size_t NDIM>
2219 bool refine=
false,
bool fence=
true) {
2225 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2229 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_bspline3();
2231 std::vector<Function<T,NDIM> > result(
NDIM);
2232 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2247 template <
typename T, std::
size_t NDIM>
2249 bool do_refine=
false,
bool fence=
true) {
2252 World& world=
v[0].world();
2256 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2259 std::vector<Function<T,NDIM> > result(
NDIM);
2260 for (
size_t i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
v[i],
false);
2262 return sum(world,result,fence);
2273 template <
typename T, std::
size_t NDIM>
2275 bool do_refine=
false,
bool fence=
true) {
2278 World& world=
v[0].world();
2282 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2297 d[0].gaxpy(1.0,
dd[0],-1.0,
false);
2298 d[1].gaxpy(1.0,
dd[1],-1.0,
false);
2299 d[2].gaxpy(1.0,
dd[2],-1.0,
false);
2314 template <
typename T,
typename R, std::
size_t NDIM>
2317 bool do_refine=
false,
bool fence=
true) {
2321 World& world=
f[0].world();
2327 d[0]=
mul(
f[1],
g[2],
false);
2328 d[1]=
mul(
f[2],
g[0],
false);
2329 d[2]=
mul(
f[0],
g[1],
false);
2339 d[0].gaxpy(1.0,
dd[0],-1.0,
false);
2340 d[1].gaxpy(1.0,
dd[1],-1.0,
false);
2341 d[2].gaxpy(1.0,
dd[2],-1.0,
false);
2348 template<
typename T, std::
size_t NDIM>
2365 template<
typename T,
size_t NDIM>
2367 const std::string
name) {
2368 if (world.
rank()==0)
print(
"loading vector of functions",
name);
2370 std::size_t
fsize=0;
2373 for (std::size_t i=0; i<
fsize; ++i) ar &
f[i];
2377 template<
typename T,
size_t NDIM>
2380 World& world=
f.front().world();
2381 if (world.
rank()==0)
print(
"saving vector of functions",
name);
2383 std::size_t
fsize=
f.size();
2385 for (std::size_t i=0; i<
fsize; ++i) ar &
f[i];
double q(double t)
Definition DKops.h:18
Definition test_ar.cc:118
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
Implements derivatives operators with variety of boundary conditions on simulation domain.
Definition derivative.h:329
Definition distributed_matrix.h:68
Manages data associated with a row/column/block distributed array.
Definition distributed_matrix.h:388
static void redistribute(World &world, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &newpmap)
Sets the default process map and redistributes all functions using the old map.
Definition funcdefaults.h:442
static TensorType get_tensor_type()
Returns the default tensor type.
Definition funcdefaults.h:323
FunctionFactory implements the named-parameter idiom for Function.
Definition function_factory.h:86
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:968
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:6214
void undo_redundant(const bool fence)
convert this from redundant to standard reconstructed form
Definition mraimpl.h:1559
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
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
static Tensor< TENSOR_RESULT_TYPE(T, R)> dot_local(const std::vector< const FunctionImpl< T, NDIM > * > &left, const std::vector< const FunctionImpl< R, NDIM > * > &right, bool sym)
Definition funcimpl.h:6266
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition funcimpl.h:136
coeffT & coeff()
Returns a non-const reference to the tensor containing the coeffs.
Definition funcimpl.h:237
A multiresolution adaptive numerical function.
Definition mra.h:144
bool compressed
Definition mra.h:1267
Function< T, NDIM > & gaxpy(const T &alpha, const Function< Q, NDIM > &other, const R &beta, bool fence=true)
Inplace, general bi-linear operation in wavelet basis. No communication except for optional fence.
Definition mra.h:1124
void set_impl(const std::shared_ptr< FunctionImpl< T, NDIM > > &impl)
Replace current FunctionImpl with provided new one.
Definition mra.h:731
long size() const
Definition lowranktensor.h:488
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
std::shared_ptr< WorldDCPmapInterface< keyT > > load_balance(double fac=1.0, bool printstuff=false)
Actually does the partitioning of the tree.
Definition lbdeux.h:390
void add_tree(const Function< T, NDIM > &f, const costT &costfn, bool fence=false)
Accumulates cost from a function.
Definition lbdeux.h:294
Convolutions in separated form (including Gaussian)
Definition operator.h:139
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
A tensor is a multidimensional array.
Definition tensor.h:318
TensorTypeData< T >::scalar_type scalar_type
C++ typename of the real type associated with a complex type.
Definition tensor.h:410
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1841
A simple, fixed dimension vector.
Definition vector.h:64
Interface to be provided by any process map.
Definition worlddc.h:122
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:176
void sum(T *buf, size_t nelem)
Inplace global sum while still processing AM & tasks.
Definition worldgop.h:890
void fence()
Returns after all local tasks have completed.
Definition world_task_queue.h:1384
A parallel world class.
Definition world.h:134
WorldTaskQueue & taskq
Task queue.
Definition world.h:215
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:354
WorldGopInterface & gop
Global operations.
Definition world.h:216
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition parallel_archive.h:321
int integer
Definition crayio.c:25
static const double R
Definition csqrt.cc:46
Declaration and initialization of tree traversal functions and generic derivative.
Tensor< T > conj_transpose(const Tensor< T > &t)
Returns a new deep copy of the complex conjugate transpose of the input tensor.
Definition tensor.h:2044
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
#define rot(x, k)
Definition lookup3.c:72
#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_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
Main include file for MADNESS and defines Function interface.
static const bool VERIFY_TREE
Definition mra.h:57
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
void save_function(const std::vector< Function< T, NDIM > > &f, const std::string name)
save a vector of functions
Definition vmra.h:2378
bool ensure_tree_state_respecting_fence(const std::vector< Function< T, NDIM > > &v, const TreeState state, bool fence)
ensure v has the requested tree state, change the tree state of v if necessary and no fence is given
Definition vmra.h:316
void rr_cholesky(Tensor< T > &A, typename Tensor< T >::scalar_type tol, Tensor< integer > &piv, int &rank)
Compute the rank-revealing Cholesky factorization.
Definition lapack.cc:1203
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
std::vector< Function< T, NDIM > > orthonormalize_rrcd(const std::vector< Function< T, NDIM > > &v, Tensor< T > &ovlp, const double tol, Tensor< integer > &piv, int &rank)
Definition vmra.h:662
Function< double, NDIM > abssq(const Function< double_complex, NDIM > &z, bool fence=true)
Returns a new function that is the square of the absolute value of the input.
Definition mra.h:2919
Function< TENSOR_RESULT_TYPE(L, R), NDIM > gaxpy_oop(TENSOR_RESULT_TYPE(L, R) alpha, const Function< L, NDIM > &left, TENSOR_RESULT_TYPE(L, R) beta, const Function< R, NDIM > &right, bool fence=true)
Returns new function alpha*left + beta*right optional fence and no automatic compression.
Definition mra.h:2101
Function< typename TensorTypeData< Q >::scalar_type, NDIM > abs_square(const Function< Q, NDIM > &func)
Definition complexfun.h:121
Function< T, NDIM > square(const Function< T, NDIM > &f, bool fence=true)
Create a new function that is the square of f - global comm only if not reconstructed.
Definition mra.h:2887
Function< TENSOR_RESULT_TYPE(L, R), NDIM > sub(const Function< L, NDIM > &left, const Function< R, NDIM > &right, bool fence=true)
Same as operator- but with optional fence and no automatic compression.
Definition mra.h:2156
std::vector< Function< T, NDIM > > reduce_rank(std::vector< Function< T, NDIM > > v, double thresh=0.0, bool fence=true)
reduces the tensor rank of the coefficient tensor (if applicable)
Definition vmra.h:366
Tensor< double > norm2s_T(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norms of a vector of functions.
Definition vmra.h:908
std::vector< double > norm2s(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norms of a vector of functions.
Definition vmra.h:895
std::vector< Function< T, NDIM > > grad_bspline_one(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2176
void set_impl(std::vector< Function< T, NDIM > > &v, const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > vimpl)
Definition vmra.h:738
Function< Q, NDIM > convert(const Function< T, NDIM > &f, bool fence=true)
Type conversion implies a deep copy. No communication except for optional fence.
Definition mra.h:2234
Function< TENSOR_RESULT_TYPE(Q, T), NDIM > mul(const Q alpha, const Function< T, NDIM > &f, bool fence=true)
Returns new function equal to alpha*f(x) with optional fence.
Definition mra.h:1884
std::vector< Function< T, NDIM > > orthonormalize_symmetric(const std::vector< Function< T, NDIM > > &v, const Tensor< T > &ovlp, double lindep=1e-12)
symmetric orthonormalization (see e.g. Szabo/Ostlund)
Definition vmra.h:500
std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > get_impl(const std::vector< Function< T, NDIM > > &v)
Definition vmra.h:731
Function< T, NDIM > div(const std::vector< Function< T, NDIM > > &v, bool do_refine=false, bool fence=true)
shorthand div operator
Definition vmra.h:2248
std::vector< Function< T, NDIM > > orthonormalize_cd(const std::vector< Function< T, NDIM > > &v, Tensor< T > &ovlp)
Definition vmra.h:625
std::vector< Function< T, NDIM > > copy_n(World &world, const Function< T, NDIM > &v, const unsigned int n, bool fence=true)
Returns a vector of n deep copies of a function.
Definition vmra.h:1428
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
tensorT Q2(const tensorT &s)
Given overlap matrix, return rotation with 2nd order error to orthonormalize the vectors.
Definition SCF.cc:138
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
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > cross(const std::vector< Function< T, NDIM > > &f, const std::vector< Function< R, NDIM > > &g, bool do_refine=false, bool fence=true)
shorthand cross operator
Definition vmra.h:2315
TreeState
Definition funcdefaults.h:59
@ nonstandard_after_apply
s and d coeffs, state after operator application
Definition funcdefaults.h:64
@ 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
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:2248
void cholesky(Tensor< T > &A)
Compute the Cholesky factorization.
Definition lapack.cc:1174
std::vector< std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > > matrix_mul_sparse(World &world, const std::vector< Function< R, NDIM > > &f, const std::vector< Function< R, NDIM > > &g, double tol, bool fence=true, bool symm=false)
Outer product of a vector of functions with a vector of functions using sparsity.
Definition vmra.h:1223
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
void truncate(World &world, std::vector< Function< T, NDIM > > &v, double tol=0.0, bool fence=true)
Truncates a vector of functions.
Definition vmra.h:335
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions.
Definition vmra.h:149
Function< TENSOR_RESULT_TYPE(T, R), NDIM > dot(World &world, const std::vector< Function< T, NDIM > > &a, const std::vector< Function< R, NDIM > > &b, bool fence=true, bool do_make_redundant=true, double tol=0.0)
Multiplies and sums two vectors of functions r = \sum_i a[i] * b[i].
Definition vmra.h:1645
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:162
std::vector< Function< T, NDIM > > impl2function(const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > vimpl)
Definition vmra.h:744
std::vector< Function< T, NDIM > > grad_bpsline_two(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2197
void set_thresh(World &world, std::vector< Function< T, NDIM > > &v, double thresh, bool fence=true)
Sets the threshold in a vector of functions.
Definition vmra.h:1363
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition vmra.h:921
std::vector< Function< T, NDIM > > flatten(const std::vector< std::vector< Function< T, NDIM > > > &vv)
Definition vmra.h:724
std::vector< CCPairFunction< T, NDIM > > operator*(const double fac, const std::vector< CCPairFunction< T, NDIM > > &arg)
Definition ccpairfunction.h:1089
static void verify_tree(World &world, const std::vector< Function< T, NDIM > > &v)
Definition SCF.cc:75
std::vector< Function< T, NDIM > > multi_to_multi_op_values(const opT &op, const std::vector< Function< T, NDIM > > &vin, const bool fence=true)
apply op on the input vector yielding an output vector of functions
Definition vmra.h:1965
static const Slice _(0,-1, 1)
Tensor< T > inverse(const Tensor< T > &a_in)
invert general square matrix A
Definition lapack.cc:832
void load_balance(const real_function_6d &f, const bool leaf)
do some load-balancing
Definition madness/chem/mp2.cc:70
TreeState get_tree_state(const Function< T, NDIM > &f)
get tree state of a function
Definition mra.h:2935
std::vector< CCPairFunction< T, NDIM > > operator-(const std::vector< CCPairFunction< T, NDIM > > c1, const std::vector< CCPairFunction< T, NDIM > > &c2)
Definition ccpairfunction.h:1060
std::vector< Function< T, NDIM > > partial_mul(const Function< T, NDIM > f, const std::vector< Function< T, LDIM > > g, const int particle)
multiply a high-dimensional function with a low-dimensional function
Definition vmra.h:1298
Function< T, NDIM > gaxpy_oop_reconstructed(const double alpha, const Function< T, NDIM > &left, const double beta, const Function< T, NDIM > &right, const bool fence=true)
Returns new function alpha*left + beta*right optional fence, having both addends reconstructed.
Definition mra.h:2119
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform_reconstructed(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:786
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
std::vector< Function< T, NDIM > > append(const std::vector< Function< T, NDIM > > &lhs, const std::vector< Function< T, NDIM > > &rhs)
combine two vectors
Definition vmra.h:717
@ TT_2D
Definition gentensor.h:120
@ TT_FULL
Definition gentensor.h:120
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
void print_size(World &world, const std::vector< Function< T, NDIM > > &v, const std::string &msg="vectorfunction")
Definition vmra.h:1900
NDIM & f
Definition mra.h:2622
Function< TENSOR_RESULT_TYPE(L, R), NDIM > add(const Function< L, NDIM > &left, const Function< R, NDIM > &right, bool fence=true)
Same as operator+ but with optional fence and no automatic compression.
Definition mra.h:2111
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
std::vector< CCPairFunction< T, NDIM > > & operator-=(std::vector< CCPairFunction< T, NDIM > > &rhs, const std::vector< CCPairFunction< T, NDIM > > &lhs)
Definition ccpairfunction.h:1082
std::vector< Function< T, NDIM > > orthonormalize(const std::vector< Function< T, NDIM > > &vf_in)
orthonormalize the vectors
Definition vmra.h:465
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
std::vector< Function< T, NDIM > > grad_ble_one(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2134
Function< TENSOR_RESULT_TYPE(typename opT::opT, R), NDIM > apply_only(const opT &op, const Function< R, NDIM > &f, bool fence=true)
Apply operator ONLY in non-standard form - required other steps missing !!
Definition mra.h:2322
std::vector< Function< T, NDIM > > grad_bspline_three(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2218
std::vector< Function< T, NDIM > > zero_functions_compressed(World &world, int n, bool fence=true)
Generates a vector of zero functions (compressed)
Definition vmra.h:449
double imag(double x)
Definition complexfun.h:56
void load_function(World &world, std::vector< Function< T, NDIM > > &f, const std::string name)
load a vector of functions
Definition vmra.h:2366
std::vector< Function< TENSOR_RESULT_TYPE(L, R), D > > vmulXX(const Function< L, D > &left, const std::vector< Function< R, D > > &vright, double tol, bool fence=true)
Use the vmra/mul(...) interface instead.
Definition mra.h:1991
void refine_to_common_level(World &world, std::vector< Function< T, NDIM > > &vf, bool fence=true)
refine all functions to a common (finest) level
Definition vmra.h:206
std::vector< Function< T, NDIM > > grad_ble_two(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2155
static bool print_timings
Definition SCF.cc:107
CCPairFunction< T, NDIM > apply(const SeparatedConvolution< T, NDIM/2 > &op, const CCPairFunction< T, NDIM > &arg)
apply the operator to the argument
Definition ccpairfunction.h:896
void normalize(World &world, std::vector< Function< T, NDIM > > &v, bool fence=true)
Normalizes a vector of functions — v[i] = v[i].scale(1.0/v[i].norm2())
Definition vmra.h:1892
void stage_halo(World &world, const std::vector< std::shared_ptr< Derivative< T, NDIM > > > &grad, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Pre-stages the neighbor coefficients that differentiating v with each of grad will need.
Definition vmra.h:381
std::vector< Function< T, NDIM > > zero_functions(World &world, int n, bool fence=true)
Generates a vector of zero functions (reconstructed)
Definition vmra.h:442
std::vector< CCPairFunction< T, NDIM > > operator+(const std::vector< CCPairFunction< T, NDIM > > c1, const std::vector< CCPairFunction< T, NDIM > > &c2)
Definition ccpairfunction.h:1052
Function< TENSOR_RESULT_TYPE(L, R), NDIM > mul_sparse(const Function< L, NDIM > &left, const Function< R, NDIM > &right, double tol, bool fence=true, bool do_make_redundant=true)
Sparse multiplication; the scalar interface redirects to the vector one in vmra.h.
Definition mra.h:1929
std::vector< Function< T, NDIM > > grad(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
shorthand gradient operator
Definition vmra.h:2116
Function< T, CCPairFunction< T, NDIM >::LDIM > inner(const CCPairFunction< T, NDIM > &c, const Function< T, CCPairFunction< T, NDIM >::LDIM > &f, const std::tuple< int, int, int > v1, const std::tuple< int, int, int > v2)
Definition ccpairfunction.h:993
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
std::vector< Function< T, NDIM > > zero_functions_auto_tree_state(World &world, int n, bool fence=true)
Generates a vector of zero functions, either compressed or reconstructed, depending on tensor type.
Definition vmra.h:456
DistributedMatrix< T > matrix_dot(const DistributedMatrixDistribution &d, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< T, NDIM > > &g, bool sym=false)
Definition vmra.h:1545
std::vector< Function< T, NDIM > > zero_functions_tree_state(World &world, int n, const TreeState state, bool fence=true)
Generates a vector of zero functions with a given tree state.
Definition vmra.h:421
double real(double x)
Definition complexfun.h:52
std::vector< CCPairFunction< T, NDIM > > & operator+=(std::vector< CCPairFunction< T, NDIM > > &lhs, const CCPairFunction< T, NDIM > &rhs)
Definition ccpairfunction.h:1068
@ same
same atoms at the same places
std::vector< Function< T, NDIM > > orthonormalize_canonical(const std::vector< Function< T, NDIM > > &v, const Tensor< T > &ovlp, double lindep=1e-12)
Definition vmra.h:562
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
Tensor< TENSOR_RESULT_TYPE(T, R) > matrix_dot_old(World &world, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< R, NDIM > > &g, bool sym=false)
Computes the matrix dot product of two function vectors - q(i,j) = dot(f[i],g[j])
Definition vmra.h:1608
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
void clear_halo(const std::vector< Function< T, NDIM > > &v)
Discards the neighbor halos staged on v.
Definition vmra.h:396
void matrix_inner(DistributedMatrix< T > &A, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< T, NDIM > > &g, bool sym=false)
Definition distpm.cc:46
double get_size(World &world, const std::vector< Function< T, NDIM > > &v)
Definition vmra.h:1934
double get_size_local(World &world, const std::vector< Function< T, NDIM > > &v)
return the size of a vector of functions for each rank
Definition vmra.h:1915
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
void syev(const Tensor< T > &A, Tensor< T > &V, Tensor< typename Tensor< T >::scalar_type > &e)
Real-symmetric or complex-Hermitian eigenproblem.
Definition lapack.cc:969
Tensor< TENSOR_RESULT_TYPE(T, R) > matrix_inner_old(World &world, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< R, NDIM > > &g, bool sym=false)
Computes the matrix inner product of two function vectors - q(i,j) = inner(f[i],g[j])
Definition vmra.h:1043
void make_nonstandard(World &world, std::vector< Function< T, NDIM > > &v, bool fence=true)
Generates non-standard form of a vector of functions.
Definition vmra.h:233
void gaxpy(const double a, ScalarResult< T > &left, const double b, const T &right, const bool fence=true)
the result type of a macrotask must implement gaxpy
Definition macrotaskq.h:244
int distance(const madness::Hash_private::HashIterator< hashT > &it, const madness::Hash_private::HashIterator< hashT > &jt)
Definition worldhashmap.h:616
static long abs(long a)
Definition tensor.h:219
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
double Q(double a)
Definition relops.cc:20
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
Definition test_ar.cc:204
double operator()(const Key< 6 > &key, const FunctionNode< double, 6 > &node) const
Definition mp2.h:70
Definition lowrankfunction.h:336
Definition dirac-hatom.cc:112
std::string ok(const bool b)
Definition test6.cc:43
AtomicInt sum
Definition test_atomicint.cc:46
int P
Definition test_binsorter.cc:9
void e()
Definition test_sig.cc:75
static const double alpha
Definition testcosine.cc:10
constexpr std::size_t NDIM
Definition testgconv.cc:54
#define TENSOR_RESULT_TYPE(L, R)
This macro simplifies access to TensorResultType.
Definition type_data.h:205
#define PROFILE_FUNC
Definition worldprofile.h:209
#define PROFILE_BLOCK(name)
Definition worldprofile.h:208