text stringlengths 0 601k |
|---|
let iter3 f = iteri3 ( fun _ -> f ) |
let for_all p ( n , incx , x ) = let rec loop count i = if count > S . __expose n then true else if p ( Array1 . unsafe_get x i ) then loop ( count + 1 ) ( i + incx ) else false in loop 1 ( index_hd n incx ) |
let exists p vx = not ( for_all ( fun xi -> not ( p xi ) ) vx ) |
let for_all2 p ( n , incx , x ) ( n ' , incy , y ) = assert ( n = n ' ) ; let rec loop count ix iy = if count > S . __expose n then true else if p ( Array1 . unsafe_get x ix ) ( Array1 . unsafe_get y iy ) then loop ( count + 1 ) ( ix + incx ) ( iy + incy ) else false in loop 1 ( index_hd n incx ) ( index_hd n incy ) |
let exists2 p vx vy = not ( for_all2 ( fun xi yi -> not ( p xi yi ) ) vx vy ) |
let mem ( ? equal ( ) ) == a = exists ( equal a ) |
let subcntvec_dyn n ( ? ofsx = 1 ) ( ( n ' , _ , x ) as vx ) = assert ( S . __expose n ' >= S . __expose n && check_cnt vx ) ; ( n , 1 , Array1 . sub x ofsx ( S . __expose n ) ) |
let subdscvec_dyn nx ( ? ofsx = 1 ) ( ? incx = 1 ) ( ny , incy , y ) = if S . __expose nx = 0 then ( nx , 1 , y ) else begin let last_idx = Slap_size . __expose nx - 1 in let incz = incx * incy in let ofsz = index ny incy ofsx - abs incz * ( if incy > 0 then 0 else last_idx ) in let ( i , j ) = ( ofsz , ofsz + abs incz... |
let subvec_dyn = subdscvec_dyn n ' : n S . t -> ofsx : int -> incx : int -> ( ' num , ' prec , fortran_layout ) Array1 . t -> ofsy : int -> incy : int -> ( ' num , ' prec , fortran_layout ) Array1 . t -> unit = " slap_vec_copy_stub_bc " " slap_vec_copy_stub " |
let copy ? y ( n , incx , x ) = let incy , y = opt_vec_alloc ( Array1 . kind x ) n y in copy_stub ~ n ~ ofsx : 1 ~ incx x ~ ofsy : 1 ~ incy y ; ( n , incy , y ) |
let cons ? y e ( n , incx , x ) = let m = Slap_size . succ n in let incy , y = opt_vec_alloc ( Array1 . kind x ) m y in Array1 . unsafe_set y 1 e ; copy_stub ~ n ~ ofsx : 1 ~ incx x ~ ofsy : 2 ~ incy y ; ( m , incy , y ) |
let hd x = let n = Slap_size . to_int ( dim x ) in assert ( n >= 1 ) ; unsafe_get x 1 |
let hd_dyn x = if Slap_size . to_int ( dim x ) >= 1 then hd x else failwith " Slap . Vec . hd_dyn : an empty vector " |
let last x = let n = Slap_size . to_int ( dim x ) in assert ( n >= 1 ) ; unsafe_get x n |
let last_dyn x = if Slap_size . to_int ( dim x ) >= 1 then last x else failwith " Slap . Vec . last_dyn : an empty vector " |
let internal_tl ~ share n x = let y = subdscvec_dyn n ~ ofsx : 2 x in if share then y else copy y |
let tl ( ? share = false ) ( ( n , _ , _ ) as x ) = assert ( Slap_size . to_int n >= 1 ) ; internal_tl ~ share ( Slap_size . pred n ) x |
let tl_dyn ( ? share = false ) ( ( n , _ , _ ) as x ) = if Slap_size . to_int n >= 1 then internal_tl ~ share ( Slap_size . pred_dyn n ) x else failwith " Slap . Vec . tl_dyn : an empty vector " |
let internal_inits ~ share n x = let y = subdscvec_dyn n ~ ofsx : 1 x in if share then y else copy y |
let inits ( ? share = false ) ( ( n , _ , _ ) as x ) = assert ( Slap_size . to_int n >= 1 ) ; internal_inits ~ share ( Slap_size . pred n ) x |
let inits_dyn ( ? share = false ) ( ( n , _ , _ ) as x ) = if Slap_size . to_int n >= 1 then internal_inits ~ share ( Slap_size . pred_dyn n ) x else failwith " Slap . Vec . inits_dyn : an empty vector " n ' : n S . t -> ofsx : int -> incx : int -> ( ' num , ' prec , fortran_layout ) Array1 . t -> ' num -> unit = " sla... |
let fill ( n , incx , x ) c = fill_stub ~ n ~ ofsx : 1 ~ incx x c |
let append ( m , incx , x ) ( n , incy , y ) = let k = S . add m n in let z = create_array1 ( Array1 . kind x ) k in copy_stub ~ n : m ~ ofsx : 1 ~ incx x ~ ofsy : 1 ~ incy : 1 z ; copy_stub ~ n ~ ofsx : 1 ~ incx : incy y ~ ofsy ( : S . __expose m + 1 ) ~ incy : 1 z ; ( k , 1 , z ) |
let rev vx = copy ( shared_rev vx ) |
let to_array ( n , incx , x ) = let ofsx = index_hd n incx in Array . init ( S . __expose n ) ( fun i -> x . { incx * i + ofsx } ) |
let unsafe_of_array kind n arr = let x = Array1 . of_array kind fortran_layout arr in ( n , 1 , x ) |
let of_array_dyn kind n arr = if S . __expose n <> Array . length arr then invalid_arg " Slap . Vec . of_array_dyn " ; unsafe_of_array kind n arr |
let to_list x = fold_right ( fun a acc -> a :: acc ) x [ ] |
let unsafe_of_list kind n lst = let x = create_array1 kind n in let f i xi = Array1 . unsafe_set x i xi ; i + 1 in ignore ( List . fold_left f 1 lst ) ; ( n , 1 , x ) |
let of_list_dyn kind n lst = if S . __expose n <> List . length lst then invalid_arg " Slap . Vec . of_list_dyn " ; unsafe_of_list kind n lst |
let to_bigarray x = let ba = create_array1 ( kind x ) ( dim x ) in iteri ( fun i a -> Array1 . unsafe_set ba i a ) x ; ba |
let unsafe_of_bigarray ( ? share = false ) n ba = let ba ' = if share then ba else begin let ba ' = create_array1 ( Array1 . kind ba ) n in Array1 . blit ba ba ' ; ba ' end in ( n , 1 , ba ' ) |
let of_bigarray_dyn ( ? share = false ) n ba = if S . __expose n <> Array1 . dim ba then invalid_arg " Slap . Vec . of_bigarray_dyn " ; unsafe_of_bigarray ~ share n ba |
type ( ' num , ' prec , ' cnt_or_dsc ) dyn = | VEC : ( ' n , ' num , ' prec , ' cnt_or_dsc ) t -> ( ' num , ' prec , ' cnt_or_dsc ) dyn |
let of_array_c kind arr = let n = Slap_size . __unexpose ( Array . length arr ) in VEC ( unsafe_of_array kind n arr ) |
let of_list_c kind lst = let n = Slap_size . __unexpose ( List . length lst ) in VEC ( unsafe_of_list kind n lst ) |
let of_bigarray_c ( ? share = false ) ba = let n = Slap_size . __unexpose ( Array1 . dim ba ) in VEC ( unsafe_of_bigarray ~ share n ba ) # endif |
let tcl_command s = ignore ( tcl_eval s ) ; ; |
let dynload args = List . iter Dynlink . loadfile args |
let init ( ) = Dynlink . init ( ) ; Dynlink . allow_unsafe_modules true ; Dynlink . add_interfaces [ ] [ ] ; let s = register_callback Widget . dummy dynload in tcl_command ( sprintf " proc caml :: run { l } { camlcb % s l } " s ) |
let _ = Printexc . print init ( ) |
module type MapKey = sig type t val to_string : t -> string end |
module type S = sig type key_elt type key = key_elt list type partial_key = key_elt list type pattern = int list type ' a t type secondary_t val empty_map : unit -> ' a t val empty_map_w_patterns : pattern list -> ' a t val empty : ' a t -> bool val mem : key -> ' a t -> bool val find : key -> ' a t -> ' a val add : ke... |
module Make ( M : MapKey ) : S with type key_elt = M . t = struct type key_elt = M . t type key = key_elt list type partial_key = key_elt list type pattern = int list module PK = struct type t = partial_key let compare = Stdlib . compare end module Pat = struct type t = pattern let compare = Stdlib . compare end module... |
let yc = ref 1 . 0 |
let print_with_time t v = Printf . printf " . % 15e " t ; Sundials . RealArray . iter ( Printf . printf " \ t % . 15e " ) v ; print_newline ( ) |
let string_of_root x = match x with | Sundials . Roots . Rising -> " rising " | Sundials . Roots . Falling -> " falling " | Sundials . Roots . NoRoot -> " noroot " |
let print_roots vs = Sundials . Roots . iter ( fun x -> Printf . printf " \ t % s " ( string_of_root x ) ) vs ; print_newline ( ) |
let f _ _ yd = yd . { x } <- ! yc ; yd . { t } <- 1 . 0 |
let g _ y gout = gout . { z_x } <- y . { x } ; gout . { z_nx } <- . - y . { x } ; gout . { z_t } <- y . { t } |
let d _ r ys = let root = Sundials . Roots . detected r in if root z_x then yc := - 1 . 0 else if root z_nx then yc := 1 . 0 else ( ) ; if root z_t then begin ys . { t } <- . - p ; print_endline " ** timer " ** end |
let y = Sundials . RealArray . of_array [ | x_i ; t_i ] | |
let y_nvec = Nvector_serial . wrap y |
let s = Cvode . ( init Adams default_tolerances f ~ roots ( : num_roots , g ) 0 . y_nvec ) |
let rootdata = Sundials . Roots . create num_roots |
let _ = Cvode . set_all_root_directions s Sundials . RootDirs . Increasing |
let _ = Printf . printf " --- period =% f \ n " p ; Printf . printf " time \ t \ t t \ n " ; Printf . printf " ------------------------------------\ n " ; print_with_time 0 . 0 y ; try let t = ref 0 . 0 in while true do let ( t ' , result ) = Cvode . solve_normal s ( ! t . + step_inc ) y_nvec in t := t ' ; print_with_t... |
module type DataTypes = sig type t val t_typ : t Ctypes . typ val free_func : ( t ptr -> unit ) option end |
module Make ( Data : DataTypes ) = struct type slist let slist : slist structure typ = structure " SList " type data = Data . t let data = Data . t_typ let free_func = Data . free_func module Comp_func = GCallback . CompareFunc . Make ( struct type t = data let t_typ = data end ) module GDestroy_notify = GCallback . GD... |
module T = Mina_numbers . Nat . Make32 ( ) |
let in_seed_update_range ( ~ constants : Constants . t ) t ( slot : t ) t = let open UInt32 . Infix in let third_epoch = constants . slots_per_epoch / UInt32 . of_int 3 in assert ( UInt32 ( . equal constants . slots_per_epoch ( of_int 3 * third_epoch ) third_epoch ) third_epoch ) third_epoch ; slot < third_epoch * UInt... |
module Checked = struct include T . Checked let in_seed_update_range ( ~ constants : Constants . var ) var ( slot : var ) var = let open Tick in let module Length = Mina_numbers . Length in let constant c = Length . Checked . Unsafe . of_field ( Field . Var . constant ( Field . of_int c ) c ) c in let % bind third_epoc... |
let gen ( constants : Constants . t ) t = let open Quickcheck . Let_syntax in let epoch_length = constants . slots_per_epoch |> UInt32 . to_int in Core . Int . gen_incl 0 epoch_length >>| UInt32 . of_int let constants = Lazy . force Constants . for_unit_tests in let module Length = Mina_numbers . Length in let test x =... |
type error += Invalid_slot of int |
let ( ) = register_error_kind ` Permanent ~ id " : slot . invalid_slot " ~ title " : invalid slot " ~ description " : Invalid slot " ~ pp ( : fun ppf x -> Format . fprintf ppf " invalid slot : % d " x ) Data_encoding . ( obj1 ( req " bad_slot " int31 ) ) ( function Invalid_slot x -> Some x | _ -> None ) ( fun x -> Inva... |
let to_int x = x |
let max_value = ( 1 lsl 16 ) - 1 |
let of_int_do_not_use_except_for_parameters i = i |
let of_int i = if Compare . Int . ( i < 0 || i > max_value ) then error ( Invalid_slot i ) else ok i |
let succ slot = of_int ( slot + 1 ) |
module Map = Map . Make ( Compare . Int ) |
module Set = Set . Make ( Compare . Int ) |
module List = struct type nonrec t = t list module Compressed = struct type elt = { skip : int ; take : int } type encoded = elt list let elt_encoding = Data_encoding . ( conv ( fun { skip ; take } -> ( skip , take ) ) ( fun ( skip , take ) -> { skip ; take } ) ( obj2 ( req " skip " uint16 ) ( req " take " uint16 ) ) )... |
let narrow f = if GobConfig . get_bool " exp . no - narrow " then ( fun a b -> a ) else f |
module SLR3 = functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct include Generic . SolverStats ( S ) ( HM ) module VS = Set . Make ( S . Var ) module P = struct type t = S . Var . t * S . Var . t [ @@ deriving eq , hash ] end module HPM = Hashtbl . Make ( P ) let solve box st vs... |
module type Version = sig val ver : int end |
module Make = functor ( V : Version ) -> functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct let h_find_option h x = try Some ( HM . find h x ) with Not_found -> None let h_find_default h x d = try HM . find h x with Not_found -> d module X = struct let keys = HM . create 1024 le... |
module type MyGenericEqBoxSolver = functor ( S : EqConstrSys ) -> functor ( H : Hashtbl . S with type key = S . v ) -> sig val solve : ( S . v -> S . d -> S . d -> S . d ) -> ( S . v * S . d ) list -> S . v list -> S . d H . t val wpoint : unit H . t val infl : S . v list H . t module X : sig val keys : int H . t end e... |
module PrintInfluence = functor ( Sol : MyGenericEqBoxSolver ) -> functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct module S1 = Sol ( S ) ( HM ) let solve box x y = let ch = Legacy . open_out " test . dot " in let r = S1 . solve box x y in let f k _ = let q = if HM . mem S1 . w... |
module TwoPhased = functor ( V : Version ) -> functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct include Make ( V ) ( S ) ( HM ) let narrow = narrow S . Dom . narrow let solve box is iv = let sd = solve ( fun _ x y -> S . Dom . widen x ( S . Dom . join x y ) ) is iv in let iv ' ... |
module JustWiden = functor ( V : Version ) -> functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct include Make ( V ) ( S ) ( HM ) let solve box is iv = solve ( fun _ x y -> S . Dom . widen x ( S . Dom . join x y ) ) is iv end |
let _ = let module W1 = JustWiden ( struct let ver = 1 end ) in let module W2 = JustWiden ( struct let ver = 2 end ) in let module W3 = JustWiden ( struct let ver = 3 end ) in Selector . add_solver ( " widen1 " , ( module EqIncrSolverFromEqSolver ( W1 ) ) ) ; Selector . add_solver ( " widen2 " , ( module EqIncrSolverFr... |
let _ = let module S1 = Make ( struct let ver = 1 end ) in let module S2 = Make ( struct let ver = 2 end ) in let module S3 = SLR3 in let module S4 = Make ( struct let ver = 4 end ) in Selector . add_solver ( " slr1 " , ( module EqIncrSolverFromEqSolver ( S1 ) ) ) ; Selector . add_solver ( " slr2 " , ( module EqIncrSol... |
module Make = functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct include Generic . SolverStats ( S ) ( HM ) module VS = Set . Make ( S . Var ) module P = struct type t = S . Var . t * S . Var . t [ @@ deriving eq , hash ] end module HPM = Hashtbl . Make ( P ) let narrow = narrow... |
let _ = Selector . add_solver ( " slr3tp " , ( module EqIncrSolverFromEqSolver ( Make ) ) ) ; |
module SLR3term = functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct include Generic . SolverStats ( S ) ( HM ) module VS = Set . Make ( S . Var ) module P = struct type t = S . Var . t * S . Var . t [ @@ deriving eq , hash ] end module HPM = Hashtbl . Make ( P ) let narrow = na... |
let _ = Selector . add_solver ( " slr3t " , ( module EqIncrSolverFromEqSolver ( SLR3term ) ) ) ; |
type ' a entry = | Dir of string * string * My_unix . stats Lazy . t * ' a * ' a entry list Lazy . t | File of string * string * My_unix . stats Lazy . t * ' a | Error of exn | Nothing |
let rec filter predicate = function | Dir ( path , name , st , attr , entries ) -> if predicate path name attr then Dir ( path , name , st , attr , lazy ( List . map ( filter predicate ) !* entries ) ) else Nothing | File ( path , name , _ , attr ) as f -> if predicate path name attr then f else Nothing | Nothing -> No... |
let real_slurp path = let cwd = Sys . getcwd ( ) in let abs x = if Filename . is_implicit x || Filename . is_relative x then cwd / x else x in let visited = Hashtbl . create 1024 in let rec scandir path names = let ( file_acc , dir_acc ) = Array . fold_left begin fun ( ( file_acc , dir_acc ) as acc ) name -> match do_e... |
let split path = let rec aux path = if path = Filename . current_dir_name then [ ] else ( Filename . basename path ) :: aux ( Filename . dirname path ) in List . rev ( aux path ) |
let rec join = function | [ ] -> assert false | [ x ] -> x | x :: xs -> x ( / join xs ) |
let rec add root path entries = match path , entries with | [ ] , _ -> entries | xpath :: xspath , ( Dir ( dpath , dname , dst , dattr , dentries ) as d ) :: entries -> if xpath = dname then Dir ( dpath , dname , dst , dattr , lazy ( add ( root / xpath ) xspath !* dentries ) ) :: entries else d :: add root path entries... |
let slurp_with_find path = let lines = My_unix . run_and_open ( Printf . sprintf " find % s " ( Filename . quote path ) ) begin fun ic -> let acc = ref [ ] in try while true do acc := input_line ic :: ! acc done ; [ ] with End_of_file -> ! acc end in let res = List . fold_right begin fun line acc -> add path ( split li... |
let slurp x = if !* My_unix . is_degraded then slurp_with_find x else real_slurp x |
let rec print print_attr f entry = match entry with | Dir ( path , name , _ , attr , entries ) -> Format . fprintf f " [ @< 2 > Dir ( % S , @ % S , @ _ , @ % a , @ % a ) ] " @ path name print_attr attr ( List . print ( print print_attr ) ) !* entries | File ( path , name , _ , attr ) -> Format . fprintf f " [ @< 2 > Fi... |
let rec fold f entry acc = match entry with | Dir ( path , name , _ , attr , contents ) -> f path name attr ( List . fold_right ( fold f ) !* contents acc ) | File ( path , name , _ , attr ) -> f path name attr acc | Nothing | Error _ -> acc |
let map f entry = let rec self entry = match entry with | Dir ( path , name , st , attr , contents ) -> Dir ( path , name , st , f path name attr , lazy ( List . map self !* contents ) ) | File ( path , name , st , attr ) -> File ( path , name , st , f path name attr ) | Nothing -> Nothing | Error e -> Error e in self ... |
let rec force = function | Dir ( _ , _ , st , _ , contents ) -> let _ = !* st in List . iter force !* contents | File ( _ , _ , st , _ ) -> ignore !* st | Nothing | Error _ -> ( ) |
type loc = int * int |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.