Source file flint__c_generated_functions__Function_description__Function.ml

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
module CI = Cstubs_internals

external flint_stubs_1_fmpz_clear : _ CI.fatptr -> unit
  = "flint_stubs_1_fmpz_clear" 

external flint_stubs_2_fmpz_get_si : _ CI.fatptr -> Signed.long
  = "flint_stubs_2_fmpz_get_si" 

external flint_stubs_3_fmpz_set_si : _ CI.fatptr -> Signed.long -> unit
  = "flint_stubs_3_fmpz_set_si" 

external flint_stubs_4_fmpz_init : _ CI.fatptr -> unit
  = "flint_stubs_4_fmpz_init" 

external flint_stubs_5_fmpz_init_set_ui
  : _ CI.fatptr -> Unsigned.ulong -> unit = "flint_stubs_5_fmpz_init_set_ui" 

external flint_stubs_6_fmpq_clear : _ CI.fatptr -> unit
  = "flint_stubs_6_fmpq_clear" 

external flint_stubs_7_fmpq_set_fmpz_frac
  : _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "flint_stubs_7_fmpq_set_fmpz_frac" 

external flint_stubs_8_free : _ CI.fatptr -> unit = "flint_stubs_8_free" 

external flint_stubs_9_strlen : _ CI.fatptr -> Unsigned.size_t
  = "flint_stubs_9_strlen" 

external flint_stubs_10_fmpz_poly_init : _ CI.fatptr -> unit
  = "flint_stubs_10_fmpz_poly_init" 

external flint_stubs_11_fmpz_poly_init2 : _ CI.fatptr -> Signed.long -> unit
  = "flint_stubs_11_fmpz_poly_init2" 

external flint_stubs_12_fmpz_poly_realloc
  : _ CI.fatptr -> Signed.long -> unit = "flint_stubs_12_fmpz_poly_realloc" 

external flint_stubs_13_fmpz_poly_clear : _ CI.fatptr -> unit
  = "flint_stubs_13_fmpz_poly_clear" 

external flint_stubs_14_fmpz_poly_get_coeff_fmpz
  : _ CI.fatptr -> _ CI.fatptr -> Signed.long -> unit
  = "flint_stubs_14_fmpz_poly_get_coeff_fmpz" 

external flint_stubs_15_fmpz_poly_set_coeff_fmpz
  : _ CI.fatptr -> Signed.long -> _ CI.fatptr -> unit
  = "flint_stubs_15_fmpz_poly_set_coeff_fmpz" 

external flint_stubs_16_fmpz_poly_set : _ CI.fatptr -> _ CI.fatptr -> unit
  = "flint_stubs_16_fmpz_poly_set" 

external flint_stubs_17_fmpz_poly_add
  : _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "flint_stubs_17_fmpz_poly_add" 

external flint_stubs_18_fmpz_poly_sub
  : _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "flint_stubs_18_fmpz_poly_sub" 

external flint_stubs_19_fmpz_poly_mul
  : _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "flint_stubs_19_fmpz_poly_mul" 

external flint_stubs_20_fmpz_poly_scalar_mul_fmpz
  : _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "flint_stubs_20_fmpz_poly_scalar_mul_fmpz" 

external flint_stubs_21_fmpz_poly_set_si : _ CI.fatptr -> Signed.long -> unit
  = "flint_stubs_21_fmpz_poly_set_si" 

type 'a result = 'a
type 'a return = 'a
type 'a fn =
 | Returns  : 'a CI.typ   -> 'a return fn
 | Function : 'a CI.typ * 'b fn  -> ('a -> 'b) fn
let map_result f x = f x
let returning t = Returns t
let (@->) f p = Function (f, p)
let foreign : type a b. string -> (a -> b) fn -> (a -> b) =
  fun name t -> match t, name with
| Function (CI.Pointer _, Function (CI.Primitive CI.Long, Returns CI.Void)),
  "fmpz_poly_set_si" ->
  (fun x1 x3 ->
    let CI.CPointer x2 = x1 in flint_stubs_21_fmpz_poly_set_si x2 x3)
| Function
    (CI.Pointer _,
     Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))),
  "fmpz_poly_scalar_mul_fmpz" ->
  (fun x4 x6 x8 ->
    let CI.CPointer x9 = x8 in
    let CI.CPointer x7 = x6 in
    let CI.CPointer x5 = x4 in
    flint_stubs_20_fmpz_poly_scalar_mul_fmpz x5 x7 x9)
| Function
    (CI.Pointer _,
     Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))),
  "fmpz_poly_mul" ->
  (fun x10 x12 x14 ->
    let CI.CPointer x15 = x14 in
    let CI.CPointer x13 = x12 in
    let CI.CPointer x11 = x10 in flint_stubs_19_fmpz_poly_mul x11 x13 x15)
| Function
    (CI.Pointer _,
     Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))),
  "fmpz_poly_sub" ->
  (fun x16 x18 x20 ->
    let CI.CPointer x21 = x20 in
    let CI.CPointer x19 = x18 in
    let CI.CPointer x17 = x16 in flint_stubs_18_fmpz_poly_sub x17 x19 x21)
| Function
    (CI.Pointer _,
     Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))),
  "fmpz_poly_add" ->
  (fun x22 x24 x26 ->
    let CI.CPointer x27 = x26 in
    let CI.CPointer x25 = x24 in
    let CI.CPointer x23 = x22 in flint_stubs_17_fmpz_poly_add x23 x25 x27)
| Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void)),
  "fmpz_poly_set" ->
  (fun x28 x30 ->
    let CI.CPointer x31 = x30 in
    let CI.CPointer x29 = x28 in flint_stubs_16_fmpz_poly_set x29 x31)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Long, Function (CI.Pointer _, Returns CI.Void))),
  "fmpz_poly_set_coeff_fmpz" ->
  (fun x32 x34 x35 ->
    let CI.CPointer x36 = x35 in
    let CI.CPointer x33 = x32 in
    flint_stubs_15_fmpz_poly_set_coeff_fmpz x33 x34 x36)
| Function
    (CI.Pointer _,
     Function
       (CI.Pointer _, Function (CI.Primitive CI.Long, Returns CI.Void))),
  "fmpz_poly_get_coeff_fmpz" ->
  (fun x37 x39 x41 ->
    let CI.CPointer x40 = x39 in
    let CI.CPointer x38 = x37 in
    flint_stubs_14_fmpz_poly_get_coeff_fmpz x38 x40 x41)
| Function (CI.Pointer _, Returns CI.Void), "fmpz_poly_clear" ->
  (fun x42 ->
    let CI.CPointer x43 = x42 in flint_stubs_13_fmpz_poly_clear x43)
| Function (CI.Pointer _, Function (CI.Primitive CI.Long, Returns CI.Void)),
  "fmpz_poly_realloc" ->
  (fun x44 x46 ->
    let CI.CPointer x45 = x44 in flint_stubs_12_fmpz_poly_realloc x45 x46)
| Function (CI.Pointer _, Function (CI.Primitive CI.Long, Returns CI.Void)),
  "fmpz_poly_init2" ->
  (fun x47 x49 ->
    let CI.CPointer x48 = x47 in flint_stubs_11_fmpz_poly_init2 x48 x49)
| Function (CI.Pointer _, Returns CI.Void), "fmpz_poly_init" ->
  (fun x50 -> let CI.CPointer x51 = x50 in flint_stubs_10_fmpz_poly_init x51)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Size_t)), "strlen" ->
  (fun x52 -> let CI.CPointer x53 = x52 in flint_stubs_9_strlen x53)
| Function (CI.Pointer _, Returns CI.Void), "free" ->
  (fun x54 -> let CI.CPointer x55 = x54 in flint_stubs_8_free x55)
| Function
    (CI.Pointer _,
     Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))),
  "fmpq_set_fmpz_frac" ->
  (fun x56 x58 x60 ->
    let CI.CPointer x61 = x60 in
    let CI.CPointer x59 = x58 in
    let CI.CPointer x57 = x56 in flint_stubs_7_fmpq_set_fmpz_frac x57 x59 x61)
| Function (CI.Pointer _, Returns CI.Void), "fmpq_clear" ->
  (fun x62 -> let CI.CPointer x63 = x62 in flint_stubs_6_fmpq_clear x63)
| Function (CI.Pointer _, Function (CI.Primitive CI.Ulong, Returns CI.Void)),
  "fmpz_init_set_ui" ->
  (fun x64 x66 ->
    let CI.CPointer x65 = x64 in flint_stubs_5_fmpz_init_set_ui x65 x66)
| Function (CI.Pointer _, Returns CI.Void), "fmpz_init" ->
  (fun x67 -> let CI.CPointer x68 = x67 in flint_stubs_4_fmpz_init x68)
| Function (CI.Pointer _, Function (CI.Primitive CI.Long, Returns CI.Void)),
  "fmpz_set_si" ->
  (fun x69 x71 ->
    let CI.CPointer x70 = x69 in flint_stubs_3_fmpz_set_si x70 x71)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Long)), "fmpz_get_si" ->
  (fun x72 -> let CI.CPointer x73 = x72 in flint_stubs_2_fmpz_get_si x73)
| Function (CI.Pointer _, Returns CI.Void), "fmpz_clear" ->
  (fun x74 -> let CI.CPointer x75 = x74 in flint_stubs_1_fmpz_clear x75)
| _, s ->  Printf.ksprintf failwith "No match for %s" s


let foreign_value : type a. string -> a Ctypes.typ -> a Ctypes.ptr =
  fun name t -> match t, name with
| _, s ->  Printf.ksprintf failwith "No match for %s" s