]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/gTopLevel/esempi/fourier/fourier_make_benchmarks.ml
Merge of the V7_3_new_exportation branch.
[helm.git] / helm / gTopLevel / esempi / fourier / fourier_make_benchmarks.ml
diff --git a/helm/gTopLevel/esempi/fourier/fourier_make_benchmarks.ml b/helm/gTopLevel/esempi/fourier/fourier_make_benchmarks.ml
new file mode 100644 (file)
index 0000000..d783089
--- /dev/null
@@ -0,0 +1,61 @@
+let rec int_to_cic n =
+   if n < 0 then 
+     "(Ropp "^int_to_cic (-n)^")"
+   else
+      match n with
+      0 -> " R0"
+      |1 -> " R1"
+      |k -> "(Rplus R1 " ^ int_to_cic (n-1) ^")"
+;;
+
+let dimx = ref 3;;
+let dimy = ref 3;;
+let kmax = ref 5;;
+let vl = [|"x";"y";"z";"t";"u";"v";"w";"g";"h";"j";"l";"m";"n";"o";"p";"q";"r";"s";"a";"b";"c";"d"|]
+;;
+
+let nth_inc n =
+  vl.(n)
+;;
+
+let preamble () = 
+  for i = 0 to !dimx do
+   print_string ("!"^nth_inc i^":R.");
+  done;
+  print_string "\n";
+;;
+
+let main () =
+  print_string "Immetti m : ";dimy := (read_int ()) - 1;
+  print_string "Immetti n : ";dimx := (read_int ()) - 1;
+  print_string "Immetti K : ";kmax := (read_int ()) + 1;
+  print_string ("Genero un sistema di "^
+   string_of_int (!dimy+1)^" disequazioni in "^
+   string_of_int (!dimx+1)^" incognite con coefficenti "^string_of_int !kmax^"\n\n");
+  Random.self_init ();
+  preamble ();
+  let max = ref 0 in
+  for i=0 to !dimy do
+     begin
+     print_string "(Rle ";
+     for o=0 to !dimx do
+       let k = ref ((Random.int !kmax)) in 
+       if !k > !max then max := !k;
+       if i=o then 
+         k := - !k
+       else
+        k := !k;
+       print_string ("(Rplus (Rmult "^int_to_cic !k^" "^nth_inc o^") ");
+     done;
+     print_string "(Ropp R1)";
+     for o=0 to !dimx  do
+       print_string (")");
+     done;
+     print_string (" R0)\n->\n");
+     end
+  done;
+  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");
+;;
+
+
+main ();;