MADNESS 0.10.1
function_factory.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2007,2010 Oak Ridge National Laboratory
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30
31 $Id$
32 */
33
34/// \file function_factory.h
35/// Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces
36
37/// We provide an abstract base class FunctionFunctorInterface, of which we derive
38/// (as of now) the following classes:
39/// - ElementaryInterface (formerly FunctorInterfaceWrapper) to wrap elementary functions
40/// - ElectronRepulsionInterface to provide 1/r12, which is not elementarily accessible
41/// - CompositeFunctionInterface to provide on-demand coefficients of pair functions
42///
43/// Each of these Interfaces can be used in a FunctionFactory to set up a Function
44
45
46#ifndef MADNESS_MRA_FUNCTION_FACTORY_H__INCLUDED
47#define MADNESS_MRA_FUNCTION_FACTORY_H__INCLUDED
48
51#include <madness/mra/key.h>
54
55
56namespace madness {
57
58// needed for the CompositeFactory
59template<typename T, std::size_t NDIM>
60class FunctionImpl;
61
62template<typename T, std::size_t NDIM>
63class Function;
64
65template<typename T, std::size_t NDIM>
66Tensor<T> fcube(const Key<NDIM>&, T (*f)(const Vector<double, NDIM>&), const Tensor<double>&);
67
68template<typename T, std::size_t NDIM>
70
71
72/// FunctionFactory implements the named-parameter idiom for Function
73
74/// C++ does not provide named arguments (as does, e.g., Python).
75/// This class provides something very close. Create functions as follows
76/// \code
77/// double myfunc(const double x[]);
78/// Function<double,3> f = FunctionFactory<double,3>(world).f(myfunc).k(11).thresh(1e-9).debug()
79/// \endcode
80/// where the methods of function factory, which specify the non-default
81/// arguments eventually passed to the \c Function constructor, can be
82/// used in any order.
83///
84/// Need to add a general functor for initial projection with a standard interface.
85template<typename T, std::size_t NDIM>
87 friend class FunctionImpl<T, NDIM>;
88
89 typedef Vector<double, NDIM> coordT; ///< Type of vector holding coordinates
90protected:
92 int _k;
93 double _thresh;
96 std::vector<Vector<double, NDIM> > _special_points;
99 bool _refine;
100 bool _empty;
103 bool _fence;
104// bool _is_on_demand;
105// bool _compressed;
107 //Tensor<int> _bc;
108 std::shared_ptr<WorldDCPmapInterface<Key<NDIM> > > _pmap;
109
110private:
111 // need to keep this private, access only via get_functor();
112 // reason is that the functor must only be constructed when the actual
113 // FuncImpl is constructed, otherwise we might depend on the ordering
114 // of the chaining (specifically, if the functor is constructed before
115 // of after the threshold is changed)
116 std::shared_ptr<FunctionFunctorInterface<T, NDIM> > _functor;
117
118public:
119
121 _world(world),
124 _initial_level(FunctionDefaults<NDIM>::get_initial_level()),
125 _special_level(FunctionDefaults<NDIM>::get_special_level()),
126 _special_points(std::vector<Vector<double, NDIM> >()),
127 _max_refine_level(FunctionDefaults<NDIM>::get_max_refine_level()),
128 _truncate_mode(FunctionDefaults<NDIM>::get_truncate_mode()),
129 _refine(FunctionDefaults<NDIM>::get_refine()),
130 _empty(false),
131 _autorefine(FunctionDefaults<NDIM>::get_autorefine()),
132 _truncate_on_project(FunctionDefaults<NDIM>::get_truncate_on_project()),
133 _fence(true), // _bc(FunctionDefaults<NDIM>::get_bc()),
135 _pmap(FunctionDefaults<NDIM>::get_pmap()), _functor() {
136 }
137
138 virtual ~FunctionFactory() {};
139
141 functor(const std::shared_ptr<FunctionFunctorInterface<T, NDIM> >& f) {
142 _functor = f;
143 return self();
144 }
145
146 /// pass in a functor that is derived from FunctionFunctorInterface
147
148 /// similar to the first version of functor, but easy-to-use
149 /// FunctionFunctorInterface must be a public base of opT
150 template<typename opT>
151 typename std::enable_if<std::is_base_of<FunctionFunctorInterface<T, NDIM>, opT>::value,
153 _functor = std::shared_ptr<FunctionFunctorInterface<T, NDIM> >(new opT(op));
154 return self();
155 }
156
157 /// pass in a functor that is *not* derived from FunctionFunctorInterface
158
159 /// similar to the first version of functor, but easy-to-use
160 template<typename opT>
161 typename std::enable_if<not std::is_base_of<FunctionFunctorInterface<T, NDIM>, opT>::value,
163 _functor = std::shared_ptr<FunctionInterface<T, NDIM, opT> >
165 return self();
166 }
167
168 FunctionFactory& compressed(bool value = true) {
170 return self();
171 }
172
175 _functor.reset();
176 return self();
177 }
178
180 f(T (*f)(const coordT&)) {
183 return self();
184 }
185
186 virtual FunctionFactory& k(int k) {
187 _k = k;
188 return self();
189 }
190
191 virtual FunctionFactory& thresh(double thresh) {
192 _thresh = thresh;
193 return self();
194 }
195
201
207
213
219
225
227 refine(bool refine = true) {
228 _refine = refine;
229 return self();
230 }
231
233 norefine(bool norefine = true) {
234 _refine = !norefine;
235 return self();
236 }
237
240 _empty = true;
241 return self();
242 }
243
246 _autorefine = true;
247 return self();
248 }
249
252 _autorefine = false;
253 return self();
254 }
255
259 return self();
260 }
261
264 _truncate_on_project = false;
265 return self();
266 }
267
269 fence(bool fence = true) {
270 _fence = fence;
271 return self();
272 }
273
276 _fence = false;
277 return self();
278 }
279
280 virtual FunctionFactory&
283 return self();
284 }
285
287 pmap(const std::shared_ptr<WorldDCPmapInterface<Key<NDIM> > >& pmap) {
288 _pmap = pmap;
289 return self();
290 }
291
292 int get_k() const { return _k; };
293
294 double get_thresh() const { return _thresh; };
295
296 World& get_world() const { return _world; };
297
298 /// return the functor; override this if the functor needs deferred construction
299 virtual std::shared_ptr<FunctionFunctorInterface<T, NDIM> > get_functor() const {
300 return _functor;
301 }
302
303 /// implement this in all derived classes for correct chaining
304 FunctionFactory& self() { return *this; }
305
306};
307
308
309/// Factory for facile setup of a CompositeFunctorInterface and its FuncImpl
310
311/// for the concept of a Factory see base class FunctionFactory
312/// here we need to provide two different dimensions, since the main purpose
313/// of this is to set up a pair function (6D), consisting of orbitals (3D),
314/// and also one- and two-electron potentials
315///
316/// This Factory constructs a FuncImpl, and also the functor to it.
317///
318/// NOTE: pass in only copies of functions, since use in here will corrupt the
319/// tree structure and functions will not pass the VERIFY test after this.
320template<typename T, std::size_t NDIM, std::size_t MDIM>
321class CompositeFactory : public FunctionFactory<T, NDIM> {
322public:
323 typedef std::shared_ptr<FunctionImpl<T, MDIM>> implT_ptr_lodim;
324 typedef std::shared_ptr<FunctionImpl<T, NDIM>> implT_ptr_hidim;
325// std::vector<implT_ptr_lodim> _particle1;
326// std::vector<implT_ptr_lodim> _particle2;
327 std::vector<implT_ptr_hidim> _ket;
328// std::shared_ptr<FunctionImpl<T, NDIM> > _ket; ///< supposedly a 6D pair function ket
329 std::shared_ptr<FunctionImpl<T, NDIM> > _g12; ///< supposedly a interaction potential
330 std::shared_ptr<FunctionImpl<T, MDIM> > _v1; ///< supposedly a potential for particle 1
331 std::shared_ptr<FunctionImpl<T, MDIM> > _v2; ///< supposedly a potential for particle 2
332 std::vector<std::shared_ptr<FunctionImpl<T, MDIM> >> _particle1; ///< supposedly particle 1
333 std::vector<std::shared_ptr<FunctionImpl<T, MDIM> >> _particle2; ///< supposedly particle 2
334
335private:
336 std::shared_ptr<CompositeFunctorInterface<T, NDIM, MDIM> > _func;
337
338 friend class CompositeFunctorInterface<T, NDIM, MDIM>;
339
340public:
341
343 : FunctionFactory<T, NDIM>(world), _ket(), _g12(), _v1(), _v2(), _particle1(), _particle2(), _func() {
344 this->_tree_state = on_demand;
345 }
346
347 /// provide directly the NDIM (6D) pair function ket
350 _ket.push_back(f.get_impl());
351 return self();
352 }
353
355 ket(const std::vector<Function<T, NDIM>>& vf) {
356 for (auto f: vf) _ket.push_back(f.get_impl());
357 return self();
358 }
359
360 /// g12 is the interaction potential (6D)
363 _g12 = f.get_impl();
364 return self();
365 }
366
367 /// a one-particle potential, acting on particle 1
370 _v1 = f.get_impl();
371 return self();
372 }
373
374 /// a one-particle potential, acting on particle 2
377 _v2 = f.get_impl();
378 return self();
379 }
380
381 /// provide particle 1, used with particle 2 to set up a pair function by
382 /// direct product
385 _particle1.push_back(f.get_impl());
386 return self();
387 }
388
389 /// provide particle 1, used with particle 2 to set up a pair function by
390 /// direct product
392 particle1(const std::vector<Function<T, MDIM>>& vf) {
393 for (auto f: vf) _particle1.push_back(f.get_impl());
394 return self();
395 }
396
397 /// provide particle 2, used with particle 1 to set up a pair function by
398 /// direct product
401 _particle2.push_back(f.get_impl());
402 return self();
403 }
404
405 /// provide particle 2, used with particle 1 to set up a pair function by
406 /// direct product
408 particle2(const std::vector<Function<T, MDIM>>& vf) {
409 for (auto f: vf) _particle2.push_back(f.get_impl());
410 return self();
411 }
412
413 // access to the functor *only* via this
414 std::shared_ptr<FunctionFunctorInterface<T, NDIM> > get_functor() const {
415
416 // return if we already have a valid functor
417 if (this->_func) return this->_func;
418
419 // construction of the functor is const in spirit, but non-const in sad reality..
420 // this Factory not only constructs the Function, but also the functor, so
421 // pass *this to the interface
422 const_cast< std::shared_ptr<CompositeFunctorInterface<T, NDIM, MDIM> >& >(this->_func) =
425 this->_world, _ket, _g12, _v1, _v2, _particle1, _particle2
426 ));
427
428 return this->_func;
429 }
430
431 CompositeFactory& self() { return *this; }
432};
433
434/// factory for generating TwoElectronInterfaces
435template<typename T=double, std::size_t NDIM=6>
436class TwoElectronFactory : public FunctionFactory<T, NDIM> {
437
438protected:
439 typedef std::shared_ptr<FunctionFunctorInterface<T, NDIM> > InterfacePtr;
440
441public:
443 : FunctionFactory<T, NDIM>(world), interface_(), bc_(FunctionDefaults<NDIM>::get_bc()) {
444 this->_tree_state = on_demand;
445 info.mu=-1.0;
447 constexpr std::size_t LDIM=NDIM/2;
448 static_assert(NDIM==2*LDIM, "NDIM must be even");
450 this->_thresh = (FunctionDefaults<LDIM>::get_thresh());
451 this->_k = (FunctionDefaults<LDIM>::get_k());
452
453 }
454
455 /// the smallest length scale to be represented (aka lo)
457 info.lo = dcut;
458 return self();
459 }
460
461 /// the requested precision
463 this->_thresh=thresh;
465 return self();
466 }
467
468 /// the exponent of a slater function
470 info.mu = g;
471 return self();
472 }
473
474 /// return the operator (1 - exp(-gamma x) / (2 gamma)
477 return self();
478 }
479
480 /// return the operator (1 - exp(-gamma x) / (2 gamma)
483 return self();
484 }
485
486 /// return the BSH operator
489 return self();
490 }
491
492 /// return the BSH operator
494 info=info1;
495 return self();
496 }
497
498 // access to the functor *only* via this
500
501 // return if we already have a valid interface
502 if (this->interface_) return this->interface_;
503
504 const_cast<InterfacePtr& >(this->interface_) =
506
507// // construction of the functor is const in spirit, but non-const in sad reality..
508// if (info.type==OT_G12) {
509// const_cast<InterfacePtr& >(this->interface_) =
510// InterfacePtr(new ElectronRepulsionInterface(info.lo, _thresh, bc_, _k));
511// } else if (info.type == OT_F12) {
512// const_cast<InterfacePtr& >(this->interface_) =
513// InterfacePtr(new SlaterF12Interface(info.mu, info.lo, _thresh, bc_, _k));
514// } else if (info.type == OT_SLATER) {
515// const_cast<InterfacePtr& >(this->interface_) =
516// InterfacePtr(new SlaterFunctionInterface(info.mu,info.lo, _thresh, bc_, _k));
517// } else if (info.type==OT_BSH) {
518// const_cast<InterfacePtr& >(this->interface_) =
519// InterfacePtr(new BSHFunctionInterface(info.mu, info.lo, _thresh, bc_, _k));
520// } else {
521// MADNESS_EXCEPTION("unimplemented integral kernel", 1);
522// }
523 return this->interface_;
524 }
525
526 TwoElectronFactory& self() { return *this; }
527
528protected:
529
530// enum operatortype {
531// coulomb_, slater_, f12_, bsh_
532// };
533
535// operatortype type_;
536
537 /// the interface providing the actual coefficients
539
540// double dcut_; ///< cutoff radius for 1/r12, aka regularization
541
542// double gamma_;
543
545
546};
547
548#if 0
549class ERIFactory : public TwoElectronFactory<ERIFactory> {
550public:
551 ERIFactory(World& world) : TwoElectronFactory<ERIFactory>(world) {}
552
553 // access to the functor *only* via this
554 InterfacePtr get_functor() const {
555
556 // return if we already have a valid interface
557 if (this->interface_) return this->interface_;
558
559 // construction of the functor is const in spirit, but non-const in sad reality..
560 const_cast<InterfacePtr& >(this->interface_)=
561 InterfacePtr(new ElectronRepulsionInterface(
562 dcut_,thresh_,bc_,k_));
563 return this->interface_;
564 }
565
566 ERIFactory& self() {return *this;}
567
568};
569
570/// a function like f(x) = 1 - exp(-mu x)
571class SlaterFunctionFactory : public TwoElectronFactory<SlaterFunctionFacto> {
572public:
573 SlaterFunctionFactory(World& world)
574: TwoElectronFactory(world), gamma_(-1.0), f12_(false) {}
575
576 /// set the exponent of the Slater function
577 SlaterFunctionFactory& gamma(double gamma) {
578 this->gamma_ = gamma;
579 return self();
580 }
581
582 /// do special f12 function
583 SlaterFunctionFactory& f12() {
584 this->f12_=true;
585 return self();
586 }
587
588 // access to the functor *only* via this
589 InterfacePtr get_functor() const {
590
591 // return if we already have a valid interface
592 if (this->interface_) return this->interface_;
593
594 // make sure gamma is set
595 MADNESS_ASSERT(gamma_>0);
596
597 // construction of the functor is const in spirit, but non-const in sad reality..
598 if (f12_) {
599 const_cast<InterfacePtr& >(this->interface_)=
600 InterfacePtr(new SlaterF12Interface(
601 gamma_,dcut_,this->_thresh,bc_,this->_k));
602 } else {
603 const_cast<InterfacePtr& >(this->interface_)=
604 InterfacePtr(new SlaterFunctionInterface(
605 gamma_,dcut_,this->_thresh,bc_,this->_k));
606 }
607 return this->interface_;
608 }
609
610 SlaterFunctionFactory& self() {return *this;}
611
612private:
613
614 double gamma_; ///< the exponent of the Slater function f(x)=exp(-gamma x)
615 bool f12_; ///< use 1-exp(-gamma x) instead of exp(-gamma x)
616};
617
618/// Factory to set up an ElectronRepulsion Function
619template<typename T, std::size_t NDIM>
620class ERIFactory : public FunctionFactory<T, NDIM> {
621
622private:
623 std::shared_ptr<ElectronRepulsionInterface> _eri;
624
625public:
626
627 /// cutoff radius for 1/r12, aka regularization
628 double _dcut;
629 BoundaryConditions<NDIM> _bc;
630
631public:
632 ERIFactory(World& world)
633: FunctionFactory<T,NDIM>(world)
634 , _eri()
635 , _dcut(FunctionDefaults<NDIM>::get_thresh())
636 , _bc(FunctionDefaults<NDIM>::get_bc())
637 {
638 this->_is_on_demand=true;
640 }
641
642 ERIFactory&
643 thresh(double thresh) {
644 this->_thresh = thresh;
645 return *this;
646 }
647
648 ERIFactory&
649 dcut(double dcut) {
650 this->_dcut = dcut;
651 return *this;
652 }
653
654 // access to the functor *only* via this
655 std::shared_ptr<FunctionFunctorInterface<T, NDIM> > get_functor() const {
656
657 // return if we already have a valid eri
658 if (this->_eri) return this->_eri;
659
660 // if (this->_world.rank()==0) print("set dcut in ERIFactory to ", _dcut);
661
662 // construction of the functor is const in spirit, but non-const in sad reality..
663 const_cast< std::shared_ptr<ElectronRepulsionInterface>& >(this->_eri)=
664 std::shared_ptr<ElectronRepulsionInterface>(
665 new ElectronRepulsionInterface(_dcut,this->_thresh,
666 _bc,this->_k));
667
668 return this->_eri;
669 }
670
671};
672#endif
673
674
675/// Does not work
676// /// Factory to set up an ElectronRepulsion Function
677// template<typename T, std::size_t NDIM>
678// class FGFactory : public FunctionFactory<T, NDIM> {
679//
680// private:
681// std::shared_ptr<FGInterface> _fg;
682//
683// public:
684//
685// /// cutoff radius for 1/r12, aka regularization
686// double _dcut;
687// double _gamma;
688// BoundaryConditions<NDIM> _bc;
689//
690// public:
691// FGFactory(World& world, double gamma)
692// : FunctionFactory<T,NDIM>(world)
693// , _fg()
694// , _dcut(FunctionDefaults<NDIM>::get_thresh())
695// , _gamma(gamma)
696// , _bc(FunctionDefaults<NDIM>::get_bc())
697// {
698// this->_is_on_demand=true;
699// MADNESS_ASSERT(NDIM==6);
700// }
701//
702// FGFactory&
703// thresh(double thresh) {
704// this->_thresh = thresh;
705// return *this;
706// }
707//
708// FGFactory&
709// dcut(double dcut) {
710// this->_dcut = dcut;
711// return *this;
712// }
713//
714// // access to the functor *only* via this
715// std::shared_ptr<FunctionFunctorInterface<T, NDIM> > get_functor() const {
716//
717// // return if we already have a valid eri
718// if (this->_fg) return this->_fg;
719//
720// // if (this->_world.rank()==0) print("set dcut in ERIFactory to ", _dcut);
721//
722// // construction of the functor is const in spirit, but non-const in sad reality..
723// const_cast< std::shared_ptr<FGInterface>& >(this->_fg)=
724// std::shared_ptr<FGInterface>(
725// new FGInterface(this->_world,_dcut,this->_thresh,
726// _gamma,_bc,this->_k));
727//
728// return this->_fg;
729// }
730//
731// };
732
733}
734
735#endif // MADNESS_MRA_FUNCTION_FACTORY_H__INCLUDED
This class is used to specify boundary conditions for all operators.
Definition funcdefaults.h:101
Factory for facile setup of a CompositeFunctorInterface and its FuncImpl.
Definition function_factory.h:321
CompositeFactory & V_for_particle2(const Function< T, MDIM > &f)
a one-particle potential, acting on particle 2
Definition function_factory.h:376
CompositeFactory & self()
Definition function_factory.h:431
CompositeFactory(World &world)
Definition function_factory.h:342
std::shared_ptr< FunctionImpl< T, MDIM > > _v2
supposedly a potential for particle 2
Definition function_factory.h:331
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor() const
return the functor; override this if the functor needs deferred construction
Definition function_factory.h:414
std::shared_ptr< FunctionImpl< T, NDIM > > _g12
supposedly a interaction potential
Definition function_factory.h:329
std::shared_ptr< FunctionImpl< T, MDIM > > _v1
supposedly a potential for particle 1
Definition function_factory.h:330
std::shared_ptr< FunctionImpl< T, MDIM > > implT_ptr_lodim
Definition function_factory.h:323
CompositeFactory & ket(const Function< T, NDIM > &f)
provide directly the NDIM (6D) pair function ket
Definition function_factory.h:349
CompositeFactory & particle1(const Function< T, MDIM > &f)
Definition function_factory.h:384
std::vector< implT_ptr_hidim > _ket
Definition function_factory.h:327
std::shared_ptr< CompositeFunctorInterface< T, NDIM, MDIM > > _func
Definition function_factory.h:336
CompositeFactory & g12(const Function< T, NDIM > &f)
g12 is the interaction potential (6D)
Definition function_factory.h:362
std::shared_ptr< FunctionImpl< T, NDIM > > implT_ptr_hidim
Definition function_factory.h:324
CompositeFactory & ket(const std::vector< Function< T, NDIM > > &vf)
Definition function_factory.h:355
CompositeFactory & particle1(const std::vector< Function< T, MDIM > > &vf)
Definition function_factory.h:392
CompositeFactory & particle2(const std::vector< Function< T, MDIM > > &vf)
Definition function_factory.h:408
CompositeFactory & particle2(const Function< T, MDIM > &f)
Definition function_factory.h:400
std::vector< std::shared_ptr< FunctionImpl< T, MDIM > > > _particle2
supposedly particle 2
Definition function_factory.h:333
std::vector< std::shared_ptr< FunctionImpl< T, MDIM > > > _particle1
supposedly particle 1
Definition function_factory.h:332
CompositeFactory & V_for_particle1(const Function< T, MDIM > &f)
a one-particle potential, acting on particle 1
Definition function_factory.h:369
CompositeFunctorInterface implements a wrapper of holding several functions and functors.
Definition function_interface.h:165
ElementaryInterface (formerly FunctorInterfaceWrapper) interfaces a c-function.
Definition function_interface.h:266
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:204
static int get_special_level()
Returns the default projection level for special boxes.
Definition funcdefaults.h:296
static int get_k()
Returns the default wavelet order.
Definition funcdefaults.h:266
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:279
static int get_initial_level()
Returns the default initial projection level.
Definition funcdefaults.h:291
FunctionFactory implements the named-parameter idiom for Function.
Definition function_factory.h:86
FunctionFactory & no_functor()
Definition function_factory.h:174
FunctionFactory & nofence()
Definition function_factory.h:275
std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > _pmap
Definition function_factory.h:108
int _truncate_mode
Definition function_factory.h:98
FunctionFactory(World &world)
Definition function_factory.h:120
World & _world
Definition function_factory.h:91
virtual FunctionFactory & thresh(double thresh)
Definition function_factory.h:191
bool _refine
Definition function_factory.h:99
std::enable_if< notstd::is_base_of< FunctionFunctorInterface< T, NDIM >, opT >::value, FunctionFactory & >::type functor(const opT &op)
pass in a functor that is not derived from FunctionFunctorInterface
Definition function_factory.h:162
TreeState _tree_state
Definition function_factory.h:106
int _initial_level
Definition function_factory.h:94
FunctionFactory & functor(const std::shared_ptr< FunctionFunctorInterface< T, NDIM > > &f)
Definition function_factory.h:141
int _special_level
Definition function_factory.h:95
FunctionFactory & max_refine_level(int max_refine_level)
Definition function_factory.h:215
World & get_world() const
Definition function_factory.h:296
FunctionFactory & truncate_on_project()
Definition function_factory.h:257
FunctionFactory & fence(bool fence=true)
Definition function_factory.h:269
FunctionFactory & autorefine()
Definition function_factory.h:245
FunctionFactory & norefine(bool norefine=true)
Definition function_factory.h:233
int _max_refine_level
Definition function_factory.h:97
bool _autorefine
Definition function_factory.h:101
FunctionFactory & f(T(*f)(const coordT &))
Definition function_factory.h:180
FunctionFactory & noautorefine()
Definition function_factory.h:251
bool _empty
Definition function_factory.h:100
virtual FunctionFactory & is_on_demand()
Definition function_factory.h:281
FunctionFactory & initial_level(int initial_level)
Definition function_factory.h:197
bool _truncate_on_project
Definition function_factory.h:102
virtual std::shared_ptr< FunctionFunctorInterface< T, NDIM > > get_functor() const
return the functor; override this if the functor needs deferred construction
Definition function_factory.h:299
int _k
Definition function_factory.h:92
virtual FunctionFactory & k(int k)
Definition function_factory.h:186
FunctionFactory & special_level(int special_level)
Definition function_factory.h:203
std::enable_if< std::is_base_of< FunctionFunctorInterface< T, NDIM >, opT >::value, FunctionFactory & >::type functor(const opT &op)
pass in a functor that is derived from FunctionFunctorInterface
Definition function_factory.h:152
double _thresh
Definition function_factory.h:93
virtual ~FunctionFactory()
Definition function_factory.h:138
FunctionFactory & special_points(std::vector< Vector< double, NDIM > > &special_points)
Definition function_factory.h:209
FunctionFactory & self()
implement this in all derived classes for correct chaining
Definition function_factory.h:304
FunctionFactory & compressed(bool value=true)
Definition function_factory.h:168
bool _fence
Definition function_factory.h:103
FunctionFactory & notruncate_on_project()
Definition function_factory.h:263
FunctionFactory & truncate_mode(int truncate_mode)
Definition function_factory.h:221
std::vector< Vector< double, NDIM > > _special_points
Definition function_factory.h:96
Vector< double, NDIM > coordT
Type of vector holding coordinates.
Definition function_factory.h:89
double get_thresh() const
Definition function_factory.h:294
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > _functor
Definition function_factory.h:116
FunctionFactory & empty()
Definition function_factory.h:239
FunctionFactory & pmap(const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap)
Definition function_factory.h:287
FunctionFactory & refine(bool refine=true)
Definition function_factory.h:227
int get_k() const
Definition function_factory.h:292
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:942
FunctionInterface implements a wrapper around any class with the operator()()
Definition function_interface.h:302
A multiresolution adaptive numerical function.
Definition mra.h:122
a function like f(x)=1/x
Definition function_interface.h:495
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:66
A tensor is a multidimension array.
Definition tensor.h:317
factory for generating TwoElectronInterfaces
Definition function_factory.h:436
TwoElectronFactory & thresh(double thresh)
the requested precision
Definition function_factory.h:462
std::shared_ptr< FunctionFunctorInterface< T, NDIM > > InterfacePtr
Definition function_factory.h:439
TwoElectronFactory & f12()
return the operator (1 - exp(-gamma x) / (2 gamma)
Definition function_factory.h:475
TwoElectronFactory & slater()
return the operator (1 - exp(-gamma x) / (2 gamma)
Definition function_factory.h:481
OperatorInfo info
Definition function_factory.h:534
TwoElectronFactory & BSH()
return the BSH operator
Definition function_factory.h:487
InterfacePtr interface_
the interface providing the actual coefficients
Definition function_factory.h:538
BoundaryConditions< NDIM > bc_
Definition function_factory.h:544
InterfacePtr get_functor() const
return the functor; override this if the functor needs deferred construction
Definition function_factory.h:499
TwoElectronFactory & gamma(double g)
the exponent of a slater function
Definition function_factory.h:469
TwoElectronFactory(World &world)
Definition function_factory.h:442
TwoElectronFactory & set_info(const OperatorInfo info1)
return the BSH operator
Definition function_factory.h:493
TwoElectronFactory & self()
Definition function_factory.h:526
TwoElectronFactory & dcut(double dcut)
the smallest length scale to be represented (aka lo)
Definition function_factory.h:456
A simple, fixed dimension vector.
Definition vector.h:64
Interface to be provided by any process map.
Definition worlddc.h:82
A parallel world class.
Definition world.h:132
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
static const double dcut
Definition he.cc:13
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
Multidimension Key for MRA tree and associated iterators.
#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
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
TreeState
Definition funcdefaults.h:58
@ on_demand
no coeffs anywhere, but a functor providing if necessary
Definition funcdefaults.h:66
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:59
@ compressed
d coeffs in internal nodes, s and d coeffs at the root
Definition funcdefaults.h:60
@ OT_SLATER
1/r
Definition operatorinfo.h:15
@ OT_BSH
(1-exp(-r))^2/r = 1/r + exp(-2r)/r - 2 exp(-r)/r
Definition operatorinfo.h:21
@ OT_F12
exp(-r2)
Definition operatorinfo.h:17
@ OT_G12
indicates the identity
Definition operatorinfo.h:14
Tensor< T > fcube(const Key< NDIM > &, T(*f)(const Vector< double, NDIM > &), const Tensor< double > &)
Definition mraimpl.h:2163
NDIM & f
Definition mra.h:2416
NDIM const Function< R, NDIM > & g
Definition mra.h:2416
std::string type(const PairType &n)
Definition PNOParameters.h:18
Definition mraimpl.h:50
static const double thresh
Definition rk.cc:45
static const long k
Definition rk.cc:44
Definition test_dc.cc:47
Definition operatorinfo.h:58
double thresh
Definition operatorinfo.h:63
OpType type
introspection
Definition operatorinfo.h:64
double mu
some introspection
Definition operatorinfo.h:61
double lo
Definition operatorinfo.h:62
Defines and implements most of Tensor.
static const int truncate_mode
Definition testcosine.cc:14
static const std::size_t NDIM
Definition testpdiff.cc:42