Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:15

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 
0029 //! This class implements a system resolution C*X = B with
0030 //! an approach solution X0. There are no conditions on the
0031 //! number of equations. The algorithm used is the Uzawa
0032 //! algorithm. It is possible to have equal or inequal  (<)
0033 //! equations to solve. The resolution is done with a
0034 //! minimization of Norm(X-X0).
0035 //! If there are only equal equations, the resolution is directly
0036 //! done and is similar to Gauss resolution with an optimisation
0037 //! because the matrix is a symmetric matrix.
0038 //! (The resolution is done with Crout algorithm)
0039 class math_Uzawa 
0040 {
0041 public:
0042 
0043   DEFINE_STANDARD_ALLOC
0044 
0045   
0046   //! Given an input matrix Cont, two input vectors Secont
0047   //! and StartingPoint, it solves Cont*X = Secont (only
0048   //! = equations) with a minimization of Norme(X-X0).
0049   //! The maximum iterations number allowed is fixed to
0050   //! NbIterations.
0051   //! The tolerance EpsLic is fixed for the dual variable
0052   //! convergence. The tolerance EpsLix is used for the
0053   //! convergence of X.
0054   //! Exception ConstructionError is raised if the line number
0055   //! of Cont is different from the length of Secont.
0056   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);
0057   
0058   //! Given an input matrix Cont, two input vectors Secont
0059   //! and StartingPoint, it solves Cont*X = Secont (the Nce
0060   //! first equations are equal equations and the Nci last
0061   //! equations are inequalities <) with a minimization
0062   //! of Norme(X-X0).
0063   //! The maximum iterations number allowed is fixed to
0064   //! NbIterations.
0065   //! The tolerance EpsLic is fixed for the dual variable
0066   //! convergence. The tolerance EpsLix is used for the
0067   //! convergence of X.
0068   //! There are no conditions on Nce and Nci.
0069   //! Exception ConstructionError is raised if the line number
0070   //! of Cont is different from the length of Secont and from
0071   //! Nce + Nci.
0072   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);
0073   
0074   //! Returns true if the computations are successful, otherwise returns false.
0075     Standard_Boolean IsDone() const;
0076   
0077   //! Returns the vector solution of the system above.
0078   //! An exception is raised if NotDone.
0079     const math_Vector& Value() const;
0080   
0081   //! Returns the initial error Cont*StartingPoint-Secont.
0082   //! An exception is raised if NotDone.
0083     const math_Vector& InitialError() const;
0084   
0085   //! returns the duale variables V of the systeme.
0086   Standard_EXPORT void Duale (math_Vector& V) const;
0087   
0088   //! Returns the difference between X solution and the
0089   //! StartingPoint.
0090   //! An exception is raised if NotDone.
0091     const math_Vector& Error() const;
0092   
0093   //! returns the number of iterations really done.
0094   //! An exception is raised if NotDone.
0095     Standard_Integer NbIterations() const;
0096   
0097   //! returns the inverse matrix of (C * Transposed(C)).
0098   //! This result is needed for the computation of the gradient
0099   //! when approximating a curve.
0100     const math_Matrix& InverseCont() const;
0101   
0102   //! Prints information on the current state of the object.
0103   Standard_EXPORT void Dump (Standard_OStream& o) const;
0104 
0105 
0106 
0107 
0108 protected:
0109 
0110   
0111   //! Is used internally by the two constructors above.
0112   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);
0113 
0114 
0115 
0116 
0117 private:
0118 
0119 
0120 
0121   math_Vector Resul;
0122   math_Vector Erruza;
0123   math_Vector Errinit;
0124   math_Vector Vardua;
0125   math_Matrix CTCinv;
0126   Standard_Integer NbIter;
0127   Standard_Boolean Done;
0128 
0129 
0130 };
0131 
0132 
0133 #include <math_Uzawa.lxx>
0134 
0135 
0136 
0137 
0138 
0139 #endif // _math_Uzawa_HeaderFile