Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:21:13

0001 // Copyright (c) 1997-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef math_Recipes_HeaderFile
0016 #define math_Recipes_HeaderFile
0017 
0018 #include <Message_ProgressRange.hxx>
0019 
0020 #include <NCollection_Allocator.hxx>
0021 
0022 template <typename T>
0023 class math_VectorBase;
0024 using math_IntegerVector = math_VectorBase<int>;
0025 using math_Vector        = math_VectorBase<double>;
0026 class math_Matrix;
0027 
0028 const int math_Status_UserAborted    = -1;
0029 const int math_Status_OK             = 0;
0030 const int math_Status_SingularMatrix = 1;
0031 const int math_Status_ArgumentError  = 2;
0032 const int math_Status_NoConvergence  = 3;
0033 
0034 Standard_EXPORT int LU_Decompose(
0035   math_Matrix&                 a,
0036   math_IntegerVector&          indx,
0037   double&                      d,
0038   double                       TINY        = 1.0e-20,
0039   const Message_ProgressRange& theProgress = Message_ProgressRange());
0040 
0041 // Given a matrix a(1..n, 1..n), this routine computes its LU decomposition,
0042 // The matrix a is replaced by this LU decomposition and the vector indx(1..n)
0043 // is an output which records the row permutation effected by the partial
0044 // pivoting; d is output as +1 or -1 depending on whether the number of row
0045 // interchanges was even or odd.
0046 
0047 Standard_EXPORT int LU_Decompose(
0048   math_Matrix&                 a,
0049   math_IntegerVector&          indx,
0050   double&                      d,
0051   math_Vector&                 vv,
0052   double                       TINY        = 1.0e-30,
0053   const Message_ProgressRange& theProgress = Message_ProgressRange());
0054 
0055 // Idem to the previous LU_Decompose function. But the input Vector vv(1..n) is
0056 // used internally as a scratch area.
0057 
0058 Standard_EXPORT void LU_Solve(const math_Matrix& a, const math_IntegerVector& indx, math_Vector& b);
0059 
0060 // Solves a * x = b for a vector x, where x is specified by a(1..n, 1..n),
0061 // indx(1..n) as returned by LU_Decompose. n is the dimension of the
0062 // square matrix A. b(1..n) is the input right-hand side and will be
0063 // replaced by the solution vector.Neither a and indx are destroyed, so
0064 // the routine may be called sequentially with different b's.
0065 
0066 Standard_EXPORT int LU_Invert(math_Matrix& a);
0067 
0068 // Given a matrix a(1..n, 1..n) this routine computes its inverse. The matrix
0069 // a is replaced by its inverse.
0070 
0071 Standard_EXPORT int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v);
0072 
0073 // Given a matrix a(1..m, 1..n), this routine computes its singular value
0074 // decomposition, a = u * w * transposed(v). The matrix u replaces a on
0075 // output. The diagonal matrix of singular values w is output as a vector
0076 // w(1..n). The matrix v is output as v(1..n, 1..n). m must be greater or
0077 // equal to n; if it is smaller, then a should be filled up to square with
0078 // zero rows.
0079 
0080 Standard_EXPORT int SVD_Decompose(math_Matrix& a, math_Vector& w, math_Matrix& v, math_Vector& rv1);
0081 
0082 // Idem to the previous LU_Decompose function. But the input Vector vv(1..m)
0083 // (the number of rows a(1..m, 1..n)) is used internally as a scratch area.
0084 
0085 Standard_EXPORT void SVD_Solve(const math_Matrix& u,
0086                                const math_Vector& w,
0087                                const math_Matrix& v,
0088                                const math_Vector& b,
0089                                math_Vector&       x);
0090 
0091 // Solves a * x = b for a vector x, where x is specified by u(1..m, 1..n),
0092 // w(1..n), v(1..n, 1..n) as returned by SVD_Decompose. m and n are the
0093 // dimensions of A, and will be equal for square matrices. b(1..m) is the
0094 // input right-hand side. x(1..n) is the output solution vector.
0095 // No input quantities are destroyed, so the routine may be called
0096 // sequentially with different b's.
0097 
0098 Standard_EXPORT int DACTCL_Decompose(math_Vector&              a,
0099                                      const math_IntegerVector& indx,
0100                                      const double              MinPivot = 1.e-20);
0101 
0102 // Given a SYMMETRIC matrix a, this routine computes its
0103 // LU decomposition.
0104 // a is given through a vector of its non zero components of the upper
0105 // triangular matrix.
0106 // indx is the indice vector of the diagonal elements of a.
0107 // a is replaced by its LU decomposition.
0108 // The range of the matrix is n = indx.Length(),
0109 // and a.Length() = indx(n).
0110 
0111 Standard_EXPORT int DACTCL_Solve(const math_Vector&        a,
0112                                  math_Vector&              b,
0113                                  const math_IntegerVector& indx,
0114                                  const double              MinPivot = 1.e-20);
0115 
0116 // Solves a * x = b for a vector x and a matrix a coming from DACTCL_Decompose.
0117 // indx is the same vector as in DACTCL_Decompose.
0118 // the vector b is replaced by the vector solution x.
0119 
0120 Standard_EXPORT int Jacobi(math_Matrix& a, math_Vector& d, math_Matrix& v, int& nrot);
0121 
0122 // Computes all eigenvalues and eigenvectors of a real symmetric matrix
0123 // a(1..n, 1..n). On output, elements of a above the diagonal are destroyed.
0124 // d(1..n) returns the eigenvalues of a. v(1..n, 1..n) is a matrix whose
0125 // columns contain, on output, the normalized eigenvectors of a. nrot returns
0126 // the number of Jacobi rotations that were required.
0127 // Eigenvalues are sorted into descending order, and eigenvectors are
0128 // arranges correspondingly.
0129 
0130 #endif