phcpack_2.4.88_e448e94a/src/Ada/CtoPHC/Funky/cosupoly.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
with text_io;                          use text_io;
with Interfaces.C;
with Standard_Natural_Numbers;         use Standard_Natural_Numbers;
with Standard_Natural_Numbers_io;      use Standard_Natural_Numbers_io;
with Standard_Integer_Numbers;         use Standard_Integer_Numbers;
with Standard_Integer_Numbers_io;      use Standard_Integer_Numbers_io;
with C_Integer_io,C_Double_io;         use C_Integer_io,C_Double_io;
with C_Integer_Arrays;                 use C_Integer_Arrays;
with C_Double_Arrays;                  use C_Double_Arrays;
with Standard_Complex_Polynomials;     use Standard_Complex_Polynomials;
with Standard_Complex_Polynomials_io;  use Standard_Complex_Polynomials_io;
with Coefficient_Support_Polynomials;  use Coefficient_Support_Polynomials;

procedure cosupoly ( n : in integer32; s : in C_intarrs.Pointer;
                     m : in integer32; c : in C_dblarrs.Pointer ) is

-- DESCRIPTION :
--   The support vector s has range 0..n-1 and the coefficient
--   vector c has range 0..m-1.

  sva : C_Integer_Array(0..Interfaces.C.size_T(n-1))
      := C_intarrs.Value(s,Interfaces.C.ptrdiff_T(n));
  cva : C_Double_Array(0..Interfaces.C.size_T(m-1)) 
      := C_dblarrs.Value(c,Interfaces.C.ptrdiff_T(m));
  numvars : constant natural32 := natural32(n)/(natural32(m)/2);
  p : Poly := Create(numvars,cva,sva);

begin
  put("The n is "); put(n,1);
  put(" and m is "); put(m,1);
  put(" number of variables : "); put(numvars,1); new_line;
 -- put("sva'first : "); put(integer(sva'first),1); new_line;
 -- put("sva'last : "); put(integer(sva'last),1); new_line;
 -- put("cva'first : "); put(integer(cva'first),1); new_line;
 -- put("cva'last : "); put(integer(cva'last),1); new_line;
  put("The support :");
  for i in 0..n-1 loop
    put(" "); put(sva(Interfaces.C.size_T(i)),1);
  end loop;
  new_line;
  put_line("The coefficients : ");
  for i in 0..m-1 loop
    put(" "); put(cva(Interfaces.C.size_T(i)));
    new_line;
  end loop;
  put_line("The polynomial defined by coefficients and support : ");
  put_line(p);
end cosupoly;