OSDN Git Service

2009-04-08 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-ngrear.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --                     ADA.NUMERICS.GENERIC_REAL_ARRAYS                     --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --            Copyright (C) 2006, Free Software Foundation, Inc.            --
10 --                                                                          --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the  contents of the part following the private keyword. --
14 --                                                                          --
15 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
16 -- terms of the  GNU General Public License as published  by the Free Soft- --
17 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
18 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
21 -- for  more details.  You should have  received  a copy of the GNU General --
22 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
23 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
24 -- Boston, MA 02110-1301, USA.                                              --
25 --                                                                          --
26 -- As a special exception,  if other files  instantiate  generics from this --
27 -- unit, or you link  this unit with other files  to produce an executable, --
28 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
29 -- covered  by the  GNU  General  Public  License.  This exception does not --
30 -- however invalidate  any other reasons why  the executable file  might be --
31 -- covered by the  GNU Public License.                                      --
32 --                                                                          --
33 -- GNAT was originally developed  by the GNAT team at  New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
35 --                                                                          --
36 ------------------------------------------------------------------------------
37
38 generic
39    type Real is digits <>;
40 package Ada.Numerics.Generic_Real_Arrays is
41    pragma Pure (Generic_Real_Arrays);
42
43    --  Types
44
45    type Real_Vector is array (Integer range <>) of Real'Base;
46    type Real_Matrix is array (Integer range <>, Integer range <>) of Real'Base;
47
48    --  Subprograms for Real_Vector types
49
50    --  Real_Vector arithmetic operations
51
52    function "+"   (Right : Real_Vector)       return Real_Vector;
53    function "-"   (Right : Real_Vector)       return Real_Vector;
54    function "abs" (Right : Real_Vector)       return Real_Vector;
55
56    function "+"   (Left, Right : Real_Vector) return Real_Vector;
57    function "-"   (Left, Right : Real_Vector) return Real_Vector;
58
59    function "*"   (Left, Right : Real_Vector) return Real'Base;
60
61    function "abs" (Right : Real_Vector)       return Real'Base;
62
63    --  Real_Vector scaling operations
64
65    function "*" (Left : Real'Base;   Right : Real_Vector) return Real_Vector;
66    function "*" (Left : Real_Vector; Right : Real'Base)   return Real_Vector;
67    function "/" (Left : Real_Vector; Right : Real'Base)   return Real_Vector;
68
69    --  Other Real_Vector operations
70
71    function Unit_Vector
72      (Index : Integer;
73       Order : Positive;
74       First : Integer := 1) return Real_Vector;
75
76    --  Subprograms for Real_Matrix types
77
78    --  Real_Matrix arithmetic operations
79
80    function "+"       (Right : Real_Matrix) return Real_Matrix;
81    function "-"       (Right : Real_Matrix) return Real_Matrix;
82    function "abs"     (Right : Real_Matrix) return Real_Matrix;
83    function Transpose (X     : Real_Matrix) return Real_Matrix;
84
85    function "+" (Left, Right : Real_Matrix) return Real_Matrix;
86    function "-" (Left, Right : Real_Matrix) return Real_Matrix;
87    function "*" (Left, Right : Real_Matrix) return Real_Matrix;
88
89    function "*" (Left, Right : Real_Vector) return Real_Matrix;
90
91    function "*" (Left : Real_Vector; Right : Real_Matrix) return Real_Vector;
92    function "*" (Left : Real_Matrix; Right : Real_Vector) return Real_Vector;
93
94    --  Real_Matrix scaling operations
95
96    function "*" (Left : Real'Base;   Right : Real_Matrix) return Real_Matrix;
97    function "*" (Left : Real_Matrix; Right : Real'Base)   return Real_Matrix;
98    function "/" (Left : Real_Matrix; Right : Real'Base)   return Real_Matrix;
99
100    --  Real_Matrix inversion and related operations
101
102    function Solve (A : Real_Matrix; X : Real_Vector) return Real_Vector;
103    function Solve (A, X : Real_Matrix) return Real_Matrix;
104    function Inverse (A : Real_Matrix) return Real_Matrix;
105    function Determinant (A : Real_Matrix) return Real'Base;
106
107    --  Eigenvalues and vectors of a real symmetric matrix
108
109    function Eigenvalues (A : Real_Matrix) return Real_Vector;
110
111    procedure Eigensystem
112      (A       : Real_Matrix;
113       Values  : out Real_Vector;
114       Vectors : out Real_Matrix);
115
116    --  Other Real_Matrix operations
117
118    function Unit_Matrix
119      (Order   : Positive;
120       First_1 : Integer := 1;
121       First_2 : Integer := 1) return Real_Matrix;
122
123 private
124    --  The following operations are either relatively simple compared to the
125    --  expense of returning unconstrained arrays, or are just function wrappers
126    --  calling procedures implementing the actual operation. By having the
127    --  front end always inline these, the expense of the unconstrained returns
128    --  can be avoided.
129
130    pragma Inline_Always ("+");
131    pragma Inline_Always ("-");
132    pragma Inline_Always ("*");
133    pragma Inline_Always ("/");
134    pragma Inline_Always ("abs");
135    pragma Inline_Always (Eigenvalues);
136    pragma Inline_Always (Inverse);
137    pragma Inline_Always (Solve);
138    pragma Inline_Always (Transpose);
139    pragma Inline_Always (Unit_Matrix);
140    pragma Inline_Always (Unit_Vector);
141 end Ada.Numerics.Generic_Real_Arrays;