Daily bump.
[official-gcc.git] / gcc / ada / s-gearop.ads
blobb922871979dfac09551990c7e4869dce43d0ae0a
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- SYSTEM.GENERIC_ARRAY_OPERATIONS --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2006, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 package System.Generic_Array_Operations is
35 pragma Pure (Generic_Array_Operations);
37 --------------------------
38 -- Square_Matrix_Length --
39 --------------------------
41 generic
42 type Scalar is private;
43 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
44 function Square_Matrix_Length (A : Matrix) return Natural;
45 -- If A is non-square, raise Constraint_Error, else return its dimension
47 ----------------------------------
48 -- Vector_Elementwise_Operation --
49 ----------------------------------
51 generic
52 type X_Scalar is private;
53 type Result_Scalar is private;
54 type X_Vector is array (Integer range <>) of X_Scalar;
55 type Result_Vector is array (Integer range <>) of Result_Scalar;
56 with function Operation (X : X_Scalar) return Result_Scalar;
57 function Vector_Elementwise_Operation (X : X_Vector) return Result_Vector;
59 ----------------------------------
60 -- Matrix_Elementwise_Operation --
61 ----------------------------------
63 generic
64 type X_Scalar is private;
65 type Result_Scalar is private;
66 type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
67 type Result_Matrix is array (Integer range <>, Integer range <>)
68 of Result_Scalar;
69 with function Operation (X : X_Scalar) return Result_Scalar;
70 function Matrix_Elementwise_Operation (X : X_Matrix) return Result_Matrix;
72 -----------------------------------------
73 -- Vector_Vector_Elementwise_Operation --
74 -----------------------------------------
76 generic
77 type Left_Scalar is private;
78 type Right_Scalar is private;
79 type Result_Scalar is private;
80 type Left_Vector is array (Integer range <>) of Left_Scalar;
81 type Right_Vector is array (Integer range <>) of Right_Scalar;
82 type Result_Vector is array (Integer range <>) of Result_Scalar;
83 with function Operation
84 (Left : Left_Scalar;
85 Right : Right_Scalar) return Result_Scalar;
86 function Vector_Vector_Elementwise_Operation
87 (Left : Left_Vector;
88 Right : Right_Vector) return Result_Vector;
90 ------------------------------------------------
91 -- Vector_Vector_Scalar_Elementwise_Operation --
92 ------------------------------------------------
94 generic
95 type X_Scalar is private;
96 type Y_Scalar is private;
97 type Z_Scalar is private;
98 type Result_Scalar is private;
99 type X_Vector is array (Integer range <>) of X_Scalar;
100 type Y_Vector is array (Integer range <>) of Y_Scalar;
101 type Result_Vector is array (Integer range <>) of Result_Scalar;
102 with function Operation
103 (X : X_Scalar;
104 Y : Y_Scalar;
105 Z : Z_Scalar) return Result_Scalar;
106 function Vector_Vector_Scalar_Elementwise_Operation
107 (X : X_Vector;
108 Y : Y_Vector;
109 Z : Z_Scalar) return Result_Vector;
111 -----------------------------------------
112 -- Matrix_Matrix_Elementwise_Operation --
113 -----------------------------------------
115 generic
116 type Left_Scalar is private;
117 type Right_Scalar is private;
118 type Result_Scalar is private;
119 type Left_Matrix is array (Integer range <>, Integer range <>)
120 of Left_Scalar;
121 type Right_Matrix is array (Integer range <>, Integer range <>)
122 of Right_Scalar;
123 type Result_Matrix is array (Integer range <>, Integer range <>)
124 of Result_Scalar;
125 with function Operation
126 (Left : Left_Scalar;
127 Right : Right_Scalar) return Result_Scalar;
128 function Matrix_Matrix_Elementwise_Operation
129 (Left : Left_Matrix;
130 Right : Right_Matrix) return Result_Matrix;
132 ------------------------------------------------
133 -- Matrix_Matrix_Scalar_Elementwise_Operation --
134 ------------------------------------------------
136 generic
137 type X_Scalar is private;
138 type Y_Scalar is private;
139 type Z_Scalar is private;
140 type Result_Scalar is private;
141 type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
142 type Y_Matrix is array (Integer range <>, Integer range <>) of Y_Scalar;
143 type Result_Matrix is array (Integer range <>, Integer range <>)
144 of Result_Scalar;
145 with function Operation
146 (X : X_Scalar;
147 Y : Y_Scalar;
148 Z : Z_Scalar) return Result_Scalar;
149 function Matrix_Matrix_Scalar_Elementwise_Operation
150 (X : X_Matrix;
151 Y : Y_Matrix;
152 Z : Z_Scalar) return Result_Matrix;
154 -----------------------------------------
155 -- Vector_Scalar_Elementwise_Operation --
156 -----------------------------------------
158 generic
159 type Left_Scalar is private;
160 type Right_Scalar is private;
161 type Result_Scalar is private;
162 type Left_Vector is array (Integer range <>) of Left_Scalar;
163 type Result_Vector is array (Integer range <>) of Result_Scalar;
164 with function Operation
165 (Left : Left_Scalar;
166 Right : Right_Scalar) return Result_Scalar;
167 function Vector_Scalar_Elementwise_Operation
168 (Left : Left_Vector;
169 Right : Right_Scalar) return Result_Vector;
171 -----------------------------------------
172 -- Matrix_Scalar_Elementwise_Operation --
173 -----------------------------------------
175 generic
176 type Left_Scalar is private;
177 type Right_Scalar is private;
178 type Result_Scalar is private;
179 type Left_Matrix is array (Integer range <>, Integer range <>)
180 of Left_Scalar;
181 type Result_Matrix is array (Integer range <>, Integer range <>)
182 of Result_Scalar;
183 with function Operation
184 (Left : Left_Scalar;
185 Right : Right_Scalar) return Result_Scalar;
186 function Matrix_Scalar_Elementwise_Operation
187 (Left : Left_Matrix;
188 Right : Right_Scalar) return Result_Matrix;
190 -----------------------------------------
191 -- Scalar_Vector_Elementwise_Operation --
192 -----------------------------------------
194 generic
195 type Left_Scalar is private;
196 type Right_Scalar is private;
197 type Result_Scalar is private;
198 type Right_Vector is array (Integer range <>) of Right_Scalar;
199 type Result_Vector is array (Integer range <>) of Result_Scalar;
200 with function Operation
201 (Left : Left_Scalar;
202 Right : Right_Scalar) return Result_Scalar;
203 function Scalar_Vector_Elementwise_Operation
204 (Left : Left_Scalar;
205 Right : Right_Vector) return Result_Vector;
207 -----------------------------------------
208 -- Scalar_Matrix_Elementwise_Operation --
209 -----------------------------------------
211 generic
212 type Left_Scalar is private;
213 type Right_Scalar is private;
214 type Result_Scalar is private;
215 type Right_Matrix is array (Integer range <>, Integer range <>)
216 of Right_Scalar;
217 type Result_Matrix is array (Integer range <>, Integer range <>)
218 of Result_Scalar;
219 with function Operation
220 (Left : Left_Scalar;
221 Right : Right_Scalar) return Result_Scalar;
222 function Scalar_Matrix_Elementwise_Operation
223 (Left : Left_Scalar;
224 Right : Right_Matrix) return Result_Matrix;
226 -------------------
227 -- Inner_Product --
228 -------------------
230 generic
231 type Left_Scalar is private;
232 type Right_Scalar is private;
233 type Result_Scalar is private;
234 type Left_Vector is array (Integer range <>) of Left_Scalar;
235 type Right_Vector is array (Integer range <>) of Right_Scalar;
236 Zero : Result_Scalar;
237 with function "*"
238 (Left : Left_Scalar;
239 Right : Right_Scalar) return Result_Scalar is <>;
240 with function "+"
241 (Left : Result_Scalar;
242 Right : Result_Scalar) return Result_Scalar is <>;
243 function Inner_Product
244 (Left : Left_Vector;
245 Right : Right_Vector) return Result_Scalar;
247 -------------------
248 -- Outer_Product --
249 -------------------
251 generic
252 type Left_Scalar is private;
253 type Right_Scalar is private;
254 type Result_Scalar is private;
255 type Left_Vector is array (Integer range <>) of Left_Scalar;
256 type Right_Vector is array (Integer range <>) of Right_Scalar;
257 type Matrix is array (Integer range <>, Integer range <>)
258 of Result_Scalar;
259 with function "*"
260 (Left : Left_Scalar;
261 Right : Right_Scalar) return Result_Scalar is <>;
262 function Outer_Product
263 (Left : Left_Vector;
264 Right : Right_Vector) return Matrix;
266 ---------------------------
267 -- Matrix_Vector_Product --
268 ---------------------------
270 generic
271 type Left_Scalar is private;
272 type Right_Scalar is private;
273 type Result_Scalar is private;
274 type Matrix is array (Integer range <>, Integer range <>)
275 of Left_Scalar;
276 type Right_Vector is array (Integer range <>) of Right_Scalar;
277 type Result_Vector is array (Integer range <>) of Result_Scalar;
278 Zero : Result_Scalar;
279 with function "*"
280 (Left : Left_Scalar;
281 Right : Right_Scalar) return Result_Scalar is <>;
282 with function "+"
283 (Left : Result_Scalar;
284 Right : Result_Scalar) return Result_Scalar is <>;
285 function Matrix_Vector_Product
286 (Left : Matrix;
287 Right : Right_Vector) return Result_Vector;
289 ---------------------------
290 -- Vector_Matrix_Product --
291 ---------------------------
293 generic
294 type Left_Scalar is private;
295 type Right_Scalar is private;
296 type Result_Scalar is private;
297 type Left_Vector is array (Integer range <>) of Left_Scalar;
298 type Matrix is array (Integer range <>, Integer range <>)
299 of Right_Scalar;
300 type Result_Vector is array (Integer range <>) of Result_Scalar;
301 Zero : Result_Scalar;
302 with function "*"
303 (Left : Left_Scalar;
304 Right : Right_Scalar) return Result_Scalar is <>;
305 with function "+"
306 (Left : Result_Scalar;
307 Right : Result_Scalar) return Result_Scalar is <>;
308 function Vector_Matrix_Product
309 (Left : Left_Vector;
310 Right : Matrix) return Result_Vector;
312 ---------------------------
313 -- Matrix_Matrix_Product --
314 ---------------------------
316 generic
317 type Left_Scalar is private;
318 type Right_Scalar is private;
319 type Result_Scalar is private;
320 type Left_Matrix is array (Integer range <>, Integer range <>)
321 of Left_Scalar;
322 type Right_Matrix is array (Integer range <>, Integer range <>)
323 of Right_Scalar;
324 type Result_Matrix is array (Integer range <>, Integer range <>)
325 of Result_Scalar;
326 Zero : Result_Scalar;
327 with function "*"
328 (Left : Left_Scalar;
329 Right : Right_Scalar) return Result_Scalar is <>;
330 with function "+"
331 (Left : Result_Scalar;
332 Right : Result_Scalar) return Result_Scalar is <>;
333 function Matrix_Matrix_Product
334 (Left : Left_Matrix;
335 Right : Right_Matrix) return Result_Matrix;
337 ---------------
338 -- Transpose --
339 ---------------
341 generic
342 type Scalar is private;
343 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
344 procedure Transpose (A : Matrix; R : out Matrix);
346 -------------------------------
347 -- Update_Vector_With_Vector --
348 -------------------------------
350 generic
351 type X_Scalar is private;
352 type Y_Scalar is private;
353 type X_Vector is array (Integer range <>) of X_Scalar;
354 type Y_Vector is array (Integer range <>) of Y_Scalar;
355 with procedure Update (X : in out X_Scalar; Y : Y_Scalar);
356 procedure Update_Vector_With_Vector (X : in out X_Vector; Y : Y_Vector);
358 -------------------------------
359 -- Update_Matrix_With_Matrix --
360 -------------------------------
362 generic
363 type X_Scalar is private;
364 type Y_Scalar is private;
365 type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
366 type Y_Matrix is array (Integer range <>, Integer range <>) of Y_Scalar;
367 with procedure Update (X : in out X_Scalar; Y : Y_Scalar);
368 procedure Update_Matrix_With_Matrix (X : in out X_Matrix; Y : Y_Matrix);
370 -----------------
371 -- Unit_Matrix --
372 -----------------
374 generic
375 type Scalar is private;
376 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
377 Zero : Scalar;
378 One : Scalar;
379 function Unit_Matrix
380 (Order : Positive;
381 First_1 : Integer := 1;
382 First_2 : Integer := 1) return Matrix;
384 -----------------
385 -- Unit_Vector --
386 -----------------
388 generic
389 type Scalar is private;
390 type Vector is array (Integer range <>) of Scalar;
391 Zero : Scalar;
392 One : Scalar;
393 function Unit_Vector
394 (Index : Integer;
395 Order : Positive;
396 First : Integer := 1) return Vector;
398 end System.Generic_Array_Operations;