0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / math / math_Householder.hxx
CommitLineData
42cf5bc1 1// Created on: 1991-08-07
2// Created by: Laurent PAINNOT
3// Copyright (c) 1991-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _math_Householder_HeaderFile
18#define _math_Householder_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <math_Matrix.hxx>
25#include <Standard_Boolean.hxx>
26#include <Standard_Integer.hxx>
27#include <Standard_Real.hxx>
28#include <math_Vector.hxx>
29#include <Standard_OStream.hxx>
30class StdFail_NotDone;
31class Standard_OutOfRange;
32class Standard_DimensionError;
33class Standard_ConstructionError;
34class math_Matrix;
35
36
37//! This class implements the least square solution of a set of
38//! linear equations of m unknowns (n >= m) using the Householder
39//! method. It solves A.X = B.
40//! This algorithm has more numerical stability than
41//! GaussLeastSquare but is longer.
42//! It must be used if the matrix is singular or nearly singular.
43//! It is about 16% longer than GaussLeastSquare if there is only
44//! one member B to solve.
45//! It is about 30% longer if there are twenty B members to solve.
46class math_Householder
47{
48public:
49
50 DEFINE_STANDARD_ALLOC
51
52
53 //! Given an input matrix A with n>= m, given an input matrix B
54 //! this constructor performs the least square resolution of
55 //! the set of linear equations A.X = B for each column of B.
56 //! If a column norm is less than EPS, the resolution can't
57 //! be done.
58 //! Exception DimensionError is raised if the row number of B
59 //! is different from the A row number.
60 Standard_EXPORT math_Householder(const math_Matrix& A, const math_Matrix& B, const Standard_Real EPS = 1.0e-20);
61
62 //! Given an input matrix A with n>= m, given an input matrix B
63 //! this constructor performs the least square resolution of
64 //! the set of linear equations A.X = B for each column of B.
65 //! If a column norm is less than EPS, the resolution can't
66 //! be done.
67 //! Exception DimensionError is raised if the row number of B
68 //! is different from the A row number.
69 Standard_EXPORT math_Householder(const math_Matrix& A, const math_Matrix& B, const Standard_Integer lowerArow, const Standard_Integer upperArow, const Standard_Integer lowerAcol, const Standard_Integer upperAcol, const Standard_Real EPS = 1.0e-20);
70
71 //! Given an input matrix A with n>= m, given an input vector B
72 //! this constructor performs the least square resolution of
73 //! the set of linear equations A.X = B.
74 //! If a column norm is less than EPS, the resolution can't
75 //! be done.
76 //! Exception DimensionError is raised if the length of B
77 //! is different from the A row number.
78 Standard_EXPORT math_Householder(const math_Matrix& A, const math_Vector& B, const Standard_Real EPS = 1.0e-20);
79
80 //! Returns true if the computations are successful, otherwise returns false.
81 Standard_Boolean IsDone() const;
82
83 //! Given the integer Index, this routine returns the
84 //! corresponding least square solution sol.
85 //! Exception NotDone is raised if the resolution has not be
86 //! done.
87 //! Exception OutOfRange is raised if Index <=0 or
88 //! Index is more than the number of columns of B.
89 void Value (math_Vector& sol, const Standard_Integer Index = 1) const;
90
91 //! Returns the matrix sol of all the solutions of the system
92 //! A.X = B.
93 //! Exception NotDone is raised is the resolution has not be
94 //! done.
95 const math_Matrix& AllValues() const;
96
97 //! Prints informations on the current state of the object.
98 Standard_EXPORT void Dump (Standard_OStream& o) const;
99
100
101
102
103protected:
104
105
106 //! This method is used internally for each constructor
107 //! above and can't be used directly.
108 Standard_EXPORT void Perform (const math_Matrix& A, const math_Matrix& B, const Standard_Real EPS);
109
110
111
112
113private:
114
115
116
117 math_Matrix Sol;
118 math_Matrix Q;
119 Standard_Boolean Done;
120 Standard_Integer mylowerArow;
121 Standard_Integer myupperArow;
122 Standard_Integer mylowerAcol;
123 Standard_Integer myupperAcol;
124
125
126};
127
128
129#include <math_Householder.lxx>
130
131
132
133
134
135#endif // _math_Householder_HeaderFile