text
stringlengths
12
786k
let g8f = Array . map ( M . twisted_prod a8a . ( 3 ) ) a8a ; ;
let g8g = Array . map M . to_full g8f ; ;
let g8h = Array . map ( M . twisted_prod a8a . ( 4 ) ) a8a ; ;
let g8i = Array . map M . to_full g8h ; ;
let g8j = Array . map ( M . twisted_prod a8a . ( 5 ) ) a8a ; ;
let g8k = Array . map M . to_full g8j ; ;
let h0 = Array . map ( Array . map Random . int ) ( Array . make_matrix 3 3 10 ) ; ;
let h0a = M . to_sparse 2 0 . 3 h0 ; ;
let h1a = M . to_sparse 2 1 . h0 ; ;
let h2a = M . to_sparse 2 10 . h0 ; ;
let h0a0 = M . to_full h0a ; ;
let h1a0 = M . to_full h1a ; ;
let h2a0 = M . to_full h2a ; ;
let ( h00b , h01b , h02b ) = ( M . mult h0a h0a , M . mult h0a h1a , M . mult h0a h2a ) ; ;
let ( h10b , h11b , h12b ) = ( M . mult h1a h0a , M . mult h1a h1a , M . mult h1a h2a ) ; ;
let ( h20b , h21b , h22b ) = ( M . mult h2a h0a , M . mult h2a h1a , M . mult h2a h2a ) ; ;
let ( h00c , h01c , h02c ) = ( M . to_full h00b , M . to_full h01b , M . to_full h02b ) ; ;
let ( h10c , h11c , h12c ) = ( M . to_full h10b , M . to_full h11b , M . to_full h12b ) ; ;
let ( h20c , h21c , h22c ) = ( M . to_full h20b , M . to_full h21b , M . to_full h22b ) ; ;
module N = Sparse_matrix . Field ( Data . Zindex ) ( Hash . Z ) ( Data . Rcoeff ) ; ;
let n0 = N . null [ | 3 ; 3 ] | ; ;
let n00 = N . to_full n0 ; ;
let n0a = N . invertibility n0 ; ;
let n0b = N . det n0 ; ;
let id0 = N . Diff_to_scal_matrix ( 1 . , N . S . null [ | 3 ; 3 ] | ) ; ;
let n1 = Array . make_matrix 3 3 1 . ; ;
let n1a = Array . map ( Array . map Random . float ) n1 ; ;
let n1b = N . to_sparse 2 0 . 3 n1a ; ;
let n1b0 = N . to_full n1b ; ;
let n1c = N . invertibility n1b ; ;
let n1d = N . det n1b ; ;
let n1e = N . pivot_downward n1b id0 ; ;
let n1f = Array . map N . to_full n1e ; ;
let n1g = N . pivot_upward n1e . ( 0 ) n1e . ( 1 ) ; ;
let n1h = Array . map N . to_full n1g ; ;
let n1i = N . inv n1b ; ;
let n1j = N . to_full n1i ; ;
let n1k = N . left_quotient n1b n1b ; ;
let n1l = N . right_quotient n1b n1b ; ;
let n1m = N . tune_inv n1b n1i ; ;
let n1n = N . to_full n1m ; ;
let i1 = N . Diff_to_scal_matrix ( 1 . , N . S . null [ | 3 ; 3 ] | ) ; ;
let i2 = N . copy i1 ; ;
let i1a = N . to_full i1 ; ;
let i1b = N . inv i1 ; ;
let i1b0 = N . to_full i1b ; ;
let i1b1 = N . mult i1 i1b ; ;
let i1b2 = N . mult i1b i1 ; ;
let i1c = N . diff_to_id_pivot_downward i1b i1 ; ;
let i1d = N . diff_to_id_invertibility i1b ; ;
let i1i = N . diff_to_id_invertibility i1 ; ;
let i2i = N . diff_to_id_invertibility i2 ; ;
let i1e = N . diff_to_id_inv i1 ; ;
let i1e0 = N . mult i1e i1 ; ;
let i1e1 = N . mult i1 i1e ; ;
let ( =:= ) = V . equal
let ( =/= ) x y = not ( V . equal x y )
let ( + ) = V . add
let ( - ) x y = V . add x ( V . neg y )
let ( |* ) = V . smul
let vec0 = V . of_list [ ( " saucisse " , 42 . 0 ) ; ( " fatigue " , 100 . 0 ) ]
let vec1 = V . of_list [ ( " saucisse " , 43 . 0 ) ; ( " fatigue " , 100 . 0 ) ]
let vec2 = V . of_list [ ( " fatigue " , 100 . 0 ) ; ( " saucisse " , 42 . 0 ) ]
let vec3 = V . of_list [ ( " fatigue " , 99 . 0 ) ; ( " saucisse " , 42 . 0 ) ; ( " fatigue " , 100 . 0 ) ]
let vec4 = V . of_list [ ( " fatigue " , 100 . 0 ) ; ( " saucisse " , 42 . 0 ) ; ( " fatigue " , 99 . 0 ) ]
let vec5 = V . of_list [ ( " saucisse " , 42 . 0 . * 2 . ) ; ( " fatigue " , 100 . 0 . * 2 . ) ]
let vec6 = V . of_list [ ( " saucisse " , 100 . ) ; ( " fatigue " , 42 . 0 ) ]
let tests = [ ( Test . tztest_assert " refl " ` Quick @@ fun ( ) -> vec0 =:= vec0 ) ; ( Test . tztest_assert " neq1 " ` Quick @@ fun ( ) -> vec0 =/= vec1 ) ; ( Test . tztest_assert " of_list1 " ` Quick @@ fun ( ) -> vec0 =:= vec2 ) ; ( Test . tztest_...
let success = ref 0
let failures = ref 0
let ( ) = let report ( ) = if ! failures = 0 then printf " Congratulation , all % d specification tests passed !\ n " ! success else printf " % d test % s passed , % d test % s failed . \ n " ! success ( if ! success > 1 then " s " else " " ) ! failures ( if ! fail...
let test name md_string desired_md = try let md = Omd . of_string md_string in if md = desired_md then ( incr success ; ) else ( incr failures ; printf " % s : FAILURE \ n " name ; printf " input = % S \ nexpected = % S \ n result = % S \ n " md_string ( Omd_backend . sexpr_of_m...
let ( ) = let open Omd in test " Paragraph , simple " " Paragraph1 \ nline2 \ n \ nP2 \ n \ n \ nP3 " [ Paragraph [ Text " Paragraph1 " ; NL ; Text " line2 " ] ; Paragraph [ Text " P2 " ] ; Paragraph [ Text " P3 " ] ] ; test " Paragraph , blank line " ...
type instr = | Data | Command
let boot_sequence = [ | 0xD5 ; 0xF0 ; 0x8D ; 0x14 ; 0xA1 ; 0xC8 ; 0x81 ; 0xCF ; 0xD9 ; 0xF1 ; 0xAF ; 0x20 ; 0x00 ] | cs = LOW ; dc = ( if instr = Data then HIGH else LOW ) ; data = d rst = HIGH ->> LOW ; cpt = 0 ->> ( cpt + 1 ) ; end_boot = ( cpt...
let m ( ) = digital_write Arduboy . rst HIGH ; let program = program_boot ( ) in for i = 0 to 1000 do let ( cs , dc , rst , data , end_boot ) = program ( ) in digital_write Arduboy . cs cs ; digital_write Arduboy . dc dc ; Spi . transfer data done
let ( ) = Arduboy . init ( ) ; Spi . begin_spi ~ ss : SS ~ sck : SCK ~ mosi : MOSI ; m ( )
type abc = [ ` Aye | ` Bee | ` Cee ]
let string_of_abc = function | ` Aye -> " aye " | ` Bee -> " bee " | ` Cee -> " cee "
let abc_of_string = function | " aye " -> Ok ` Aye | " bee " -> Ok ` Bee | " cee " -> Ok ` Cee | _ -> Error " abc_of_string "
module Q = struct open Caqti_type . Std open Caqti_request . Infix let select_null_etc = tup2 ( option int ) ( option int ) -->! tup2 bool ( option int ) @:- " SELECT ? IS NULL , " ? let select_and = tup2 bool bool -->! bool @:- " SELECT ? AND " ? let select_plus_int = tup2 int int...
module Make ( Ground : Testlib . Sig . Ground ) = struct open Ground let repeat n f = let rec loop i = if i = n then return ( ) else f i >>= fun ( ) -> loop ( i + 1 ) in loop 0 let env _ = let open Caqti_query in function | " x1 " -> L " 734 " | " x2 " -> Q " I ' m q...
module Req = struct include Caqti_type . Std include Caqti_request . Infix end
let create_req = Req . ( unit . --> unit @:- " CREATE TABLE tmp ( integer primary key not null ) " )
let bad_insert_req = Req . ( unit -->! unit @:- " INSERT INTO tmp VALUES ( 1 ) , ( 1 ) " )
let test_error ( module C : Caqti_blocking . CONNECTION ) = C . exec create_req ( ) |> Result . iter_error ( Alcotest . failf " % a " Caqti_error . pp ) ; ( match C . find bad_insert_req ( ) with | Ok ( ) -> Alcotest . fail " unexpected ok from bad_insert " | Error (...
let test_cases_on_connection = [ " test_error " , ` Quick , test_error ; ]
let mk_test ( name , pool ) = let pass_conn ( name , speed , f ) = let f ' ( ) = Caqti_blocking . Pool . use ( fun c -> Ok ( f c ) ) pool |> function | Ok ( ) -> ( ) | Error err -> Alcotest . failf " % a " Caqti_error . pp err in ( name , speed , f ' ) ...
let mk_tests { uris ; tweaks_version } = let connect_pool uri = ( match Caqti_blocking . connect_pool uri ~ max_size : 1 ? tweaks_version with | Ok pool -> ( test_name_of_uri uri , pool ) | Error err -> raise ( Caqti_error . Exn err ) ) in let is_sqlite3 uri = Uri . scheme uri = So...
let ( ) = Alcotest_cli . run_with_args_dependency " test_sqlite3 " common_args mk_tests
let sexp_of_int = Core_kernel . Core_kernel_stable . sexp_of_int in let r = Int_conversions . sexp_of_int_style in let old = ! r in r := ` Underscores ; print_s [ % sexp ( 1234 : int ) ] ; [ % expect { | 1_234 } ] ; | r := ` No_underscores ; print_s [ % sexp ( 1234 ...
module Hashtbl = struct let % test_module " Hashtbl . V1 " = ( module Stable_unit_test . Make_unordered_container ( struct module Hashable = Core_kernel_stable . Hashable . V1 . Make ( Int ) module Table = Hashable . Table type t = string Table . t [ @@ deriving sexp , bin_io ] le...
module Map = struct module V1 ( Key : sig type t [ @@ deriving bin_io , sexp ] include Comparator . S with type t := t end ) : sig type ' a t = ( Key . t , ' a , Key . comparator_witness ) Map . t include Stable1 with type ' a t := ' a t end = Map . Stable . V1 . Make ( ...
module Set = struct module type F = functor ( Elt : Stable ) -> sig type t = ( Elt . t , Elt . comparator_witness ) Set . t [ @@ deriving sexp , bin_io , compare ] end module Test ( F : F ) = Stable_unit_test . Make ( struct include F ( Int ) let equal = Set . equal let te...
module Debug ( Stack : S ) : S with type ' a t = ' a Stack . t = struct open Stack type nonrec ' a t = ' a t let invariant = invariant let check_and_return t = invariant ignore t ; t ; ; let debug t f = let result = Result . try_with f in invariant ignore t ; Result . ok_exn result ; ...
module Test ( Stack : S ) : S with type ' a t = ' a Stack . t = struct open Stack type nonrec ' a t = ' a t include Test_container . Test_S1 ( Stack ) let invariant = invariant let create = create let is_empty = is_empty let top_exn = top_exn let pop_exn = pop_exn let pop = pop let top =...
let assert_ok rc = assert ( rc = Rc . OK ) OK
let assert_done rc = assert ( rc = Rc . DONE ) DONE
let column_decltype s i = match column_decltype s i with | None -> " < NONE " > | Some str -> str
let stepbystep s = assert_done ( iter s ~ f ( : function r -> Array . iteri ( fun i c -> printf " % s column [ column % d ] d % s = % s \ n " %! ( column_decltype s i ) i i ( column_name s i ) i ( Data . to_string_coerce c ) c ) c r ) r ) r