INMOST
A toolkit for distributed mathematical modeling
INMOST::Residual Class Reference

The Residual class provides a representation for array of residuals of nonlinear equations. More...

#include <inmost_residual.h>

Public Member Functions

 Residual (std::string name="", INMOST_DATA_ENUM_TYPE start=0, INMOST_DATA_ENUM_TYPE end=0, INMOST_MPI_Comm _comm=INMOST_MPI_COMM_WORLD)
 Constructor. More...
 
 Residual (const Residual &other)
 Copy constructor. More...
 
Residualoperator= (Residual const &other)
 Assignment operator. More...
 
INMOST_DATA_ENUM_TYPE GetFirstIndex () const
 Retrieve the first index of the equations in the local partition.
 
INMOST_DATA_ENUM_TYPE GetLastIndex () const
 Retrieve the last index of the equations in the local partition.
 
void GetInterval (INMOST_DATA_ENUM_TYPE &start, INMOST_DATA_ENUM_TYPE &end) const
 Retrieve the first and the last indices of the equations in the local partition. More...
 
void SetInterval (INMOST_DATA_ENUM_TYPE beg, INMOST_DATA_ENUM_TYPE end)
 Assign the new first and last indices of the equations in the local partition. More...
 
__INLINE multivar_expression_reference operator[] (INMOST_DATA_ENUM_TYPE row)
 Retrieve a residual value and a jacobian row corresponding to certain equation. More...
 
__INLINE double Value (INMOST_DATA_ENUM_TYPE row) const
 Retrieve a residual value corresponding to certain equation. More...
 
__INLINE double & Value (INMOST_DATA_ENUM_TYPE row)
 Retrieve a residual value corresponding to certain equation. More...
 
Matrix< multivar_expression_referenceoperator[] (const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &rows)
 Retrieve a vector of entries in residual, corresponding to a set of equations. More...
 
rMatrix Value (const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &rows) const
 Retrieve a vector of entries in residual, corresponding to a set of equations. More...
 
Matrix< value_referenceValue (const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &rows)
 Retrieve a vector of entries in residual, corresponding to a set of equations. More...
 
Sparse::HessianMatrixGetHessian ()
 Retrieve hessian matrix. Use in nonlinear solver.
 
const Sparse::HessianMatrixGetHessian () const
 Retrieve hessian matrix without right of modificaiton.
 
Sparse::MatrixGetJacobian ()
 Retrieve jacobian matrix. Use in Sparse::Solver::Solve function.
 
const Sparse::MatrixGetJacobian () const
 Retrieve jacobian matrix without right of modificaiton.
 
Sparse::VectorGetResidual ()
 Retrieve right hand side vector. Use in Sparse::Solver::Solve function.
 
const Sparse::VectorGetResidual () const
 Retrieve right hand side vector without right of modification.
 
void ClearResidual ()
 Zero out right hand side vector.
 
void ClearJacobian ()
 Remove all entries in jacobian matrix.
 
void ClearHessian ()
 Remove all entries in hessian matrix.
 
void Clear ()
 Zero out right hand side vector and remove all entries in jacobian matrix.
 
INMOST_DATA_REAL_TYPE Norm ()
 Compute the second norm of the right hand side vector over all of the processors.
 
void Rescale (INMOST_DATA_ENUM_TYPE p=2)
 Normalize jacobian rows to unit p-norms and scale right hand side accordingly. More...
 
void InitLocks ()
 Initialize openmp locks.
 
__INLINE void Lock (INMOST_DATA_ENUM_TYPE pos)
 Lock an equation to avoid simultaneous shared access. More...
 
__INLINE void UnLock (INMOST_DATA_ENUM_TYPE pos)
 UnLock an equation to allow simultaneous shared access. More...
 
__INLINE bool TestLock (INMOST_DATA_ENUM_TYPE pos)
 Try to lock the equation. More...
 

Detailed Description

The Residual class provides a representation for array of residuals of nonlinear equations.

By working with the residual class you automatically assemble right hand side and the jacobian of a nonlinear system of equation. Jacobian matrix has a sparse representation.

Todo:
  1. Extend for hessian calculation.

Definition at line 17 of file inmost_residual.h.

Constructor & Destructor Documentation

◆ Residual() [1/2]

INMOST::Residual::Residual ( std::string  name = "",
INMOST_DATA_ENUM_TYPE  start = 0,
INMOST_DATA_ENUM_TYPE  end = 0,
INMOST_MPI_Comm  _comm = INMOST_MPI_COMM_WORLD 
)

Constructor.

Parameters
nameName for the matrix and right hand side. Can be used to set options for linear solver.
startFirst index of the equation in the local partition. Use Automatizator::GetFirstIndex.
endLast index of the equation in the local partition. Use Automatizator::GetLastIndex.
_commMPI Communicator.

◆ Residual() [2/2]

INMOST::Residual::Residual ( const Residual other)

Copy constructor.

Warning
May be expensive if matrices are large.

Member Function Documentation

◆ GetInterval()

void INMOST::Residual::GetInterval ( INMOST_DATA_ENUM_TYPE &  start,
INMOST_DATA_ENUM_TYPE &  end 
) const

Retrieve the first and the last indices of the equations in the local partition.

Parameters
startThe first index of the equations will be recorded here.
endThe last index of the equations will be recorded here.

◆ Lock()

__INLINE void INMOST::Residual::Lock ( INMOST_DATA_ENUM_TYPE  pos)
inline

Lock an equation to avoid simultaneous shared access.

Parameters
posEquation number.

Definition at line 102 of file inmost_residual.h.

◆ operator=()

Residual& INMOST::Residual::operator= ( Residual const &  other)

Assignment operator.

Warning
May be expensive if matrices are large.

◆ operator[]() [1/2]

Matrix<multivar_expression_reference> INMOST::Residual::operator[] ( const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &  rows)

Retrieve a vector of entries in residual, corresponding to a set of equations.

Parameters
rowsA row-vector of equation numbers.
Astructure that can be used in or assigned an automatic differentiation matrix expression.

◆ operator[]() [2/2]

__INLINE multivar_expression_reference INMOST::Residual::operator[] ( INMOST_DATA_ENUM_TYPE  row)
inline

Retrieve a residual value and a jacobian row corresponding to certain equation.

Parameters
rowEquation number.
Returns
A structure that can be used in or assigned an automatic differentiation expression.

Definition at line 51 of file inmost_residual.h.

◆ Rescale()

void INMOST::Residual::Rescale ( INMOST_DATA_ENUM_TYPE  p = 2)

Normalize jacobian rows to unit p-norms and scale right hand side accordingly.

Use ENUMUNDEF as p to scale to infinite-norm.

◆ SetInterval()

void INMOST::Residual::SetInterval ( INMOST_DATA_ENUM_TYPE  beg,
INMOST_DATA_ENUM_TYPE  end 
)

Assign the new first and last indices of the equations in the local partition.

Parameters
startThe new first index of the equations.
endThe new last index of the equations.

◆ TestLock()

__INLINE bool INMOST::Residual::TestLock ( INMOST_DATA_ENUM_TYPE  pos)
inline

Try to lock the equation.

Parameters
posEquation number.
Returns
True if equation was locked.

Definition at line 109 of file inmost_residual.h.

◆ UnLock()

__INLINE void INMOST::Residual::UnLock ( INMOST_DATA_ENUM_TYPE  pos)
inline

UnLock an equation to allow simultaneous shared access.

Parameters
posEquation number.

Definition at line 105 of file inmost_residual.h.

◆ Value() [1/4]

Matrix<value_reference> INMOST::Residual::Value ( const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &  rows)

Retrieve a vector of entries in residual, corresponding to a set of equations.

Parameters
rowsA row-vector of equation numbers.
Astructure that can be used in or assigned an automatic differentiation matrix expression.

◆ Value() [2/4]

rMatrix INMOST::Residual::Value ( const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &  rows) const

Retrieve a vector of entries in residual, corresponding to a set of equations.

Parameters
rowsA row-vector of equation numbers.
Astructure that can be used in or assigned an automatic differentiation matrix expression.

◆ Value() [3/4]

__INLINE double& INMOST::Residual::Value ( INMOST_DATA_ENUM_TYPE  row)
inline

Retrieve a residual value corresponding to certain equation.

Parameters
rowEquation number.
Returns
A structure that can be used in or assigned an automatic differentiation expression.

Definition at line 60 of file inmost_residual.h.

◆ Value() [4/4]

__INLINE double INMOST::Residual::Value ( INMOST_DATA_ENUM_TYPE  row) const
inline

Retrieve a residual value corresponding to certain equation.

Parameters
rowEquation number.
Returns
A structure that can be used in or assigned an automatic differentiation expression.

Definition at line 56 of file inmost_residual.h.


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