0032402: Coding Rules - eliminate msvc warning C4668 (symbol is not defined as a...
[occt.git] / src / math / math_Uzawa.hxx
CommitLineData
42cf5bc1 1// Created on: 1991-08-22
2// Created by: Laurent PAINNOT
3// Copyright (c) 1991-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _math_Uzawa_HeaderFile
18#define _math_Uzawa_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <math_Vector.hxx>
25#include <math_Matrix.hxx>
26#include <Standard_Integer.hxx>
27#include <Standard_Boolean.hxx>
28#include <Standard_Real.hxx>
29#include <Standard_OStream.hxx>
30class StdFail_NotDone;
31class Standard_ConstructionError;
32class math_Matrix;
33
34
35//! This class implements a system resolution C*X = B with
36//! an approach solution X0. There are no conditions on the
37//! number of equations. The algorithm used is the Uzawa
38//! algorithm. It is possible to have equal or inequal (<)
39//! equations to solve. The resolution is done with a
40//! minimization of Norm(X-X0).
41//! If there are only equal equations, the resolution is directly
42//! done and is similar to Gauss resolution with an optimisation
43//! because the matrix is a symmetric matrix.
44//! (The resolution is done with Crout algorithm)
45class math_Uzawa
46{
47public:
48
49 DEFINE_STANDARD_ALLOC
50
51
52 //! Given an input matrix Cont, two input vectors Secont
53 //! and StartingPoint, it solves Cont*X = Secont (only
54 //! = equations) with a minimization of Norme(X-X0).
a25d5aaa 55 //! The maximum iterations number allowed is fixed to
42cf5bc1 56 //! NbIterations.
57 //! The tolerance EpsLic is fixed for the dual variable
58 //! convergence. The tolerance EpsLix is used for the
59 //! convergence of X.
5e6e5914 60 //! Exception ConstructionError is raised if the line number
42cf5bc1 61 //! of Cont is different from the length of Secont.
62 Standard_EXPORT math_Uzawa(const math_Matrix& Cont, const math_Vector& Secont, const math_Vector& StartingPoint, const Standard_Real EpsLix = 1.0e-06, const Standard_Real EpsLic = 1.0e-06, const Standard_Integer NbIterations = 500);
63
64 //! Given an input matrix Cont, two input vectors Secont
65 //! and StartingPoint, it solves Cont*X = Secont (the Nce
66 //! first equations are equal equations and the Nci last
67 //! equations are inequalities <) with a minimization
68 //! of Norme(X-X0).
a25d5aaa 69 //! The maximum iterations number allowed is fixed to
42cf5bc1 70 //! NbIterations.
71 //! The tolerance EpsLic is fixed for the dual variable
72 //! convergence. The tolerance EpsLix is used for the
73 //! convergence of X.
74 //! There are no conditions on Nce and Nci.
5e6e5914 75 //! Exception ConstructionError is raised if the line number
42cf5bc1 76 //! of Cont is different from the length of Secont and from
77 //! Nce + Nci.
78 Standard_EXPORT math_Uzawa(const math_Matrix& Cont, const math_Vector& Secont, const math_Vector& StartingPoint, const Standard_Integer Nci, const Standard_Integer Nce, const Standard_Real EpsLix = 1.0e-06, const Standard_Real EpsLic = 1.0e-06, const Standard_Integer NbIterations = 500);
79
80 //! Returns true if the computations are successful, otherwise returns false.
81 Standard_Boolean IsDone() const;
82
83 //! Returns the vector solution of the system above.
84 //! An exception is raised if NotDone.
85 const math_Vector& Value() const;
86
87 //! Returns the initial error Cont*StartingPoint-Secont.
88 //! An exception is raised if NotDone.
89 const math_Vector& InitialError() const;
90
91 //! returns the duale variables V of the systeme.
92 Standard_EXPORT void Duale (math_Vector& V) const;
93
94 //! Returns the difference between X solution and the
95 //! StartingPoint.
96 //! An exception is raised if NotDone.
97 const math_Vector& Error() const;
98
99 //! returns the number of iterations really done.
100 //! An exception is raised if NotDone.
101 Standard_Integer NbIterations() const;
102
103 //! returns the inverse matrix of (C * Transposed(C)).
104 //! This result is needed for the computation of the gradient
105 //! when approximating a curve.
106 const math_Matrix& InverseCont() const;
107
108 //! Prints information on the current state of the object.
109 Standard_EXPORT void Dump (Standard_OStream& o) const;
110
111
112
113
114protected:
115
116
117 //! Is used internally by the two constructors above.
118 Standard_EXPORT void Perform (const math_Matrix& Cont, const math_Vector& Secont, const math_Vector& StartingPoint, const Standard_Integer Nci, const Standard_Integer Nce, const Standard_Real EpsLix = 1.0e-06, const Standard_Real EpsLic = 1.0e-06, const Standard_Integer NbIterations = 500);
119
120
121
122
123private:
124
125
126
127 math_Vector Resul;
128 math_Vector Erruza;
129 math_Vector Errinit;
130 math_Vector Vardua;
131 math_Matrix CTCinv;
132 Standard_Integer NbIter;
133 Standard_Boolean Done;
134
135
136};
137
138
139#include <math_Uzawa.lxx>
140
141
142
143
144
145#endif // _math_Uzawa_HeaderFile