Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Polynomials/exponent_vectors.adb, Revision 1.1.1.1
1.1 maekawa 1: package body Exponent_Vectors is
2:
3: -- CREATORS :
4:
5: function Create ( p : Standard_Complex_Laur_Polys.Poly ) return VecVec is
6:
7: use Standard_Complex_Laur_Polys;
8: res : VecVec(1..Number_of_Terms(p));
9: ind : natural := 0;
10:
11: procedure Add_Exponent ( t : in Term; continue : out boolean ) is
12: begin
13: ind := ind + 1;
14: res(ind) := new Vector(t.dg'range);
15: for i in t.dg'range loop
16: res(ind)(i) := t.dg(i);
17: end loop;
18: continue := true;
19: end Add_Exponent;
20: procedure Add_Exponents is new Visiting_Iterator(Add_Exponent);
21:
22: begin
23: Add_Exponents(p);
24: return res;
25: end Create;
26:
27: function Create ( p : Standard_Complex_Polynomials.Poly ) return VecVec is
28:
29: use Standard_Complex_Polynomials;
30: res : VecVec(1..Number_of_Terms(p));
31: ind : natural := 0;
32:
33: procedure Add_Exponent ( t : in Term; continue : out boolean ) is
34: begin
35: ind := ind + 1;
36: res(ind) := new Vector(t.dg'range);
37: for i in t.dg'range loop
38: res(ind)(i) := t.dg(i);
39: end loop;
40: continue := true;
41: end Add_Exponent;
42: procedure Add_Exponents is new Visiting_Iterator(Add_Exponent);
43:
44: begin
45: Add_Exponents(p);
46: return res;
47: end Create;
48:
49: function Create ( p : Poly_Sys ) return Exponent_Vectors_Array is
50:
51: res : Exponent_Vectors_Array(p'range);
52:
53: begin
54: for i in p'range loop
55: declare
56: cpi : constant VecVec := Create(p(i));
57: begin
58: res(i) := new VecVec(cpi'range);
59: for j in cpi'range loop
60: res(i)(j) := cpi(j);
61: end loop;
62: end; -- a detour for GNAT 3.07
63: -- res(i) := new VecVec'(Create(p(i)));
64: end loop;
65: return res;
66: end Create;
67:
68: function Create ( p : Laur_Sys ) return Exponent_Vectors_Array is
69:
70: res : Exponent_Vectors_Array(p'range);
71:
72: begin
73: for i in p'range loop
74: declare
75: cpi : constant VecVec := Create(p(i));
76: begin
77: res(i) := new VecVec(cpi'range);
78: for j in cpi'range loop
79: res(i)(j) := cpi(j);
80: end loop;
81: end; -- a detour for GNAT 3.07
82: -- res(i) := new VecVec'(Create(p(i)));
83: end loop;
84: return res;
85: end Create;
86:
87: -- SELECTOR :
88:
89: function Position ( ev : VecVec; v : Vector ) return integer is
90: begin
91: for i in ev'range loop
92: if Equal(ev(i).all,v)
93: then return i;
94: end if;
95: end loop;
96: return ev'last+1;
97: end Position;
98:
99: -- EVALUATORS :
100:
101: function Eval ( e : Vector; c : Complex_Number;
102: x : Standard_Complex_Vectors.Vector )
103: return Complex_Number is
104:
105: res : Complex_Number := c;
106:
107: begin
108: for i in e'range loop
109: for j in 1..e(i) loop
110: res := res*x(i);
111: end loop;
112: for j in 1..-e(i) loop
113: res := res/x(i);
114: end loop;
115: end loop;
116: return res;
117: end Eval;
118:
119: function Eval ( ev : VecVec; c,x : Standard_Complex_Vectors.Vector )
120: return Complex_Number is
121:
122: res : Complex_Number := Eval(ev(ev'first).all,c(c'first),x);
123:
124: begin
125: for i in c'first+1..c'last loop
126: res := res + Eval(ev(i).all,c(i),x);
127: end loop;
128: return res;
129: end Eval;
130:
131: function Eval ( ev : Exponent_Vectors_Array;
132: c : Standard_Complex_VecVecs.VecVec;
133: x : Standard_Complex_Vectors.Vector )
134: return Standard_Complex_Vectors.Vector is
135:
136: res : Standard_Complex_Vectors.Vector(x'range);
137:
138: begin
139: for i in ev'range loop
140: res(i) := Eval(ev(i).all,c(i).all,x);
141: end loop;
142: return res;
143: end Eval;
144:
145: -- DESTRUCTORS :
146:
147: procedure Clear ( v : in out Exponent_Vectors_Array ) is
148: begin
149: for i in v'range loop
150: Deep_Clear(v(i));
151: end loop;
152: end Clear;
153:
154: end Exponent_Vectors;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>