b311480e |
1 | -- Created on: 1991-08-07 |
2 | -- Created by: Laurent PAINNOT |
3 | -- Copyright (c) 1991-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | |
24 | class Householder from math |
25 | |
26 | ---Purpose: This class implements the least square solution of a set of |
27 | -- linear equations of m unknowns (n >= m) using the Householder |
28 | -- method. It solves A.X = B. |
29 | -- This algorithm has more numerical stability than |
30 | -- GaussLeastSquare but is longer. |
31 | -- It must be used if the matrix is singular or nearly singular. |
32 | -- It is about 16% longer than GaussLeastSquare if there is only |
33 | -- one member B to solve. |
34 | -- It is about 30% longer if there are twenty B members to solve. |
35 | |
36 | uses Matrix from math, |
37 | Vector from math, |
38 | OStream from Standard |
39 | |
40 | raises NotDone from StdFail, |
41 | OutOfRange from Standard, |
42 | DimensionError from Standard, |
43 | ConstructionError from Standard |
44 | |
45 | is |
46 | |
47 | Create(A, B: Matrix; EPS: Real = 1.0e-20) |
48 | ---Purpose: Given an input matrix A with n>= m, given an input matrix B |
49 | -- this constructor performs the least square resolution of |
50 | -- the set of linear equations A.X = B for each column of B. |
51 | -- If a column norm is less than EPS, the resolution can't |
52 | -- be done. |
53 | -- Exception DimensionError is raised if the row number of B |
54 | -- is different from the A row number. |
55 | |
56 | returns Householder |
57 | raises DimensionError; |
58 | |
59 | Create(A, B: Matrix; lowerArow, upperArow, lowerAcol, upperAcol: Integer; |
60 | EPS: Real = 1.0e-20) |
61 | ---Purpose: Given an input matrix A with n>= m, given an input matrix B |
62 | -- this constructor performs the least square resolution of |
63 | -- the set of linear equations A.X = B for each column of B. |
64 | -- If a column norm is less than EPS, the resolution can't |
65 | -- be done. |
66 | -- Exception DimensionError is raised if the row number of B |
67 | -- is different from the A row number. |
68 | |
69 | returns Householder |
70 | raises DimensionError; |
71 | |
72 | |
73 | Create(A: Matrix; B: Vector; EPS: Real = 1.0e-20) |
74 | ---Purpose: Given an input matrix A with n>= m, given an input vector B |
75 | -- this constructor performs the least square resolution of |
76 | -- the set of linear equations A.X = B. |
77 | -- If a column norm is less than EPS, the resolution can't |
78 | -- be done. |
79 | -- Exception DimensionError is raised if the length of B |
80 | -- is different from the A row number. |
81 | |
82 | returns Householder |
83 | raises DimensionError; |
84 | |
85 | |
86 | Perform(me: in out; A, B: Matrix; EPS: Real) |
87 | ---Purpose: This method is used internally for each constructor |
88 | -- above and can't be used directly. |
89 | |
90 | is static protected; |
91 | |
92 | |
93 | IsDone(me) |
94 | ---Purpose: Returns true if the computations are successful, otherwise returns false. |
95 | ---C++: inline |
96 | returns Boolean |
97 | is static; |
98 | |
99 | |
100 | Value(me; sol : out Vector; Index: Integer = 1) |
101 | ---Purpose: Given the integer Index, this routine returns the |
102 | -- corresponding least square solution sol. |
103 | -- Exception NotDone is raised if the resolution has not be |
104 | -- done. |
105 | -- Exception OutOfRange is raised if Index <=0 or |
106 | -- Index is more than the number of columns of B. |
107 | ---C++: inline |
108 | |
109 | raises NotDone, OutOfRange |
110 | is static; |
111 | |
112 | |
113 | AllValues(me) |
114 | ---Purpose: Returns the matrix sol of all the solutions of the system |
115 | -- A.X = B. |
116 | -- Exception NotDone is raised is the resolution has not be |
117 | -- done. |
118 | ---C++: inline |
119 | ---C++: return const& |
120 | |
121 | returns Matrix |
122 | raises NotDone, ConstructionError |
123 | is static; |
124 | |
125 | |
126 | |
127 | Dump(me; o: in out OStream) |
128 | ---Purpose: Prints informations on the current state of the object. |
129 | |
130 | is static; |
131 | |
132 | |
133 | fields |
134 | |
135 | Sol: Matrix; |
136 | Q: Matrix; |
137 | Done: Boolean; |
138 | mylowerArow: Integer; |
139 | myupperArow: Integer; |
140 | mylowerAcol: Integer; |
141 | myupperAcol: Integer; |
142 | |
143 | end Householder; |