Back to home page

EIC code displayed by LXR

 
 

    


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

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