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) {
215 if (vf[i].is_initialized()) v_ptr.push_back(vf[i].
get_impl().get());
219 std::sort(v_ptr.begin(),v_ptr.end());
220 typename std::vector<FunctionImpl<T, NDIM>*>::iterator it;
221 it = std::unique(v_ptr.begin(), v_ptr.end());
224 std::vector< Tensor<T> >
c(v_ptr.size());
225 v_ptr[0]->refine_to_common_level(v_ptr,
c, key0);
226 if (fence) v_ptr[0]->world.gop.fence();
228 for (
unsigned int i=0; i<vf.size(); i++) vf[i].
verify_tree();
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()) {
275 auto change_initial_to_intermediate =[](
const std::vector<Function<T,NDIM>>&
v,
280 if (
f.is_initialized() and
f.get_impl()->get_tree_state()==initialstate) {
281 f.change_tree_state(intermediatestate,
false);
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();
376 template <
typename T, std::
size_t NDIM>
377 std::vector< Function<T,NDIM> >
384 std::vector< Function<T,NDIM> > df(
v.size());
385 for (
unsigned int i=0; i<
v.size(); ++i) {
386 df[i] =
D(
v[i],
false);
393 template <
typename T, std::
size_t NDIM>
394 std::vector< Function<T,NDIM> >
396 std::vector< Function<T,NDIM> > r(n);
397 for (
int i=0; i<n; ++i) {
403 print(
"zero_functions_tree_state: unknown tree state");
404 throw std::runtime_error(
"zero_functions_tree_state: unknown tree state");
414 template <
typename T, std::
size_t NDIM>
415 std::vector< Function<T,NDIM> >
417 return zero_functions_tree_state<T,NDIM>(world,n,
reconstructed,fence);
421 template <
typename T, std::
size_t NDIM>
422 std::vector< Function<T,NDIM> >
424 return zero_functions_tree_state<T,NDIM>(world,n,
compressed,fence);
428 template <
typename T, std::
size_t NDIM>
429 std::vector< Function<T,NDIM> >
432 return zero_functions_tree_state<T,NDIM>(world,n,state,fence);
438 template<
typename T, std::
size_t NDIM>
440 if (vf_in.size()==0)
return std::vector<Function<T,NDIM>>();
441 World& world=vf_in.front().world();
442 auto vf=
copy(world,vf_in);
444 if (vf.size()==1)
return copy(world,vf_in);
449 for (
int i=0; i<s.dim(0); ++i)
Q(i,i) += 1.5;
456 for (
int i=0; i<
Q.dim(0); ++i)
457 for (
int j=0; j<i; ++j)
473 template <
typename T, std::
size_t NDIM>
477 double lindep = 1
e-12) {
478 if(
v.empty())
return v;
480 World& world =
v.front().world();
481 const size_t n =
v.
size();
486 lindep *= s(s.size() - 1);
489 int rank = 0, nlindep = 0;
490 for(
size_t i = 0; i < n; ++i) {
491 const auto s_i = s(i);
492 s(i) = 1.0 / sqrt(s_i);
493 (s_i > lindep) ? rank++ : nlindep++;
499 if (world.
rank() == 0)
500 print(
"WARNING: linear dependencies detected in ", nlindep,
501 " functions, rank = ", rank);
507 for(
size_t i = 0; i < n; ++i){
508 for(
size_t j = 0; j < n; ++j){
509 U(i, j) = U(i, j) * s(j);
521 template <
typename T, std::
size_t NDIM>
523 double lindep = 1
e-12){
524 if(
v.empty())
return v;
535 template <
typename T, std::
size_t NDIM>
539 double lindep = 1
e-12) {
540 if(
v.empty())
return v;
542 World& world =
v.front().world();
543 const size_t n =
v.
size();
548 lindep *= s(s.size() - 1);
551 int rank = 0, nlindep = 0;
552 for(
size_t i = 0; i < n; ++i) {
553 const auto s_i = s(i);
555 s(i) = 1.0 / sqrt(s_i);
565 if (world.
rank() == 0)
566 print(
"Linear dependencies detected: removed ", nlindep,
567 " functions, rank = ", rank);
568 U = U(
_,
Slice(nlindep, -1));
569 s = s(
Slice(nlindep, -1));
573 for(
size_t i = 0; i < n; ++i){
574 for(
size_t j = 0; j < rank; ++j){
575 U(i, j) = U(i, j) * s(j);
585 template <
typename T, std::
size_t NDIM>
587 double lindep = 1
e-12){
588 if(
v.empty())
return v;
598 template <
typename T, std::
size_t NDIM>
603 if (
v.empty())
return v;
611 World& world=
v.front().world();
619 template <
typename T, std::
size_t NDIM>
621 if(
v.empty())
return v;
623 World& world=
v.front().world();
635 template <
typename T, std::
size_t NDIM>
650 std::vector<Function<T,NDIM> > pv(rank);
660 World& world=
v.front().world();
668 template <
typename T, std::
size_t NDIM>
678 template <
typename T, std::
size_t NDIM>
684 World& world=
v.front().world();
690 template <
typename T, std::
size_t NDIM>
692 std::vector<Function<T,NDIM> >
v=lhs;
693 for (std::size_t i = 0; i < rhs.size(); ++i)
v.push_back(rhs[i]);
697 template <
typename T, std::
size_t NDIM>
699 std::vector<Function<T,NDIM> >result;
700 for(
const auto& x:vv) result=
append(result,x);
704 template<
typename T, std::
size_t NDIM>
706 std::vector<std::shared_ptr<FunctionImpl<T,NDIM>>> result;
707 for (
auto&
f :
v) result.push_back(
f.get_impl());
711 template<
typename T, std::
size_t NDIM>
714 for (std::size_t i=0; i<vimpl.size(); ++i)
v[i].
set_impl(vimpl[i]);
717 template<
typename T, std::
size_t NDIM>
719 std::vector<Function<T,NDIM>>
v(vimpl.size());
720 for (std::size_t i=0; i<vimpl.size(); ++i)
v[i].
set_impl(vimpl[i]);
729 template <
typename T,
typename R, std::
size_t NDIM>
742 std::vector< Function<resultT,NDIM> > vc = zero_functions_compressed<resultT,NDIM>(world,
m);
745 for (
int i=0; i<
m; ++i) {
746 for (
int j=0; j<n; ++j) {
747 if (
c(j,i) !=
R(0.0)) vc[i].gaxpy(resultT(1.0),
v[j],resultT(
c(j,i)),
false);
758 template <
typename T,
typename R, std::
size_t NDIM>
774 vv.get_impl()->get_tree_state()==
reconstructed,
"trees have to be reconstructed in transform_reconstructed");
776 std::vector< Function<resultT,NDIM> > result = zero_functions<resultT,NDIM>(world,
m);
778 for (
int i=0; i<
m; ++i) {
780 for (
int j=0; j<n; ++j) {
781 if (
c(j,i) !=
R(0.0))
v[j].get_impl()->accumulate_trees(*(result[i].
get_impl()),resultT(
c(j,i)),
true);
789 for (
auto& r : result) r.get_impl()->finalize_sum();
797 template <
typename L,
typename R, std::
size_t NDIM>
805 = zero_functions_compressed<TENSOR_RESULT_TYPE(L,R),NDIM>(world,
c.dim(1));
808 vresult[0].vtransform(
v,
c, vresult, tol, fence);
812 template <
typename T,
typename R, std::
size_t NDIM>
828 c.copy_to_replicated(tmp);
831 std::vector< Function<resultT,NDIM> > vc = zero_functions_compressed<resultT,NDIM>(world,
m);
834 for (
int i=0; i<
m; ++i) {
835 for (
int j=0; j<n; ++j) {
836 if (tmp(j,i) !=
R(0.0)) vc[i].gaxpy(1.0,
v[j],tmp(j,i),
false);
846 template <
typename T,
typename Q, std::
size_t NDIM>
849 const std::vector<Q>& factors,
852 for (
unsigned int i=0; i<
v.size(); ++i)
v[i].
scale(factors[i],
false);
857 template <
typename T,
typename Q, std::
size_t NDIM>
863 for (
unsigned int i=0; i<
v.size(); ++i)
v[i].
scale(factor,
false);
868 template <
typename T, std::
size_t NDIM>
872 std::vector<double> norms(
v.size());
874 for (
unsigned int i=0; i<
v.size(); ++i) norms[i] =
v[i].norm2sq_local();
875 world.
gop.
sum(&norms[0], norms.size());
876 for (
unsigned int i=0; i<
v.size(); ++i) norms[i] = sqrt(norms[i]);
881 template <
typename T, std::
size_t NDIM>
886 for (
unsigned int i = 0; i <
v.size(); ++i) norms[i] =
v[i].norm2sq_local();
888 for (
unsigned int i = 0; i <
v.size(); ++i) norms[i] = sqrt(norms[i]);
894 template <
typename T, std::
size_t NDIM>
897 if (
v.size()==0)
return 0.0;
899 std::vector<double> norms(
v.size());
900 for (
unsigned int i=0; i<
v.size(); ++i) norms[i] =
v[i].norm2sq_local();
901 world.
gop.
sum(&norms[0], norms.size());
902 for (
unsigned int i=1; i<
v.size(); ++i) norms[0] += norms[i];
904 return sqrt(norms[0]);
950 template <
typename T, std::
size_t NDIM>
958 const int64_t n =
A.coldim();
959 const int64_t
m =
A.rowdim();
963 const int ichunk = 1000;
964 const int jchunk = 1000;
965 for (int64_t ilo=0; ilo<n; ilo+=ichunk) {
966 int64_t ihi = std::min(ilo + ichunk, n);
967 std::vector< Function<T,NDIM> > ivec(
f.begin()+ilo,
f.begin()+ihi);
968 for (int64_t jlo=0; jlo<
m; jlo+=jchunk) {
969 int64_t jhi = std::min(jlo + jchunk,
m);
970 std::vector< Function<T,NDIM> > jvec(
g.begin()+jlo,
g.begin()+jhi);
973 A.copy_from_replicated_patch(ilo, ihi - 1, jlo, jhi - 1,
P);
984 template <
typename T,
typename R, std::
size_t NDIM>
991 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
992 return v.front().get_impl()->get_tensor_type();
998 std::vector<const FunctionImpl<T,NDIM>*> left(
f.size());
999 std::vector<const FunctionImpl<R,NDIM>*> right(
g.size());
1000 for (
unsigned int i=0; i<
f.size(); i++) left[i] =
f[i].
get_impl().get();
1001 for (
unsigned int i=0; i<
g.size(); i++) right[i]=
g[i].
get_impl().get();
1016 template <
typename T,
typename R, std::
size_t NDIM>
1022 long n=
f.size(),
m=
g.size();
1028 if ((
void*)(&
f) != (
void*)(&
g))
compress(world,
g);
1030 for (
long i=0; i<n; ++i) {
1032 if (sym) jtop = i+1;
1033 for (
long j=0; j<jtop; ++j) {
1034 r(i,j) =
f[i].inner_local(
g[j]);
1035 if (sym) r(j,i) =
conj(r(i,j));
1060 template <
typename T,
typename R, std::
size_t NDIM>
1065 long n=
f.size(),
m=
g.size();
1069 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1070 return v.front().get_impl()->get_tensor_type();
1076 for (
long i=0; i<n; ++i) r(i) =
f[i].inner_local(
g[i]);
1088 template <
typename T,
typename R, std::
size_t NDIM>
1096 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1097 return v.front().get_impl()->get_tensor_type();
1100 f.change_tree_state(operating_state,
false);
1104 for (
long i=0; i<n; ++i) {
1105 r(i) =
f.inner_local(
g[i]);
1116 template <
typename T,
typename R, std::
size_t NDIM>
1120 if(
f.empty())
return 0.0;
1121 else return inner(
f[0].world(),
f,
g).sum();
1126 template <
typename T,
typename R, std::
size_t NDIM>
1133 a.reconstruct(
false);
1140 template <
typename T,
typename R, std::
size_t NDIM>
1148 a.reconstruct(
false);
1151 for (
unsigned int i=0; i<
v.size(); ++i) {
1152 v[i].norm_tree(
false);
1171 template <
typename T,
typename R, std::
size_t NDIM>
1178 bool symm =
false) {
1180 bool same=(&
f == &
g);
1184 for (
auto& ff :
f) ff.norm_tree(
false);
1185 if (not same)
for (
auto& gg :
g) gg.norm_tree(
false);
1188 std::vector<std::vector<Function<R,NDIM> > >result(
f.size());
1189 std::vector<Function<R,NDIM>> g_i;
1190 for (int64_t i=
f.size()-1; i>=0; --i) {
1192 result[i]=
vmulXX(
f[i],
g, tol,
false);
1194 if (g_i.empty()) g_i =
g;
1196 result[i]=
vmulXX(
f[i], g_i, tol,
false);
1204 template <
typename T, std::
size_t NDIM>
1210 for (
unsigned int i=0; i<
v.size(); ++i) {
1211 v[i].norm_tree(
false);
1217 template <
typename T,
typename R, std::
size_t NDIM>
1229 for (
unsigned int i=0; i<
a.size(); ++i) {
1230 q[i] =
mul(
a[i],
b[i],
false);
1243 template<
typename T, std::
size_t NDIM, std::
size_t LDIM>
1248 std::vector<Function<T,NDIM> > result(
g.size());
1249 for (
auto& r : result) r.set_impl(
f,
false);
1257 for (std::size_t i=0; i<result.size(); ++i) {
1264 for (
auto& ig :
g) ig.get_impl()->undo_redundant(
false);
1269 template<
typename T, std::
size_t NDIM, std::
size_t LDIM>
1271 const std::tuple<int,int,int>
v) {
1272 return partial_mul<T,NDIM,LDIM>(
f,
g,std::array<int,3>({std::get<0>(
v),std::get<1>(
v),std::get<2>(
v)}));
1277 template <
typename T, std::
size_t NDIM>
1278 std::vector< Function<T,NDIM> >
1282 return mul<T,T,NDIM>(world,
v,
v, fence);
1293 template <
typename T, std::
size_t NDIM>
1294 std::vector< Function<typename Tensor<T>::scalar_type,
NDIM> >
1300 std::vector<Function<scalartype,NDIM> > result(
v.size());
1301 for (
size_t i=0; i<
v.size(); ++i) result[i]=
abs_square(
v[i],
false);
1308 template <
typename T, std::
size_t NDIM>
1310 for (
unsigned int j=0; j<
v.size(); ++j) {
1311 v[j].set_thresh(
thresh,
false);
1317 template <
typename T, std::
size_t NDIM>
1318 std::vector< Function<T,NDIM> >
1323 std::vector< Function<T,NDIM> > r =
copy(world,
v);
1324 for (
unsigned int i=0; i<
v.size(); ++i) {
1332 template <
typename T,
typename R, std::
size_t NDIM>
1336 std::vector< Function<R,NDIM> > r(
v.size());
1337 for (
unsigned int i=0; i<
v.size(); ++i) {
1338 r[i] = convert<T,R,NDIM>(
v[i],
false);
1346 template <
typename T, std::
size_t NDIM>
1347 std::vector< Function<T,NDIM> >
1352 std::vector< Function<T,NDIM> > r(
v.size());
1353 for (
unsigned int i=0; i<
v.size(); ++i) {
1354 r[i] =
copy(
v[i],
false);
1362 template <
typename T, std::
size_t NDIM>
1363 std::vector< Function<T,NDIM> >
1366 std::vector< Function<T,NDIM> > r(
v.size());
1367 if (
v.size()>0) r=
copy(
v.front().world(),
v,fence);
1372 template <
typename T, std::
size_t NDIM>
1373 std::vector< Function<T,NDIM> >
1376 const unsigned int n,
1379 std::vector< Function<T,NDIM> > r(n);
1380 for (
unsigned int i=0; i<n; ++i) {
1381 r[i] =
copy(
v,
false);
1396 template <
typename T, std::
size_t NDIM>
1400 bool fence =
true) {
1402 std::vector<Function<T, NDIM>> r(
v.size());
1403 for (
unsigned int i = 0; i <
v.size(); ++i) {
1404 r[i] =
copy(
v[i], pmap,
false);
1411 template <
typename T,
typename R, std::
size_t NDIM>
1423 for (
unsigned int i=0; i<
a.size(); ++i) {
1424 r[i] =
add(
a[i],
b[i],
false);
1431 template <
typename T,
typename R, std::
size_t NDIM>
1442 for (
unsigned int i=0; i<
b.size(); ++i) {
1443 r[i] =
add(
a,
b[i],
false);
1448 template <
typename T,
typename R, std::
size_t NDIM>
1454 return add(world,
a,
b, fence);
1458 template <
typename T,
typename R, std::
size_t NDIM>
1470 for (
unsigned int i=0; i<
a.size(); ++i) {
1471 r[i] =
sub(
a[i],
b[i],
false);
1478 template <
typename T, std::
size_t NDIM>
1485 for (
unsigned int i=0; i<
f.size(); ++i) r.
gaxpy(1.0,
f[i],1.0,
false);
1490 template <
typename T, std::
size_t NDIM>
1498 const int64_t n =
A.coldim();
1499 const int64_t
m =
A.rowdim();
1503 const int ichunk = 1000;
1504 const int jchunk = 1000;
1505 for (int64_t ilo = 0; ilo < n; ilo += ichunk) {
1506 int64_t ihi = std::min(ilo + ichunk, n);
1507 std::vector<Function<T, NDIM>> ivec(
f.begin() + ilo,
f.begin() + ihi);
1508 for (int64_t jlo = 0; jlo <
m; jlo += jchunk) {
1509 int64_t jhi = std::min(jlo + jchunk,
m);
1510 std::vector<Function<T, NDIM>> jvec(
g.begin() + jlo,
g.begin() + jhi);
1513 A.copy_from_replicated_patch(ilo, ihi - 1, jlo, jhi - 1,
P);
1524 template <
typename T,
typename R, std::
size_t NDIM>
1535 std::vector<const FunctionImpl<T, NDIM>*> left(
f.size());
1536 std::vector<const FunctionImpl<R, NDIM>*> right(
g.size());
1537 for (
unsigned int i = 0; i <
f.size(); i++) left[i] =
f[i].
get_impl().get();
1538 for (
unsigned int i = 0; i <
g.size(); i++) right[i] =
g[i].
get_impl().get();
1553 template <
typename T,
typename R, std::
size_t NDIM>
1559 long n=
f.size(),
m=
g.size();
1565 if ((
void*)(&
f) != (
void*)(&
g))
compress(world,
g);
1567 for (
long i=0; i<n; ++i) {
1569 if (sym) jtop = i+1;
1570 for (
long j=0; j<jtop; ++j) {
1572 r(j,i) =
f[i].dot_local(
g[j]);
1574 r(i,j) =
conj(r(j,i));
1576 r(i,j) =
f[i].dot_local(
g[j]);
1587 template <
typename T,
typename R, std::
size_t NDIM>
1594 return sum(world,
mul(world,
a,
b,
true),fence);
1600 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1610 if (
a.size()==0)
return std::vector<Function<resultT,NDIM> >();
1612 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1613 return v.front().get_impl()->get_tensor_type();
1617 World& world=
a[0].world();
1618 std::vector<Function<resultT,NDIM> > result(
a.size());
1625 print(
"could not respect fence in gaxpy");
1642 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1651 if (
a.size()==0)
return std::vector<Function<resultT,NDIM> >();
1653 World& world=
a[0].world();
1659 print(
"could not respect fence in gaxpy_oop");
1663 std::vector<Function<resultT,NDIM> > result(
a.size());
1664 for (
unsigned int i=0; i<
a.size(); ++i) {
1667 if (fence) world.gop.fence();
1673 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1675 if (
a.size() == 0)
return;
1676 World& world=
a.front().world();
1681 template <
typename T,
typename Q,
typename R, std::
size_t NDIM>
1690 if (
a.empty())
return;
1692 auto tensor_type = [](
const std::vector<Function<T,NDIM>>&
v) {
1693 return v.front().get_impl()->get_tensor_type();
1697 bool do_in_reconstructed_state=tensor_type(
a)!=
TT_FULL;
1706 print(
"could not respect fence in gaxpy");
1720 print(
"could not respect fence in gaxpy for a");
1728 print(
"could not respect fence in gaxpy for b");
1735 for (
unsigned int i=0; i<
a.size(); ++i) {
1739 for (
unsigned int i=0; i<
a.size(); ++i)
a[i].
get_impl()->finalize_sum();
1747 template <
typename opT,
typename R, std::
size_t NDIM>
1750 const std::vector< std::shared_ptr<opT> >&
op,
1756 std::vector< Function<R,NDIM> >&
ncf = *
const_cast< std::vector< Function<R,NDIM>
>* >(&
f);
1762 for (
unsigned int i=0; i<
f.size(); ++i) {
1778 template <
typename T,
typename R, std::
size_t NDIM, std::
size_t KDIM>
1787 template <
typename T,
typename R, std::
size_t NDIM, std::
size_t KDIM>
1794 std::vector< Function<R,NDIM> >&
ncf = *
const_cast< std::vector< Function<R,NDIM>
>* >(&
f);
1801 if (
print_timings) printf(
"timer: %20.20s %8.2fs\n",
"make_nonstandard", wall1-wall0);
1804 for (
unsigned int i=0; i<
f.size(); ++i) {
1811 if (
op.destructive()) {
1812 for (
auto& ff :
ncf) ff.clear(
false);
1820 for (
auto& r : result) r.get_impl()->finalize_apply();
1824 for (
auto& r : result) r.get_impl()->print_timer();
1833 template <
typename T, std::
size_t NDIM>
1836 std::vector<double> nn =
norm2s(world,
v);
1837 for (
unsigned int i=0; i<
v.size(); ++i)
v[i].
scale(1.0/nn[i],
false);
1841 template <
typename T, std::
size_t NDIM>
1844 if(world.
rank()==0) std::cout <<
"print_size: " << msg <<
" is empty" << std::endl;
1845 }
else if(
v.size()==1){
1846 v.front().print_size(msg);
1856 template <
typename T, std::
size_t NDIM>
1860 if (x.is_initialized()) size+=x.size_local();
1862 const double d=
sizeof(
T);
1863 const double fac=1024*1024*1024;
1868 template <
typename T, std::
size_t NDIM>
1875 template <
typename T, std::
size_t NDIM>
1878 if (
v.empty())
return 0.0;
1880 const double d=
sizeof(
T);
1881 const double fac=1024*1024*1024;
1884 for(
unsigned int i=0;i<
v.size();i++){
1885 if (
v[i].is_initialized()) size+=
v[i].size();
1893 template <
typename T, std::
size_t NDIM>
1895 const double d=
sizeof(
T);
1896 const double fac=1024*1024*1024;
1897 double size=
f.size();
1906 template <
typename T,
typename opT, std::
size_t NDIM>
1909 const bool fence=
true) {
1912 World& world=vin[0].world();
1915 std::vector<Function<T,NDIM> > vout=zero_functions<T,NDIM>(world,
op.get_result_size());
1916 for (
auto& out : vout) out.set_impl(vin[0],
false);
1927 template <
typename T, std::
size_t NDIM>
1935 template <
typename T, std::
size_t NDIM>
1943 template <
typename T, std::
size_t NDIM>
1951 template <
typename T, std::
size_t NDIM>
1959 template <
typename T, std::
size_t NDIM>
1967 template <
typename T, std::
size_t NDIM>
1975 template <
typename T,
typename R, std::
size_t NDIM>
1979 std::vector<Function<T,NDIM> > tmp=
copy(rhs[0].world(),rhs);
1986 template <
typename T,
typename R, std::
size_t NDIM>
1998 template <
typename T,
typename R, std::
size_t NDIM>
2001 if (
v.size()>0)
return mul(
v[0].world(),
a,
v,
true);
2007 template <
typename T,
typename R, std::
size_t NDIM>
2010 if (
v.size()>0)
return mul(
v[0].world(),
a,
v,
true);
2015 template <
typename T, std::
size_t NDIM>
2018 if (lhs.size() > 0)
gaxpy(lhs.front().world(), 1.0, lhs, 1.0, rhs);
2022 template <
typename T, std::
size_t NDIM>
2026 if (lhs.size() > 0)
gaxpy(lhs.front().world(), 1.0, lhs, -1.0, rhs);
2031 template <
typename T, std::
size_t NDIM>
2032 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> >
2034 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> > result(
v.size());
2035 for (std::size_t i=0; i<
v.size(); ++i) result[i]=
real(
v[i],
false);
2036 if (fence and result.size()>0) result[0].world().gop.fence();
2041 template <
typename T, std::
size_t NDIM>
2042 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> >
2044 std::vector<Function<typename Tensor<T>::scalar_type,
NDIM> > result(
v.size());
2045 for (std::size_t i=0; i<
v.size(); ++i) result[i]=
imag(
v[i],
false);
2046 if (fence and result.size()>0) result[0].world().gop.fence();
2057 template <
typename T, std::
size_t NDIM>
2059 bool refine=
false,
bool fence=
true) {
2065 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2066 gradient_operator<T,NDIM>(world);
2068 std::vector<Function<T,NDIM> > result(
NDIM);
2069 for (
size_t i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2075 template <
typename T, std::
size_t NDIM>
2077 bool refine=
false,
bool fence=
true) {
2083 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2084 gradient_operator<T,NDIM>(world);
2087 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_ble1();
2089 std::vector<Function<T,NDIM> > result(
NDIM);
2090 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2096 template <
typename T, std::
size_t NDIM>
2098 bool refine=
false,
bool fence=
true) {
2104 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2105 gradient_operator<T,NDIM>(world);
2108 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_ble2();
2110 std::vector<Function<T,NDIM> > result(
NDIM);
2111 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2117 template <
typename T, std::
size_t NDIM>
2119 bool refine=
false,
bool fence=
true) {
2125 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2126 gradient_operator<T,NDIM>(world);
2129 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_bspline1();
2131 std::vector<Function<T,NDIM> > result(
NDIM);
2132 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2138 template <
typename T, std::
size_t NDIM>
2140 bool refine=
false,
bool fence=
true) {
2146 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2147 gradient_operator<T,NDIM>(world);
2150 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_bspline2();
2152 std::vector<Function<T,NDIM> > result(
NDIM);
2153 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2159 template <
typename T, std::
size_t NDIM>
2161 bool refine=
false,
bool fence=
true) {
2167 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2168 gradient_operator<T,NDIM>(world);
2171 for (
unsigned int i=0; i<
NDIM; ++i) (*
grad[i]).set_bspline3();
2173 std::vector<Function<T,NDIM> > result(
NDIM);
2174 for (
unsigned int i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
f,
false);
2189 template <
typename T, std::
size_t NDIM>
2191 bool do_refine=
false,
bool fence=
true) {
2194 World& world=
v[0].world();
2196 if (do_refine)
refine(world,
v);
2198 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2199 gradient_operator<T,NDIM>(world);
2201 std::vector<Function<T,NDIM> > result(
NDIM);
2202 for (
size_t i=0; i<
NDIM; ++i) result[i]=
apply(*(
grad[i]),
v[i],
false);
2204 return sum(world,result,fence);
2215 template <
typename T, std::
size_t NDIM>
2217 bool do_refine=
false,
bool fence=
true) {
2220 World& world=
v[0].world();
2222 if (do_refine)
refine(world,
v);
2224 std::vector< std::shared_ptr< Derivative<T,NDIM> > >
grad=
2225 gradient_operator<T,NDIM>(world);
2227 std::vector<Function<T,NDIM> >
d(
NDIM),dd(
NDIM);
2239 d[0].gaxpy(1.0,dd[0],-1.0,
false);
2240 d[1].gaxpy(1.0,dd[1],-1.0,
false);
2241 d[2].gaxpy(1.0,dd[2],-1.0,
false);
2256 template <
typename T,
typename R, std::
size_t NDIM>
2259 bool do_refine=
false,
bool fence=
true) {
2263 World& world=
f[0].world();
2269 d[0]=
mul(
f[1],
g[2],
false);
2270 d[1]=
mul(
f[2],
g[0],
false);
2271 d[2]=
mul(
f[0],
g[1],
false);
2273 dd[0]=
mul(
f[2],
g[1],
false);
2274 dd[1]=
mul(
f[0],
g[2],
false);
2275 dd[2]=
mul(
f[1],
g[0],
false);
2281 d[0].gaxpy(1.0,dd[0],-1.0,
false);
2282 d[1].gaxpy(1.0,dd[1],-1.0,
false);
2283 d[2].gaxpy(1.0,dd[2],-1.0,
false);
2290 template<
typename T, std::
size_t NDIM>
2307 template<
typename T,
size_t NDIM>
2309 const std::string
name) {
2310 if (world.
rank()==0)
print(
"loading vector of functions",
name);
2312 std::size_t fsize=0;
2315 for (std::size_t i=0; i<fsize; ++i) ar &
f[i];
2319 template<
typename T,
size_t NDIM>
2322 World& world=
f.front().world();
2323 if (world.
rank()==0)
print(
"saving vector of functions",
name);
2325 std::size_t fsize=
f.size();
2327 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:266
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:433
static TensorType get_tensor_type()
Returns the default tensor type.
Definition funcdefaults.h:325
FunctionFactory implements the named-parameter idiom for Function.
Definition function_factory.h:86
FunctionFactory & compressed(bool value=true)
Definition function_factory.h:168
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:945
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:6081
void undo_redundant(const bool fence)
convert this from redundant to standard reconstructed form
Definition mraimpl.h:1538
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:3659
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:1407
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:6133
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition funcimpl.h:127
coeffT & coeff()
Returns a non-const reference to the tensor containing the coeffs.
Definition funcimpl.h:227
A multiresolution adaptive numerical function.
Definition mra.h:139
World & world() const
Returns the world.
Definition mra.h:693
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:1055
void set_impl(const std::shared_ptr< FunctionImpl< T, NDIM > > &impl)
Replace current FunctionImpl with provided new one.
Definition mra.h:666
void multi_to_multi_op_values(const opT &op, const std::vector< Function< T, NDIM > > &vin, std::vector< Function< T, NDIM > > &vout, const bool fence=true)
apply op on the input vector yielding an output vector of functions
Definition mra.h:1615
bool is_initialized() const
Returns true if the function is initialized.
Definition mra.h:167
long size() const
Definition lowranktensor.h:488
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:69
std::shared_ptr< WorldDCPmapInterface< keyT > > load_balance(double fac=1.0, bool printstuff=false)
Actually does the partitioning of the tree.
Definition lbdeux.h:320
void add_tree(const Function< T, NDIM > &f, const costT &costfn, bool fence=false)
Accumulates cost from a function.
Definition lbdeux.h:289
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:317
TensorTypeData< T >::scalar_type scalar_type
C++ typename of the real type associated with a complex type.
Definition tensor.h:409
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1840
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:161
void sum(T *buf, size_t nelem)
Inplace global sum while still processing AM & tasks.
Definition worldgop.h:872
void fence()
Returns after all local tasks have completed.
Definition world_task_queue.h:1384
A parallel world class.
Definition world.h:132
WorldTaskQueue & taskq
Task queue.
Definition world.h:206
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:320
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:330
WorldGopInterface & gop
Global operations.
Definition world.h:207
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.
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:28
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:2043
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:2320
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:636
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:2825
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:2011
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:2793
response_space scale(response_space a, double b)
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:2065
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:882
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:869
std::vector< Function< T, NDIM > > grad_bspline_one(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2118
void set_impl(std::vector< Function< T, NDIM > > &v, const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > vimpl)
Definition vmra.h:712
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:2143
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:1795
void truncate(World &world, response_space &v, double tol, bool fence)
Definition basic_operators.cc:31
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:474
std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > get_impl(const std::vector< Function< T, NDIM > > &v)
Definition vmra.h:705
Function< T, NDIM > div(const std::vector< Function< T, NDIM > > &v, bool do_refine=false, bool fence=true)
shorthand div operator
Definition vmra.h:2190
std::vector< Function< T, NDIM > > orthonormalize_cd(const std::vector< Function< T, NDIM > > &v, Tensor< T > &ovlp)
Definition vmra.h:599
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:1374
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:1205
tensorT Q2(const tensorT &s)
Given overlap matrix, return rotation with 2nd order error to orthonormalize the vectors.
Definition SCF.cc:137
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:731
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:2257
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
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:2157
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:1173
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 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
response_space transpose(response_space &f)
Definition basic_operators.cc:10
std::vector< Function< T, NDIM > > impl2function(const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > vimpl)
Definition vmra.h:718
std::vector< Function< T, NDIM > > grad_bpsline_two(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2139
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:1309
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition vmra.h:895
std::vector< Function< T, NDIM > > flatten(const std::vector< std::vector< Function< T, NDIM > > > &vv)
Definition vmra.h:698
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:74
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:1907
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:2841
std::vector< CCPairFunction< T, NDIM > > operator-(const std::vector< CCPairFunction< T, NDIM > > c1, const std::vector< CCPairFunction< T, NDIM > > &c2)
Definition ccpairfunction.h:1060
Function< TENSOR_RESULT_TYPE(L, R), NDIM > mul_sparse(const Function< L, NDIM > &left, const Function< R, NDIM > &right, double tol, bool fence=true)
Sparse multiplication — left and right must be reconstructed and if tol!=0 have tree of norms already...
Definition mra.h:1836
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:1244
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:2029
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:760
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:226
response_space apply(World &world, std::vector< std::vector< std::shared_ptr< real_convolution_3d > > > &op, response_space &f)
Definition basic_operators.cc:43
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:691
@ 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:1842
NDIM & f
Definition mra.h:2528
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:2021
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:2854
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)
Multiplies and sums two vectors of functions r = \sum_i a[i] * b[i].
Definition vmra.h:1589
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:439
NDIM const Function< R, NDIM > & g
Definition mra.h:2528
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:2076
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:2231
std::vector< Function< T, NDIM > > grad_bspline_three(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
Definition vmra.h:2160
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:423
double inner(response_space &a, response_space &b)
Definition response_functions.h:639
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:2308
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:1901
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:2097
static bool print_timings
Definition SCF.cc:106
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:1834
std::vector< Function< T, NDIM > > zero_functions(World &world, int n, bool fence=true)
Generates a vector of zero functions (reconstructed)
Definition vmra.h:416
std::vector< CCPairFunction< T, NDIM > > operator+(const std::vector< CCPairFunction< T, NDIM > > c1, const std::vector< CCPairFunction< T, NDIM > > &c2)
Definition ccpairfunction.h:1052
std::vector< Function< T, NDIM > > grad(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
shorthand gradient operator
Definition vmra.h:2058
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:2484
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:430
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:1491
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:395
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
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:536
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:1554
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
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:1876
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:1857
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:2096
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:1017
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:218
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