1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
-- File: DirectPolynomialRoots.cdl
-- Created: Mon May 13 16:47:42 1991
-- Author: Laurent PAINNOT
-- <lpa@topsn3>
---Copyright: Matra Datavision 1991, 1992
class DirectPolynomialRoots from math
---Purpose:
-- This class implements the calculation of all the real roots of a real
-- polynomial of degree <= 4 using a direct method. Once found,
-- the roots are polished using the Newton method.
uses OStream from Standard
raises RangeError from Standard,
InfiniteSolutions from StdFail
is
Create(A, B, C, D, E: Real)
---Purpose:
-- computes all the real roots of the polynomial
-- Ax4 + Bx3 + Cx2 + Dx + E using a direct method.
returns DirectPolynomialRoots;
Create(A, B, C, D: Real)
---Purpose:
-- computes all the real roots of the polynomial
-- Ax3 + Bx2 + Cx + D using a direct method.
returns DirectPolynomialRoots;
Create(A, B, C: Real)
---Purpose:
-- computes all the real roots of the polynomial
-- Ax2 + Bx + C using a direct method.
returns DirectPolynomialRoots;
Create(A, B: Real)
---Purpose:
-- computes the real root of the polynomial Ax + B.
returns DirectPolynomialRoots;
Solve(me: in out; A, B, C, D, E: Real)
is static protected;
Solve(me: in out; A, B, C, D: Real)
is static protected;
Solve(me: in out; A, B, C: Real)
is static protected;
Solve(me: in out; A, B: Real)
is static protected;
IsDone(me)
---Purpose: Returns true if the computations are successful, otherwise returns false.
---C++: inline
returns Boolean
is static;
InfiniteRoots(me)
---Purpose: Returns true if there is an infinity of roots, otherwise returns false.
---C++: inline
returns Boolean
is static;
NbSolutions(me)
---Purpose: returns the number of solutions.
-- An exception is raised if there are an infinity of roots.
---C++: inline
returns Integer
raises InfiniteSolutions
is static;
Value(me; Nieme: Integer)
---Purpose: returns the value of the Nieme root.
-- An exception is raised if there are an infinity of roots.
-- Exception RangeError is raised if Nieme is < 1
-- or Nieme > NbSolutions.
---C++: inline
returns Real
raises InfiniteSolutions, RangeError
is static;
Dump(me; o: in out OStream)
---Purpose: Prints on the stream o information on the current state
-- of the object.
-- Is used to redefine the operator <<.
is static;
fields
Done: Boolean;
InfiniteStatus: Boolean;
NbSol: Integer;
TheRoots: Real[4];
end DirectPolynomialRoots;
|