adagsl_335d13f0/examples/combination/src/combination.adb

 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
with Ada.Text_IO;            use Ada.Text_IO;
with Ada.Text_IO.C_Streams;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Integer_Text_IO;    use Ada.Integer_Text_IO;
with Interfaces.C;           use Interfaces.C;
with Interfaces.C.Strings;   use Interfaces.C.Strings;
with Ada.Strings.Unbounded;  use Ada.Strings.Unbounded;
with Ada.Command_Line;       use Ada.Command_Line;

with GNAT.Source_Info; use GNAT.Source_Info;

with gsl;
with gsl.rng;
with gsl.randist;
with gsl.combination ;

procedure Combination is
   Status : Int ;
   procedure Test1 is
      c : access gsl.combination.gsl_combination := gsl.combination.alloc(9,3);
   begin
      Put_Line(gnat.source_info.enclosing_entity);
      gsl.combination.init_first(c);
      Status := gsl.GSL_SUCCESS ;
      while Status = gsl.GSL_SUCCESS
      loop
         Status := gsl.combination.show(c);
         Status := gsl.combination.next(c);
      end loop ;
   end Test1;
   procedure Test2 is
      c : access gsl.combination.gsl_combination := gsl.combination.alloc(9,3);
   begin
      Put_Line(gnat.source_info.enclosing_entity);
      gsl.combination.init_last(c);
      Status := gsl.GSL_SUCCESS ;
      while Status = gsl.GSL_SUCCESS
      loop
         Status := gsl.combination.show(c);
         Status := gsl.combination.prev(c);
      end loop ;
   end Test2;
   procedure Test3 is
      c : access gsl.combination.gsl_combination ;
      Status : int ;
   begin
      Put_Line(gnat.source_info.enclosing_entity);
      for i in 1..4
      loop
         c := gsl.combination.calloc(4,size_t(i));
         Status := gsl.combination.show(c);
         loop
            Status := gsl.combination.next(c);
            if Status /= gsl.GSL_SUCCESS
            then
               exit ;
            end if ;
            Status := gsl.combination.show(c);
         end loop ;
      end loop ;

   end Test3 ;

begin
   Test1;
   Test2;
   Test3;
end Combination;