(* Recuperation des donnees dans un tableau de tableaux *) let line1 ficdat = let cin = open_in ficdat in let line1 = input_line cin in close_in cin; line1 let nb_pairs ficdat = let buf = Scanf.Scanning.from_string (line1 ficdat) in let _ = Scanf.bscanf buf "%d %f" (fun n ln -> n,ln) in let rec loop n = let stop = try Scanf.bscanf buf " %f %f" (fun x lx -> false) with End_of_file -> true in if stop then n else loop (n+1) in loop 0 let scan ficdat = match nb_pairs ficdat with | 1 -> (fun b -> Scanf.sscanf b "%d %f %f %f" (fun n ln x lx -> [|float_of_int n; ln; x; lx|])) | 2 -> (fun b -> Scanf.sscanf b "%d %f %f %f %f %f" (fun n ln x lx y ly -> [|float_of_int n; ln; x; lx; y; ly|])) | 3 -> (fun b -> Scanf.sscanf b "%d %f %f %f %f %f %f %f" (fun n ln x lx y ly z lz -> [|float_of_int n; ln; x; lx; y; ly; z; lz|])) | _ -> assert false let arr_list ficdat = let scan = scan ficdat in let cin = open_in ficdat in let rec loop () = let line_opt = try Some (input_line cin) with End_of_file -> close_in cin; None in match line_opt with | None -> [] | Some line -> scan line :: loop () in loop () let array_of_dat ficdat = Array.of_list (arr_list ficdat) (* exploitation *) type col = A | F1 | F2 | F3 let dircol = function | A -> 0 | F1 -> 2 | F2 -> 4 | F3 -> 6 let logcol = function | A -> 1 | F1 -> 3 | F2 -> 5 | F3 -> 7 let diff_log_n arr c = let nb_rows = Array.length arr in arr.(nb_rows - 1).(logcol c) -. arr.(nb_rows / 2).(logcol c) let expo c arr = diff_log_n arr c /. diff_log_n arr A let exp_f1 = expo F1 let exp_f2 = expo F2 let exp_f3 = expo F3 let test f c r = let x = r.(dircol A) in let y = r.(dircol c) in y /. (f x) let x (x:float) = x let xp p x = x ** p let xplog p x = (x ** p) *. log x let xloglog x = x *. log (log x) let xploglog p x = (x ** p) *. log (log x) let x2 x = x ** 2. let x3 x = x ** 3. let xlog x = x *. log x let xlog2 x = x *. (log x ** 2.) let x2log x = (x ** 2.) *. log x let x2loglog x = (x ** 2.) *. log (log x) let x3log x = (x ** 3.) *. log x let x2log_1 x = (x ** 2.) /. log x let check arr col coeff f = Array.map (test (fun x -> coeff *. f x) col) arr (* resultats *) let arind = array_of_dat "resultind+.dat" let _ = exp_f1 arind let _ = exp_f2 arind let _ok = check arind F1 0.38e-7 (xp 1.7) let _nok = check arind F1 0.1e-7 (xploglog 1.6) let _nok = check arind F1 0.1e-7 x2log_1 let _nok = check arind F2 0.1e-7 (xp 1.69) let _nok = check arind F2 0.1e-7 x2log_1 (* *) let arindabm1 = array_of_dat "resultindabm1.dat" let _ = exp_f1 arindabm1 let _ = exp_f2 arindabm1 let _ = exp_f3 arindabm1 let _ok = check arindabm1 F1 0.88e-7 x2 let _nok = check arindabm1 F2 1.7e-9 x2 let _nok = check arindabm1 F3 1.0e-10 x (* *) let arindabm2 = array_of_dat "resultindabm2.dat" let _ = exp_f1 arindabm2 let _ = exp_f2 arindabm2 let _ = exp_f3 arindabm2 let _ok = check arindabm2 F1 21.6e-8 x2 let _ok = check arindabm2 F1 1.06e-7 x2loglog let _ok = check arindabm2 F2 1.8e-8 (xp 1.8) let _ok = check arindabm2 F2 0.3e-7 x2log_1 let _nok = check arindabm2 F3 21.e-8 x let _nok = check arindabm2 F3 10.5e-8 xloglog (* *) let arivtabm2 = array_of_dat "resultivtabm2.dat" let _ = exp_f1 arivtabm2 let _ = exp_f2 arivtabm2 let _ = exp_f3 arivtabm2 let _ok = check arivtabm2 F1 3.8e-8 x3 let _ok = check arivtabm2 F2 0.78e-8 x3 let _ok = check arivtabm2 F3 0.72e-8 x3 (* *)