Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 08:36:30

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_Crout_HeaderFile
0018 #define _math_Crout_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 //! This class implements the Crout algorithm used to solve a
0029 //! system A*X = B where A is a symmetric matrix. It can be used to
0030 //! invert a symmetric matrix.
0031 //! This algorithm is similar to Gauss but is faster than Gauss.
0032 //! Only the inferior triangle of A and the diagonal can be given.
0033 class math_Crout
0034 {
0035 public:
0036   DEFINE_STANDARD_ALLOC
0037 
0038   //! Given an input matrix A, this algorithm inverts A by the
0039   //! Crout algorithm. The user can give only the inferior
0040   //! triangle for the implementation.
0041   //! A can be decomposed like this:
0042   //! A = L * D * T(L) where L is triangular inferior and D is
0043   //! diagonal.
0044   //! If one element of A is less than MinPivot, A is
0045   //! considered as singular.
0046   //! Exception NotSquare is raised if A is not a square matrix.
0047   Standard_EXPORT math_Crout(const math_Matrix& A, const Standard_Real MinPivot = 1.0e-20);
0048 
0049   //! Returns True if all has been correctly done.
0050   Standard_Boolean IsDone() const;
0051 
0052   //! Given an input vector <B>, this routine returns the
0053   //! solution of the set of linear equations A . X = B.
0054   //! Exception NotDone is raised if the decomposition was not
0055   //! done successfully.
0056   //! Exception DimensionError is raised if the range of B is
0057   //! not equal to the rowrange of A.
0058   Standard_EXPORT void Solve(const math_Vector& B, math_Vector& X) const;
0059 
0060   //! returns the inverse matrix of A. Only the inferior
0061   //! triangle is returned.
0062   //! Exception NotDone is raised if NotDone.
0063   const math_Matrix& Inverse() const;
0064 
0065   //! returns in Inv the inverse matrix of A. Only the inferior
0066   //! triangle is returned.
0067   //! Exception NotDone is raised if NotDone.
0068   void Invert(math_Matrix& Inv) const;
0069 
0070   //! Returns the value of the determinant of the previously LU
0071   //! decomposed matrix A. Zero is returned if the matrix A is considered as singular.
0072   //! Exceptions
0073   //! StdFail_NotDone if the algorithm fails (and IsDone returns false).
0074   Standard_Real Determinant() const;
0075 
0076   //! Prints on the stream o information on the current state
0077   //! of the object.
0078   Standard_EXPORT void Dump(Standard_OStream& o) const;
0079 
0080 protected:
0081 private:
0082   math_Matrix      InvA;
0083   Standard_Boolean Done;
0084   Standard_Real    Det;
0085 };
0086 
0087 #include <math_Crout.lxx>
0088 
0089 #endif // _math_Crout_HeaderFile