Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:58:36

0001 // Created on: 1991-08-22
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _math_Uzawa_HeaderFile
0018 #define _math_Uzawa_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <math_Vector.hxx>
0024 #include <math_Matrix.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_OStream.hxx>
0027 
0028 //! This class implements a system resolution C*X = B with
0029 //! an approach solution X0. There are no conditions on the
0030 //! number of equations. The algorithm used is the Uzawa
0031 //! algorithm. It is possible to have equal or inequal (<)
0032 //! equations to solve. The resolution is done with a
0033 //! minimization of Norm(X-X0).
0034 //! If there are only equal equations, the resolution is directly
0035 //! done and is similar to Gauss resolution with an optimisation
0036 //! because the matrix is a symmetric matrix.
0037 //! (The resolution is done with Crout algorithm)
0038 class math_Uzawa
0039 {
0040 public:
0041   DEFINE_STANDARD_ALLOC
0042 
0043   //! Given an input matrix Cont, two input vectors Secont
0044   //! and StartingPoint, it solves Cont*X = Secont (only
0045   //! = equations) with a minimization of Norme(X-X0).
0046   //! The maximum iterations number allowed is fixed to
0047   //! NbIterations.
0048   //! The tolerance EpsLic is fixed for the dual variable
0049   //! convergence. The tolerance EpsLix is used for the
0050   //! convergence of X.
0051   //! Exception ConstructionError is raised if the line number
0052   //! of Cont is different from the length of Secont.
0053   Standard_EXPORT math_Uzawa(const math_Matrix& Cont,
0054                              const math_Vector& Secont,
0055                              const math_Vector& StartingPoint,
0056                              const double       EpsLix       = 1.0e-06,
0057                              const double       EpsLic       = 1.0e-06,
0058                              const int          NbIterations = 500);
0059 
0060   //! Given an input matrix Cont, two input vectors Secont
0061   //! and StartingPoint, it solves Cont*X = Secont (the Nce
0062   //! first equations are equal equations and the Nci last
0063   //! equations are inequalities <) with a minimization
0064   //! of Norme(X-X0).
0065   //! The maximum iterations number allowed is fixed to
0066   //! NbIterations.
0067   //! The tolerance EpsLic is fixed for the dual variable
0068   //! convergence. The tolerance EpsLix is used for the
0069   //! convergence of X.
0070   //! There are no conditions on Nce and Nci.
0071   //! Exception ConstructionError is raised if the line number
0072   //! of Cont is different from the length of Secont and from
0073   //! Nce + Nci.
0074   Standard_EXPORT math_Uzawa(const math_Matrix& Cont,
0075                              const math_Vector& Secont,
0076                              const math_Vector& StartingPoint,
0077                              const int          Nci,
0078                              const int          Nce,
0079                              const double       EpsLix       = 1.0e-06,
0080                              const double       EpsLic       = 1.0e-06,
0081                              const int          NbIterations = 500);
0082 
0083   //! Returns true if the computations are successful, otherwise returns false.
0084   bool IsDone() const;
0085 
0086   //! Returns the vector solution of the system above.
0087   //! An exception is raised if NotDone.
0088   const math_Vector& Value() const;
0089 
0090   //! Returns the initial error Cont*StartingPoint-Secont.
0091   //! An exception is raised if NotDone.
0092   const math_Vector& InitialError() const;
0093 
0094   //! returns the duale variables V of the systeme.
0095   Standard_EXPORT void Duale(math_Vector& V) const;
0096 
0097   //! Returns the difference between X solution and the
0098   //! StartingPoint.
0099   //! An exception is raised if NotDone.
0100   const math_Vector& Error() const;
0101 
0102   //! returns the number of iterations really done.
0103   //! An exception is raised if NotDone.
0104   int NbIterations() const;
0105 
0106   //! returns the inverse matrix of (C * Transposed(C)).
0107   //! This result is needed for the computation of the gradient
0108   //! when approximating a curve.
0109   const math_Matrix& InverseCont() const;
0110 
0111   //! Prints information on the current state of the object.
0112   Standard_EXPORT void Dump(Standard_OStream& o) const;
0113 
0114 protected:
0115   //! Is used internally by the two constructors above.
0116   Standard_EXPORT void Perform(const math_Matrix& Cont,
0117                                const math_Vector& Secont,
0118                                const math_Vector& StartingPoint,
0119                                const int          Nci,
0120                                const int          Nce,
0121                                const double       EpsLix       = 1.0e-06,
0122                                const double       EpsLic       = 1.0e-06,
0123                                const int          NbIterations = 500);
0124 
0125 private:
0126   math_Vector Resul;
0127   math_Vector Erruza;
0128   math_Vector Errinit;
0129   math_Vector Vardua;
0130   math_Matrix CTCinv;
0131   int         NbIter;
0132   bool        Done;
0133 };
0134 
0135 #include <math_Uzawa.lxx>
0136 
0137 #endif // _math_Uzawa_HeaderFile