File: plplot_auxiliary.ads

package info (click to toggle)
plplot 5.10.0%2Bdfsg2-0.4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 25,792 kB
  • ctags: 13,517
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,208; makefile: 210; lisp: 75; sed: 25; fortran: 7
file content (102 lines) | stat: -rw-r--r-- 4,643 bytes parent folder | download | duplicates (2)
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
-- $Id: plplot_auxiliary.ads 12890 2013-12-19 20:45:09Z jbauck $

-- Auxiliary types and subprograms to be with-ed and by all the Ada 
-- bindings to PLplot

-- Copyright (C) 2006-2010 Jerry Bauck

-- This file is part of PLplot.

-- PLplot is free software; you can redistribute it and/or modify
-- it under the terms of the GNU Library General Public License as published
-- by the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.

-- PLplot 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 Library General Public License for more details.

-- You should have received a copy of the GNU Library General Public License
-- along with PLplot; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

with
    Ada.Strings.Bounded, -- fixme Probable cruft.
    Ada.Strings.Unbounded;

use 
    Ada.Strings.Bounded,
    Ada.Strings.Unbounded;
    
--    with Ada.Numerics.Long_Real_Arrays;

package PLplot_Auxiliary is

--------------------------------------------------------------------------------
--           Utility type declarations used by the bindings                   --
--------------------------------------------------------------------------------

    -- Declarations for Ada 95 and Ada 2005 when it is desired to _not_ invoke
    -- the numerical capability of Annex G.3.
   type Real_Vector is array (Integer range <>) of Long_Float;
   type Real_Matrix is array (Integer range <>, Integer range <>) of Long_Float;


    -- Declarations when using Ada 2005 and it is desired to invoke the numerics
    -- Annex G.3 or the user simply prefers to declare real vectors and matrices
    -- in a manner that is type-compatible with that annex. ALSO IN THIS CASE
    -- uncomment the line above: with Ada.Numerics.Long_Real_Arrays;.
    -- Using Annex G.3 requires linking to BLAS and LAPACK libraries or the
    -- PLplot build process will fail when attempting to link the Ada examples
    -- e.g. x01a.adb.
--    subtype Real_Vector is Ada.Numerics.Long_Real_Arrays.Real_Vector;
--    subtype Real_Matrix is Ada.Numerics.Long_Real_Arrays.Real_Matrix;

    ----------------------------------------------------------------------------
    -- Implementation note: The easy ability to switch to Ada 2005 Annex G.3
    -- capability (with only these simple edits to this file) is the only reason
    -- for requiring that this package be with-ed in the bindings. Only the
    -- examples use the utility procedures below--not the bindings themselves.
    -- If it were ever to be decided to abandon Ada 95 compatibility and to
    -- require all Ada-capable PLplot builds to link to BLAS and LAPACK, then
    -- the with-s to this package in the bindings could be removed.
    ----------------------------------------------------------------------------


--------------------------------------------------------------------------------
--            Utility procedures useful in compiling the examples             --
--------------------------------------------------------------------------------

    -- Mimic C conversion of float to integer; something similar works in e.g.
    -- plplot_thin.adb.
    -- C truncates towards 0. Ada rounds to nearest integer; midway rounded 
    -- away from zero, e.g. Inteter(±3.5) is ±4. But any completely reliable 
    -- conversion is probalby not possible; indeed, this one exactly emulates C
    -- when tested for values around ±2 to ±3. Both convert ±2.9999999999999997
    -- to ±2 and ±2.9999999999999998 to ±3.
    function Trunc(a : Long_Float) return Integer;

    -- Find minimum in a 1D array.
    function Vector_Min(x : Real_Vector) return Long_Float;

    -- Find minimum and its location in a 1D array.
    procedure Vector_Min(x               : Real_Vector;
                         The_Minimum     : out Long_Float;
                         Location_Of_Min : out Integer);

    -- Find maximum in a 1D array.
    function Vector_Max(x : Real_Vector) return Long_Float;

    -- Find maximum and its location in a 1D array.
    procedure Vector_Max(x               : Real_Vector;
                         The_Maximum     : out Long_Float;
                         Location_Of_Max : out Integer);
    
    -- Find minimum in a 2D array.
    function Matrix_Min(x : Real_Matrix) return Long_Float;
    
    -- Find maximum in a 2D array.
    function Matrix_Max(x : Real_Matrix) return Long_Float;

end PLplot_Auxiliary;