b311480e |
1 | -- Created on: 1991-05-06 |
2 | -- Created by: Laurent PAINNOT |
3 | -- Copyright (c) 1991-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | |
24 | class IntegerVector from math |
25 | |
26 | ---Purpose: |
27 | -- This class implements the real IntegerVector abstract data type. |
28 | -- IntegerVectors can have an arbitrary range which must be define at |
29 | -- the declaration and cannot be changed after this declaration. |
30 | -- Example: math_IntegerVector V1(-3, 5); // an IntegerVector with |
31 | -- range [-3..5] |
32 | -- |
33 | -- IntegerVector is copied through assignement : |
34 | -- math_IntegerVector V2( 1, 9); |
35 | -- .... |
36 | -- V2 = V1; |
37 | -- V1(1) = 2.0; // the IntegerVector V2 will not be modified. |
38 | -- |
39 | -- The Exception RangeError is raised when trying to access outside |
40 | -- the range of an IntegerVector : |
41 | -- V1(11) = 0 // --> will raise RangeError; |
42 | -- |
43 | -- The Exception DimensionError is raised when the dimensions of two |
44 | -- IntegerVectors are not compatible : |
45 | -- math_IntegerVector V3(1, 2); |
46 | -- V3 = V1; // --> will raise DimensionError; |
47 | -- V1.Add(V3) // --> will raise DimensionError; |
48 | |
49 | uses Matrix from math, |
50 | SingleTabOfInteger from math, |
51 | OStream from Standard |
52 | |
53 | raises DimensionError from Standard, |
54 | DivideByZero from Standard, |
55 | RangeError from Standard |
56 | |
57 | is |
58 | |
59 | Create(First, Last: Integer) |
60 | ---Purpose: contructs an IntegerVector in the range [Lower..Upper] |
61 | |
62 | returns IntegerVector; |
63 | |
64 | Create(First, Last: Integer; InitialValue : Integer) |
65 | ---Purpose: contructs an IntegerVector in the range [Lower..Upper] |
66 | -- with all the elements set to InitialValue. |
67 | |
68 | returns IntegerVector; |
69 | |
70 | |
71 | Init(me : in out; InitialValue: Integer); |
72 | ---Purpose: Initialize an IntegerVector with all the elements |
73 | -- set to InitialValue. |
74 | |
75 | |
76 | Create(Tab : Address; First, Last: Integer) |
77 | ---Purpose: constructs an IntegerVector in the range [Lower..Upper] |
78 | -- which share the "c array" Tab. |
79 | |
80 | returns IntegerVector; |
81 | |
82 | |
83 | Create(Other: IntegerVector) |
84 | ---Purpose: constructs a copy for initialization. |
85 | -- An exception is raised if the lengths of the IntegerVectors |
86 | -- are different. |
87 | |
88 | returns IntegerVector |
89 | raises DimensionError; |
90 | |
91 | |
92 | SetFirst(me: in out; First: Integer) |
93 | ---Purpose: is used internally to set the Lower value of the |
94 | -- IntegerVector. |
95 | |
96 | is static protected; |
97 | |
98 | |
99 | Length(me) |
100 | ---Purpose: returns the length of an IntegerVector |
101 | ---C++: inline |
102 | |
103 | returns Integer |
104 | is static; |
105 | |
106 | |
107 | Lower(me) |
108 | ---Purpose: returns the value of the Lower index of an IntegerVector. |
109 | ---C++: inline |
110 | |
111 | returns Integer |
112 | is static; |
113 | |
114 | |
115 | Upper(me) |
116 | ---Purpose: returns the value of the Upper index of an IntegerVector. |
117 | ---C++: inline |
118 | |
119 | returns Integer |
120 | is static; |
121 | |
122 | |
123 | Norm(me) |
124 | ---Purpose: returns the value of the norm of an IntegerVector. |
125 | |
126 | returns Real |
127 | is static; |
128 | |
129 | |
130 | Norm2 (me) |
131 | ---Purpose: returns the value of the square of the norm of an |
132 | -- IntegerVector. |
133 | |
134 | returns Real |
135 | is static; |
136 | |
137 | |
138 | Max(me) |
139 | ---Purpose: returns the value of the Index of the maximum element of |
140 | -- an IntegerVector. |
141 | |
142 | returns Integer |
143 | is static; |
144 | |
145 | |
146 | Min(me) |
147 | ---Purpose: returns the value of the Index of the minimum element |
148 | -- of an IntegerVector. |
149 | |
150 | returns Integer |
151 | is static; |
152 | |
153 | |
154 | Invert(me: in out) |
155 | ---Purpose: inverses an IntegerVector. |
156 | ---Example: [1, 2, 3, 4] becomes [4, 3, 2, 1]. |
157 | |
158 | is static; |
159 | |
160 | |
161 | Inverse(me) |
162 | ---Purpose: returns the inverse IntegerVector of an IntegerVector. |
163 | |
164 | returns IntegerVector |
165 | is static; |
166 | |
167 | |
168 | Set(me: in out; I1, I2: Integer; V: IntegerVector) |
169 | ---Purpose: sets an IntegerVector from <I1> to <I2> to the |
170 | -- IntegerVector <V>; |
171 | -- An exception is raised if I1<LowerIndex or I2>UpperIndex or I1>I2. |
172 | -- An exception is raised if I2-I1+1 is different from the Length of V. |
173 | |
174 | raises DimensionError |
175 | is static; |
176 | |
177 | |
178 | Slice(me; I1, I2: Integer) |
179 | ---Purpose: slices the values of the IntegerVector between <I1> and |
180 | -- <I2>: |
181 | -- Example: [2, 1, 2, 3, 4, 5] becomes [2, 4, 3, 2, 1, 5] between 2 and 5. |
182 | -- An exception is raised if I1<LowerIndex or I2>UpperIndex. |
183 | |
184 | returns IntegerVector |
185 | raises DimensionError |
186 | is static; |
187 | |
188 | |
189 | Multiply (me: in out; Right: Integer) |
190 | ---Purpose: returns the product of an IntegerVector by an integer value. |
191 | ---C++: alias operator *= |
192 | |
193 | raises DimensionError from Standard |
194 | is static; |
195 | |
196 | |
197 | Multiplied (me; Right: Integer) |
198 | ---Purpose: returns the product of an IntegerVector by an integer value. |
199 | ---C++: alias operator* |
200 | |
201 | returns IntegerVector |
202 | raises DimensionError from Standard |
203 | is static; |
204 | |
205 | TMultiplied (me; Right: Integer) |
206 | ---Purpose: returns the product of a vector and a real value. |
207 | ---C++: alias "friend math_IntegerVector operator *(const Standard_Integer Left,const math_IntegerVector& Right);" |
208 | returns IntegerVector |
209 | is static; |
210 | |
211 | Add (me: in out; Right: IntegerVector) |
212 | ---Purpose: adds the IntegerVector <Right> to an IntegerVector. |
213 | -- An exception is raised if the IntegerVectors have not the same |
214 | -- length. |
215 | -- An exception is raised if the lengths are not equal. |
216 | ---C++: alias operator += |
217 | |
218 | raises DimensionError |
219 | is static; |
220 | |
221 | |
222 | Added (me; Right: IntegerVector) |
223 | ---Purpose: adds the IntegerVector <Right> to an IntegerVector. |
224 | -- An exception is raised if the IntegerVectors have not the same |
225 | -- length. |
226 | -- An exception is raised if the lengths are not equal. |
227 | ---C++:alias operator+ |
228 | |
229 | returns IntegerVector |
230 | raises DimensionError |
231 | is static; |
232 | |
233 | |
234 | |
235 | Add (me: in out; Left, Right: IntegerVector) |
236 | ---Purpose: sets an IntegerVector to the sum of the IntegerVector |
237 | -- <Left> and the IntegerVector <Right>. |
238 | -- An exception is raised if the lengths are different. |
239 | |
240 | raises DimensionError |
241 | is static; |
242 | |
243 | |
244 | Subtract(me: in out; Left, Right: IntegerVector) |
245 | ---Purpose: sets an IntegerVector to the substraction of |
246 | -- <Right> from <Left>. |
247 | -- An exception is raised if the IntegerVectors have not the same |
248 | -- length. |
249 | |
250 | raises DimensionError |
251 | is static; |
252 | |
253 | |
254 | Value(me; Num: Integer) |
255 | ---Purpose: accesses (in read or write mode) the value of index Num of |
256 | -- an IntegerVector. |
257 | ---C++: alias operator() |
258 | ---C++: return & |
259 | ---C++: inline |
260 | |
261 | returns Integer |
262 | raises RangeError from Standard |
263 | is static; |
264 | |
265 | |
266 | Initialized(me: in out; Other: IntegerVector) |
267 | ---Purpose: Initialises an IntegerVector by copying <Other>. |
268 | -- An exception is raised if the Lengths are different. |
269 | ---C++: alias operator= |
270 | ---C++: return & |
271 | |
272 | returns IntegerVector |
273 | raises DimensionError |
274 | is static; |
275 | |
276 | |
277 | |
278 | Multiplied(me; Right: IntegerVector) |
279 | ---Purpose: returns the inner product of 2 IntegerVectors. |
280 | -- An exception is raised if the lengths are not equal. |
281 | ---C++: alias operator* |
282 | |
283 | returns Integer |
284 | raises DimensionError |
285 | is static; |
286 | |
287 | |
288 | Opposite(me: in out) |
289 | ---Purpose: returns the opposite of an IntegerVector. |
290 | ---C++: alias operator- |
291 | |
292 | returns IntegerVector |
293 | is static; |
294 | |
295 | |
296 | Subtract(me: in out; Right: IntegerVector) |
297 | ---Purpose: returns the subtraction of <Right> from <me>. |
298 | -- An exception is raised if the IntegerVectors have not the same length. |
299 | ---C++: alias operator-= |
300 | |
301 | raises DimensionError |
302 | is static; |
303 | |
304 | |
305 | Subtracted(me; Right: IntegerVector) |
306 | ---Purpose: returns the subtraction of <Right> from <me>. |
307 | -- An exception is raised if the IntegerVectors have not the same length. |
308 | ---C++: alias operator- |
309 | |
310 | returns IntegerVector |
311 | raises DimensionError |
312 | is static; |
313 | |
314 | |
315 | Multiply(me: in out; Left: Integer; Right: IntegerVector) |
316 | ---Purpose: returns the multiplication of an integer by an |
317 | -- IntegerVector. |
318 | |
319 | raises DimensionError |
320 | is static; |
321 | |
322 | |
323 | Dump(me; o: in out OStream) |
324 | ---Purpose: Prints on the stream o information on the current state |
325 | -- of the object. |
326 | -- Is used to redefine the operator <<. |
327 | |
328 | is static; |
329 | |
330 | |
331 | fields |
332 | |
333 | FirstIndex: Integer; |
334 | LastIndex: Integer; |
335 | Array: SingleTabOfInteger; |
336 | |
337 | friends |
338 | class Matrix from math |
339 | |
340 | |
341 | end IntegerVector; |