File : ada_blas-get_precision.ads
-------------------------------------------------------------------------------
-- Copyright (C) 2000-2001 Centre National de la Recherche Scientifique --
-- --
-- This program is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --
-- GNU General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this program; if not, write to the Free Software --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
-- --
-- Author: Duncan Sands (Duncan.Sands@math.u-psud.fr) --
-- Departement de Mathematiques, Batiment 425, --
-- Universite de Paris-XI, Orsay, France. --
-- http://topo.math.u-psud.fr/~sands --
-------------------------------------------------------------------------------
-- Determines the BLAS precision corresponding to Float_Type'Base
generic
type Float_Type is digits <>;
package Ada_BLAS.Get_Precision is
pragma Pure (Ada_BLAS.Get_Precision);
Precision : constant Precision_Type;
private
-- The following method of determining Precision was chosen in order to
-- encourage compile time evaluation and thus, hopefully, dead code
-- elimination. Constraint_Error will be raised if double and single
-- precision are the same (this should never happen since the Fortran
-- standard requires double precision to be more precise than single
-- precision). I appreciate that the value of Precision is not
-- guaranteed to be correct for all machines, all compilers and all values
-- of Float_Type. However, I don't know any examples of it being wrong.
-- IF PRECISION IS SET WRONGLY ON YOUR MACHINE, PLEASE LET ME KNOW!
Precision : constant Precision_Type := Precision_Type'Val (
Precision_Type'Pos (Unsupported)
-
Boolean'Pos ( -- Test for double precision
Float_Type'Base'Digits = Interfaces.Fortran.Double_Precision'Digits
and Float_Type'Base'Size = Interfaces.Fortran.Double_Precision'Size
)
- 2 *
Boolean'Pos ( -- Test for single precision
Float_Type'Base'Digits = Interfaces.Fortran.Real'Digits and
Float_Type'Base'Size = Interfaces.Fortran.Real'Size
)
);
end Ada_BLAS.Get_Precision;