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>
31 class Standard_DimensionError;
32 class StdFail_NotDone;
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.
51 //! Given an input n X n matrix A this constructor performs its LU
52 //! decomposition with partial pivoting (interchange of rows).
53 //! This LU decomposition is stored internally and may be used to
54 //! do subsequent calculation.
55 //! If the largest pivot found is less than MinPivot the matrix A is
56 //! considered as singular.
57 //! Exception NotSquare is raised if A is not a square matrix.
58 Standard_EXPORT math_Gauss(const math_Matrix& A, const Standard_Real MinPivot = 1.0e-20);
60 //! Returns true if the computations are successful, otherwise returns false
61 Standard_Boolean IsDone() const;
64 //! Given the input Vector B this routine returns the solution X of the set
65 //! of linear equations A . X = B.
66 //! Exception NotDone is raised if the decomposition of A was not done
68 //! Exception DimensionError is raised if the range of B is not
69 //! equal to the number of rows of A.
70 Standard_EXPORT void Solve (const math_Vector& B, math_Vector& X) const;
73 //! Given the input Vector B this routine solves the set of linear
74 //! equations A . X = B. B is replaced by the vector solution X.
75 //! Exception NotDone is raised if the decomposition of A was not done
77 //! Exception DimensionError is raised if the range of B is not
78 //! equal to the number of rows of A.
79 Standard_EXPORT void Solve (math_Vector& B) const;
82 //! This routine returns the value of the determinant of the previously LU
83 //! decomposed matrix A.
84 //! Exception NotDone may be raised if the decomposition of A was not done
85 //! successfully, zero is returned if the matrix A was considered as singular.
86 Standard_EXPORT Standard_Real Determinant() const;
89 //! This routine outputs Inv the inverse of the previously LU decomposed
91 //! Exception DimensionError is raised if the ranges of B are not
92 //! equal to the ranges of A.
93 Standard_EXPORT void Invert (math_Matrix& Inv) const;
95 //! Prints on the stream o information on the current state
97 //! Is used to redefine the operator <<.
98 Standard_EXPORT void Dump (Standard_OStream& o) const;
107 Standard_Boolean Singular;
109 math_IntegerVector Index;
117 Standard_Boolean Done;
123 #include <math_Gauss.lxx>
129 #endif // _math_Gauss_HeaderFile