Solves a non-linear system of the form A(X)=Y. More...

#include <newton.hh>

Inheritance diagram for concepts::Newton< F >:
concepts::VecOperator< F::d_type > concepts::Operator< F >

Public Types

typedef Cmplxtype< F >::type c_type
 Real type of data type. More...
 
typedef Realtype< F >::type r_type
 Real type of data type. More...
 

Public Member Functions

virtual void apply_ ()
 Intrinsic application method without argument. More...
 
virtual void apply_ (const Vector< typename F::d_type > &fncY, Vector< typename F::d_type > &fncX)
 
virtual const uint dimX () const
 Returns the size of the image space of the operator (number of rows of the corresponding matrix) More...
 
virtual const uint dimY () const
 Returns the size of the source space of the operator (number of columns of the corresponding matrix) More...
 
virtual void hide_messages ()
 
 Newton (std::function< Vector< typename F::d_type >(Vector< typename F::d_type >)> A, Real dx, uint dimY, uint dimX, Real tol=1e-8, Real iterMax=1000)
 Constructor. More...
 
 Newton (std::function< Vector< typename F::d_type >(Vector< typename F::d_type >)> A, std::function< F(Vector< typename F::d_type >)> JacA, uint dimY, uint dimX, Real tol=1e-8, Real iterMax=50)
 Constructor. More...
 
void operator() ()
 Application method without second argument. Used for parallel solvers. More...
 
virtual void operator() (const Function< c_type > &fncY, Function< c_type > &fncX)
 Application operator for complex function fncY. More...
 
virtual void operator() (const Function< r_type > &fncY, Function< F > &fncX)
 Application operator for real function fncY. More...
 
void operator() (const Matrix< c_type > &mX, Matrix< c_type > &mY)
 Application method to complex matrices. Calls apply_() More...
 
void operator() (const Matrix< r_type > &mX, Matrix< F > &mY)
 Application method to real matrices. Calls function apply() More...
 
virtual void operator() (const Vector< c_type > &fncY, Vector< c_type > &fncX)
 Application operator for complex function fncY. More...
 
virtual void operator() (const Vector< r_type > &fncY, Vector< F > &fncX)
 Application operator for real vector fncY. More...
 
virtual void show_messages ()
 
virtual ~Newton ()
 

Public Attributes

F::d_type type
 

Protected Member Functions

virtual void apply_ (const Vector< F > &fncY, Vector< F > &fncX)=0
 Intrinsic application method, i.e. More...
 
virtual std::ostream & info (std::ostream &os) const
 
virtual void setLinearSolver_ (F *Jacobian)
 Set linear solver. More...
 

Protected Attributes

std::function< Vector< typename F::d_type >Vector< typename F::d_type >)> & A_
 Function that evaluates the matrix A applied to vector X. More...
 
bool definedJacA_
 Flag that states if the Jacobian matrix has been set. More...
 
uint dimX_
 Size of the unknown. More...
 
uint dimY_
 Size of the data. More...
 
Real dx_
 Step for the computation of the pseudo-Jacobian. More...
 
uint iterMax_
 Maximum number of iterations. More...
 
std::function< F(Vector< typename F::d_type >)> * JacA_
 Function that evaluates the Jacobian of matrix A applied to vector X. More...
 
std::unique_ptr< concepts::Operator< typename F::d_type > > linearSolver_
 Internal linear solver. More...
 
Real tol_
 Tolerance for the functional. More...
 
bool verbose_
 Internal flag for verbosity. More...
 

Detailed Description

template<class F>
class concepts::Newton< F >

Solves a non-linear system of the form A(X)=Y.

Definition at line 35 of file newton.hh.

Member Typedef Documentation

◆ c_type

typedef Cmplxtype<F>::type concepts::VecOperator< F >::c_type
inherited

Real type of data type.

Definition at line 120 of file compositions.hh.

◆ r_type

typedef Realtype<F>::type concepts::VecOperator< F >::r_type
inherited

Real type of data type.

Definition at line 118 of file compositions.hh.

Constructor & Destructor Documentation

◆ Newton() [1/2]

template<class F >
concepts::Newton< F >::Newton ( std::function< Vector< typename F::d_type >(Vector< typename F::d_type >)>  A,
Real  dx,
uint  dimY,
uint  dimX,
Real  tol = 1e-8,
Real  iterMax = 1000 
)
inline

Constructor.

Parameters
Anon-linear operator that has to be solved
dimYsize of the data
dimXsize of the unknown
dxstep for the algorithm
tol(optional) tolerance that will be used for the algorithm
iterMax(optional) maximum number of iterations before the algorithm decides failure

Definition at line 51 of file newton.hh.

◆ Newton() [2/2]

template<class F >
concepts::Newton< F >::Newton ( std::function< Vector< typename F::d_type >(Vector< typename F::d_type >)>  A,
std::function< F(Vector< typename F::d_type >)>  JacA,
uint  dimY,
uint  dimX,
Real  tol = 1e-8,
Real  iterMax = 50 
)
inline

Constructor.

Parameters
Anon-linear operator that has to be solved
JacAJacobian of the non-linear operator A
dimYsize of the data
dimXsize of the unknown
dxstep for the algorithm
tol(optional) tolerance that will be used for the algorithm
iterMax(optional) maximum number of iterations before the algorithm decides failure

Definition at line 67 of file newton.hh.

◆ ~Newton()

template<class F >
virtual concepts::Newton< F >::~Newton ( )
inlinevirtual

Definition at line 75 of file newton.hh.

Member Function Documentation

◆ apply_() [1/3]

template<class F >
virtual void concepts::Newton< F >::apply_ ( )
virtual

Intrinsic application method without argument.

Implements concepts::VecOperator< F::d_type >.

◆ apply_() [2/3]

virtual void concepts::VecOperator< F >::apply_ ( const Vector< F > &  fncY,
Vector< F > &  fncX 
)
protectedpure virtualinherited

Intrinsic application method, i.e.

real Operator and real Vector or complex Operator and real Vector.

◆ apply_() [3/3]

template<class F >
virtual void concepts::Newton< F >::apply_ ( const Vector< typename F::d_type > &  fncY,
Vector< typename F::d_type > &  fncX 
)
virtual

◆ dimX()

template<class F >
virtual const uint concepts::Operator< F >::dimX ( ) const
inlinevirtualinherited

Returns the size of the image space of the operator (number of rows of the corresponding matrix)

Definition at line 93 of file compositions.hh.

◆ dimY()

template<class F >
virtual const uint concepts::Operator< F >::dimY ( ) const
inlinevirtualinherited

Returns the size of the source space of the operator (number of columns of the corresponding matrix)

Definition at line 98 of file compositions.hh.

◆ hide_messages()

template<class F >
virtual void concepts::Newton< F >::hide_messages ( )
virtual

◆ info()

virtual std::ostream& concepts::VecOperator< F >::info ( std::ostream &  os) const
protectedvirtualinherited

Reimplemented from concepts::Operator< F >.

◆ operator()() [1/7]

void concepts::VecOperator< F >::operator()
virtualinherited

Application method without second argument. Used for parallel solvers.

Reimplemented from concepts::Operator< F >.

◆ operator()() [2/7]

virtual void concepts::VecOperator< F >::operator() ( const Function< c_type > &  fncY,
Function< c_type > &  fncX 
)
virtualinherited

Application operator for complex function fncY.

Computes fncX = A(fncY) where A is this operator. fncX becomes complex.

In derived classes its enough to implement the operator() for complex Operator's. If a real counterpart is not implemented, the function fncY is splitted into real and imaginary part and the application operator for real functions is called for each. Then the result is combined.

If in a derived class the operator() for complex Operator's is not implemented, a exception is thrown from here.

Reimplemented from concepts::Operator< F >.

◆ operator()() [3/7]

virtual void concepts::VecOperator< F >::operator() ( const Function< r_type > &  fncY,
Function< F > &  fncX 
)
virtualinherited

Application operator for real function fncY.

Computes fncX = A(fncY) where A is this operator.

fncX becomes the type of the operator, for real data it becomes real, for complex data it becomes complex.

In derived classes its enough to implement the operator() for real Operator's. If a complex counterpart is not implemented, the function fncY is transformed to a complex function and then the application operator for complex functions is called.

If in a derived class the operator() for real Operator's is not implemented, a exception is thrown from here.

Reimplemented from concepts::Operator< F >.

◆ operator()() [4/7]

void concepts::VecOperator< F >::operator() ( const Matrix< c_type > &  mX,
Matrix< c_type > &  mY 
)
inherited

Application method to complex matrices. Calls apply_()

◆ operator()() [5/7]

void concepts::VecOperator< F >::operator() ( const Matrix< r_type > &  mX,
Matrix< F > &  mY 
)
inherited

Application method to real matrices. Calls function apply()

◆ operator()() [6/7]

virtual void concepts::VecOperator< F >::operator() ( const Vector< c_type > &  fncY,
Vector< c_type > &  fncX 
)
virtualinherited

Application operator for complex function fncY.

Computes fncX = A(fncY) where A is this operator. fncX becomes complex.

In derived classes its enough to implement the operator() for complex Operator's. If a real counterpart is not implemented, the vector fncY is splitted into real and imaginary part and the application operator for real vectors is called for each. Then the result is combined

If in a derived class the operator() for complex Operator's i not implemented, a exception is thrown from here.

◆ operator()() [7/7]

virtual void concepts::VecOperator< F >::operator() ( const Vector< r_type > &  fncY,
Vector< F > &  fncX 
)
virtualinherited

Application operator for real vector fncY.

Computes fncX = A(fncY) where A is this operator.

Type of fncX becomes that of the operator, for real data it becomes real, for complex data it becomes complex.

In derived classes its enough to implement the operator() for real Operator's. If a complex counterpart is not implemented, the vector fncY is transformed to a complex vector and then the application for complex vectors is called.

If in a derived class the operator() for real Operator's is not implemented, a exception is thrown from here.

◆ setLinearSolver_()

template<class F >
virtual void concepts::Newton< F >::setLinearSolver_ ( F *  Jacobian)
protectedvirtual

Set linear solver.

◆ show_messages()

template<class F >
virtual void concepts::Newton< F >::show_messages ( )
virtual

Reimplemented from concepts::Operator< F >.

Member Data Documentation

◆ A_

template<class F >
std::function<Vector<typename F::d_type>Vector<typename F::d_type>)>& concepts::Newton< F >::A_
protected

Function that evaluates the matrix A applied to vector X.

Definition at line 92 of file newton.hh.

◆ definedJacA_

template<class F >
bool concepts::Newton< F >::definedJacA_
protected

Flag that states if the Jacobian matrix has been set.

Definition at line 100 of file newton.hh.

◆ dimX_

template<class F >
uint concepts::Newton< F >::dimX_
protected

Size of the unknown.

Definition at line 109 of file newton.hh.

◆ dimY_

template<class F >
uint concepts::Newton< F >::dimY_
protected

Size of the data.

Definition at line 106 of file newton.hh.

◆ dx_

template<class F >
Real concepts::Newton< F >::dx_
protected

Step for the computation of the pseudo-Jacobian.

Definition at line 103 of file newton.hh.

◆ iterMax_

template<class F >
uint concepts::Newton< F >::iterMax_
protected

Maximum number of iterations.

Definition at line 115 of file newton.hh.

◆ JacA_

template<class F >
std::function<F(Vector<typename F::d_type>)>* concepts::Newton< F >::JacA_
protected

Function that evaluates the Jacobian of matrix A applied to vector X.

Definition at line 95 of file newton.hh.

◆ linearSolver_

template<class F >
std::unique_ptr<concepts::Operator<typename F::d_type> > concepts::Newton< F >::linearSolver_
protected

Internal linear solver.

Definition at line 121 of file newton.hh.

◆ tol_

template<class F >
Real concepts::Newton< F >::tol_
protected

Tolerance for the functional.

Definition at line 112 of file newton.hh.

◆ type

template<class F >
F::d_type concepts::Newton< F >::type

Definition at line 39 of file newton.hh.

◆ verbose_

template<class F >
bool concepts::Newton< F >::verbose_
protected

Internal flag for verbosity.

Definition at line 118 of file newton.hh.


The documentation for this class was generated from the following file:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich