Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Polynomials/graded_lexicographic_order.adb, Revision 1.1.1.1
1.1 maekawa 1: with Standard_Natural_Vectors;
2: with Standard_Integer_Vectors;
3:
4: package body Graded_Lexicographic_Order is
5:
6: -- FOR STANDARD NATURAL VECTORS :
7:
8: function "<" ( v1,v2 : Standard_Natural_Vectors.Vector ) return boolean is
9:
10: use Standard_Natural_Vectors;
11: s1,s2 : natural;
12:
13: begin
14: s1 := Sum(v1);
15: s2 := Sum(v2);
16: if s1 < s2
17: then return true;
18: elsif s1 > s2
19: then return false;
20: else if v1'first /= v2'first or else v1'last /= v2'last
21: then raise CONSTRAINT_ERROR;
22: else for i in v1'range loop
23: if v1(i) < v2(i)
24: then return true;
25: elsif v1(i) > v2(i)
26: then return false;
27: end if;
28: end loop;
29: return false; -- v1 = v2
30: end if;
31: end if;
32: end "<";
33:
34: function "<" ( v1,v2 : Standard_Natural_Vectors.Link_to_Vector )
35: return boolean is
36:
37: use Standard_Natural_Vectors;
38:
39: begin
40: if v2 = null
41: then return false;
42: elsif v1 = null
43: then if Sum(v2) > 0
44: then return true;
45: else return false;
46: end if;
47: else return v1.all < v2.all;
48: end if;
49: end "<";
50:
51: function ">" ( v1,v2 : Standard_Natural_Vectors.Vector ) return boolean is
52:
53: use Standard_Natural_Vectors;
54:
55: s1,s2 : natural;
56:
57: begin
58: s1 := Sum(v1);
59: s2 := Sum(v2);
60: if s1 < s2
61: then return false;
62: elsif s1 > s2
63: then return true;
64: else if v1'first /= v2'first or else v1'last /= v2'last
65: then raise CONSTRAINT_ERROR;
66: else for i in v1'range loop
67: if v1(i) < v2(i)
68: then return false;
69: elsif v1(i) > v2(i)
70: then return true;
71: end if;
72: end loop;
73: return false; -- v1 = v2
74: end if;
75: end if;
76: end ">";
77:
78: function ">" ( v1,v2 : Standard_Natural_Vectors.Link_to_Vector )
79: return boolean is
80:
81: use Standard_Natural_Vectors;
82:
83: begin
84: if v1 = null
85: then return false;
86: elsif v2 = null
87: then if Sum(v1) > 0
88: then return true;
89: else return false;
90: end if;
91: else return v1.all > v2.all;
92: end if;
93: end ">";
94:
95: -- FOR STANDARD INTEGER VECTORS :
96:
97: function "<" ( v1,v2 : Standard_Integer_Vectors.Vector ) return boolean is
98:
99: use Standard_Integer_Vectors;
100:
101: s1,s2 : integer;
102:
103: begin
104: s1 := Sum(v1);
105: s2 := Sum(v2);
106: if s1 < s2
107: then return true;
108: elsif s1 > s2
109: then return false;
110: else if v1'first /= v2'first or else v1'last /= v2'last
111: then raise CONSTRAINT_ERROR;
112: else for i in v1'range loop
113: if v1(i) < v2(i)
114: then return true;
115: elsif v1(i) > v2(i)
116: then return false;
117: end if;
118: end loop;
119: return false; -- v1 = v2
120: end if;
121: end if;
122: end "<";
123:
124: function "<" ( v1,v2 : Standard_Integer_Vectors.Link_to_Vector )
125: return boolean is
126:
127: use Standard_Integer_Vectors;
128:
129: begin
130: if v2 = null
131: then return false;
132: elsif v1 = null
133: then if Sum(v2) > 0
134: then return true;
135: else return false;
136: end if;
137: else return v1.all < v2.all;
138: end if;
139: end "<";
140:
141: function ">" ( v1,v2 : Standard_Integer_Vectors.Vector ) return boolean is
142:
143: use Standard_Integer_Vectors;
144:
145: s1,s2 : integer;
146:
147: begin
148: s1 := Sum(v1);
149: s2 := Sum(v2);
150: if s1 < s2
151: then return false;
152: elsif s1 > s2
153: then return true;
154: else if v1'first /= v2'first or else v1'last /= v2'last
155: then raise CONSTRAINT_ERROR;
156: else for i in v1'range loop
157: if v1(i) < v2(i)
158: then return false;
159: elsif v1(i) > v2(i)
160: then return true;
161: end if;
162: end loop;
163: return false; -- v1 = v2
164: end if;
165: end if;
166: end ">";
167:
168: function ">" ( v1,v2 : Standard_Integer_Vectors.Link_to_Vector )
169: return boolean is
170:
171: use Standard_Integer_Vectors;
172:
173: begin
174: if v1 = null
175: then return false;
176: elsif v2 = null
177: then if Sum(v1) > 0
178: then return true;
179: else return false;
180: end if;
181: else return v1.all > v2.all;
182: end if;
183: end ">";
184:
185: end Graded_Lexicographic_Order;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>