annotate gcc/ada/libgnat/s-gearop.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . G E N E R I C _ A R R A Y _ O P E R A T I O N S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2006-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package System.Generic_Array_Operations is
kono
parents:
diff changeset
33 pragma Pure (Generic_Array_Operations);
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 ---------------------
kono
parents:
diff changeset
36 -- Back_Substitute --
kono
parents:
diff changeset
37 ---------------------
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 generic
kono
parents:
diff changeset
40 type Scalar is private;
kono
parents:
diff changeset
41 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
42 with function "-" (Left, Right : Scalar) return Scalar is <>;
kono
parents:
diff changeset
43 with function "*" (Left, Right : Scalar) return Scalar is <>;
kono
parents:
diff changeset
44 with function "/" (Left, Right : Scalar) return Scalar is <>;
kono
parents:
diff changeset
45 with function Is_Non_Zero (X : Scalar) return Boolean is <>;
kono
parents:
diff changeset
46 procedure Back_Substitute (M, N : in out Matrix);
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 --------------
kono
parents:
diff changeset
49 -- Diagonal --
kono
parents:
diff changeset
50 --------------
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 generic
kono
parents:
diff changeset
53 type Scalar is private;
kono
parents:
diff changeset
54 type Vector is array (Integer range <>) of Scalar;
kono
parents:
diff changeset
55 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
56 function Diagonal (A : Matrix) return Vector;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 -----------------------
kono
parents:
diff changeset
59 -- Forward_Eliminate --
kono
parents:
diff changeset
60 -----------------------
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 -- Use elementary row operations to put square matrix M in row echolon
kono
parents:
diff changeset
63 -- form. Identical row operations are performed on matrix N, must have the
kono
parents:
diff changeset
64 -- same number of rows as M.
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 generic
kono
parents:
diff changeset
67 type Scalar is private;
kono
parents:
diff changeset
68 type Real is digits <>;
kono
parents:
diff changeset
69 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
70 with function "abs" (Right : Scalar) return Real'Base is <>;
kono
parents:
diff changeset
71 with function "-" (Left, Right : Scalar) return Scalar is <>;
kono
parents:
diff changeset
72 with function "*" (Left, Right : Scalar) return Scalar is <>;
kono
parents:
diff changeset
73 with function "/" (Left, Right : Scalar) return Scalar is <>;
kono
parents:
diff changeset
74 Zero : Scalar;
kono
parents:
diff changeset
75 One : Scalar;
kono
parents:
diff changeset
76 procedure Forward_Eliminate
kono
parents:
diff changeset
77 (M : in out Matrix;
kono
parents:
diff changeset
78 N : in out Matrix;
kono
parents:
diff changeset
79 Det : out Scalar);
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 --------------------------
kono
parents:
diff changeset
82 -- Square_Matrix_Length --
kono
parents:
diff changeset
83 --------------------------
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 generic
kono
parents:
diff changeset
86 type Scalar is private;
kono
parents:
diff changeset
87 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
88 function Square_Matrix_Length (A : Matrix) return Natural;
kono
parents:
diff changeset
89 -- If A is non-square, raise Constraint_Error, else return its dimension
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 ----------------------------------
kono
parents:
diff changeset
92 -- Vector_Elementwise_Operation --
kono
parents:
diff changeset
93 ----------------------------------
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 generic
kono
parents:
diff changeset
96 type X_Scalar is private;
kono
parents:
diff changeset
97 type Result_Scalar is private;
kono
parents:
diff changeset
98 type X_Vector is array (Integer range <>) of X_Scalar;
kono
parents:
diff changeset
99 type Result_Vector is array (Integer range <>) of Result_Scalar;
kono
parents:
diff changeset
100 with function Operation (X : X_Scalar) return Result_Scalar;
kono
parents:
diff changeset
101 function Vector_Elementwise_Operation (X : X_Vector) return Result_Vector;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 ----------------------------------
kono
parents:
diff changeset
104 -- Matrix_Elementwise_Operation --
kono
parents:
diff changeset
105 ----------------------------------
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 generic
kono
parents:
diff changeset
108 type X_Scalar is private;
kono
parents:
diff changeset
109 type Result_Scalar is private;
kono
parents:
diff changeset
110 type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
kono
parents:
diff changeset
111 type Result_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
112 of Result_Scalar;
kono
parents:
diff changeset
113 with function Operation (X : X_Scalar) return Result_Scalar;
kono
parents:
diff changeset
114 function Matrix_Elementwise_Operation (X : X_Matrix) return Result_Matrix;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 -----------------------------------------
kono
parents:
diff changeset
117 -- Vector_Vector_Elementwise_Operation --
kono
parents:
diff changeset
118 -----------------------------------------
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 generic
kono
parents:
diff changeset
121 type Left_Scalar is private;
kono
parents:
diff changeset
122 type Right_Scalar is private;
kono
parents:
diff changeset
123 type Result_Scalar is private;
kono
parents:
diff changeset
124 type Left_Vector is array (Integer range <>) of Left_Scalar;
kono
parents:
diff changeset
125 type Right_Vector is array (Integer range <>) of Right_Scalar;
kono
parents:
diff changeset
126 type Result_Vector is array (Integer range <>) of Result_Scalar;
kono
parents:
diff changeset
127 with function Operation
kono
parents:
diff changeset
128 (Left : Left_Scalar;
kono
parents:
diff changeset
129 Right : Right_Scalar) return Result_Scalar;
kono
parents:
diff changeset
130 function Vector_Vector_Elementwise_Operation
kono
parents:
diff changeset
131 (Left : Left_Vector;
kono
parents:
diff changeset
132 Right : Right_Vector) return Result_Vector;
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 ------------------------------------------------
kono
parents:
diff changeset
135 -- Vector_Vector_Scalar_Elementwise_Operation --
kono
parents:
diff changeset
136 ------------------------------------------------
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 generic
kono
parents:
diff changeset
139 type X_Scalar is private;
kono
parents:
diff changeset
140 type Y_Scalar is private;
kono
parents:
diff changeset
141 type Z_Scalar is private;
kono
parents:
diff changeset
142 type Result_Scalar is private;
kono
parents:
diff changeset
143 type X_Vector is array (Integer range <>) of X_Scalar;
kono
parents:
diff changeset
144 type Y_Vector is array (Integer range <>) of Y_Scalar;
kono
parents:
diff changeset
145 type Result_Vector is array (Integer range <>) of Result_Scalar;
kono
parents:
diff changeset
146 with function Operation
kono
parents:
diff changeset
147 (X : X_Scalar;
kono
parents:
diff changeset
148 Y : Y_Scalar;
kono
parents:
diff changeset
149 Z : Z_Scalar) return Result_Scalar;
kono
parents:
diff changeset
150 function Vector_Vector_Scalar_Elementwise_Operation
kono
parents:
diff changeset
151 (X : X_Vector;
kono
parents:
diff changeset
152 Y : Y_Vector;
kono
parents:
diff changeset
153 Z : Z_Scalar) return Result_Vector;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -----------------------------------------
kono
parents:
diff changeset
156 -- Matrix_Matrix_Elementwise_Operation --
kono
parents:
diff changeset
157 -----------------------------------------
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 generic
kono
parents:
diff changeset
160 type Left_Scalar is private;
kono
parents:
diff changeset
161 type Right_Scalar is private;
kono
parents:
diff changeset
162 type Result_Scalar is private;
kono
parents:
diff changeset
163 type Left_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
164 of Left_Scalar;
kono
parents:
diff changeset
165 type Right_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
166 of Right_Scalar;
kono
parents:
diff changeset
167 type Result_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
168 of Result_Scalar;
kono
parents:
diff changeset
169 with function Operation
kono
parents:
diff changeset
170 (Left : Left_Scalar;
kono
parents:
diff changeset
171 Right : Right_Scalar) return Result_Scalar;
kono
parents:
diff changeset
172 function Matrix_Matrix_Elementwise_Operation
kono
parents:
diff changeset
173 (Left : Left_Matrix;
kono
parents:
diff changeset
174 Right : Right_Matrix) return Result_Matrix;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 ------------------------------------------------
kono
parents:
diff changeset
177 -- Matrix_Matrix_Scalar_Elementwise_Operation --
kono
parents:
diff changeset
178 ------------------------------------------------
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 generic
kono
parents:
diff changeset
181 type X_Scalar is private;
kono
parents:
diff changeset
182 type Y_Scalar is private;
kono
parents:
diff changeset
183 type Z_Scalar is private;
kono
parents:
diff changeset
184 type Result_Scalar is private;
kono
parents:
diff changeset
185 type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
kono
parents:
diff changeset
186 type Y_Matrix is array (Integer range <>, Integer range <>) of Y_Scalar;
kono
parents:
diff changeset
187 type Result_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
188 of Result_Scalar;
kono
parents:
diff changeset
189 with function Operation
kono
parents:
diff changeset
190 (X : X_Scalar;
kono
parents:
diff changeset
191 Y : Y_Scalar;
kono
parents:
diff changeset
192 Z : Z_Scalar) return Result_Scalar;
kono
parents:
diff changeset
193 function Matrix_Matrix_Scalar_Elementwise_Operation
kono
parents:
diff changeset
194 (X : X_Matrix;
kono
parents:
diff changeset
195 Y : Y_Matrix;
kono
parents:
diff changeset
196 Z : Z_Scalar) return Result_Matrix;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 -----------------------------------------
kono
parents:
diff changeset
199 -- Vector_Scalar_Elementwise_Operation --
kono
parents:
diff changeset
200 -----------------------------------------
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 generic
kono
parents:
diff changeset
203 type Left_Scalar is private;
kono
parents:
diff changeset
204 type Right_Scalar is private;
kono
parents:
diff changeset
205 type Result_Scalar is private;
kono
parents:
diff changeset
206 type Left_Vector is array (Integer range <>) of Left_Scalar;
kono
parents:
diff changeset
207 type Result_Vector is array (Integer range <>) of Result_Scalar;
kono
parents:
diff changeset
208 with function Operation
kono
parents:
diff changeset
209 (Left : Left_Scalar;
kono
parents:
diff changeset
210 Right : Right_Scalar) return Result_Scalar;
kono
parents:
diff changeset
211 function Vector_Scalar_Elementwise_Operation
kono
parents:
diff changeset
212 (Left : Left_Vector;
kono
parents:
diff changeset
213 Right : Right_Scalar) return Result_Vector;
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 -----------------------------------------
kono
parents:
diff changeset
216 -- Matrix_Scalar_Elementwise_Operation --
kono
parents:
diff changeset
217 -----------------------------------------
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 generic
kono
parents:
diff changeset
220 type Left_Scalar is private;
kono
parents:
diff changeset
221 type Right_Scalar is private;
kono
parents:
diff changeset
222 type Result_Scalar is private;
kono
parents:
diff changeset
223 type Left_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
224 of Left_Scalar;
kono
parents:
diff changeset
225 type Result_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
226 of Result_Scalar;
kono
parents:
diff changeset
227 with function Operation
kono
parents:
diff changeset
228 (Left : Left_Scalar;
kono
parents:
diff changeset
229 Right : Right_Scalar) return Result_Scalar;
kono
parents:
diff changeset
230 function Matrix_Scalar_Elementwise_Operation
kono
parents:
diff changeset
231 (Left : Left_Matrix;
kono
parents:
diff changeset
232 Right : Right_Scalar) return Result_Matrix;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 -----------------------------------------
kono
parents:
diff changeset
235 -- Scalar_Vector_Elementwise_Operation --
kono
parents:
diff changeset
236 -----------------------------------------
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 generic
kono
parents:
diff changeset
239 type Left_Scalar is private;
kono
parents:
diff changeset
240 type Right_Scalar is private;
kono
parents:
diff changeset
241 type Result_Scalar is private;
kono
parents:
diff changeset
242 type Right_Vector is array (Integer range <>) of Right_Scalar;
kono
parents:
diff changeset
243 type Result_Vector is array (Integer range <>) of Result_Scalar;
kono
parents:
diff changeset
244 with function Operation
kono
parents:
diff changeset
245 (Left : Left_Scalar;
kono
parents:
diff changeset
246 Right : Right_Scalar) return Result_Scalar;
kono
parents:
diff changeset
247 function Scalar_Vector_Elementwise_Operation
kono
parents:
diff changeset
248 (Left : Left_Scalar;
kono
parents:
diff changeset
249 Right : Right_Vector) return Result_Vector;
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 -----------------------------------------
kono
parents:
diff changeset
252 -- Scalar_Matrix_Elementwise_Operation --
kono
parents:
diff changeset
253 -----------------------------------------
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 generic
kono
parents:
diff changeset
256 type Left_Scalar is private;
kono
parents:
diff changeset
257 type Right_Scalar is private;
kono
parents:
diff changeset
258 type Result_Scalar is private;
kono
parents:
diff changeset
259 type Right_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
260 of Right_Scalar;
kono
parents:
diff changeset
261 type Result_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
262 of Result_Scalar;
kono
parents:
diff changeset
263 with function Operation
kono
parents:
diff changeset
264 (Left : Left_Scalar;
kono
parents:
diff changeset
265 Right : Right_Scalar) return Result_Scalar;
kono
parents:
diff changeset
266 function Scalar_Matrix_Elementwise_Operation
kono
parents:
diff changeset
267 (Left : Left_Scalar;
kono
parents:
diff changeset
268 Right : Right_Matrix) return Result_Matrix;
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 -------------------
kono
parents:
diff changeset
271 -- Inner_Product --
kono
parents:
diff changeset
272 -------------------
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 generic
kono
parents:
diff changeset
275 type Left_Scalar is private;
kono
parents:
diff changeset
276 type Right_Scalar is private;
kono
parents:
diff changeset
277 type Result_Scalar is private;
kono
parents:
diff changeset
278 type Left_Vector is array (Integer range <>) of Left_Scalar;
kono
parents:
diff changeset
279 type Right_Vector is array (Integer range <>) of Right_Scalar;
kono
parents:
diff changeset
280 Zero : Result_Scalar;
kono
parents:
diff changeset
281 with function "*"
kono
parents:
diff changeset
282 (Left : Left_Scalar;
kono
parents:
diff changeset
283 Right : Right_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
284 with function "+"
kono
parents:
diff changeset
285 (Left : Result_Scalar;
kono
parents:
diff changeset
286 Right : Result_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
287 function Inner_Product
kono
parents:
diff changeset
288 (Left : Left_Vector;
kono
parents:
diff changeset
289 Right : Right_Vector) return Result_Scalar;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 -------------
kono
parents:
diff changeset
292 -- L2_Norm --
kono
parents:
diff changeset
293 -------------
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 generic
kono
parents:
diff changeset
296 type X_Scalar is private;
kono
parents:
diff changeset
297 type Result_Real is digits <>;
kono
parents:
diff changeset
298 type X_Vector is array (Integer range <>) of X_Scalar;
kono
parents:
diff changeset
299 with function "abs" (Right : X_Scalar) return Result_Real is <>;
kono
parents:
diff changeset
300 with function Sqrt (X : Result_Real'Base) return Result_Real'Base is <>;
kono
parents:
diff changeset
301 function L2_Norm (X : X_Vector) return Result_Real'Base;
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 -------------------
kono
parents:
diff changeset
304 -- Outer_Product --
kono
parents:
diff changeset
305 -------------------
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 generic
kono
parents:
diff changeset
308 type Left_Scalar is private;
kono
parents:
diff changeset
309 type Right_Scalar is private;
kono
parents:
diff changeset
310 type Result_Scalar is private;
kono
parents:
diff changeset
311 type Left_Vector is array (Integer range <>) of Left_Scalar;
kono
parents:
diff changeset
312 type Right_Vector is array (Integer range <>) of Right_Scalar;
kono
parents:
diff changeset
313 type Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
314 of Result_Scalar;
kono
parents:
diff changeset
315 with function "*"
kono
parents:
diff changeset
316 (Left : Left_Scalar;
kono
parents:
diff changeset
317 Right : Right_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
318 function Outer_Product
kono
parents:
diff changeset
319 (Left : Left_Vector;
kono
parents:
diff changeset
320 Right : Right_Vector) return Matrix;
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 ---------------------------
kono
parents:
diff changeset
323 -- Matrix_Vector_Product --
kono
parents:
diff changeset
324 ---------------------------
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 generic
kono
parents:
diff changeset
327 type Left_Scalar is private;
kono
parents:
diff changeset
328 type Right_Scalar is private;
kono
parents:
diff changeset
329 type Result_Scalar is private;
kono
parents:
diff changeset
330 type Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
331 of Left_Scalar;
kono
parents:
diff changeset
332 type Right_Vector is array (Integer range <>) of Right_Scalar;
kono
parents:
diff changeset
333 type Result_Vector is array (Integer range <>) of Result_Scalar;
kono
parents:
diff changeset
334 Zero : Result_Scalar;
kono
parents:
diff changeset
335 with function "*"
kono
parents:
diff changeset
336 (Left : Left_Scalar;
kono
parents:
diff changeset
337 Right : Right_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
338 with function "+"
kono
parents:
diff changeset
339 (Left : Result_Scalar;
kono
parents:
diff changeset
340 Right : Result_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
341 function Matrix_Vector_Product
kono
parents:
diff changeset
342 (Left : Matrix;
kono
parents:
diff changeset
343 Right : Right_Vector) return Result_Vector;
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345 ---------------------------
kono
parents:
diff changeset
346 -- Vector_Matrix_Product --
kono
parents:
diff changeset
347 ---------------------------
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 generic
kono
parents:
diff changeset
350 type Left_Scalar is private;
kono
parents:
diff changeset
351 type Right_Scalar is private;
kono
parents:
diff changeset
352 type Result_Scalar is private;
kono
parents:
diff changeset
353 type Left_Vector is array (Integer range <>) of Left_Scalar;
kono
parents:
diff changeset
354 type Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
355 of Right_Scalar;
kono
parents:
diff changeset
356 type Result_Vector is array (Integer range <>) of Result_Scalar;
kono
parents:
diff changeset
357 Zero : Result_Scalar;
kono
parents:
diff changeset
358 with function "*"
kono
parents:
diff changeset
359 (Left : Left_Scalar;
kono
parents:
diff changeset
360 Right : Right_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
361 with function "+"
kono
parents:
diff changeset
362 (Left : Result_Scalar;
kono
parents:
diff changeset
363 Right : Result_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
364 function Vector_Matrix_Product
kono
parents:
diff changeset
365 (Left : Left_Vector;
kono
parents:
diff changeset
366 Right : Matrix) return Result_Vector;
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 ---------------------------
kono
parents:
diff changeset
369 -- Matrix_Matrix_Product --
kono
parents:
diff changeset
370 ---------------------------
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 generic
kono
parents:
diff changeset
373 type Left_Scalar is private;
kono
parents:
diff changeset
374 type Right_Scalar is private;
kono
parents:
diff changeset
375 type Result_Scalar is private;
kono
parents:
diff changeset
376 type Left_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
377 of Left_Scalar;
kono
parents:
diff changeset
378 type Right_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
379 of Right_Scalar;
kono
parents:
diff changeset
380 type Result_Matrix is array (Integer range <>, Integer range <>)
kono
parents:
diff changeset
381 of Result_Scalar;
kono
parents:
diff changeset
382 Zero : Result_Scalar;
kono
parents:
diff changeset
383 with function "*"
kono
parents:
diff changeset
384 (Left : Left_Scalar;
kono
parents:
diff changeset
385 Right : Right_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
386 with function "+"
kono
parents:
diff changeset
387 (Left : Result_Scalar;
kono
parents:
diff changeset
388 Right : Result_Scalar) return Result_Scalar is <>;
kono
parents:
diff changeset
389 function Matrix_Matrix_Product
kono
parents:
diff changeset
390 (Left : Left_Matrix;
kono
parents:
diff changeset
391 Right : Right_Matrix) return Result_Matrix;
kono
parents:
diff changeset
392
kono
parents:
diff changeset
393 ----------------------------
kono
parents:
diff changeset
394 -- Matrix_Vector_Solution --
kono
parents:
diff changeset
395 ----------------------------
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 generic
kono
parents:
diff changeset
398 type Scalar is private;
kono
parents:
diff changeset
399 Zero : Scalar;
kono
parents:
diff changeset
400 type Vector is array (Integer range <>) of Scalar;
kono
parents:
diff changeset
401 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
402 with procedure Back_Substitute (M, N : in out Matrix) is <>;
kono
parents:
diff changeset
403 with procedure Forward_Eliminate
kono
parents:
diff changeset
404 (M : in out Matrix;
kono
parents:
diff changeset
405 N : in out Matrix;
kono
parents:
diff changeset
406 Det : out Scalar) is <>;
kono
parents:
diff changeset
407 function Matrix_Vector_Solution (A : Matrix; X : Vector) return Vector;
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 ----------------------------
kono
parents:
diff changeset
410 -- Matrix_Matrix_Solution --
kono
parents:
diff changeset
411 ----------------------------
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 generic
kono
parents:
diff changeset
414 type Scalar is private;
kono
parents:
diff changeset
415 Zero : Scalar;
kono
parents:
diff changeset
416 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
417 with procedure Back_Substitute (M, N : in out Matrix) is <>;
kono
parents:
diff changeset
418 with procedure Forward_Eliminate
kono
parents:
diff changeset
419 (M : in out Matrix;
kono
parents:
diff changeset
420 N : in out Matrix;
kono
parents:
diff changeset
421 Det : out Scalar) is <>;
kono
parents:
diff changeset
422 function Matrix_Matrix_Solution (A : Matrix; X : Matrix) return Matrix;
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 ----------
kono
parents:
diff changeset
425 -- Sqrt --
kono
parents:
diff changeset
426 ----------
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 generic
kono
parents:
diff changeset
429 type Real is digits <>;
kono
parents:
diff changeset
430 function Sqrt (X : Real'Base) return Real'Base;
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 -----------------
kono
parents:
diff changeset
433 -- Swap_Column --
kono
parents:
diff changeset
434 -----------------
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436 generic
kono
parents:
diff changeset
437 type Scalar is private;
kono
parents:
diff changeset
438 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
439 procedure Swap_Column (A : in out Matrix; Left, Right : Integer);
kono
parents:
diff changeset
440
kono
parents:
diff changeset
441 ---------------
kono
parents:
diff changeset
442 -- Transpose --
kono
parents:
diff changeset
443 ---------------
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 generic
kono
parents:
diff changeset
446 type Scalar is private;
kono
parents:
diff changeset
447 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
448 procedure Transpose (A : Matrix; R : out Matrix);
kono
parents:
diff changeset
449
kono
parents:
diff changeset
450 -------------------------------
kono
parents:
diff changeset
451 -- Update_Vector_With_Vector --
kono
parents:
diff changeset
452 -------------------------------
kono
parents:
diff changeset
453
kono
parents:
diff changeset
454 generic
kono
parents:
diff changeset
455 type X_Scalar is private;
kono
parents:
diff changeset
456 type Y_Scalar is private;
kono
parents:
diff changeset
457 type X_Vector is array (Integer range <>) of X_Scalar;
kono
parents:
diff changeset
458 type Y_Vector is array (Integer range <>) of Y_Scalar;
kono
parents:
diff changeset
459 with procedure Update (X : in out X_Scalar; Y : Y_Scalar);
kono
parents:
diff changeset
460 procedure Update_Vector_With_Vector (X : in out X_Vector; Y : Y_Vector);
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 -------------------------------
kono
parents:
diff changeset
463 -- Update_Matrix_With_Matrix --
kono
parents:
diff changeset
464 -------------------------------
kono
parents:
diff changeset
465
kono
parents:
diff changeset
466 generic
kono
parents:
diff changeset
467 type X_Scalar is private;
kono
parents:
diff changeset
468 type Y_Scalar is private;
kono
parents:
diff changeset
469 type X_Matrix is array (Integer range <>, Integer range <>) of X_Scalar;
kono
parents:
diff changeset
470 type Y_Matrix is array (Integer range <>, Integer range <>) of Y_Scalar;
kono
parents:
diff changeset
471 with procedure Update (X : in out X_Scalar; Y : Y_Scalar);
kono
parents:
diff changeset
472 procedure Update_Matrix_With_Matrix (X : in out X_Matrix; Y : Y_Matrix);
kono
parents:
diff changeset
473
kono
parents:
diff changeset
474 -----------------
kono
parents:
diff changeset
475 -- Unit_Matrix --
kono
parents:
diff changeset
476 -----------------
kono
parents:
diff changeset
477
kono
parents:
diff changeset
478 generic
kono
parents:
diff changeset
479 type Scalar is private;
kono
parents:
diff changeset
480 type Matrix is array (Integer range <>, Integer range <>) of Scalar;
kono
parents:
diff changeset
481 Zero : Scalar;
kono
parents:
diff changeset
482 One : Scalar;
kono
parents:
diff changeset
483 function Unit_Matrix
kono
parents:
diff changeset
484 (Order : Positive;
kono
parents:
diff changeset
485 First_1 : Integer := 1;
kono
parents:
diff changeset
486 First_2 : Integer := 1) return Matrix;
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 -----------------
kono
parents:
diff changeset
489 -- Unit_Vector --
kono
parents:
diff changeset
490 -----------------
kono
parents:
diff changeset
491
kono
parents:
diff changeset
492 generic
kono
parents:
diff changeset
493 type Scalar is private;
kono
parents:
diff changeset
494 type Vector is array (Integer range <>) of Scalar;
kono
parents:
diff changeset
495 Zero : Scalar;
kono
parents:
diff changeset
496 One : Scalar;
kono
parents:
diff changeset
497 function Unit_Vector
kono
parents:
diff changeset
498 (Index : Integer;
kono
parents:
diff changeset
499 Order : Positive;
kono
parents:
diff changeset
500 First : Integer := 1) return Vector;
kono
parents:
diff changeset
501
kono
parents:
diff changeset
502 end System.Generic_Array_Operations;