b311480e |
1 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | #ifndef math_Recipes_HeaderFile |
16 | #define math_Recipes_HeaderFile |
17 | |
18 | #include <Standard_Boolean.hxx> |
19 | #include <Standard_Integer.hxx> |
20 | #include <Standard_Real.hxx> |
21 | |
22 | #ifndef __math_API |
23 | # if defined(WNT) && !defined(HAVE_NO_DLL) |
24 | # ifdef __math_DLL |
25 | # define __math_API __declspec( dllexport ) |
26 | # else |
27 | # define __math_API __declspec( dllimport ) |
28 | # endif /* __math_DLL */ |
29 | # else |
30 | # define __math_API |
31 | # endif /* WNT */ |
32 | #endif /* __math_API */ |
33 | |
34 | class math_IntegerVector; |
35 | class math_Vector; |
36 | class math_Matrix; |
37 | |
38 | |
39 | const Standard_Integer math_Status_OK = 0; |
40 | const Standard_Integer math_Status_SingularMatrix = 1; |
41 | const Standard_Integer math_Status_ArgumentError = 2; |
42 | const Standard_Integer math_Status_NoConvergence = 3; |
43 | |
44 | __math_API Standard_Integer LU_Decompose(math_Matrix& a, |
45 | math_IntegerVector& indx, |
46 | Standard_Real& d, |
47 | Standard_Real TINY = 1.0e-20); |
48 | |
49 | // Given a matrix a(1..n, 1..n), this routine computes its LU decomposition, |
50 | // The matrix a is replaced by this LU decomposition and the vector indx(1..n) |
51 | // is an output which records the row permutation effected by the partial |
52 | // pivoting; d is output as +1 or -1 depending on wether the number of row |
53 | // interchanges was even or odd. |
54 | |
55 | __math_API Standard_Integer LU_Decompose(math_Matrix& a, |
56 | math_IntegerVector& indx, |
57 | Standard_Real& d, |
58 | math_Vector& vv, |
59 | Standard_Real TINY = 1.0e-30); |
60 | |
61 | // Idem to the previous LU_Decompose function. But the input Vector vv(1..n) is |
62 | // used internally as a scratch area. |
63 | |
64 | |
65 | __math_API void LU_Solve(const math_Matrix& a, |
66 | const math_IntegerVector& indx, |
67 | math_Vector& b); |
68 | |
69 | // Solves a * x = b for a vector x, where x is specified by a(1..n, 1..n), |
70 | // indx(1..n) as returned by LU_Decompose. n is the dimension of the |
71 | // square matrix A. b(1..n) is the input right-hand side and will be |
72 | // replaced by the solution vector.Neither a and indx are destroyed, so |
73 | // the routine may be called sequentially with different b's. |
74 | |
75 | |
76 | __math_API Standard_Integer LU_Invert(math_Matrix& a); |
77 | |
78 | // Given a matrix a(1..n, 1..n) this routine computes its inverse. The matrix |
79 | // a is replaced by its inverse. |
80 | |
81 | |
82 | __math_API Standard_Integer SVD_Decompose(math_Matrix& a, |
83 | math_Vector& w, |
84 | math_Matrix& v); |
85 | |
86 | // Given a matrix a(1..m, 1..n), this routine computes its singular value |
87 | // decomposition, a = u * w * transposed(v). The matrix u replaces a on |
88 | // output. The diagonal matrix of singular values w is output as a vector |
89 | // w(1..n). The matrix v is output as v(1..n, 1..n). m must be greater or |
90 | // equal to n; if it is smaller, then a should be filled up to square with |
91 | // zero rows. |
92 | |
93 | |
94 | __math_API Standard_Integer SVD_Decompose(math_Matrix& a, |
95 | math_Vector& w, |
96 | math_Matrix& v, |
97 | math_Vector& rv1); |
98 | |
99 | |
100 | // Idem to the previous LU_Decompose function. But the input Vector vv(1..m) |
101 | // (the number of rows a(1..m, 1..n)) is used internally as a scratch area. |
102 | |
103 | |
104 | __math_API void SVD_Solve(const math_Matrix& u, |
105 | const math_Vector& w, |
106 | const math_Matrix& v, |
107 | const math_Vector& b, |
108 | math_Vector& x); |
109 | |
110 | // Solves a * x = b for a vector x, where x is specified by u(1..m, 1..n), |
111 | // w(1..n), v(1..n, 1..n) as returned by SVD_Decompose. m and n are the |
112 | // dimensions of A, and will be equal for square matrices. b(1..m) is the |
113 | // input right-hand side. x(1..n) is the output solution vector. |
114 | // No input quantities are destroyed, so the routine may be called |
115 | // sequentially with different b's. |
116 | |
117 | |
118 | |
119 | __math_API Standard_Integer DACTCL_Decompose(math_Vector& a, const math_IntegerVector& indx, |
120 | const Standard_Real MinPivot = 1.e-20); |
121 | |
122 | // Given a SYMMETRIC matrix a, this routine computes its |
123 | // LU decomposition. |
124 | // a is given through a vector of its non zero components of the upper |
125 | // triangular matrix. |
126 | // indx is the indice vector of the diagonal elements of a. |
127 | // a is replaced by its LU decomposition. |
128 | // The range of the matrix is n = indx.Length(), |
129 | // and a.Length() = indx(n). |
130 | |
131 | |
132 | |
133 | __math_API Standard_Integer DACTCL_Solve(const math_Vector& a, math_Vector& b, |
134 | const math_IntegerVector& indx, |
135 | const Standard_Real MinPivot = 1.e-20); |
136 | |
137 | // Solves a * x = b for a vector x and a matrix a coming from DACTCL_Decompose. |
138 | // indx is the same vector as in DACTCL_Decompose. |
139 | // the vector b is replaced by the vector solution x. |
140 | |
141 | |
142 | |
143 | |
144 | __math_API Standard_Integer Jacobi(math_Matrix& a, math_Vector& d, math_Matrix& v, Standard_Integer& nrot); |
145 | |
146 | // Computes all eigenvalues and eigenvectors of a real symmetric matrix |
147 | // a(1..n, 1..n). On output, elements of a above the diagonal are destroyed. |
148 | // d(1..n) returns the eigenvalues of a. v(1..n, 1..n) is a matrix whose |
149 | // columns contain, on output, the normalized eigenvectors of a. nrot returns |
150 | // the number of Jacobi rotations that were required. |
151 | // Eigenvalues are sorted into descending order, and eigenvectors are |
152 | // arranges correspondingly. |
153 | |
7fd59977 |
154 | #endif |
155 | |
156 | |
157 | |
158 | |
159 | |
160 | |
161 | |
162 | |
163 | |