1 // Copyright (c) 1997-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef math_Recipes_HeaderFile
16 #define math_Recipes_HeaderFile
18 #include <Standard_Boolean.hxx>
19 #include <Standard_Integer.hxx>
20 #include <Standard_Real.hxx>
21 #include <Standard_Handle.hxx>
22 #include <Message_ProgressRange.hxx>
24 class math_IntegerVector;
28 const Standard_Integer math_Status_UserAborted = -1;
29 const Standard_Integer math_Status_OK = 0;
30 const Standard_Integer math_Status_SingularMatrix = 1;
31 const Standard_Integer math_Status_ArgumentError = 2;
32 const Standard_Integer math_Status_NoConvergence = 3;
34 Standard_EXPORT Standard_Integer LU_Decompose(math_Matrix& a,
35 math_IntegerVector& indx,
37 Standard_Real TINY = 1.0e-20,
38 const Message_ProgressRange& theProgress = Message_ProgressRange());
40 // Given a matrix a(1..n, 1..n), this routine computes its LU decomposition,
41 // The matrix a is replaced by this LU decomposition and the vector indx(1..n)
42 // is an output which records the row permutation effected by the partial
43 // pivoting; d is output as +1 or -1 depending on wether the number of row
44 // interchanges was even or odd.
46 Standard_EXPORT Standard_Integer LU_Decompose(math_Matrix& a,
47 math_IntegerVector& indx,
50 Standard_Real TINY = 1.0e-30,
51 const Message_ProgressRange& theProgress = Message_ProgressRange());
53 // Idem to the previous LU_Decompose function. But the input Vector vv(1..n) is
54 // used internally as a scratch area.
57 Standard_EXPORT void LU_Solve(const math_Matrix& a,
58 const math_IntegerVector& indx,
61 // Solves a * x = b for a vector x, where x is specified by a(1..n, 1..n),
62 // indx(1..n) as returned by LU_Decompose. n is the dimension of the
63 // square matrix A. b(1..n) is the input right-hand side and will be
64 // replaced by the solution vector.Neither a and indx are destroyed, so
65 // the routine may be called sequentially with different b's.
68 Standard_EXPORT Standard_Integer LU_Invert(math_Matrix& a);
70 // Given a matrix a(1..n, 1..n) this routine computes its inverse. The matrix
71 // a is replaced by its inverse.
74 Standard_EXPORT Standard_Integer SVD_Decompose(math_Matrix& a,
78 // Given a matrix a(1..m, 1..n), this routine computes its singular value
79 // decomposition, a = u * w * transposed(v). The matrix u replaces a on
80 // output. The diagonal matrix of singular values w is output as a vector
81 // w(1..n). The matrix v is output as v(1..n, 1..n). m must be greater or
82 // equal to n; if it is smaller, then a should be filled up to square with
86 Standard_EXPORT Standard_Integer SVD_Decompose(math_Matrix& a,
92 // Idem to the previous LU_Decompose function. But the input Vector vv(1..m)
93 // (the number of rows a(1..m, 1..n)) is used internally as a scratch area.
96 Standard_EXPORT void SVD_Solve(const math_Matrix& u,
102 // Solves a * x = b for a vector x, where x is specified by u(1..m, 1..n),
103 // w(1..n), v(1..n, 1..n) as returned by SVD_Decompose. m and n are the
104 // dimensions of A, and will be equal for square matrices. b(1..m) is the
105 // input right-hand side. x(1..n) is the output solution vector.
106 // No input quantities are destroyed, so the routine may be called
107 // sequentially with different b's.
111 Standard_EXPORT Standard_Integer DACTCL_Decompose(math_Vector& a, const math_IntegerVector& indx,
112 const Standard_Real MinPivot = 1.e-20);
114 // Given a SYMMETRIC matrix a, this routine computes its
116 // a is given through a vector of its non zero components of the upper
117 // triangular matrix.
118 // indx is the indice vector of the diagonal elements of a.
119 // a is replaced by its LU decomposition.
120 // The range of the matrix is n = indx.Length(),
121 // and a.Length() = indx(n).
125 Standard_EXPORT Standard_Integer DACTCL_Solve(const math_Vector& a, math_Vector& b,
126 const math_IntegerVector& indx,
127 const Standard_Real MinPivot = 1.e-20);
129 // Solves a * x = b for a vector x and a matrix a coming from DACTCL_Decompose.
130 // indx is the same vector as in DACTCL_Decompose.
131 // the vector b is replaced by the vector solution x.
136 Standard_EXPORT Standard_Integer Jacobi(math_Matrix& a, math_Vector& d, math_Matrix& v, Standard_Integer& nrot);
138 // Computes all eigenvalues and eigenvectors of a real symmetric matrix
139 // a(1..n, 1..n). On output, elements of a above the diagonal are destroyed.
140 // d(1..n) returns the eigenvalues of a. v(1..n, 1..n) is a matrix whose
141 // columns contain, on output, the normalized eigenvectors of a. nrot returns
142 // the number of Jacobi rotations that were required.
143 // Eigenvalues are sorted into descending order, and eigenvectors are
144 // arranges correspondingly.