Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1991-08-07
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_Householder_HeaderFile
0018 #define _math_Householder_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <math_Matrix.hxx>
0025 #include <math_Vector.hxx>
0026 #include <Standard_OStream.hxx>
0027 
0028 
0029 //! This class implements the least square solution of a set of
0030 //! linear equations of m unknowns (n >= m) using the Householder
0031 //! method. It solves A.X = B.
0032 //! This algorithm has more numerical stability than
0033 //! GaussLeastSquare but is longer.
0034 //! It must be used if the matrix is singular or nearly singular.
0035 //! It is about 16% longer than GaussLeastSquare if there is only
0036 //! one member B to solve.
0037 //! It is about 30% longer if there are twenty B members to solve.
0038 class math_Householder 
0039 {
0040 public:
0041 
0042   DEFINE_STANDARD_ALLOC
0043 
0044   
0045   //! Given an input matrix A with n>= m, given an input matrix B
0046   //! this constructor performs the least square resolution of
0047   //! the set of linear equations A.X = B for each column of B.
0048   //! If a column norm is less than EPS, the resolution can't
0049   //! be done.
0050   //! Exception DimensionError is raised if the row number of B
0051   //! is different from the A row number.
0052   Standard_EXPORT math_Householder(const math_Matrix& A, const math_Matrix& B, const Standard_Real EPS = 1.0e-20);
0053   
0054   //! Given an input matrix A with n>= m, given an input matrix B
0055   //! this constructor performs the least square resolution of
0056   //! the set of linear equations A.X = B for each column of B.
0057   //! If a column norm is less than EPS, the resolution can't
0058   //! be done.
0059   //! Exception DimensionError is raised if the row number of B
0060   //! is different from the A row number.
0061   Standard_EXPORT math_Householder(const math_Matrix& A, const math_Matrix& B, const Standard_Integer lowerArow, const Standard_Integer upperArow, const Standard_Integer lowerAcol, const Standard_Integer upperAcol, const Standard_Real EPS = 1.0e-20);
0062   
0063   //! Given an input matrix A with n>= m, given an input vector B
0064   //! this constructor performs the least square resolution of
0065   //! the set of linear equations A.X = B.
0066   //! If a column norm is less than EPS, the resolution can't
0067   //! be done.
0068   //! Exception DimensionError is raised if the length of B
0069   //! is different from the A row number.
0070   Standard_EXPORT math_Householder(const math_Matrix& A, const math_Vector& B, const Standard_Real EPS = 1.0e-20);
0071   
0072   //! Returns true if the computations are successful, otherwise returns false.
0073     Standard_Boolean IsDone() const;
0074   
0075   //! Given the integer Index, this routine returns the
0076   //! corresponding least square solution sol.
0077   //! Exception NotDone is raised if the resolution has not be
0078   //! done.
0079   //! Exception OutOfRange is raised if Index <=0 or
0080   //! Index is more than the number of columns of B.
0081     void Value (math_Vector& sol, const Standard_Integer Index = 1) const;
0082   
0083   //! Returns the matrix sol of all the solutions of the system
0084   //! A.X = B.
0085   //! Exception NotDone is raised is the resolution has not be
0086   //! done.
0087     const math_Matrix& AllValues() const;
0088   
0089   //! Prints information on the current state of the object.
0090   Standard_EXPORT void Dump (Standard_OStream& o) const;
0091 
0092 
0093 
0094 
0095 protected:
0096 
0097   
0098   //! This method is used internally for each constructor
0099   //! above and can't be used directly.
0100   Standard_EXPORT void Perform (const math_Matrix& A, const math_Matrix& B, const Standard_Real EPS);
0101 
0102 
0103 
0104 
0105 private:
0106 
0107 
0108 
0109   math_Matrix Sol;
0110   math_Matrix Q;
0111   Standard_Boolean Done;
0112   Standard_Integer mylowerArow;
0113   Standard_Integer myupperArow;
0114   Standard_Integer mylowerAcol;
0115   Standard_Integer myupperAcol;
0116 
0117 
0118 };
0119 
0120 
0121 #include <math_Householder.lxx>
0122 
0123 
0124 
0125 
0126 
0127 #endif // _math_Householder_HeaderFile