1 #ifndef INMOST_RESIDUAL_INCLUDED
2 #define INMOST_RESIDUAL_INCLUDED
4 #include "inmost_common.h"
5 #include "inmost_sparse.h"
7 #if defined(USE_AUTODIFF) && defined(USE_SOLVER)
29 Residual(std::string name =
"", INMOST_DATA_ENUM_TYPE start = 0, INMOST_DATA_ENUM_TYPE end = 0, INMOST_MPI_Comm _comm = INMOST_MPI_COMM_WORLD);
43 void GetInterval(INMOST_DATA_ENUM_TYPE & start, INMOST_DATA_ENUM_TYPE & end)
const;
47 void SetInterval(INMOST_DATA_ENUM_TYPE beg, INMOST_DATA_ENUM_TYPE end);
56 __INLINE
double Value(INMOST_DATA_ENUM_TYPE row)
const {
return residual[row];}
60 __INLINE
double &
Value(INMOST_DATA_ENUM_TYPE row) {
return residual[row]; }
94 INMOST_DATA_REAL_TYPE
Norm();
97 void Rescale(INMOST_DATA_ENUM_TYPE p = 2);
102 __INLINE
void Lock(INMOST_DATA_ENUM_TYPE pos) {
if(!locks.Empty()) locks.Lock(pos);}
105 __INLINE
void UnLock(INMOST_DATA_ENUM_TYPE pos) {
if(!locks.Empty()) locks.UnLock(pos);}
109 __INLINE
bool TestLock(INMOST_DATA_ENUM_TYPE pos) {
if(!locks.Empty())
return locks.TestLock(pos);
return false;}
Abstract class for a matrix, used to abstract away all the data storage and access and provide common...
Class for linear algebra operations on dense matrices.
The Residual class provides a representation for array of residuals of nonlinear equations.
INMOST_DATA_ENUM_TYPE GetLastIndex() const
Retrieve the last index of the equations in the local partition.
void Rescale(INMOST_DATA_ENUM_TYPE p=2)
Normalize jacobian rows to unit p-norms and scale right hand side accordingly.
__INLINE bool TestLock(INMOST_DATA_ENUM_TYPE pos)
Try to lock the equation.
Sparse::Matrix & GetJacobian()
Retrieve jacobian matrix. Use in Sparse::Solver::Solve function.
const Sparse::Matrix & GetJacobian() const
Retrieve jacobian matrix without right of modificaiton.
void Clear()
Zero out right hand side vector and remove all entries in jacobian matrix.
void ClearJacobian()
Remove all entries in jacobian matrix.
__INLINE void UnLock(INMOST_DATA_ENUM_TYPE pos)
UnLock an equation to allow simultaneous shared access.
INMOST_DATA_ENUM_TYPE GetFirstIndex() const
Retrieve the first index of the equations in the local partition.
__INLINE double & Value(INMOST_DATA_ENUM_TYPE row)
Retrieve a residual value corresponding to certain equation.
void InitLocks()
Initialize openmp locks.
__INLINE multivar_expression_reference operator[](INMOST_DATA_ENUM_TYPE row)
Retrieve a residual value and a jacobian row corresponding to certain equation.
void ClearHessian()
Remove all entries in hessian matrix.
INMOST_DATA_REAL_TYPE Norm()
Compute the second norm of the right hand side vector over all of the processors.
rMatrix Value(const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &rows) const
Retrieve a vector of entries in residual, corresponding to a set of equations.
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.
void ClearResidual()
Zero out right hand side vector.
const Sparse::HessianMatrix & GetHessian() const
Retrieve hessian matrix without right of modificaiton.
Residual(const Residual &other)
Copy constructor.
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.
Residual & operator=(Residual const &other)
Assignment operator.
Sparse::Vector & GetResidual()
Retrieve right hand side vector. Use in Sparse::Solver::Solve function.
__INLINE double Value(INMOST_DATA_ENUM_TYPE row) const
Retrieve a residual value corresponding to certain equation.
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.
__INLINE void Lock(INMOST_DATA_ENUM_TYPE pos)
Lock an equation to avoid simultaneous shared access.
const Sparse::Vector & GetResidual() const
Retrieve right hand side vector without right of modification.
Matrix< value_reference > Value(const AbstractMatrix< INMOST_DATA_INTEGER_TYPE > &rows)
Retrieve a vector of entries in residual, corresponding to a set of equations.
Sparse::HessianMatrix & GetHessian()
Retrieve hessian matrix. Use in nonlinear solver.
Class to store the distributed sparse hessian hyper matrix by compressed symmetric matrices.
This class can be used for shared access to matrix with OpenMP.
Class to store the distributed sparse matrix by compressed rows.
Distributed vector class.
INMOST_DATA_ENUM_TYPE GetLastIndex() const
Get the last index of the distributed vector interval.
INMOST_DATA_ENUM_TYPE GetFirstIndex() const
Get the first index of the distributed vector interval.