]> matita.cs.unibo.it Git - helm.git/blob - helm/gTopLevel/esempi/fourier/fourier_make_benchmarks.ml
ocaml 3.09 transition
[helm.git] / helm / gTopLevel / esempi / fourier / fourier_make_benchmarks.ml
1 let rec int_to_cic n =
2    if n < 0 then 
3      "(Ropp "^int_to_cic (-n)^")"
4    else
5       match n with
6       0 -> " R0"
7       |1 -> " R1"
8       |k -> "(Rplus R1 " ^ int_to_cic (n-1) ^")"
9 ;;
10
11 let dimx = ref 3;;
12 let dimy = ref 3;;
13 let kmax = ref 5;;
14 let vl = [|"x";"y";"z";"t";"u";"v";"w";"g";"h";"j";"l";"m";"n";"o";"p";"q";"r";"s";"a";"b";"c";"d"|]
15 ;;
16
17 let nth_inc n =
18   vl.(n)
19 ;;
20
21 let preamble () = 
22   for i = 0 to !dimx do
23    print_string ("!"^nth_inc i^":R.");
24   done;
25   print_string "\n";
26 ;;
27
28 let main () =
29   print_string "Immetti m : ";dimy := (read_int ()) - 1;
30   print_string "Immetti n : ";dimx := (read_int ()) - 1;
31   print_string "Immetti K : ";kmax := (read_int ()) + 1;
32   print_string ("Genero un sistema di "^
33    string_of_int (!dimy+1)^" disequazioni in "^
34    string_of_int (!dimx+1)^" incognite con coefficenti "^string_of_int !kmax^"\n\n");
35   Random.self_init ();
36   preamble ();
37   let max = ref 0 in
38   for i=0 to !dimy do
39      begin
40      print_string "(Rle ";
41      for o=0 to !dimx do
42        let k = ref ((Random.int !kmax)) in 
43        if !k > !max then max := !k;
44        if i=o then 
45          k := - !k
46        else
47          k := !k;
48        print_string ("(Rplus (Rmult "^int_to_cic !k^" "^nth_inc o^") ");
49      done;
50      print_string "(Ropp R1)";
51      for o=0 to !dimx  do
52        print_string (")");
53      done;
54      print_string (" R0)\n->\n");
55      end
56   done;
57   print_string ("\n\nIl massimo K e' "^string_of_int !max^".\nLa tesi la puoi scegliere tu, ma se ricopi una ipotesi vai tranquillo.\n");
58 ;;
59
60
61 main ();;