1 // Created on: 1991-05-13
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _math_Gauss_HeaderFile
18 #define _math_Gauss_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <math_Matrix.hxx>
26 #include <math_IntegerVector.hxx>
27 #include <Standard_Real.hxx>
28 #include <math_Vector.hxx>
29 #include <Standard_OStream.hxx>
32 class Standard_DimensionError;
33 class StdFail_NotDone;
35 class Message_ProgressIndicator;
37 //! This class implements the Gauss LU decomposition (Crout algorithm)
38 //! with partial pivoting (rows interchange) of a square matrix and
39 //! the different possible derived calculation :
40 //! - solution of a set of linear equations.
41 //! - inverse of a matrix.
42 //! - determinant of a matrix.
49 //! Given an input n X n matrix A this constructor performs its LU
50 //! decomposition with partial pivoting (interchange of rows).
51 //! This LU decomposition is stored internally and may be used to
52 //! do subsequent calculation.
53 //! If the largest pivot found is less than MinPivot the matrix A is
54 //! considered as singular.
55 //! Exception NotSquare is raised if A is not a square matrix.
56 Standard_EXPORT math_Gauss(const math_Matrix& A,
57 const Standard_Real MinPivot = 1.0e-20,
58 const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)());
60 //! Returns true if the computations are successful, otherwise returns false
61 Standard_Boolean IsDone() const { return Done; }
63 //! Given the input Vector B this routine returns the solution X of the set
64 //! of linear equations A . X = B.
65 //! Exception NotDone is raised if the decomposition of A was not done
67 //! Exception DimensionError is raised if the range of B is not
68 //! equal to the number of rows of A.
69 Standard_EXPORT void Solve (const math_Vector& B, math_Vector& X) const;
71 //! Given the input Vector B this routine solves the set of linear
72 //! equations A . X = B. B is replaced by the vector solution X.
73 //! Exception NotDone is raised if the decomposition of A was not done
75 //! Exception DimensionError is raised if the range of B is not
76 //! equal to the number of rows of A.
77 Standard_EXPORT void Solve (math_Vector& B) const;
79 //! This routine returns the value of the determinant of the previously LU
80 //! decomposed matrix A.
81 //! Exception NotDone may be raised if the decomposition of A was not done
82 //! successfully, zero is returned if the matrix A was considered as singular.
83 Standard_EXPORT Standard_Real Determinant() const;
85 //! This routine outputs Inv the inverse of the previously LU decomposed
87 //! Exception DimensionError is raised if the ranges of B are not
88 //! equal to the ranges of A.
89 Standard_EXPORT void Invert (math_Matrix& Inv) const;
91 //! Prints on the stream o information on the current state
93 //! Is used to redefine the operator <<.
94 Standard_EXPORT void Dump (Standard_OStream& o) const;
99 math_IntegerVector Index;
101 Standard_Boolean Done;
105 inline Standard_OStream& operator<<(Standard_OStream& o, const math_Gauss& mG)
111 #endif // _math_Gauss_HeaderFile