MADNESS 0.10.1
madness::XNonlinearSolver< T, C, Alloc > Class Template Reference

Generalized version of NonlinearSolver not limited to a single madness function. More...

#include <nonlinsol.h>

Collaboration diagram for madness::XNonlinearSolver< T, C, Alloc >:

Public Member Functions

 XNonlinearSolver (const Alloc &alloc=Alloc(), bool print=false)
 XNonlinearSolver (const XNonlinearSolver &other)
void clear_subspace ()
Tensor< C > get_c () const
std::vector< T > & get_plist ()
std::vector< T > & get_rlist ()
std::vector< T > & get_ulist ()
void initialize (const T &u_initial)
void set_maxsub (int maxsub)
T update (const T &u, const T &r, const double rcondtol=1e-8, const double cabsmax=1000.0)
 Computes next trial solution vector.
T update (const T &u_preliminary, const double rcondtol=1e-8, const double cabsmax=1000.0)
 Computes next trial solution vector.

Public Attributes

bool do_print

Private Attributes

Alloc alloc
Tensor< C > c
 coefficients for linear combination
unsigned int maxsub
 Maximum size of subspace dimension.
std::vector< T > plist
 Subspace information.
Tensor< C > Q
std::vector< T > rlist
std::vector< T > ulist

Detailed Description

template<class T, class C = double, class Alloc = default_allocator<T>>
class madness::XNonlinearSolver< T, C, Alloc >

Generalized version of NonlinearSolver not limited to a single madness function.

This solves the equation $r(u) = 0$ where u and r are both of type T and inner products between two items of type T produce a number of type C (defaulting to double). The type T must support storage in an STL vector, scaling by a constant of type C, inplace addition (+=), subtraction, allocation with value zero, and inner products computed with the interface inner(a,b). Have a look in examples/testsolver.cc for a simple but complete example, and in examples/h2dynamic.cc for a more complex example.

I've not yet tested with anything except C=double and I think that the KAIN routine will need extending for anything else.

Constructor & Destructor Documentation

◆ XNonlinearSolver() [1/2]

template<class T, class C = double, class Alloc = default_allocator<T>>
madness::XNonlinearSolver< T, C, Alloc >::XNonlinearSolver ( const Alloc & alloc = Alloc(),
bool print = false )
inline

◆ XNonlinearSolver() [2/2]

template<class T, class C = double, class Alloc = default_allocator<T>>
madness::XNonlinearSolver< T, C, Alloc >::XNonlinearSolver ( const XNonlinearSolver< T, C, Alloc > & other)
inline

Member Function Documentation

◆ clear_subspace()

template<class T, class C = double, class Alloc = default_allocator<T>>
void madness::XNonlinearSolver< T, C, Alloc >::clear_subspace ( )
inline

◆ get_c()

template<class T, class C = double, class Alloc = default_allocator<T>>
Tensor< C > madness::XNonlinearSolver< T, C, Alloc >::get_c ( ) const
inline

◆ get_plist()

template<class T, class C = double, class Alloc = default_allocator<T>>
std::vector< T > & madness::XNonlinearSolver< T, C, Alloc >::get_plist ( )
inline

◆ get_rlist()

template<class T, class C = double, class Alloc = default_allocator<T>>
std::vector< T > & madness::XNonlinearSolver< T, C, Alloc >::get_rlist ( )
inline

◆ get_ulist()

template<class T, class C = double, class Alloc = default_allocator<T>>
std::vector< T > & madness::XNonlinearSolver< T, C, Alloc >::get_ulist ( )
inline

◆ initialize()

template<class T, class C = double, class Alloc = default_allocator<T>>
void madness::XNonlinearSolver< T, C, Alloc >::initialize ( const T & u_initial)
inline

Referenced by test_with_function().

◆ set_maxsub()

template<class T, class C = double, class Alloc = default_allocator<T>>
void madness::XNonlinearSolver< T, C, Alloc >::set_maxsub ( int maxsub)
inline

◆ update() [1/2]

template<class T, class C = double, class Alloc = default_allocator<T>>
T madness::XNonlinearSolver< T, C, Alloc >::update ( const T & u,
const T & r,
const double rcondtol = 1e-8,
const double cabsmax = 1000.0 )
inline

Computes next trial solution vector.

You are responsible for performing step restriction or line search (not necessary for linear problems).

Parameters
uCurrent solution vector
rCorresponding residual
Returns
Next trial solution vector
Parameters
[in]rcondtolrcond less than this will cause the subspace to be shrunk due to linear dependence
[in]cabsmaxmaximum element of c greater than this will cause the subspace to be shrunk due to li

Referenced by iterate(), madness::Zcis::iterate(), madness::PNO::t_solve(), and test_with_function().

◆ update() [2/2]

template<class T, class C = double, class Alloc = default_allocator<T>>
T madness::XNonlinearSolver< T, C, Alloc >::update ( const T & u_preliminary,
const double rcondtol = 1e-8,
const double cabsmax = 1000.0 )
inline

Computes next trial solution vector.

this version of update avoids using the residual by computing it on the fly note the distinction between u_preliminary (input) and u_kain (output) residual[i] = u_kain[i] - u_preliminary[i+1] ulist[i] = u_kain[i] plist[i] = u_preliminary[i]

Parameters
[in]u_preliminarynew solution before KAIN
[out]u_kainnew solution after KAIN

Member Data Documentation

◆ alloc

◆ c

template<class T, class C = double, class Alloc = default_allocator<T>>
Tensor<C> madness::XNonlinearSolver< T, C, Alloc >::c
private

coefficients for linear combination

◆ do_print

template<class T, class C = double, class Alloc = default_allocator<T>>
bool madness::XNonlinearSolver< T, C, Alloc >::do_print

Referenced by iterate(), and madness::PNO::t_solve().

◆ maxsub

template<class T, class C = double, class Alloc = default_allocator<T>>
unsigned int madness::XNonlinearSolver< T, C, Alloc >::maxsub
private

Maximum size of subspace dimension.

◆ plist

template<class T, class C = double, class Alloc = default_allocator<T>>
std::vector<T> madness::XNonlinearSolver< T, C, Alloc >::plist
private

Subspace information.

◆ Q

◆ rlist

template<class T, class C = double, class Alloc = default_allocator<T>>
std::vector<T> madness::XNonlinearSolver< T, C, Alloc >::rlist
private

◆ ulist

template<class T, class C = double, class Alloc = default_allocator<T>>
std::vector<T> madness::XNonlinearSolver< T, C, Alloc >::ulist
private

The documentation for this class was generated from the following file: