OSDN Git Service

gcc/ada/
[pf3gnuchains/gcc-fork.git] / gcc / ada / i-forbla.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --                         INTERFACES.FORTRAN.BLAS                          --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --         Copyright (C) 2006-2007, 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 ------------------------------------------------------------------------------
33
34 --  This package provides a thin binding to the standard Fortran BLAS library.
35 --  Documentation and a reference BLAS implementation is available from
36 --  ftp://ftp.netlib.org. The main purpose of this package is to facilitate
37 --  implementation of the Ada 2005 Ada.Numerics.Generic_Real_Arrays and
38 --  Ada.Numerics.Generic_Complex_Arrays packages. Bindings to other BLAS
39 --  routines may be added over time.
40
41 --  As actual linker arguments to link with the BLAS implementation differs
42 --  according to platform and chosen BLAS implementation, the linker arguments
43 --  are given in the body of this package. The body may need to be modified in
44 --  order to link with different BLAS implementations tuned to the specific
45 --  target.
46
47 package Interfaces.Fortran.BLAS is
48    pragma Pure;
49    pragma Elaborate_Body;
50
51    No_Trans   : aliased constant Character := 'N';
52    Trans      : aliased constant Character := 'T';
53    Conj_Trans : aliased constant Character := 'C';
54
55    --  Vector types
56
57    type Real_Vector is array (Integer range <>) of Real;
58
59    type Complex_Vector is array (Integer range <>) of Complex;
60
61    type Double_Precision_Vector is array (Integer range <>)
62      of Double_Precision;
63
64    type Double_Complex_Vector is array (Integer range <>) of Double_Complex;
65
66    --  Matrix types
67
68    type Real_Matrix is array (Integer range <>, Integer range <>)
69      of Real;
70
71    type Double_Precision_Matrix is array (Integer range <>, Integer range <>)
72      of Double_Precision;
73
74    type Complex_Matrix is array (Integer range <>, Integer range <>)
75      of Complex;
76
77    type Double_Complex_Matrix is array (Integer range <>, Integer range <>)
78      of Double_Complex;
79
80    --  BLAS Level 1
81
82    function sdot
83      (N     : Positive;
84       X     : Real_Vector;
85       Inc_X : Integer := 1;
86       Y     : Real_Vector;
87       Inc_Y : Integer := 1) return Real;
88
89    function ddot
90      (N     : Positive;
91       X     : Double_Precision_Vector;
92       Inc_X : Integer := 1;
93       Y     : Double_Precision_Vector;
94       Inc_Y : Integer := 1) return Double_Precision;
95
96    function cdotu
97      (N     : Positive;
98       X     : Complex_Vector;
99       Inc_X : Integer := 1;
100       Y     : Complex_Vector;
101       Inc_Y : Integer := 1) return Complex;
102
103    function zdotu
104      (N     : Positive;
105       X     : Double_Complex_Vector;
106       Inc_X : Integer := 1;
107       Y     : Double_Complex_Vector;
108       Inc_Y : Integer := 1) return Double_Complex;
109
110    function snrm2
111      (N     : Natural;
112       X     : Real_Vector;
113       Inc_X : Integer := 1) return Real;
114
115    function dnrm2
116      (N     : Natural;
117       X     : Double_Precision_Vector;
118       Inc_X : Integer := 1) return Double_Precision;
119
120    function scnrm2
121      (N     : Natural;
122       X     : Complex_Vector;
123       Inc_X : Integer := 1) return Real;
124
125    function dznrm2
126      (N     : Natural;
127       X     : Double_Complex_Vector;
128       Inc_X : Integer := 1) return Double_Precision;
129
130    --  BLAS Level 2
131
132    procedure sgemv
133      (Trans : access constant Character;
134       M     : Natural := 0;
135       N     : Natural := 0;
136       Alpha : Real := 1.0;
137       A     : Real_Matrix;
138       Ld_A  : Positive;
139       X     : Real_Vector;
140       Inc_X : Integer := 1;  -- must be non-zero
141       Beta  : Real := 0.0;
142       Y     : in out Real_Vector;
143       Inc_Y : Integer := 1); -- must be non-zero
144
145    procedure dgemv
146      (Trans : access constant Character;
147       M     : Natural := 0;
148       N     : Natural := 0;
149       Alpha : Double_Precision := 1.0;
150       A     : Double_Precision_Matrix;
151       Ld_A  : Positive;
152       X     : Double_Precision_Vector;
153       Inc_X : Integer := 1;  -- must be non-zero
154       Beta  : Double_Precision := 0.0;
155       Y     : in out Double_Precision_Vector;
156       Inc_Y : Integer := 1); -- must be non-zero
157
158    procedure cgemv
159      (Trans : access constant Character;
160       M     : Natural := 0;
161       N     : Natural := 0;
162       Alpha : Complex := (1.0, 1.0);
163       A     : Complex_Matrix;
164       Ld_A  : Positive;
165       X     : Complex_Vector;
166       Inc_X : Integer := 1;  -- must be non-zero
167       Beta  : Complex := (0.0, 0.0);
168       Y     : in out Complex_Vector;
169       Inc_Y : Integer := 1); -- must be non-zero
170
171    procedure zgemv
172      (Trans : access constant Character;
173       M     : Natural := 0;
174       N     : Natural := 0;
175       Alpha : Double_Complex := (1.0, 1.0);
176       A     : Double_Complex_Matrix;
177       Ld_A  : Positive;
178       X     : Double_Complex_Vector;
179       Inc_X : Integer := 1;  -- must be non-zero
180       Beta  : Double_Complex := (0.0, 0.0);
181       Y     : in out Double_Complex_Vector;
182       Inc_Y : Integer := 1); -- must be non-zero
183
184    --  BLAS Level 3
185
186    procedure sgemm
187      (Trans_A : access constant Character;
188       Trans_B : access constant Character;
189       M       : Positive;
190       N       : Positive;
191       K       : Positive;
192       Alpha   : Real := 1.0;
193       A       : Real_Matrix;
194       Ld_A    : Integer;
195       B       : Real_Matrix;
196       Ld_B    : Integer;
197       Beta    : Real := 0.0;
198       C       : in out Real_Matrix;
199       Ld_C    : Integer);
200
201    procedure dgemm
202      (Trans_A : access constant Character;
203       Trans_B : access constant Character;
204       M       : Positive;
205       N       : Positive;
206       K       : Positive;
207       Alpha   : Double_Precision := 1.0;
208       A       : Double_Precision_Matrix;
209       Ld_A    : Integer;
210       B       : Double_Precision_Matrix;
211       Ld_B    : Integer;
212       Beta    : Double_Precision := 0.0;
213       C       : in out Double_Precision_Matrix;
214       Ld_C    : Integer);
215
216    procedure cgemm
217      (Trans_A : access constant Character;
218       Trans_B : access constant Character;
219       M       : Positive;
220       N       : Positive;
221       K       : Positive;
222       Alpha   : Complex := (1.0, 1.0);
223       A       : Complex_Matrix;
224       Ld_A    : Integer;
225       B       : Complex_Matrix;
226       Ld_B    : Integer;
227       Beta    : Complex := (0.0, 0.0);
228       C       : in out Complex_Matrix;
229       Ld_C    : Integer);
230
231    procedure zgemm
232      (Trans_A : access constant Character;
233       Trans_B : access constant Character;
234       M       : Positive;
235       N       : Positive;
236       K       : Positive;
237       Alpha   : Double_Complex := (1.0, 1.0);
238       A       : Double_Complex_Matrix;
239       Ld_A    : Integer;
240       B       : Double_Complex_Matrix;
241       Ld_B    : Integer;
242       Beta    : Double_Complex := (0.0, 0.0);
243       C       : in out Double_Complex_Matrix;
244       Ld_C    : Integer);
245
246 private
247    pragma Import (Fortran, cdotu,  "cdotu_");
248    pragma Import (Fortran, cgemm,  "cgemm_");
249    pragma Import (Fortran, cgemv,  "cgemv_");
250    pragma Import (Fortran, ddot,   "ddot_");
251    pragma Import (Fortran, dgemm,  "dgemm_");
252    pragma Import (Fortran, dgemv,  "dgemv_");
253    pragma Import (Fortran, dnrm2,  "dnrm2_");
254    pragma Import (Fortran, dznrm2, "dznrm2_");
255    pragma Import (Fortran, scnrm2, "scnrm2_");
256    pragma Import (Fortran, sdot,   "sdot_");
257    pragma Import (Fortran, sgemm,  "sgemm_");
258    pragma Import (Fortran, sgemv,  "sgemv_");
259    pragma Import (Fortran, snrm2,  "snrm2_");
260    pragma Import (Fortran, zdotu,  "zdotu_");
261    pragma Import (Fortran, zgemm,  "zgemm_");
262    pragma Import (Fortran, zgemv,  "zgemv_");
263 end Interfaces.Fortran.BLAS;