34#ifndef MADNESS_EXAMPLES_NONLINSOL_H__INCLUDED
35#define MADNESS_EXAMPLES_NONLINSOL_H__INCLUDED
72 if (
c.absmax()<cabsmax) {
74 }
else if(rcond < rcondtol){
75 if (do_print)
print(
"Increasing subspace singular value threshold ",
c[
m - 1], rcond);
78 if (do_print)
print(
"Forcing full step due to subspace malfunction");
101 const unsigned int tmp =
maxsub;
119 const double rcondtol=1
e-8,
const double cabsmax=1000.0) {
128 for (
int i=0; i<=iter; i++) {
140 for (
int i=0; i<=iter; i++) {
168 template<
typename T, std::
size_t NDIM>
179 return zero_functions<T, NDIM>(
world,
n);
201 template <
class T,
class C =
double,
class Alloc = default_allocator<T> >
246 T update(
const T&
u,
const T& r,
const double rcondtol=1
e-8,
const double cabsmax=1000.0) {
248 int iter =
ulist.size();
255 for (
int i=0; i<=iter; i++) {
267 for (
int i=0; i<=iter; i++) {
282 template<
typename T, std::
size_t NDIM>
283 static inline XNonlinearSolver<std::vector<Function<T,NDIM>>,
T,vector_function_allocator<T,NDIM>>
FunctionFactory implements the named-parameter idiom for Function.
Definition function_factory.h:86
A multiresolution adaptive numerical function.
Definition mra.h:122
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:602
std::size_t size() const
Returns the number of coefficients in the function ... collective global sum.
Definition mra.h:538
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:981
const Function< T, NDIM > & compress(bool fence=true) const
Compresses the function, transforming into wavelet basis. Possible non-blocking comm.
Definition mra.h:721
A simple Krylov-subspace nonlinear equation solver.
Definition nonlinsol.h:90
void set_maxsub(const unsigned int &new_maxsub)
Definition nonlinsol.h:97
real_tensor Q
Definition nonlinsol.h:94
bool do_print
Definition nonlinsol.h:104
std::vector< Function< double, NDIM > > ulist
Definition nonlinsol.h:93
Function< double, NDIM > update(const Function< double, NDIM > &u, const Function< double, NDIM > &r, const double rcondtol=1e-8, const double cabsmax=1000.0)
Computes next trial solution vector.
Definition nonlinsol.h:118
unsigned int get_maxsub() const
Definition nonlinsol.h:100
NonlinearSolverND(unsigned int maxsub=10)
Definition nonlinsol.h:106
unsigned int maxsub
Maximum size of subspace dimension.
Definition nonlinsol.h:91
std::vector< Function< double, NDIM > > rlist
Definition nonlinsol.h:93
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
A tensor is a multidimension array.
Definition tensor.h:317
A parallel world class.
Definition world.h:132
Generalized version of NonlinearSolver not limited to a single madness function.
Definition nonlinsol.h:202
void set_maxsub(int maxsub)
Definition nonlinsol.h:227
XNonlinearSolver(const Alloc &alloc=Alloc(), bool print=false)
Definition nonlinsol.h:211
void clear_subspace()
Definition nonlinsol.h:230
Tensor< C > c
coefficients for linear combination
Definition nonlinsol.h:207
Tensor< C > Q
Definition nonlinsol.h:206
std::vector< T > & get_rlist()
Definition nonlinsol.h:225
std::vector< T > ulist
Definition nonlinsol.h:205
Tensor< C > get_c() const
Definition nonlinsol.h:228
std::vector< T > & get_ulist()
Definition nonlinsol.h:224
std::vector< T > rlist
Subspace information.
Definition nonlinsol.h:205
Alloc alloc
Definition nonlinsol.h:204
T update(const T &u, const T &r, const double rcondtol=1e-8, const double cabsmax=1000.0)
Computes next trial solution vector.
Definition nonlinsol.h:246
bool do_print
Definition nonlinsol.h:209
XNonlinearSolver(const XNonlinearSolver &other)
Definition nonlinsol.h:217
unsigned int maxsub
Maximum size of subspace dimension.
Definition nonlinsol.h:203
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
static double u(double r, double c)
Definition he.cc:20
Main include file for MADNESS and defines Function interface.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
Tensor< T > KAIN(const Tensor< T > &Q, double rcond=1e-12)
Solves non-linear equation using KAIN (returns coefficients to compute next vector)
Definition solvers.h:98
NonlinearSolverND< 3 > NonlinearSolver
Definition nonlinsol.h:156
void check_linear_dependence(const Tensor< C > &Q, Tensor< C > &c, const double rcondtol, const double cabsmax, bool do_print=true)
check for subspace linear dependency
Definition nonlinsol.h:63
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:225
XNonlinearSolver< std::vector< Function< double, 6 > >, double, vector_function_allocator< double, 6 > > NonlinearVectorSolver_6d
Definition nonlinsol.h:291
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
XNonlinearSolver< std::vector< Function< double, 3 > >, double, vector_function_allocator< double, 3 > > NonlinearVectorSolver_3d
Definition nonlinsol.h:290
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:284
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:2002
double Q(double a)
Definition relops.cc:20
static const double c
Definition relops.cc:10
static const double m
Definition relops.cc:9
Defines interfaces for optimization and non-linear equation solvers.
Definition nonlinsol.h:160
T operator()()
Definition nonlinsol.h:161
Definition nonlinsol.h:169
const int n
Definition nonlinsol.h:171
World & world
Definition nonlinsol.h:170
vector_function_allocator(World &world, const int nn)
Definition nonlinsol.h:175
std::vector< Function< T, NDIM > > operator()()
allocate a vector of n empty functions
Definition nonlinsol.h:178
void e()
Definition test_sig.cc:75