-
Notifications
You must be signed in to change notification settings - Fork 3
/
ada-numerics-generic_complex_arrays.ads
332 lines (230 loc) · 10.8 KB
/
ada-numerics-generic_complex_arrays.ads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
-- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.Numerics.Generic_Real_Arrays;
with Ada.Numerics.Generic_Complex_Types;
generic
with package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (<>);
with package Complex_Types is
new Ada.Numerics.Generic_Complex_Types (Real_Arrays.Real);
package Ada.Numerics.Generic_Complex_Arrays is
pragma Pure (Generic_Complex_Arrays);
-- Types
type Complex_Vector is array (Integer range <>) of Complex_Types.Complex;
type Complex_Matrix is
array (Integer range <>, Integer range <>) of Complex_Types.Complex;
-- Subprograms for Complex_Vector types
-- Complex_Vector selection, conversion and composition operations
function Re (X : in Complex_Vector) return Real_Arrays.Real_Vector;
function Im (X : in Complex_Vector) return Real_Arrays.Real_Vector;
procedure Set_Re (X : in out Complex_Vector;
Re : in Real_Arrays.Real_Vector);
procedure Set_Im (X : in out Complex_Vector;
Im : in Real_Arrays.Real_Vector);
function Compose_From_Cartesian (Re : in Real_Arrays.Real_Vector)
return Complex_Vector;
function Compose_From_Cartesian (Re : in Real_Arrays.Real_Vector;
Im : in Real_Arrays.Real_Vector)
return Complex_Vector;
function Modulus (X : in Complex_Vector) return Real_Arrays.Real_Vector;
function "abs" (Right : in Complex_Vector) return Real_Arrays.Real_Vector
renames Modulus;
function Argument (X : in Complex_Vector) return Real_Arrays.Real_Vector;
function Argument (X : in Complex_Vector;
Cycle : in Real_Arrays.Real'Base)
return Real_Arrays.Real_Vector;
function Compose_From_Polar (Modulus : in Real_Arrays.Real_Vector;
Argument : in Real_Arrays.Real_Vector)
return Complex_Vector;
function Compose_From_Polar (Modulus : in Real_Arrays.Real_Vector;
Argument : in Real_Arrays.Real_Vector;
Cycle : in Real_Arrays.Real'Base)
return Complex_Vector;
-- Complex_Vector arithmetic operations
function "+" (Right : in Complex_Vector) return Complex_Vector;
function "-" (Right : in Complex_Vector) return Complex_Vector;
function Conjugate (X : in Complex_Vector) return Complex_Vector;
function "+" (Left : in Complex_Vector;
Right : in Complex_Vector)
return Complex_Vector;
function "-" (Left : in Complex_Vector;
Right : in Complex_Vector)
return Complex_Vector;
function "*" (Left : in Complex_Vector;
Right : Complex_Vector)
return Complex_Types.Complex;
function "abs" (Right : in Complex_Vector) return Complex_Types.Complex;
-- Mixed Real_Arrays.Real_Vector and Complex_Vector arithmetic operations
function "+" (Left : in Real_Arrays.Real_Vector;
Right : in Complex_Vector)
return Complex_Vector;
function "+" (Left : in Complex_Vector;
Right : in Real_Arrays.Real_Vector)
return Complex_Vector;
function "-" (Left : in Real_Arrays.Real_Vector;
Right : in Complex_Vector)
return Complex_Vector;
function "-" (Left : in Complex_Vector;
Right : in Real_Arrays.Real_Vector)
return Complex_Vector;
function "*" (Left : in Real_Arrays.Real_Vector;
Right : in Complex_Vector)
return Complex_Types.Complex;
function "*" (Left : in Complex_Vector;
Right : in Real_Arrays.Real_Vector)
return Complex_Types.Complex;
-- Complex_Vector scaling operations
function "*" (Left : in Complex_Types.Complex;
Right : in Complex_Vector)
return Complex_Vector;
function "*" (Left : in Complex_Vector;
Right : in Complex_Types.Complex)
return Complex_Vector;
function "/" (Left : in Complex_Vector;
Right : in Complex_Types.Complex)
return Complex_Vector;
function "*" (Left : in Real_Arrays.Real'Base;
Right : in Complex_Vector)
return Complex_Vector;
function "*" (Left : in Complex_Vector;
Right : in Real_Arrays.Real'Base)
return Complex_Vector;
function "/" (Left : in Complex_Vector;
Right : in Real_Arrays.Real'Base)
return Complex_Vector;
-- Other Complex_Vector operations
function Unit_Vector (Index : in Integer;
Order : in Positive;
First : in Integer := 1)
return Complex_Vector;
-- Subprograms for Complex_Matrix types
-- Complex_Matrix selection, conversion and composition operations
function Re (X : in Complex_Matrix) return Real_Arrays.Real_Matrix;
function Im (X : in Complex_Matrix) return Real_Arrays.Real_Matrix;
procedure Set_Re (X : in out Complex_Matrix;
Re : in Real_Arrays.Real_Matrix);
procedure Set_Im (X : in out Complex_Matrix;
Im : in Real_Arrays.Real_Matrix);
function Compose_From_Cartesian (Re : in Real_Arrays.Real_Matrix)
return Complex_Matrix;
function Compose_From_Cartesian (Re : in Real_Arrays.Real_Matrix;
Im : in Real_Arrays.Real_Matrix)
return Complex_Matrix;
function Modulus (X : in Complex_Matrix) return Real_Arrays.Real_Matrix;
function "abs" (Right : in Complex_Matrix) return Real_Arrays.Real_Matrix
renames Modulus;
function Argument (X : in Complex_Matrix) return Real_Arrays.Real_Matrix;
function Argument (X : in Complex_Matrix;
Cycle : in Real_Arrays.Real'Base)
return Real_Arrays.Real_Matrix;
function Compose_From_Polar (Modulus : in Real_Arrays.Real_Matrix;
Argument : in Real_Arrays.Real_Matrix)
return Complex_Matrix;
function Compose_From_Polar (Modulus : in Real_Arrays.Real_Matrix;
Argument : in Real_Arrays.Real_Matrix;
Cycle : in Real_Arrays.Real'Base)
return Complex_Matrix;
-- Complex_Matrix arithmetic operations
function "+" (Right : in Complex_Matrix) return Complex_Matrix;
function "-" (Right : in Complex_Matrix) return Complex_Matrix;
function Conjugate (X : in Complex_Matrix) return Complex_Matrix;
function Transpose (X : in Complex_Matrix) return Complex_Matrix;
function "+" (Left : in Complex_Matrix;
Right : in Complex_Matrix)
return Complex_Matrix;
function "-" (Left : in Complex_Matrix;
Right : in Complex_Matrix)
return Complex_Matrix;
function "*" (Left : in Complex_Matrix;
Right : in Complex_Matrix)
return Complex_Matrix;
function "*" (Left : in Complex_Vector;
Right : in Complex_Vector)
return Complex_Matrix;
function "*" (Left : in Complex_Vector;
Right : in Complex_Matrix)
return Complex_Vector;
function "*" (Left : in Complex_Matrix;
Right : in Complex_Vector)
return Complex_Vector;
-- Mixed Real_Arrays.Real_Matrix and Complex_Matrix arithmetic operations
function "+" (Left : in Real_Arrays.Real_Matrix;
Right : in Complex_Matrix)
return Complex_Matrix;
function "+" (Left : in Complex_Matrix;
Right : in Real_Arrays.Real_Matrix)
return Complex_Matrix;
function "-" (Left : in Real_Arrays.Real_Matrix;
Right : in Complex_Matrix)
return Complex_Matrix;
function "-" (Left : in Complex_Matrix;
Right : in Real_Arrays.Real_Matrix)
return Complex_Matrix;
function "*" (Left : in Real_Arrays.Real_Matrix;
Right : in Complex_Matrix)
return Complex_Matrix;
function "*" (Left : in Complex_Matrix;
Right : in Real_Arrays.Real_Matrix)
return Complex_Matrix;
function "*" (Left : in Real_Arrays.Real_Vector;
Right : in Complex_Vector)
return Complex_Matrix;
function "*" (Left : in Complex_Vector;
Right : in Real_Arrays.Real_Vector)
return Complex_Matrix;
function "*" (Left : in Real_Arrays.Real_Vector;
Right : in Complex_Matrix)
return Complex_Vector;
function "*" (Left : in Complex_Vector;
Right : in Real_Arrays.Real_Matrix)
return Complex_Vector;
function "*" (Left : in Real_Arrays.Real_Matrix;
Right : in Complex_Vector)
return Complex_Vector;
function "*" (Left : in Complex_Matrix;
Right : in Real_Arrays.Real_Vector)
return Complex_Vector;
-- Complex_Matrix scaling operations
function "*" (Left : in Complex_Types.Complex;
Right : in Complex_Matrix)
return Complex_Matrix;
function "*" (Left : in Complex_Matrix;
Right : in Complex_Types.Complex)
return Complex_Matrix;
function "/" (Left : in Complex_Matrix;
Right : in Complex_Types.Complex)
return Complex_Matrix;
function "*" (Left : in Real_Arrays.Real'Base;
Right : in Complex_Matrix)
return Complex_Matrix;
function "*" (Left : in Complex_Matrix;
Right : in Real_Arrays.Real'Base)
return Complex_Matrix;
function "/" (Left : in Complex_Matrix;
Right : in Real_Arrays.Real'Base)
return Complex_Matrix;
-- Complex_Matrix inversion and related operations
function Solve (A : in Complex_Matrix;
X : in Complex_Vector)
return Complex_Vector;
function Solve (A : in Complex_Matrix;
X : in Complex_Matrix)
return Complex_Matrix;
function Inverse (A : in Complex_Matrix) return Complex_Matrix;
function Determinant (A : in Complex_Matrix) return Complex_Types.Complex;
-- Eigenvalues and vectors of a Hermitian matrix
function Eigenvalues (A : in Complex_Matrix) return Real_Arrays.Real_Vector;
procedure Eigensystem (A : in Complex_Matrix;
Values : out Real_Arrays.Real_Vector;
Vectors : out Complex_Matrix);
-- Other Complex_Matrix operations
function Unit_Matrix (Order : in Positive;
First_1 : in Integer := 1;
First_2 : in Integer := 1)
return Complex_Matrix;
end Ada.Numerics.Generic_Complex_Arrays;