7fd59977 |
1 | -- File: Jacobi.cdl |
2 | -- Created: Tue May 14 18:21:21 1991 |
3 | -- Author: Laurent PAINNOT |
4 | -- <lpa@topsn3> |
5 | ---Copyright: Matra Datavision 1991, 1992 |
6 | |
7 | |
8 | |
9 | class Jacobi from math |
10 | ---Purpose: |
11 | -- This class implements the Jacobi method to find the eigenvalues and |
12 | -- the eigenvectors of a real symmetric square matrix. |
13 | -- A sort of eigenvalues is done. |
14 | |
15 | uses Vector from math, |
16 | Matrix from math, |
17 | OStream from Standard |
18 | |
19 | raises NotDone from StdFail |
20 | |
21 | is |
22 | |
23 | Create(A: Matrix) |
24 | ---Purpose: |
25 | -- Given a Real n X n matrix A, this constructor computes all its |
26 | -- eigenvalues and eigenvectors using the Jacobi method. |
27 | -- The exception NotSquare is raised if the matrix is not square. |
28 | -- No verification that the matrix A is really symmetric is done. |
29 | |
30 | returns Jacobi; |
31 | |
32 | |
33 | IsDone(me) |
34 | ---Purpose: Returns true if the computations are successful, otherwise returns false. |
35 | ---C++: inline |
36 | returns Boolean |
37 | is static; |
38 | |
39 | |
40 | Values(me) |
41 | ---Purpose: Returns the eigenvalues vector. |
42 | -- Exception NotDone is raised if calculation is not done successfully. |
43 | ---C++: inline |
44 | ---C++: return const& |
45 | returns Vector |
46 | raises NotDone |
47 | is static; |
48 | |
49 | |
50 | Value(me; Num: Integer) |
51 | ---Purpose: returns the eigenvalue number Num. |
52 | -- Eigenvalues are in the range (1..n). |
53 | -- Exception NotDone is raised if calculation is not done successfully. |
54 | ---C++: inline |
55 | returns Real |
56 | raises NotDone |
57 | is static; |
58 | |
59 | |
60 | Vectors(me) |
61 | ---Purpose: returns the eigenvectors matrix. |
62 | -- Exception NotDone is raised if calculation is not done successfully. |
63 | ---C++: inline |
64 | ---C++: return const& |
65 | returns Matrix |
66 | raises NotDone |
67 | is static; |
68 | |
69 | |
70 | Vector(me; Num: Integer; V : out Vector) |
71 | ---Purpose: Returns the eigenvector V of number Num. |
72 | -- Eigenvectors are in the range (1..n). |
73 | -- Exception NotDone is raised if calculation is not done successfully. |
74 | ---C++: inline |
75 | raises NotDone |
76 | is static; |
77 | |
78 | |
79 | |
80 | Dump(me; o: in out OStream) |
81 | ---Purpose: Prints information on the current state of the object. |
82 | -- Is used to redefine the operator <<. |
83 | |
84 | is static; |
85 | |
86 | |
87 | fields |
88 | |
89 | Done: Boolean; |
90 | AA: Matrix; |
91 | NbRotations: Integer; |
92 | EigenValues: Vector; |
93 | EigenVectors: Matrix; |
94 | |
95 | end Jacobi; |