37 #ifndef MADNESS_MRA_MRA_H__INCLUDED
38 #define MADNESS_MRA_MRA_H__INCLUDED
53 #define FUNCTION_INSTANTIATE_1
54 #define FUNCTION_INSTANTIATE_2
55 #define FUNCTION_INSTANTIATE_3
56 #if !defined(HAVE_IBMBGP) || !defined(HAVE_IBMBGQ)
57 #define FUNCTION_INSTANTIATE_4
58 #define FUNCTION_INSTANTIATE_5
59 #define FUNCTION_INSTANTIATE_6
62 static const bool VERIFY_TREE =
false;
66 void startup(World& world,
int argc,
char** argv);
83 template<
typename T, std::
size_t NDIM>
86 template<
typename T, std::
size_t NDIM>
89 template<
typename T, std::
size_t NDIM>
92 template<
typename T, std::
size_t NDIM>
93 class FunctionFactory;
95 template<
typename T, std::
size_t NDIM>
96 class FunctionFunctorInterface;
98 template<
typename T, std::
size_t NDIM>
101 template<
typename T, std::
size_t NDIM>
104 template<
typename T, std::
size_t NDIM>
107 template<
typename T, std::
size_t NDIM, std::
size_t LDIM,
typename opT>
110 template<
typename T, std::
size_t NDIM,
typename opT>
113 template<
typename T, std::
size_t NDIM>
124 template <
typename T, std::
size_t NDIM>
172 if (
this != &f) impl = f.impl;
187 const double eps=1e-15;
191 user_to_sim(xuser,xsim);
194 for (std::size_t d=0; d<
NDIM; ++d) {
195 if (xsim[d] < -eps) {
198 else if (xsim[d] < eps) {
202 if (xsim[d] > 1.0+eps) {
205 else if (xsim[d] > 1.0-eps) {
211 impl->eval(xsim, impl->key0(), result.
remote_ref(impl->world));
220 const double eps=1e-15;
224 user_to_sim(xuser,xsim);
227 for (std::size_t d=0; d<
NDIM; ++d) {
228 if (xsim[d] < -eps) {
231 else if (xsim[d] < eps) {
235 if (xsim[d] > 1.0+eps) {
238 else if (xsim[d] > 1.0-eps) {
242 return impl->eval_local_only(xsim,maxlevel);
253 const double eps=1e-15;
257 user_to_sim(xuser,xsim);
260 for (std::size_t d=0; d<
NDIM; ++d) {
261 if (xsim[d] < -eps) {
264 else if (xsim[d] < eps) {
268 if (xsim[d] > 1.0+eps) {
271 else if (xsim[d] > 1.0-eps) {
277 impl->evaldepthpt(xsim, impl->key0(), result.
remote_ref(impl->world));
290 const double eps=1e-15;
294 user_to_sim(xuser,xsim);
297 for (std::size_t d=0; d<
NDIM; ++d) {
298 if (xsim[d] < -eps) {
301 else if (xsim[d] < eps) {
305 if (xsim[d] > 1.0+eps) {
308 else if (xsim[d] > 1.0-eps) {
314 impl->evalR(xsim, impl->key0(), result.
remote_ref(impl->world));
330 const std::vector<long>& npt,
331 bool eval_refine =
false)
const {
334 const double eps=1e-14;
338 for (std::size_t d=0; d<
NDIM; ++d) {
339 simlo[d] = cell(d,0);
340 simhi[d] = cell(d,1);
342 user_to_sim(simlo, simlo);
343 user_to_sim(simhi, simhi);
347 for (std::size_t d=0; d<
NDIM; ++d) {
352 double delta = eps*(simhi[d]-simlo[d]);
356 return impl->eval_plot_cube(simlo, simhi, npt, eval_refine);
375 if (impl->world.rank() == 0) result =
eval(xuser).get();
376 impl->world.gop.broadcast(result);
384 T operator()(
double x,
double y=0,
double z=0,
double xx=0,
double yy=0,
double zz=0)
const {
387 if (
NDIM>=2) r[1] = y;
388 if (
NDIM>=3) r[2] = z;
389 if (
NDIM>=4) r[3] = xx;
390 if (
NDIM>=5) r[4] = yy;
391 if (
NDIM>=6) r[5] = zz;
410 if (impl->world.rank() == 0) result =
evaldepthpt(xuser).get();
411 impl->world.gop.broadcast(result);
423 template <
typename funcT>
428 return impl->errsq_local(func);
438 template <
typename funcT>
445 double local = impl->errsq_local(func);
446 impl->world.gop.sum(local);
447 impl->world.gop.fence();
454 if (impl) impl->verify_tree();
464 return impl->is_compressed();
474 return impl->tree_size();
479 if (!impl)
print(
"function",name,
"not assigned yet");
480 impl->print_size(name);
487 return impl->max_depth();
495 return impl->max_local_depth();
503 return impl->max_nodes();
510 return impl->min_nodes();
525 if (!impl)
return true;
526 return impl->get_autorefine();
536 impl->set_autorefine(value);
537 if (
fence) impl->world.gop.fence();
544 if (!impl)
return 0.0;
545 return impl->get_thresh();
555 impl->set_thresh(value);
556 if (
fence) impl->world.gop.fence();
564 return impl->get_k();
579 if (!impl)
return *
this;
582 impl->truncate(tol,
fence);
607 this->impl->set_functor(functor);
608 print(
"set functor in mra.h");
616 template <
typename R>
633 return impl->get_pmap();
643 return impl->norm2sq_local();
654 double local = impl->norm2sq_local();
656 impl->world.gop.sum(local);
657 impl->world.gop.fence();
687 impl->world.gop.fence();
704 if (impl->is_nonstandard())
return;
707 impl->compress(
true, keepleaves,
false,
fence);
722 impl->standard(
fence);
756 template <
typename opT>
761 impl->refine(op,
fence);
770 template <
typename Archive>
void serialize (Archive& ar) {}
780 bool fence =
true)
const {
783 impl->broaden(bc.is_periodic(),
fence);
791 return impl->coeffs_for_jun(n,mode);
811 if (impl) impl->print_tree(os);
817 os <<
"digraph G {" << std::endl;
818 if (impl) impl->print_tree_graphviz(os);
819 os <<
"}" << std::endl;
827 if (impl) impl->print_info();
836 template <
typename Archive>
void serialize(Archive& ar) {}
843 this->
unaryop(SimpleUnaryOpWrapper(
f));
848 template <
typename opT>
853 impl->unary_op_value_inplace(op,
fence);
858 template <
typename opT>
863 impl->unary_op_coeff_inplace(op,
fence);
868 template <
typename opT>
873 impl->unary_op_node_inplace(op,
fence);
895 template <
typename Q>
900 impl->scale_inplace(q,
fence);
910 impl->add_scalar_inplace(t,
fence);
923 template <
typename Q,
typename R>
942 template <
typename Q>
955 return gaxpy(
T(1.0), other, Q(1.0),
true);
962 template <
typename Q>
975 return gaxpy(
T(1.0), other, Q(-1.0),
true);
982 template <
typename Q>
998 impl->square_inplace(
fence);
1007 impl->abs_inplace(
fence);
1016 impl->abs_square_inplace(
fence);
1027 if (!impl)
return 0.0;
1029 return impl->trace_local();
1036 if (!impl)
return 0.0;
1037 T sum = impl->trace_local();
1038 impl->world.gop.sum(sum);
1039 impl->world.gop.fence();
1045 template <
typename R>
1051 if (VERIFY_TREE) g.verify_tree();
1052 return impl->inner_local(*(g.get_impl()));
1059 template<
typename R>
1065 impl->get_coeffs().clear();
1068 impl->make_Vphi(gnode_is_leaf,
fence);
1076 template<
typename opT>
1081 impl->get_coeffs().clear();
1083 impl->make_Vphi(leaf_op,
fence);
1094 impl->get_coeffs().clear();
1096 impl->make_Vphi(leaf_op,
fence);
1102 template<
size_t LDIM,
size_t KDIM,
typename opT>
1108 impl->hartree_product(left,right,
leaf_op,
true);
1114 template<
size_t LDIM,
size_t KDIM>
1119 impl->hartree_product(left,right,
leaf_op,
true);
1128 template <
typename R>
1134 if (not g.is_initialized())
return 0.0;
1143 if (this->
is_on_demand())
return g.inner_on_demand(*
this);
1144 if (g.is_on_demand())
return this->inner_on_demand(g);
1147 if (VERIFY_TREE) g.verify_tree();
1152 if (!g.is_compressed()) g.compress(
false);
1153 impl->world.gop.fence();
1158 if (not this->
get_impl()->is_redundant()) this->
get_impl()->make_redundant(
false);
1159 if (not g.get_impl()->is_redundant()) g.get_impl()->make_redundant(
false);
1160 impl->world.gop.fence();
1168 if (this->get_impl()->is_redundant()) this->get_impl()->undo_redundant(false);
1169 if (g.get_impl()->is_redundant()) g.get_impl()->undo_redundant(false);
1170 impl->
world.gop.fence();
1185 if (not impl->is_redundant()) impl->make_redundant(
true);
1186 T local = impl->inner_ext_local(
f, leaf_refine);
1187 if (not keep_redundant) impl->undo_redundant(
true);
1199 T inner_ext(
T (*
f)(
const coordT&),
const bool leaf_refine=
true,
const bool keep_redundant=
false)
const {
1201 if (not impl->is_redundant()) impl->make_redundant(
true);
1202 T local = impl->inner_ext_local(
f, leaf_refine);
1203 impl->world.gop.sum(local);
1204 impl->world.gop.fence();
1205 if (not keep_redundant) impl->undo_redundant(
true);
1219 if (not impl->is_redundant()) impl->make_redundant(
true);
1220 T local = impl->inner_ext_local(
f, leaf_refine);
1221 if (not keep_redundant) impl->undo_redundant(
true);
1235 if (not impl->is_redundant()) impl->make_redundant(
true);
1236 T local = impl->inner_ext_local(
f, leaf_refine);
1237 impl->world.gop.sum(local);
1238 impl->world.gop.fence();
1239 if (not keep_redundant) impl->undo_redundant(
true);
1248 template <
typename L>
1264 template <
typename R>
1282 g.get_impl()->get_coeffs().
clear();
1293 template <typename R,
size_t LDIM>
1299 static const size_t KDIM=
NDIM-LDIM;
1309 this->
get_impl()->project_out(result.get_impl().get(),gimpl,
dim,
true);
1311 result.world().gop.
fence();
1312 result.get_impl()->trickle_down(
true);
1323 template <
typename Archive>
1327 long magic = 0l,
id = 0l, ndim = 0l,
k = 0l;
1328 ar & magic &
id & ndim &
k;
1344 template <
typename Archive>
1358 if (not impl)
return;
1359 impl->change_tensor_type1(targs,
fence);
1364 template <
typename Q,
typename opT>
1377 template <
typename Q, std::
size_t D>
1378 static std::vector< std::shared_ptr< FunctionImpl<Q,D> > >
vimpl(
const std::vector<
Function<Q,D> >& v) {
1380 std::vector< std::shared_ptr< FunctionImpl<Q,D> > > r(v.size());
1381 for (
unsigned int i=0; i<v.size(); ++i) r[i] = v[i].
get_impl();
1388 std::vector< Tensor<T> >
c(vf.size());
1389 std::vector<implT*> v(vf.size());
1390 bool mustfence =
false;
1391 for (
unsigned int i=0; i<v.size(); ++i) {
1393 vf[i].reconstruct(
false);
1396 v[i] = vf[i].get_impl().get();
1398 vf[0].impl->refine_to_common_level(v,
c, key0);
1399 if (mustfence) vf[0].world().gop.fence();
1400 if (
fence) vf[0].world().gop.fence();
1402 for (
unsigned int i=0; i<vf.size(); i++) vf[i].
verify_tree();
1406 template <
typename opT>
1408 std::vector<implT*> v(vf.size());
1409 for (
unsigned int i=0; i<v.size(); ++i) {
1412 impl->multiop_values(op, v);
1418 template <
typename L,
typename R>
1426 std::vector<FunctionImpl<T,NDIM>*> vresult(right.size());
1427 std::vector<const FunctionImpl<R,NDIM>*> vright(right.size());
1428 for (
unsigned int i=0; i<right.size(); ++i) {
1429 result[i].set_impl(left,
false);
1430 vresult[i] = result[i].impl.get();
1431 vright[i] = right[i].impl.get();
1434 left.
world().gop.fence();
1435 vresult[0]->mulXXvec(left.
get_impl().get(), vright, vresult, tol,
fence);
1441 template<
typename L,
typename R>
1451 impl->multiply(leaf_op1,gimpl,fimpl,
fence);
1454 impl->multiply(leaf_op1,fimpl,gimpl,
fence);
1459 template <
typename R,
typename Q>
1470 template <
typename L,
typename R>
1489 for (std::size_t i=0; i<NDIM; ++i) MADNESS_ASSERT(map[i]>=0 &&
static_cast<std::size_t
>(map[i])<
NDIM);
1491 impl->mapdim(*f.impl,map,fence);
1498 impl->make_redundant(
true);
1500 double local = impl->check_symmetry_local();
1501 impl->world.gop.sum(local);
1502 impl->world.gop.fence();
1503 double asy=
sqrt(local);
1504 if (this->
world().rank()==0)
print(
"asymmetry wrt particle",asy);
1505 impl->undo_redundant(
true);
1512 impl->reduce_rank(impl->get_tensor_args(),
fence);
1517 template <
typename T,
typename opT,
int NDIM>
1526 template <
typename Q,
typename T, std::
size_t NDIM>
1527 Function<TENSOR_RESULT_TYPE(Q,T),NDIM>
1540 template <
typename Q,
typename T, std::
size_t NDIM>
1541 Function<TENSOR_RESULT_TYPE(Q,T),NDIM>
1551 template <
typename Q,
typename T, std::
size_t NDIM>
1552 Function<TENSOR_RESULT_TYPE(Q,T),NDIM>
1554 return mul(alpha, f,
true);
1560 template <
typename Q,
typename T, std::
size_t NDIM>
1561 Function<TENSOR_RESULT_TYPE(Q,T),NDIM>
1563 return mul(alpha, f,
true);
1567 template <
typename L,
typename R,std::
size_t NDIM>
1568 Function<TENSOR_RESULT_TYPE(L,R),NDIM>
1584 template <
typename L,
typename R,std::
size_t NDIM>
1585 Function<TENSOR_RESULT_TYPE(L,R),NDIM>
1591 template <
typename L,
typename R,
typename opT, std::
size_t NDIM>
1592 Function<TENSOR_RESULT_TYPE(L,R),NDIM>
1605 template <
typename Q,
typename opT, std::
size_t NDIM>
1606 Function<typename opT::resultT, NDIM>
1618 template <
typename Q,
typename opT, std::
size_t NDIM>
1619 Function<typename opT::resultT, NDIM>
1632 template <
typename L,
typename R, std::
size_t D>
1633 std::vector< Function<TENSOR_RESULT_TYPE(L,R),D> >
1636 std::vector< Function<TENSOR_RESULT_TYPE(L,R),D> > vresult(vright.size());
1637 vresult[0].vmulXX(left, vright, vresult, tol,
fence);
1645 template <
typename L,
typename R, std::
size_t NDIM>
1646 Function<TENSOR_RESULT_TYPE(L,R), NDIM>
1651 return mul(left,right,
true);
1655 template<
typename T, std::
size_t KDIM, std::
size_t LDIM>
1656 Function<T,KDIM+LDIM>
1678 if (not same) right.
standard(
false);
1679 left2.
world().gop.fence();
1687 template<
typename T, std::
size_t KDIM, std::
size_t LDIM,
typename opT>
1688 Function<T,KDIM+LDIM>
1702 if (result.
world().rank()==0) {
1703 print(
"incomplete FunctionFactory in Function::hartree_product");
1704 print(
"thresh: ", thresh);
1715 if (not same) right.
standard(
false);
1716 left2.
world().gop.fence();
1722 template <
typename L,
typename R,std::
size_t NDIM>
1723 Function<TENSOR_RESULT_TYPE(L,R),NDIM>
1732 template <
typename L,
typename R,std::
size_t NDIM>
1733 Function<TENSOR_RESULT_TYPE(L,R),NDIM>
1741 template<
typename T, std::
size_t NDIM>
1757 template <
typename L,
typename R, std::
size_t NDIM>
1758 Function<TENSOR_RESULT_TYPE(L,R), NDIM>
1771 return add(left,right,
true);
1776 template <
typename L,
typename R,std::
size_t NDIM>
1777 Function<TENSOR_RESULT_TYPE(L,R),NDIM>
1787 template <
typename L,
typename R, std::
size_t NDIM>
1788 Function<TENSOR_RESULT_TYPE(L,R), NDIM>
1799 return sub(left,right,
true);
1805 template <
typename T, std::
size_t NDIM>
1809 return result.
square(
true);
1813 template <
typename T,
int NDIM>
1817 return result.
abs(
true);
1821 template <
typename T,
int NDIM>
1834 template <
typename T, std::
size_t NDIM>
1837 bool fence =
true) {
1849 template <
typename T, std::
size_t NDIM>
1864 template <
typename T,
typename Q, std::
size_t NDIM>
1878 template <
typename T, std::
size_t NDIM>
1895 template <
typename opT,
typename T, std::
size_t LDIM>
1896 Function<TENSOR_RESULT_TYPE(typename opT::opT,T), LDIM+LDIM>
1916 result.get_impl()->reset_timer();
1920 result.get_impl()->recursive_apply(op, f1.
get_impl().get(),f2.
get_impl().get(),
true);
1922 result.get_impl()->print_timer();
1925 result.get_impl()->finalize_apply(
true);
1927 if (op.modified()) {
1928 result.get_impl()->trickle_down(
true);
1930 result.reconstruct();
1940 template <
typename opT,
typename R, std::
size_t NDIM>
1941 Function<TENSOR_RESULT_TYPE(typename opT::opT,R), NDIM>
1959 if (opT::opdim==6) {
1962 if (result.
world().rank()==0)
print(
"time in finlize_apply", time);
1973 template <
typename opT,
typename R, std::
size_t NDIM>
1974 Function<TENSOR_RESULT_TYPE(typename opT::opT,R), NDIM>
1985 if (opT::opdim==6) ff.
print_size(
"ff in apply after reconstruct");
1987 if (op.modified()) {
1990 ff.
get_impl()->make_redundant(
true);
1992 ff.
get_impl()->undo_redundant(
false);
1993 result.
get_impl()->trickle_down(
true);
2002 if (op.is_slaterf12) ftrace=f.
trace();
2008 if (opT::opdim==6) fff.
print_size(
"ff in apply after nonstandard");
2009 if ((opT::opdim==6) and (f.
world().rank()==0)) {
2010 fff.
get_impl()->timer_filter.print(
"filter");
2011 fff.
get_impl()->timer_compress_svd.print(
"compress_svd");
2016 if (op.destructive()) {
2017 ff.
world().gop.fence();
2022 if (op.is_slaterf12) result=(result-ftrace).
scale(-0.5/op.mu());
2025 if (opT::opdim==6) result.
print_size(
"result after reconstruction");
2030 template <
typename opT,
typename R, std::
size_t NDIM>
2031 Function<TENSOR_RESULT_TYPE(typename opT::opT,R), NDIM>
2057 template <
typename T, std::
size_t NDIM>
2071 template <
typename T, std::
size_t NDIM>
2077 std::vector<long> map(
NDIM);
2080 if (symmetry==
"sy_particle") {
2081 map[0]=3; map[1]=4; map[2]=5;
2082 map[3]=0; map[4]=1; map[5]=2;
2083 }
else if (symmetry==
"cx") {
2084 map[0]=0; map[1]=2; map[2]=1;
2085 map[3]=3; map[4]=5; map[5]=4;
2087 }
else if (symmetry==
"cy") {
2088 map[0]=2; map[1]=1; map[2]=0;
2089 map[3]=5; map[4]=4; map[5]=3;
2091 }
else if (symmetry==
"cz") {
2092 map[0]=1; map[1]=0; map[2]=2;
2093 map[3]=4; map[4]=3; map[5]=5;
2096 if (f.
world().rank()==0) {
2097 print(
"unknown parameter in symmetrize:",symmetry);
2102 result.
mapdim(f,map,
true);
2115 template<
typename T, std::
size_t NDIM, std::
size_t LDIM>
2130 result.
world().gop.fence();
2133 result.
world().gop.fence();
2137 result.
world().gop.fence();
2144 result.
world().gop.fence();
2146 result.
get_impl()->multiply(fimpl,gimpl,particle);
2147 result.
world().gop.fence();
2160 template <
typename T, std::
size_t NDIM>
2178 template <
typename T,
typename R, std::
size_t NDIM>
2184 template <
typename T,
typename R, std::
size_t NDIM>
2185 typename IsSupported<TensorTypeData<R>, Function<TENSOR_RESULT_TYPE(T,R),NDIM> >::type
2187 return (f*R(1.0)).add_scalar(r);
2190 template <
typename T,
typename R, std::
size_t NDIM>
2191 typename IsSupported<TensorTypeData<R>, Function<TENSOR_RESULT_TYPE(T,R),NDIM> >::type
2193 return (f*R(1.0)).add_scalar(r);
2196 template <
typename T,
typename R, std::
size_t NDIM>
2197 typename IsSupported<TensorTypeData<R>, Function<TENSOR_RESULT_TYPE(T,R),NDIM> >::type
2199 return (f*R(1.0)).add_scalar(-r);
2202 template <
typename T,
typename R, std::
size_t NDIM>
2203 typename IsSupported<TensorTypeData<R>, Function<TENSOR_RESULT_TYPE(T,R),NDIM> >::type
2205 return (f*R(-1.0)).add_scalar(r);
2209 template <std::
size_t NDIM>
2219 template <std::
size_t NDIM>
2229 template <std::
size_t NDIM>
2233 Tensor<double> r =
abs(t);
2242 template <std::
size_t NDIM>
2248 template <std::
size_t NDIM>
2254 template <std::
size_t NDIM>
2266 template <
class T, std::
size_t NDIM>
2273 template <
class T, std::
size_t NDIM>
2291 #endif // MADNESS_MRA_MRA_H__INCLUDED
MADNESS_ASSERT(is_compressed())
void unaryop(const opT &op, bool fence=true)
Inplace unary operation on function values.
Definition: mra.h:849
T operator()(const coordT &xuser) const
Evaluates the function at a point in user coordinates. Collective operation.
Definition: mra.h:370
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > func
Definition: mra.h:1271
SimpleUnaryOpWrapper(T(*f)(T))
Definition: mra.h:832
WorldGopInterface & gop
Global operations.
Definition: worldfwd.h:462
Function< TENSOR_RESULT_TYPE(L, R), NDIM > operator+(const Function< L, NDIM > &left, const Function< R, NDIM > &right)
Adds two functions with the new result being of type TensorResultType
Definition: mra.h:1759
bool is_initialized() const
Returns true if the function is initialized.
Definition: mra.h:146
void vtransform(const std::vector< Function< R, NDIM > > &v, const Tensor< Q > &c, std::vector< Function< T, NDIM > > &vresult, double tol, bool fence=true)
sparse transformation of a vector of functions ... private
Definition: mra.h:1460
Definition: shared_ptr_bits.h:38
IsSupported< TensorTypeData< Q >, Function< T, NDIM > >::type & operator*=(const Q q)
Inplace scaling by a constant.
Definition: mra.h:984
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:1742
Function< T, NDIM > & fill_tree(const opT &op, bool fence=true)
With this being an on-demand function, fill the MRA tree according to different criteria.
Definition: mra.h:1077
bool autorefine() const
Returns value of autorefine flag. No communication.
Definition: mra.h:523
T norm(Vector< T, N > v)
Compute norm of a Vector.
Definition: array.h:447
double imag(double x)
Definition: complexfun.h:56
Function< T, NDIM > & truncate(double tol=0.0, bool fence=true)
Truncate the function with optional fence. Compresses with fence if not compressed.
Definition: mra.h:577
Header to declare stuff which has not yet found a home.
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:175
void serialize(Archive &ar)
Definition: mra.h:2226
Void gaxpy_ext(const Function< L, NDIM > &left, T(*f)(const coordT &), T alpha, T beta, double tol, bool fence=true) const
Definition: mra.h:1249
Tensor< T > eval_cube(const Tensor< double > &cell, const std::vector< long > &npt, bool eval_refine=false) const
Evaluates a cube/slice of points (probably for plotting) ... collective but no fence necessary...
Definition: mra.h:329
TENSOR_RESULT_TYPE(T, R) inner_local(const Function<R
Returns local part of inner product ... throws if both not compressed.
T inner_ext(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine=true, const bool keep_redundant=false) const
Definition: mra.h:1233
const int NDIM
Definition: tdse1.cc:44
Function< T, NDIM > & gaxpy_oop(T alpha, const Function< L, NDIM > &left, T beta, const Function< R, NDIM > &right, bool fence)
This is replaced with alpha*left + beta*right ... private.
Definition: mra.h:1471
Function(const Function< T, NDIM > &f)
Copy constructor is shallow. No communication, works in either basis.
Definition: mra.h:164
An archive for storing local or parallel data wrapping BinaryFstreamOutputArchive.
Definition: parar.h:241
Future< T > eval(const coordT &xuser) const
Evaluates the function at a point in user coordinates. Possible non-blocking comm.
Definition: mra.h:185
void startup(World &world, int argc, char **argv)
Definition: startup.cc:44
const Function< T, NDIM > & compress(bool fence=true) const
Compresses the function, transforming into wavelet basis. Possible non-blocking comm.
Definition: mra.h:683
void load(World &world, Archive &ar)
Replaces this function with one loaded from an archive using the default processor map...
Definition: mra.h:1324
const std::shared_ptr< FunctionImpl< T, NDIM > > & get_impl() const
Returns a shared-pointer to the implementation.
Definition: mra.h:589
Provides typedefs to hide use of templates and to increase interoperability.
const mpreal dim(const mpreal &a, const mpreal &b, mp_rnd_t rnd_mode)
Definition: mpreal.h:2201
T inner_ext_local(T(*f)(const coordT &), const bool leaf_refine=true, const bool keep_redundant=false) const
Definition: mra.h:1183
Implements ParallelInputArchive and ParallelOutputArchive.
const double L
Definition: 3dharmonic.cc:123
void nonstandard(bool keepleaves, bool fence=true)
Compresses the function retaining scaling function coeffs. Possible non-blocking comm.
Definition: mra.h:701
void serialize(Archive &ar)
Definition: mra.h:2237
void mul_on_demand(const Function< L, NDIM > &f, const Function< R, NDIM > &g, bool fence=true)
Same as operator* but with optional fence and no automatic reconstruction.
Definition: mra.h:1442
::std::string string
Definition: gtest-port.h:872
Function< T, NDIM > & fill_tree(bool fence=true)
With this being an on-demand function, fill the MRA tree according to different criteria.
Definition: mra.h:1090
void set_autorefine(bool value, bool fence=true)
Sets the value of the autorefine flag. Optional global fence.
Definition: mra.h:533
returns true if the result of a hartree_product is a leaf node (compute norm & error) ...
Definition: funcimpl.h:493
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition: mra.h:138
T operator()(double x, double y=0, double z=0, double xx=0, double yy=0, double zz=0) const
Evaluates the function at a point in user coordinates. Collective operation.
Definition: mra.h:384
void serialize(Archive &ar)
Definition: mra.h:2216
double check_symmetry() const
check symmetry of a function by computing the 2nd derivative
Definition: mra.h:1496
Definition: type_data.h:150
double err(const funcT &func) const
Returns an estimate of the difference ||this-func|| ... global sum performed.
Definition: mra.h:439
static void doconj(const Key< NDIM >, Tensor< T > &t)
Definition: mra.h:877
void refine_to_common_level(std::vector< Function< T, NDIM > > &vf, bool fence=true)
Refine vector of functions down to common finest level (reconstructs as necessary, optional fence)
Definition: mra.h:1386
double resultT
Definition: mra.h:2211
Function< TENSOR_RESULT_TYPE(typename opT::opT, R), NDIM > apply_1d_realspace_push(const opT &op, const Function< R, NDIM > &f, int axis, bool fence=true)
Definition: mra.h:2032
Objects that implement their own parallel archive interface should derive from this.
Definition: parar.h:52
FunctionImpl< T, NDIM > implT
Definition: mra.h:135
Function< T, NDIM > & fill_tree(const Function< R, NDIM > &g, bool fence=true)
With this being an on-demand function, fill the MRA tree according to different criteria.
Definition: mra.h:1060
returns true if the function has a leaf node at key (works only locally)
Definition: funcimpl.h:434
NDIM & f
Definition: mra.h:2179
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:1942
Function< T, NDIM > & add_scalar(T t, bool fence=true)
Inplace add scalar. No communication except for optional fence.
Definition: mra.h:906
void verify_tree() const
Verifies the tree data structure ... global sync implied.
Definition: mra.h:452
Declaration and initialization of tree traversal functions and generic derivative.
void serialize(Archive &ar)
Definition: mra.h:836
Provides FunctionDefaults and utilities for coordinate transformation.
static const double & get_thresh()
Returns the default threshold.
Definition: funcdefaults.h:225
static std::vector< std::shared_ptr< FunctionImpl< Q, D > > > vimpl(const std::vector< Function< Q, D > > &v)
Returns vector of FunctionImpl pointers corresponding to vector of functions.
Definition: mra.h:1378
Function< T, KDIM+LDIM > hartree_product(const Function< T, KDIM > &left2, const Function< T, LDIM > &right2)
Performs a Hartree product on the two given low-dimensional functions.
Definition: mra.h:1657
void set_functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > functor)
Replace the current functor with the provided new one.
Definition: mra.h:606
void set_thresh(double value, bool fence=true)
Sets the vaule of the truncation threshold. Optional global fence.
Definition: mra.h:552
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:1734
bool operator()(implT *impl, const Key< NDIM > &key, const nodeT &t) const
Definition: mra.h:766
Default store of a thingy via serialize(ar,t)
Definition: archive.h:708
bool is_on_demand() const
Definition: mra.h:611
void operator()(const Key< NDIM > &key, Tensor< T > &t) const
Definition: mra.h:833
Function< T, NDIM > & scale(const Q q, bool fence=true)
Inplace, scale the function by a constant. No communication except for optional fence.
Definition: mra.h:896
std::size_t tree_size() const
Returns the number of nodes in the function tree ... collective global sum.
Definition: mra.h:471
const double beta
Definition: gygi_soltion.cc:63
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition: funcdefaults.h:48
This header should include pretty much everything needed for the parallel runtime.
T inner(const vecfunc< T, NDIM > &a, const vecfunc< T, NDIM > &b)
the non-linear solver requires an inner product
Definition: nemo.h:112
#define PROFILE_MEMBER_FUNC(classname)
Definition: worldprofile.h:199
Function< T, NDIM > & reduce_rank(const bool fence=true)
reduce the rank of the coefficient tensors
Definition: mra.h:1510
Function< T, NDIM > & operator-=(const Function< Q, NDIM > &other)
Inplace subtraction of functions in the wavelet basis.
Definition: mra.h:963
Provides FunctionCommonData, FunctionImpl and FunctionFactory.
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:2255
void do_hartree_product(const FunctionImpl< T, LDIM > *left, const FunctionImpl< T, KDIM > *right, const opT *op)
perform the hartree product of f*g, invoked by result
Definition: mra.h:1103
return impl inner_local * g())
Defines and implements most of Tensor.
FunctionFactory & fence(bool fence=true)
Definition: function_factory.h:217
T inner_ext(T(*f)(const coordT &), const bool leaf_refine=true, const bool keep_redundant=false) const
Definition: mra.h:1199
Function< T, NDIM > conj(bool fence=true)
Inplace complex conjugate. No communication except for optional fence.
Definition: mra.h:885
Implements most functionality of separated operators.
FunctionFactory & empty()
Definition: function_factory.h:192
World & world() const
Returns the world.
Definition: mra.h:622
Function< T, NDIM > & operator+=(const Function< Q, NDIM > &other)
Inplace addition of functions in the wavelet basis.
Definition: mra.h:943
Function< T, NDIM > & abs(bool fence=true)
Returns *this for chaining.
Definition: mra.h:1003
T * get() const
Definition: shared_ptr_bits.h:485
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition: mra.h:2222
Function< T, NDIM > & multiop_values(const opT &op, const std::vector< Function< T, NDIM > > &vf)
This is replaced with op(vector of functions) ... private.
Definition: mra.h:1407
leaf_op< T, NDIM > fnode_is_leaf(this->get_impl().get())
double norm2() const
Returns the 2-norm of the function ... global sum ... works in either basis.
Definition: mra.h:650
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
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:1865
Defines operations on vectors of FunctionsThis file defines a number of operations on vectors of func...
Function< T, NDIM > & abs_square(bool fence=true)
Returns *this for chaining.
Definition: mra.h:1012
int k() const
Returns the number of multiwavelets (k). No communication.
Definition: mra.h:561
Function< typename opT::resultT, NDIM > & unary_op_coeffs(const Function< Q, NDIM > &func, const opT &op, bool fence)
This is replaced with left*right ... private.
Definition: mra.h:1365
void reconstruct(bool fence=true) const
Reconstructs the function, transforming into scaling function basis. Possible non-blocking comm...
Definition: mra.h:737
Definition: funcimpl.h:557
FunctionFactory< T, NDIM > factoryT
Definition: mra.h:137
void clear(bool fence=true)
Clears the function as if constructed uninitialized. Optional fence.
Definition: mra.h:799
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:1835
T trace() const
Returns global value of int(f(x),x) ... global comm required.
Definition: mra.h:1034
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:1778
void unaryop_coeff(const opT &op, bool fence=true)
Unary operation applied inplace to the coefficients.
Definition: mra.h:859
void refine_general(const opT &op, bool fence=true) const
Inplace autorefines the function. Optional fence. Possible non-blocking comm.
Definition: mra.h:757
T(* f)(T)
Definition: mra.h:831
void set_impl(const Function< R, NDIM > &f, bool zero=true)
Replace current FunctionImpl with a new one using the same parameters & map as f. ...
Definition: mra.h:617
~Function()
Destruction of any underlying implementation is deferred to next global fence.
Definition: mra.h:177
T inner_ext_local(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > f, const bool leaf_refine=true, const bool keep_redundant=false) const
Definition: mra.h:1217
This class is used to specify boundary conditions for all operatorsExterior boundary conditions (i...
Definition: funcdefaults.h:72
Default load of a thingy via serialize(ar,t)
Definition: archive.h:718
#define UNARY_OPTIMIZED_ITERATOR(X, x, exp)
Definition: tensor_macros.h:658
TensorArgs holds the arguments for creating a LowRankTensor.
Definition: gentensor.h:127
std::size_t max_nodes() const
Returns the max number of nodes on a processor.
Definition: mra.h:500
Function< T, NDIM > & operator=(const Function< T, NDIM > &f)
Assignment is shallow. No communication, works in either basis.
Definition: mra.h:170
static void store(const ParallelOutputArchive &ar, const Function< T, NDIM > &f)
Definition: mra.h:2275
bool & is_on_demand()
Definition: mraimpl.h:269
tensorT sqrt(const tensorT &s, double tol=1e-8)
Computes matrix square root (not used any more?)
Definition: DFcode/moldft.cc:446
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
void fence()
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition: worldgop.cc:52
Function< T, NDIM > & square(bool fence=true)
Inplace squaring of function ... global comm only if not reconstructed.
Definition: mra.h:994
void verify() const
Asserts that the function is initialized.
Definition: mra.h:141
void print_info() const
Print a summary of the load balancing info.
Definition: mra.h:825
void refine(bool fence=true)
Inplace autorefines the function using same test as for squaring.
Definition: mra.h:774
return local
Definition: mra.h:1172
A multiresolution adaptive numerical function.
Definition: derivative.h:61
void unaryop_node(const opT &op, bool fence=true)
Unary operation applied inplace to the nodes.
Definition: mra.h:869
int Level
Definition: key.h:58
NDIM &g const
Definition: mra.h:1046
void print_size(const std::string name) const
print some info about this
Definition: mra.h:478
const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap() const
Returns a shared pointer to the process map.
Definition: mra.h:630
void broaden(const BoundaryConditions< NDIM > &bc=FunctionDefaults< NDIM >::get_bc(), bool fence=true) const
Inplace broadens support in scaling function basis.
Definition: mra.h:779
void vmulXX(const Function< L, NDIM > &left, const std::vector< Function< R, NDIM > > &right, std::vector< Function< T, NDIM > > &result, double tol, bool fence)
Multiplication of function * vector of functions using recursive algorithm of mulxx.
Definition: mra.h:1419
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition: derivative.h:58
double errsq_local(const funcT &func) const
Returns an estimate of the difference ||this-func||^2 from local data.
Definition: mra.h:424
Abstract base class interface required for functors used as input to Functions.
Definition: function_interface.h:58
Function< typename opT::resultT, NDIM > unary_op(const Function< Q, NDIM > &func, const opT &op, bool fence=true)
Out of place application of unary operation to function values with optional fence.
Definition: mra.h:1607
void store(Archive &ar) const
Stores the function to an archive.
Definition: mra.h:1345
std::size_t max_local_depth() const
Returns the maximum local depth of the function tree ... no communications.
Definition: mra.h:492
double real(double x)
Definition: complexfun.h:52
World * get_world() const
Returns pointer to the world.
Definition: parar.h:98
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 alread...
Definition: mra.h:1569
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition: mra.h:2212
void print_tree_graphviz(std::ostream &os=std::cout) const
Process 0 prints a graphviz-formatted output of all nodes in the tree (collective) ...
Definition: mra.h:815
void reset()
Definition: shared_ptr_bits.h:459
void set_impl(const std::shared_ptr< FunctionImpl< T, NDIM > > &impl)
Replace current FunctionImpl with provided new one.
Definition: mra.h:596
Function< TENSOR_RESULT_TYPE(Q, T), NDIM > operator*(const Function< T, NDIM > &f, const Q alpha)
Returns new function equal to f(x)*alpha.
Definition: mra.h:1553
double resultT
Definition: mra.h:2221
double norm2sq_local() const
Returns the square of the norm of the local function ... no communication.
Definition: mra.h:640
Definition: funcimpl.h:603
impl world gop sum(local)
remote_refT remote_ref(World &world) const
Returns a structure used to pass references to another process.
Definition: worldfut.h:552
if(VERIFY_TREE) verify_tree()
const double delta
Definition: dielectric_external_field.cc:120
Tensor< T > coeffs_for_jun(Level n, long mode=0)
Get the scaling function coeffs at level n starting from NS form.
Definition: mra.h:788
void change_tensor_type(const TensorArgs &targs, bool fence=true)
change the tensor type of the coefficients in the FunctionNode
Definition: mra.h:1357
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition: mra.h:515
Implements (2nd generation) static load/data balancing for functions.
Defines/implements plotting interface for functions.
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:924
Implements WorldContainer.
Function< TENSOR_RESULT_TYPE(L, R), NDIM > operator-(const Function< L, NDIM > &left, const Function< R, NDIM > &right)
Subtracts two functions with the new result being of type TensorResultType
Definition: mra.h:1789
A future is a possibly yet unevaluated value.
Definition: ref.h:210
A type you can return when you want to return void ... use "return None".
Definition: typestuff.h:154
Future< Level > evaldepthpt(const coordT &xuser) const
Definition: mra.h:251
std::size_t min_nodes() const
Returns the min number of nodes on a processor.
Definition: mra.h:507
void unaryop(T(*f)(T))
Inplace unary operation on function values.
Definition: mra.h:840
Function()
Default constructor makes uninitialized function. No communication.
Definition: mra.h:153
void sum_down(bool fence=true) const
Sums scaling coeffs down tree restoring state with coeffs only at leaves. Optional fence...
Definition: mra.h:746
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
Interface to be provided by any process map.
Definition: worlddc.h:64
const T1 & f1
Definition: gtest-tuple.h:680
void print(const A &a)
Print a single item to std::cout terminating with new line.
Definition: print.h:122
void print_tree(std::ostream &os=std::cout) const
Process 0 prints a summary of all nodes in the tree (collective)
Definition: mra.h:809
Function< T, NDIM > project(const Function< T, NDIM > &other, int k=FunctionDefaults< NDIM >::get_k(), double thresh=FunctionDefaults< NDIM >::get_thresh(), bool fence=true)
Definition: mra.h:2162
void serialize(Archive &ar)
Definition: mra.h:770
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
void norm_tree(bool fence=true) const
Initializes information about the function norm at all length scales.
Definition: mra.h:663
void standard(bool fence=true)
Converts the function from nonstandard form to standard form. Possible non-blocking comm...
Definition: mra.h:718
double thresh() const
Returns value of truncation threshold. No communication.
Definition: mra.h:542
Multidimension Key for MRA tree and associated iterators.
Future< long > evalR(const coordT &xuser) const
Evaluates the function rank at a point in user coordinates. Possible non-blocking comm...
Definition: mra.h:288
void do_hartree_product(const FunctionImpl< T, LDIM > *left, const FunctionImpl< T, KDIM > *right)
perform the hartree product of f*g, invoked by result
Definition: mra.h:1115
Tensor< double > operator()(const Key< NDIM > &key, const Tensor< double_complex > &t) const
Definition: mra.h:2232
const T1 const T2 & f2
Definition: gtest-tuple.h:680
double resultT
Definition: mra.h:2231
Function< T, NDIM > symmetrize(const Function< T, NDIM > &f, const std::string symmetry, bool fence=true)
symmetrize a function
Definition: mra.h:2073
FunctionFactory implements the named-parameter idiom for Function.
Definition: funcimpl.h:70
bool autorefine_square_test(const keyT &key, const nodeT &t) const
Returns true if this block of coeffs needs autorefining.
Definition: mraimpl.h:953
std::pair< bool, T > eval_local_only(const Vector< double, NDIM > &xuser, Level maxlevel) const
Evaluate function only if point is local returning (true,value); otherwise return (false...
Definition: mra.h:219
void undo_redundant(const bool fence)
convert this from redundant to standard reconstructed form
Definition: mraimpl.h:1504
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:2116
FunctionNode< T, NDIM > nodeT
Definition: mra.h:136
returns true if the node is well represented compared to its parent
Definition: funcimpl.h:456
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
Function< T, NDIM > apply(const Derivative< T, NDIM > &D, const Function< T, NDIM > &f, bool fence=true)
Applies derivative operator to function (for syntactic equivalence to integral operator apply) ...
Definition: derivative.h:613
const double c
Definition: gfit.cc:200
T trace_local() const
Returns local contribution to int(f(x),x) ... no communication.
Definition: mra.h:1025
std::size_t max_depth() const
Returns the maximum depth of the function tree ... collective global sum.
Definition: mra.h:484
Function< TENSOR_RESULT_TYPE(T, R), NDIM-LDIM > project_out(const Function< R, LDIM > &g, const int dim) const
project this on the low-dim function g: h(x) =
Definition: mra.h:1294
Function< TENSOR_RESULT_TYPE(L, R), NDIM > binary_op(const Function< L, NDIM > &left, const Function< R, NDIM > &right, const opT &op, bool fence=true)
Generate new function = op(left,right) where op acts on the function values.
Definition: mra.h:1593
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:69
Level depthpt(const coordT &xuser) const
Definition: mra.h:405
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:1528
bool is_compressed() const
Returns true if compressed, false otherwise. No communication.
Definition: mra.h:461
#define PROFILE_FUNC
Definition: worldprofile.h:198
Traits class to specify support of numeric types.
Definition: type_data.h:56
Function(const factoryT &factory)
Constructor from FunctionFactory provides named parameter idiom. Possible non-blocking communication...
Definition: mra.h:157
void make_redundant(const bool fence)
convert this to redundant, i.e. have sum coefficients on all levels
Definition: mraimpl.h:1485
Function< T, NDIM > & mapdim(const Function< T, NDIM > &f, const std::vector< long > &map, bool fence)
This is replaced with mapdim(f) ... private.
Definition: mra.h:1485