33 #ifndef MADNESS_MRA_VMRA_H__INCLUDED 
   34 #define MADNESS_MRA_VMRA_H__INCLUDED 
  129     template <
typename T, std::
size_t NDIM>
 
  135         bool must_fence = 
false;
 
  136         for (
unsigned int i=0; i<v.size(); ++i) {
 
  137             if (!v[i].is_compressed()) {
 
  138                 v[i].compress(
false);
 
  143         if (fence && must_fence) world.
gop.
fence();
 
  148     template <
typename T, std::
size_t NDIM>
 
  153         bool must_fence = 
false;
 
  154         for (
unsigned int i=0; i<v.size(); ++i) {
 
  155             if (v[i].is_compressed()) {
 
  156                 v[i].reconstruct(
false);
 
  161         if (fence && must_fence) world.
gop.
fence();
 
  166     template <
typename T, std::
size_t NDIM>
 
  172         for (
unsigned int i=0; i<v.size(); ++i) {
 
  173             v[i].nonstandard(
false,
false);
 
  180     template <
typename T, std::
size_t NDIM>
 
  185         for (
unsigned int i=0; i<v.size(); ++i) {
 
  186             v[i].standard(
false);
 
  193     template <
typename T, std::
size_t NDIM>
 
  202         for (
unsigned int i=0; i<v.size(); ++i) {
 
  203             v[i].truncate(tol, 
false);
 
  210     template <
typename T, std::
size_t NDIM>
 
  211     std::vector< Function<T,NDIM> >
 
  218         std::vector< Function<T,NDIM> > df(v.size());
 
  219         for (
unsigned int i=0; i<v.size(); ++i) {
 
  220             df[i] = D(v[i],
false);
 
  227     template <
typename T, std::
size_t NDIM>
 
  228     std::vector< Function<T,NDIM> >
 
  231         std::vector< Function<T,NDIM> > r(n);
 
  232         for (
int i=0; i<n; ++i)
 
  243     template <
typename T, 
typename R, std::
size_t NDIM>
 
  244     std::vector< Function<TENSOR_RESULT_TYPE(T,R),NDIM> >
 
  254         MADNESS_ASSERT(n==c.dim(0));
 
  256         std::vector< Function<resultT,NDIM> > vc = zero_functions<resultT,NDIM>(world, 
m);
 
  260         for (
int i=0; i<
m; ++i) {
 
  261             for (
int j=0; j<n; ++j) {
 
  262                 if (
c(j,i) != 
R(0.0)) vc[i].gaxpy(1.0,v[j],
c(j,i),
false);
 
  266         if (fence) world.gop.fence();
 
  271     template <
typename L, 
typename R, std::
size_t NDIM>
 
  272     std::vector< Function<TENSOR_RESULT_TYPE(L,R),NDIM> >
 
  275         MADNESS_ASSERT(v.size() == (
unsigned int)(c.dim(0)));
 
  277         std::vector< Function<TENSOR_RESULT_TYPE(L,R),NDIM> > vresult(c.dim(1));
 
  278         for (
int i=0; i<c.dim(1); ++i) {
 
  284         vresult[0].vtransform(v, c, vresult, tol, fence);
 
  289     template <
typename T, 
typename Q, std::
size_t NDIM>
 
  292                const std::vector<Q>& factors,
 
  295         for (
unsigned int i=0; i<v.size(); ++i) v[i].
scale(factors[i],
false);
 
  300     template <
typename T, 
typename Q, std::
size_t NDIM>
 
  306         for (
unsigned int i=0; i<v.size(); ++i) v[i].
scale(factor,
false);
 
  311     template <
typename T, std::
size_t NDIM>
 
  315         std::vector<double> norms(v.size());
 
  316         for (
unsigned int i=0; i<v.size(); ++i) norms[i] = v[i].norm2sq_local();
 
  317         world.
gop.
sum(&norms[0], norms.size());
 
  318         for (
unsigned int i=0; i<v.size(); ++i) norms[i] = 
sqrt(norms[i]);
 
  324     template <
typename T, std::
size_t NDIM>
 
  328         std::vector<double> norms(v.size());
 
  329         for (
unsigned int i=0; i<v.size(); ++i) norms[i] = v[i].norm2sq_local();
 
  330         world.
gop.
sum(&norms[0], norms.size());
 
  331         for (
unsigned int i=1; i<v.size(); ++i) norms[0] += norms[i];
 
  333         return sqrt(norms[0]);
 
  383     template <
typename T, 
typename R, std::
size_t NDIM>
 
  389         long n=
f.size(), 
m=
g.size();
 
  390         Tensor< TENSOR_RESULT_TYPE(T,R) > r(n,
m);
 
  391         if (sym) MADNESS_ASSERT(n==
m);
 
  397          for (
long i=0; i<n; ++i) {
 
  400              for (
long j=0; j<jtop; ++j) {
 
  401                  r(i,j) = 
f[i].inner_local(
g[j]);
 
  402                  if (sym) r(j,i) = 
conj(r(i,j));
 
  425     template <
typename T, 
typename R, std::
size_t NDIM>
 
  430         long n=
f.size(), 
m=
g.size();
 
  431         MADNESS_ASSERT(n==
m);
 
  432         Tensor< TENSOR_RESULT_TYPE(T,R) > r(n);
 
  437         for (
long i=0; i<n; ++i) {
 
  438             r(i) = 
f[i].inner_local(
g[i]);
 
  449     template <
typename T, 
typename R, std::
size_t NDIM>
 
  455         Tensor< TENSOR_RESULT_TYPE(T,R) > r(n);
 
  460         for (
long i=0; i<n; ++i) {
 
  461             r(i) = f.inner_local(
g[i]);
 
  472     template <
typename T, 
typename R, std::
size_t NDIM>
 
  473     std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  482         return vmulXX(a, v, 0.0, fence);
 
  486     template <
typename T, 
typename R, std::
size_t NDIM>
 
  487     std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  497         for (
unsigned int i=0; i<v.size(); ++i) {
 
  498             v[i].norm_tree(
false);
 
  501         return vmulXX(a, v, tol, fence);
 
  505     template <
typename T, std::
size_t NDIM>
 
  511         for (
unsigned int i=0; i<v.size(); ++i) {
 
  512             v[i].norm_tree(
false);
 
  518     template <
typename T, 
typename R, std::
size_t NDIM>
 
  519     std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  529         std::vector< Function<TENSOR_RESULT_TYPE(T,R),NDIM> > q(
a.size());
 
  530         for (
unsigned int i=0; i<
a.size(); ++i) {
 
  531             q[i] = 
mul(
a[i], 
b[i], 
false);
 
  539     template <
typename T, std::
size_t NDIM>
 
  540     std::vector< Function<T,NDIM> >
 
  544         return mul<T,T,NDIM>(world, v, v, fence);
 
  555     template <
typename T, std::
size_t NDIM>
 
  557         for (
unsigned int j=0; j<v.size(); ++j) {
 
  558             v[j].set_thresh(thresh,
false);
 
  564     template <
typename T, std::
size_t NDIM>
 
  565     std::vector< Function<T,NDIM> >
 
  570         std::vector< Function<T,NDIM> > r = 
copy(world, v); 
 
  571         for (
unsigned int i=0; i<v.size(); ++i) {
 
  580     template <
typename T, std::
size_t NDIM>
 
  581     std::vector< Function<T,NDIM> >
 
  586         std::vector< Function<T,NDIM> > r(v.size());
 
  587         for (
unsigned int i=0; i<v.size(); ++i) {
 
  588             r[i] = 
copy(v[i], 
false);
 
  595     template <
typename T, std::
size_t NDIM>
 
  596     std::vector< Function<T,NDIM> >
 
  599          const unsigned int n,
 
  602         std::vector< Function<T,NDIM> > r(n);
 
  603         for (
unsigned int i=0; i<n; ++i) {
 
  604             r[i] = 
copy(v, 
false);
 
  611     template <
typename T, 
typename R, std::
size_t NDIM>
 
  612     std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  618         MADNESS_ASSERT(
a.size() == 
b.size());
 
  622         std::vector< Function<TENSOR_RESULT_TYPE(T,R),NDIM> > r(
a.size());
 
  623         for (
unsigned int i=0; i<
a.size(); ++i) {
 
  624             r[i] = 
add(
a[i], 
b[i], 
false);
 
  631     template <
typename T, 
typename R, std::
size_t NDIM>
 
  632     std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  641         std::vector< Function<TENSOR_RESULT_TYPE(T,R),NDIM> > r(
b.size());
 
  642         for (
unsigned int i=0; i<
b.size(); ++i) {
 
  643             r[i] = 
add(a, 
b[i], 
false);
 
  648     template <
typename T, 
typename R, std::
size_t NDIM>
 
  649     inline std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  654         return add(world, a, 
b, fence);
 
  658     template <
typename T, 
typename R, std::
size_t NDIM>
 
  659     std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  665         MADNESS_ASSERT(
a.size() == 
b.size());
 
  669         std::vector< Function<TENSOR_RESULT_TYPE(T,R),NDIM> > r(
a.size());
 
  670         for (
unsigned int i=0; i<
a.size(); ++i) {
 
  671             r[i] = 
sub(
a[i], 
b[i], 
false);
 
  679     template <
typename T, 
typename Q, 
typename R, std::
size_t NDIM>
 
  687         MADNESS_ASSERT(
a.size() == 
b.size());
 
  691         for (
unsigned int i=0; i<
a.size(); ++i) {
 
  692             a[i].gaxpy(alpha, 
b[i], beta, 
false);
 
  699     template <
typename opT, 
typename R, std::
size_t NDIM>
 
  700     std::vector< Function<TENSOR_RESULT_TYPE(typename opT::opT,R), NDIM> >
 
  706         MADNESS_ASSERT(
f.size()==
op.size());
 
  708         std::vector< Function<R,NDIM> >& ncf = *
const_cast< std::vector< Function<R,NDIM> 
>* >(&
f);
 
  713         std::vector< Function<TENSOR_RESULT_TYPE(typename opT::opT,R), NDIM> > result(
f.size());
 
  714         for (
unsigned int i=0; i<
f.size(); ++i) {
 
  715             MADNESS_ASSERT(not 
op[i]->is_slaterf12);
 
  730     template <
typename T, 
typename R, std::
size_t NDIM>
 
  731     std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> >
 
  737         std::vector< Function<R,NDIM> >& ncf = *
const_cast< std::vector< Function<R,NDIM> 
>* >(&
f);
 
  742         std::vector< Function<TENSOR_RESULT_TYPE(T,R), NDIM> > result(
f.size());
 
  743         for (
unsigned int i=0; i<
f.size(); ++i) {
 
  754             for (
unsigned int i=0; i<
f.size(); ++i) {
 
  755                 double trace=
f[i].trace();
 
  756                 result[i]=(result[i]-trace).
scale(-0.5/op.
mu());
 
  764     template <
typename T, std::
size_t NDIM>
 
  767         std::vector<double> nn = 
norm2s(world, v);
 
  768         for (
unsigned int i=0; i<v.size(); ++i) v[i].
scale(1.0/nn[i],
false);
 
  773     template <
typename T, std::
size_t NDIM>
 
  776         if (v.empty()) 
return 0.0;
 
  778         const double d=
sizeof(
T);
 
  779         const double fac=1024*1024*1024;
 
  782         for(
unsigned int i=0;i<v.size();i++){
 
  791 #endif // MADNESS_MRA_VMRA_H__INCLUDED 
void matrix_inner(DistributedMatrix< T > &A, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< T, NDIM > > &g, bool sym=false)
Definition: chem/distpm.cc:38
 
WorldGopInterface & gop
Global operations. 
Definition: worldfwd.h:462
 
Definition: shared_ptr_bits.h:38
 
void reconstruct(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Reconstruct a vector of functions. 
Definition: vmra.h:149
 
NDIM const Function< R, NDIM > & g
Definition: mra.h:2179
 
const double R
Definition: dielectric.cc:191
 
Main include file for MADNESS and defines Function interface. 
 
void gaxpy(World &world, Q alpha, std::vector< Function< T, NDIM > > &a, Q beta, const std::vector< Function< R, NDIM > > &b, bool fence=true)
Generalized A*X+Y for vectors of functions -— a[i] = alpha*a[i] + beta*b[i]. 
Definition: vmra.h:680
 
const Function< T, NDIM > & compress(bool fence=true) const 
Compresses the function, transforming into wavelet basis. Possible non-blocking comm. 
Definition: mra.h:683
 
Implements derivatives operators with variety of boundary conditions on simulation domain...
Definition: derivative.h:272
 
void truncate(World &world, std::vector< Function< T, NDIM > > &v, double tol=0.0, bool fence=true)
Truncates a vector of functions. 
Definition: vmra.h:194
 
void nonstandard(World &world, std::vector< Function< T, NDIM > > &v, bool fence=true)
Generates non-standard form of a vector of functions. 
Definition: vmra.h:167
 
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
 
Declaration and initialization of tree traversal functions and generic derivative. 
 
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
 
TENSOR_RESULT_TYPE(T, R) inner(const Function<T
Computes the scalar/inner product between two functions. 
 
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:506
 
const double beta
Definition: gygi_soltion.cc:63
 
T inner(const vecfunc< T, NDIM > &a, const vecfunc< T, NDIM > &b)
the non-linear solver requires an inner product 
Definition: nemo.h:112
 
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:312
 
bool is_slaterf12
Definition: operator.h:134
 
#define PROFILE_BLOCK(name)
Definition: worldprofile.h:197
 
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
 
void scale(World &world, std::vector< Function< T, NDIM > > &v, const std::vector< Q > &factors, bool fence=true)
Scales inplace a vector of functions by distinct values. 
Definition: vmra.h:290
 
void reconstruct(bool fence=true) const 
Reconstructs the function, transforming into scaling function basis. Possible non-blocking comm...
Definition: mra.h:737
 
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
 
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
 
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
 
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:1634
 
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:556
 
void sum(T *buf, size_t nelem)
Inplace global sum while still processing AM & tasks. 
Definition: worldgop.h:767
 
void standard(World &world, std::vector< Function< T, NDIM > > &v, bool fence=true)
Generates standard form of a vector of functions. 
Definition: vmra.h:181
 
tensorT sqrt(const tensorT &s, double tol=1e-8)
Computes matrix square root (not used any more?) 
Definition: DFcode/moldft.cc:446
 
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:1806
 
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
 
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions. 
Definition: vmra.h:325
 
A multiresolution adaptive numerical function. 
Definition: derivative.h:61
 
void fence()
Returns after all local tasks have completed. 
Definition: worldtask.h:1086
 
const double m
Definition: gfit.cc:199
 
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
 
WorldTaskQueue & taskq
Task queue. 
Definition: worldfwd.h:461
 
bool & destructive()
Definition: operator.h:161
 
double get_size(World &world, const std::vector< Function< T, NDIM > > &v)
Definition: vmra.h:774
 
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
 
void norm_tree(bool fence=true) const 
Initializes information about the function norm at all length scales. 
Definition: mra.h:663
 
const double & mu() const 
Definition: operator.h:165
 
FunctionFactory implements the named-parameter idiom for Function. 
Definition: funcimpl.h:70
 
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
 
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const DistributedMatrix< R > &c, bool fence=true)
Definition: chem/SCF.cc:86
 
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79
 
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:765
 
std::vector< Function< T, NDIM > > zero_functions(World &world, int n)
Generates a vector of zero functions. 
Definition: vmra.h:229
 
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
 
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:1879
 
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions. 
Definition: vmra.h:130