MetaOCaml version 3.08.0 alpha 017 # type ('a, 'b, 'c) container2d = { get : ('a, 'b) code -> ('a, int) code -> ('a, int) code -> ('a, 'c) code; set : ('a, 'b) code -> ('a, int) code -> ('a, int) code -> ('a, 'c) code -> ('a, unit) code; dim1 : ('a, 'b) code -> ('a, int) code; dim2 : ('a, 'b) code -> ('a, int) code; mapper : ('a, 'c -> 'c) code -> ('a, 'b) code -> ('a, 'b) code; copy : ('a, 'b) code -> ('a, 'b) code; } # type ('a, 'b, 'c) state = { b : ('a, 'b) code; r : ('a, int ref) code; c : ('a, int ref) code; m : ('a, int) code; n : ('a, int) code; det : ('a, 'c ref) code; detsign : ('a, 'c ref) code; } # type ('a, 'b) domain = { zero : ('a, 'b) code; one : ('a, 'b) code; minusone : ('a, 'b) code; plus : ('a, 'b) code -> ('a, 'b) code -> ('a, 'b) code; times : ('a, 'b) code -> ('a, 'b) code -> ('a, 'b) code; minus : ('a, 'b) code -> ('a, 'b) code -> ('a, 'b) code; div : ('a, 'b) code -> ('a, 'b) code -> ('a, 'b) code; smaller_than : (('a, 'b) code -> ('a, 'b) code -> ('a, bool) code) option; normalizerf : ('a, 'b -> 'b) code option; normalizerg : (('a, 'b) code -> ('a, 'b) code) option; } # type ('a, 'b) outputs = Matrix of 'a | MatrixRank of 'a * int | MatrixDet of 'a * 'b | MatrixRankDet of 'a * int * 'b # type outchoice = JustMatrix | Rank | Det | RankDet # type dettrack = TrackNothing | TrackDet # type ge_choices = { fracfree : bool; track : dettrack; outputs : outchoice; } # val orcond_gen : ('a, bool) code -> ('a, bool) code option -> ('a, bool) code = # val seq : ('a, 'b) code -> ('a, 'c) code -> ('a, 'c) code = # val sapply2 : ('a -> 'b -> 'c) option -> 'a -> 'b -> 'c option = # val dapply1 : ('a -> 'a) option -> 'a -> 'a = # val mdapply1 : ('a -> ('b, 'c) code -> ('b, 'c) code) -> 'a option -> ('b, 'c) code -> ('b, 'c) code = # val choose_output : ('a, 'b) domain -> ('a, 'c, 'b) state -> outchoice -> ('a, ('c, 'b) outputs) code = val ge_state_gen : ('a, 'b) domain -> ('a, 'c, 'b) container2d -> (('a, 'c, 'b) state -> ('a, int option) code) -> (('a, 'c, 'b) state -> ('a, int) code -> ('a, int) code -> ('a, 'd) code) -> (('a, 'c, 'b) state -> ('a, 'e) code) -> ge_choices -> ('a, 'c -> ('c, 'b) outputs) code = # val swapr_gen : ('a, 'b) domain -> ('a, 'c, 'd) container2d -> dettrack -> ('a, 'c, 'b) state -> ('a, int) code -> ('a, int) code -> ('a, unit) code = # val findpivot_gen : ('a, 'b) domain -> ('a, 'c, 'b) container2d -> (('a, bool) code -> ('a, bool) code option -> ('a, bool) code) -> ('a, 'c, 'd) state -> ('a, int option) code = # val zerobelow_gen : ('a, 'b) domain -> ('a, 'c, 'b) container2d -> ge_choices -> ('a, 'c, 'b) state -> ('a, unit) code = # val specializer : ('a, 'b) domain -> ('a, 'c, 'b) container2d -> fracfree:bool -> outputs:outchoice -> ('a, 'c -> ('c, 'b) outputs) code = # val dom_float : ('a, float) domain = {zero = .<0.>.; one = .<1.>.; minusone = .<(-1.)>.; plus = ; times = ; minus = ; div = ; smaller_than = Some ; normalizerf = None; normalizerg = None} # val dom_int : ('a, int) domain = {zero = .<0>.; one = .<1>.; minusone = .<(-1)>.; plus = ; times = ; minus = ; div = ; smaller_than = Some ; normalizerf = None; normalizerg = None} # val array_container : ('a, 'b array array, 'b) container2d = {get = ; set = ; dim1 = ; dim2 = ; mapper = ; copy = } # val spec_ge_float : ('a, float array array -> (float array array, float) outputs) code = . let b_2 = (Array.map (fun x_9 -> (Array.copy x_9)) (Array.copy a_1)) and r_3 = (ref 0) and c_4 = (ref 0) and m_5 = (Array.length a_1.(0)) and n_6 = (Array.length a_1) and det_7 = (ref 1.) and detsign_8 = (ref 1.) in while (((! c_4) < m_5) && ((! r_3) < n_6)) do (match let i_16 = (ref (-1)) in for j_17 = (! r_3) to (n_6 - 1) do if (not ((b_2.(j_17)).(! c_4) = 0.)) then if (((! i_16) = (-1)) || ((abs_float (b_2.(j_17)).(! c_4)) < (abs_float (b_2.(! i_16)).(! c_4)))) then (i_16 := j_17) done; if ((! i_16) == (-1)) then (None) else (Some (! i_16)) with | Some (i_10) -> if (i_10 <> (! r_3)) then for j_14 = (! c_4) to (m_5 - 1) do let t_15 = (b_2.(i_10)).(j_14) in (b_2.(i_10)).(j_14) <- (b_2.(! r_3)).(j_14); (b_2.(! r_3)).(j_14) <- t_15; (detsign_8 := ((! detsign_8) *. (-1.))) done; begin for i_11 = ((! r_3) + 1) to (n_6 - 1) do if (not ((b_2.(i_11)).(! c_4) = 0.)) then begin let t_12 = ((b_2.(i_11)).(! c_4) /. (b_2.(! r_3)).(! c_4)) in for j_13 = ((! c_4) + 1) to (m_5 - 1) do (b_2.(i_11)).(j_13) <- ((b_2.(i_11)).(j_13) -. (t_12 *. (b_2.(! r_3)).(j_13))) done; (b_2.(i_11)).(! c_4) <- 0. end done; (det_7 := ((! det_7) *. (b_2.(! r_3)).(! c_4))) end; (r_3 := ((! r_3) + 1)) | None -> (detsign_8 := 0.)); (c_4 := ((! c_4) + 1)) done; (MatrixRankDet (b_2, (! r_3), ((! det_7) *. (! detsign_8))))>. # val spec_ge_int : ('a, int array array -> (int array array, int) outputs) code = . let b_2 = (Array.map (fun x_9 -> (Array.copy x_9)) (Array.copy a_1)) and r_3 = (ref 0) and c_4 = (ref 0) and m_5 = (Array.length a_1.(0)) and n_6 = (Array.length a_1) and det_7 = (ref 1) and detsign_8 = (ref 1) in while (((! c_4) < m_5) && ((! r_3) < n_6)) do (match let i_16 = (ref (-1)) in for j_17 = (! r_3) to (n_6 - 1) do if (not ((b_2.(j_17)).(! c_4) = 0)) then if (((! i_16) = (-1)) || ((abs (b_2.(j_17)).(! c_4)) < (abs (b_2.(! i_16)).(! c_4)))) then (i_16 := j_17) done; if ((! i_16) == (-1)) then (None) else (Some (! i_16)) with | Some (i_10) -> if (i_10 <> (! r_3)) then for j_14 = (! c_4) to (m_5 - 1) do let t_15 = (b_2.(i_10)).(j_14) in (b_2.(i_10)).(j_14) <- (b_2.(! r_3)).(j_14); (b_2.(! r_3)).(j_14) <- t_15; (detsign_8 := ((! detsign_8) * (-1))) done; begin for i_11 = ((! r_3) + 1) to (n_6 - 1) do if (not ((b_2.(i_11)).(! c_4) = 0)) then begin for j_12 = ((! c_4) + 1) to (m_5 - 1) do let t_13 = (((b_2.(i_11)).(j_12) * (b_2.(! r_3)).(! c_4)) - ((b_2.(! r_3)).(j_12) * (b_2.(i_11)).(! r_3))) in (b_2.(i_11)).(j_12) <- (t_13 / (! det_7)) done; (b_2.(i_11)).(! c_4) <- 0 end done; (det_7 := (b_2.(! r_3)).(! c_4)) end; (r_3 := ((! r_3) + 1)) | None -> (detsign_8 := 0)); (c_4 := ((! c_4) + 1)) done; (MatrixRankDet (b_2, (! r_3), ((! det_7) * (! detsign_8))))>. # val ge_float3 : float array array -> (float array array, float) outputs = # val ge_int3 : int array array -> (int array array, int) outputs = #