1 -- File: IntegerVector.cdl
2 -- Created: Mon May 6 14:55:20 1991
3 -- Author: Laurent PAINNOT
5 ---Copyright: Matra Datavision 1991, 1992
9 class IntegerVector from math
12 -- This class implements the real IntegerVector abstract data type.
13 -- IntegerVectors can have an arbitrary range which must be define at
14 -- the declaration and cannot be changed after this declaration.
15 -- Example: math_IntegerVector V1(-3, 5); // an IntegerVector with
18 -- IntegerVector is copied through assignement :
19 -- math_IntegerVector V2( 1, 9);
22 -- V1(1) = 2.0; // the IntegerVector V2 will not be modified.
24 -- The Exception RangeError is raised when trying to access outside
25 -- the range of an IntegerVector :
26 -- V1(11) = 0 // --> will raise RangeError;
28 -- The Exception DimensionError is raised when the dimensions of two
29 -- IntegerVectors are not compatible :
30 -- math_IntegerVector V3(1, 2);
31 -- V3 = V1; // --> will raise DimensionError;
32 -- V1.Add(V3) // --> will raise DimensionError;
34 uses Matrix from math,
35 SingleTabOfInteger from math,
38 raises DimensionError from Standard,
39 DivideByZero from Standard,
40 RangeError from Standard
44 Create(First, Last: Integer)
45 ---Purpose: contructs an IntegerVector in the range [Lower..Upper]
47 returns IntegerVector;
49 Create(First, Last: Integer; InitialValue : Integer)
50 ---Purpose: contructs an IntegerVector in the range [Lower..Upper]
51 -- with all the elements set to InitialValue.
53 returns IntegerVector;
56 Init(me : in out; InitialValue: Integer);
57 ---Purpose: Initialize an IntegerVector with all the elements
58 -- set to InitialValue.
61 Create(Tab : Address; First, Last: Integer)
62 ---Purpose: constructs an IntegerVector in the range [Lower..Upper]
63 -- which share the "c array" Tab.
65 returns IntegerVector;
68 Create(Other: IntegerVector)
69 ---Purpose: constructs a copy for initialization.
70 -- An exception is raised if the lengths of the IntegerVectors
74 raises DimensionError;
77 SetFirst(me: in out; First: Integer)
78 ---Purpose: is used internally to set the Lower value of the
85 ---Purpose: returns the length of an IntegerVector
93 ---Purpose: returns the value of the Lower index of an IntegerVector.
101 ---Purpose: returns the value of the Upper index of an IntegerVector.
109 ---Purpose: returns the value of the norm of an IntegerVector.
116 ---Purpose: returns the value of the square of the norm of an
124 ---Purpose: returns the value of the Index of the maximum element of
132 ---Purpose: returns the value of the Index of the minimum element
133 -- of an IntegerVector.
140 ---Purpose: inverses an IntegerVector.
141 ---Example: [1, 2, 3, 4] becomes [4, 3, 2, 1].
147 ---Purpose: returns the inverse IntegerVector of an IntegerVector.
149 returns IntegerVector
153 Set(me: in out; I1, I2: Integer; V: IntegerVector)
154 ---Purpose: sets an IntegerVector from <I1> to <I2> to the
155 -- IntegerVector <V>;
156 -- An exception is raised if I1<LowerIndex or I2>UpperIndex or I1>I2.
157 -- An exception is raised if I2-I1+1 is different from the Length of V.
159 raises DimensionError
163 Slice(me; I1, I2: Integer)
164 ---Purpose: slices the values of the IntegerVector between <I1> and
166 -- Example: [2, 1, 2, 3, 4, 5] becomes [2, 4, 3, 2, 1, 5] between 2 and 5.
167 -- An exception is raised if I1<LowerIndex or I2>UpperIndex.
169 returns IntegerVector
170 raises DimensionError
174 Multiply (me: in out; Right: Integer)
175 ---Purpose: returns the product of an IntegerVector by an integer value.
176 ---C++: alias operator *=
178 raises DimensionError from Standard
182 Multiplied (me; Right: Integer)
183 ---Purpose: returns the product of an IntegerVector by an integer value.
184 ---C++: alias operator*
186 returns IntegerVector
187 raises DimensionError from Standard
190 TMultiplied (me; Right: Integer)
191 ---Purpose: returns the product of a vector and a real value.
192 ---C++: alias "friend math_IntegerVector operator *(const Standard_Integer Left,const math_IntegerVector& Right);"
193 returns IntegerVector
196 Add (me: in out; Right: IntegerVector)
197 ---Purpose: adds the IntegerVector <Right> to an IntegerVector.
198 -- An exception is raised if the IntegerVectors have not the same
200 -- An exception is raised if the lengths are not equal.
201 ---C++: alias operator +=
203 raises DimensionError
207 Added (me; Right: IntegerVector)
208 ---Purpose: adds the IntegerVector <Right> to an IntegerVector.
209 -- An exception is raised if the IntegerVectors have not the same
211 -- An exception is raised if the lengths are not equal.
212 ---C++:alias operator+
214 returns IntegerVector
215 raises DimensionError
220 Add (me: in out; Left, Right: IntegerVector)
221 ---Purpose: sets an IntegerVector to the sum of the IntegerVector
222 -- <Left> and the IntegerVector <Right>.
223 -- An exception is raised if the lengths are different.
225 raises DimensionError
229 Subtract(me: in out; Left, Right: IntegerVector)
230 ---Purpose: sets an IntegerVector to the substraction of
231 -- <Right> from <Left>.
232 -- An exception is raised if the IntegerVectors have not the same
235 raises DimensionError
239 Value(me; Num: Integer)
240 ---Purpose: accesses (in read or write mode) the value of index Num of
242 ---C++: alias operator()
247 raises RangeError from Standard
251 Initialized(me: in out; Other: IntegerVector)
252 ---Purpose: Initialises an IntegerVector by copying <Other>.
253 -- An exception is raised if the Lengths are different.
254 ---C++: alias operator=
257 returns IntegerVector
258 raises DimensionError
263 Multiplied(me; Right: IntegerVector)
264 ---Purpose: returns the inner product of 2 IntegerVectors.
265 -- An exception is raised if the lengths are not equal.
266 ---C++: alias operator*
269 raises DimensionError
274 ---Purpose: returns the opposite of an IntegerVector.
275 ---C++: alias operator-
277 returns IntegerVector
281 Subtract(me: in out; Right: IntegerVector)
282 ---Purpose: returns the subtraction of <Right> from <me>.
283 -- An exception is raised if the IntegerVectors have not the same length.
284 ---C++: alias operator-=
286 raises DimensionError
290 Subtracted(me; Right: IntegerVector)
291 ---Purpose: returns the subtraction of <Right> from <me>.
292 -- An exception is raised if the IntegerVectors have not the same length.
293 ---C++: alias operator-
295 returns IntegerVector
296 raises DimensionError
300 Multiply(me: in out; Left: Integer; Right: IntegerVector)
301 ---Purpose: returns the multiplication of an integer by an
304 raises DimensionError
308 Dump(me; o: in out OStream)
309 ---Purpose: Prints on the stream o information on the current state
311 -- Is used to redefine the operator <<.
320 Array: SingleTabOfInteger;
323 class Matrix from math