0022904: Clean up sccsid variables
[occt.git] / src / math / math_Gauss.cxx
1 //#ifndef DEB
2 #define No_Standard_RangeError
3 #define No_Standard_OutOfRange
4 #define No_Standard_DimensionError
5 //#endif
6
7 #include <math_Gauss.ixx>
8 #include <math_Recipes.hxx>
9
10 #include <math_NotSquare.hxx> 
11 #include <StdFail_NotDone.hxx>
12 #include <Standard_DimensionError.hxx>
13 #include <Standard_NotImplemented.hxx>
14
15     math_Gauss::math_Gauss(const math_Matrix& A, 
16                            const Standard_Real MinPivot) 
17                            : LU   (1, A.RowNumber(), 1, A.ColNumber()),
18                              Index(1, A.RowNumber()) {
19
20       math_NotSquare_Raise_if(A.RowNumber() != A.ColNumber(), " ");     
21       LU = A;
22       Standard_Integer Error = LU_Decompose(LU, 
23                                   Index, 
24                                   D,
25                                   MinPivot);
26       if(!Error) {
27         Done = Standard_True;
28       }
29       else {
30         Done = Standard_False;
31       }
32     }
33
34     void  math_Gauss::Solve(const math_Vector& B, math_Vector& X) const{
35
36        StdFail_NotDone_Raise_if(!Done, " ");
37
38        X = B;
39        LU_Solve(LU,
40                 Index,
41                 X);
42     }
43
44     void math_Gauss::Solve (math_Vector& X) const{
45
46        StdFail_NotDone_Raise_if(!Done, " ");
47
48        if(X.Length() != LU.RowNumber()) {
49          Standard_DimensionError::Raise();
50        }
51        LU_Solve(LU,
52                 Index,
53                 X);
54     }
55
56     Standard_Real math_Gauss::Determinant() const{
57
58        StdFail_NotDone_Raise_if(!Done, " ");
59
60        Standard_Real Result = D;
61        for(Standard_Integer J = 1; J <= LU.UpperRow(); J++) {
62          Result *= LU(J,J);
63        }
64        return Result;
65     }
66
67     void math_Gauss::Invert(math_Matrix& Inv) const{
68
69        StdFail_NotDone_Raise_if(!Done, " ");
70
71        Standard_DimensionError_Raise_if((Inv.RowNumber() != LU.RowNumber()) ||
72                                         (Inv.ColNumber() != LU.ColNumber()),
73                                         " ");
74
75        Standard_Integer LowerRow = Inv.LowerRow();
76        Standard_Integer LowerCol = Inv.LowerCol();
77        math_Vector Column(1, LU.UpperRow());
78
79        Standard_Integer I, J;
80        for(J = 1; J <= LU.UpperRow(); J++) {
81          for(I = 1; I <= LU.UpperRow(); I++) {
82            Column(I) = 0.0;
83          }
84          Column(J) = 1.0;
85          LU_Solve(LU, Index, Column);
86          for(I = 1; I <= LU.RowNumber(); I++) {
87            Inv(I+LowerRow-1,J+LowerCol-1) = Column(I);
88          }
89        }
90
91     }
92
93
94 void math_Gauss::Dump(Standard_OStream& o) const {
95        o << "math_Gauss ";
96        if(Done) {
97          o<< " Status = Done \n";
98          o << " Determinant of A = " << D << endl;
99        }
100        else {
101          o << " Status = not Done \n";
102        }
103     }
104
105
106
107