text
stringlengths
0
601k
type _ t = A : int t | B : ' a t * ' b t -> ( ' a ' * b ) t
let g f = f ( )
let _ = g 3 ; ; [ %% expect { | ^ unit -> ' a Hint : Did you forget to wrap the expression using ` fun ( ) ' ->? } ] ; ; |
let _ = print_int 3 ; print_newline ; print_int 5 ; ; [ %% expect { | ^^^^^^^^^^^^^ but an expression was expected of type unit because it is in the left - hand side of a sequence Hint : Did you forget to provide ` ( ) ' as argument ? } ] ; ; |
let x = read_int in [ %% expect { | ^ but an expression was expected of type int Hint : Did you forget to provide ` ( ) ' as argument ? } ] ; ; |
let g f = let _ = f ( ) in f = 3 ; ; [ %% expect { | ^ unit -> ' a Hint : Did you forget to wrap the expression using ` fun ( ) ' ->? } ] ; ; |
let g f = let _ = f ( ) in 3 = f ; ; [ %% expect { | ^ but an expression was expected of type int Hint : Did you forget to provide ` ( ) ' as argument ? } ] |
let to_array order traversal nodes = let s = Owl_utils . Stack . make ( ) in let f u = Owl_utils . Stack . push s u in M . iter_descendants ~ order ~ traversal f nodes ; Array . map M . attr ( Owl_utils . Stack . to_array s )
let graph ( ) = let n0 , n1 , n2 , n3 , n4 = M . node 0 , M . node 1 , M . node 2 , M . node 3 , M . node 4 in M . connect [ | n0 ] | [ | n1 ; n2 ; n3 ] ; | M . connect [ | n1 ] | [ | n2 ] ; | M . connect [ | n2 ; n3 ] | [ | n4 ] ; | n0 , n1 , n2 , n3 , n4
module To_test = struct let topo0 ( ) = let _ , _ , _ , _ , n4 = graph ( ) in Array . map M . attr ( M . topo_sort [ | n4 ] ) | = [ | 0 ; 1 ; 2 ; 3 ; 4 ] | let topo1 ( ) = let _ , _ , n2 , n3 , _ = graph ( ) in Array . map M . attr ( M . topo_sort [ | n2 ; n3 ] ) | = [ | 0 ; 1 ; 2 ; 3 ] | let dfs0 ( ) = let n0 , n1 , n2 = M . node 0 , M . node 1 , M . node 2 in M . connect [ | n0 ] | [ | n1 ] ; | M . connect [ | n1 ] | [ | n2 ] ; | M . connect [ | n2 ] | [ | n0 ] ; | to_array DFS PostOrder [ | n0 ] | = [ | 2 ; 1 ; 0 ] | let dfs1 ( ) = let n0 = M . node 0 in to_array DFS PreOrder [ | n0 ] | = [ | 0 ] | let bfs0 ( ) = let n0 , n1 , n2 , n3 , n4 = M . node 0 , M . node 1 , M . node 2 , M . node 3 , M . node 4 in M . connect [ | n0 ] | [ | n1 ; n3 ] ; | M . connect [ | n1 ] | [ | n2 ; n3 ] ; | M . connect [ | n2 ] | [ | n3 ] ; | M . connect [ | n2 ; n3 ] | [ | n4 ] ; | to_array BFS PreOrder [ | n0 ] | = [ | 0 ; 1 ; 3 ; 2 ; 4 ] | let num0 ( ) = let _ , _ , n2 , _ , _ = graph ( ) in M . num_ancestor [ | n2 ] | = 3 && M . num_descendant [ | n2 ] | = 2 end
let topo0 ( ) = Alcotest . ( check bool ) " topo0 " true ( To_test . topo0 ( ) )
let topo1 ( ) = Alcotest . ( check bool ) " topo1 " true ( To_test . topo1 ( ) )
let dfs0 ( ) = Alcotest . ( check bool ) " dfs0 " true ( To_test . dfs0 ( ) )
let dfs1 ( ) = Alcotest . ( check bool ) " dfs1 " true ( To_test . dfs1 ( ) )
let bfs0 ( ) = Alcotest . ( check bool ) " bfs0 " true ( To_test . bfs0 ( ) )
let num0 ( ) = Alcotest . ( check bool ) " num0 " true ( To_test . num0 ( ) )
let test_set = [ " topo0 " , ` Slow , topo0 ; " topo1 " , ` Slow , topo1 ; " dfs0 " , ` Slow , dfs0 ; " dfs1 " , ` Slow , dfs1 ; " bfs0 " , ` Slow , bfs0 ; " num0 " , ` Slow , num0 ]
module M = Owl . Lazy . Make ( Owl_algodiff_primal_ops . D )
let tol = 20 . 0 . * epsilon_float
let cmp a b = Arr . ( l1norm ' ( a - b ) ) < tol
let x0 = Arr . zeros [ | 3 ; 4 ] |
let x1 = Arr . ones [ | 3 ; 4 ] |
let x2 = Arr . sequential ~ a : 1 . [ | 3 ; 4 ] |
let x3 = Arr . ( uniform [ | 3 ; 4 ] | - x1 )
let x4 = Arr . ( uniform [ | 4 ; 4 ] | -$ 1 . )
module To_test = struct let fun00 ( ) = let x = M . var_arr " " in let y = M . abs x in M . assign_arr x x3 ; M . eval_arr [ | y ] ; | let a = M . unpack_arr y in let b = Arr . abs x3 in cmp a b let fun01 ( ) = let x = M . var_arr " " in let y = x |> M . sin |> M . cos in M . assign_arr x x3 ; M . eval_arr [ | y ] ; | let a = M . unpack_arr y in let b = x3 |> Arr . sin |> Arr . cos in cmp a b let fun02 ( ) = let x = M . var_arr " " in let y = x |> M . neg |> M . cosh |> M . tanh in M . assign_arr x x3 ; M . eval_arr [ | y ] ; | let a = M . unpack_arr y in let b = x3 |> Arr . cosh |> Arr . tanh in cmp a b let fun03 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . add x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . add x2 x3 in cmp a b let fun04 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . sub x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . sub x2 x3 in cmp a b let fun05 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . mul x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . mul x2 x3 in cmp a b let fun06 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . div x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . div x2 x3 in cmp a b let fun07 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . pow x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . pow x2 x3 in cmp a b let fun08 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . atan2 x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . atan2 x2 x3 in cmp a b let fun09 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . hypot x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . hypot x2 x3 in cmp a b let fun10 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . min2 x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . min2 x2 x3 in cmp a b let fun11 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . max2 x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . max2 x2 x3 in cmp a b let fun12 ( ) = let x = M . var_arr " " in let y = M . var_arr " " in let z = M . max2 x y in M . assign_arr x x2 ; M . assign_arr y x3 ; M . eval_arr [ | z ] ; | let a = M . unpack_arr z in let b = Arr . max2 x2 x3 in cmp a b let fun13 ( ) = let x = M . var_arr " " in let y = M . dot x x in M . assign_arr x x4 ; M . eval_arr [ | y ] ; | let a = M . unpack_arr y in let b = Arr . dot x4 x4 in cmp a b end
let fun00 ( ) = Alcotest . ( check bool ) " fun00 " true ( To_test . fun00 ( ) )
let fun01 ( ) = Alcotest . ( check bool ) " fun01 " true ( To_test . fun01 ( ) )
let fun02 ( ) = Alcotest . ( check bool ) " fun02 " true ( To_test . fun02 ( ) )
let fun03 ( ) = Alcotest . ( check bool ) " fun03 " true ( To_test . fun03 ( ) )
let fun04 ( ) = Alcotest . ( check bool ) " fun04 " true ( To_test . fun04 ( ) )
let fun05 ( ) = Alcotest . ( check bool ) " fun05 " true ( To_test . fun05 ( ) )
let fun06 ( ) = Alcotest . ( check bool ) " fun06 " true ( To_test . fun06 ( ) )
let fun07 ( ) = Alcotest . ( check bool ) " fun07 " true ( To_test . fun07 ( ) )
let fun08 ( ) = Alcotest . ( check bool ) " fun08 " true ( To_test . fun08 ( ) )
let fun09 ( ) = Alcotest . ( check bool ) " fun09 " true ( To_test . fun09 ( ) )
let fun10 ( ) = Alcotest . ( check bool ) " fun10 " true ( To_test . fun10 ( ) )
let fun11 ( ) = Alcotest . ( check bool ) " fun11 " true ( To_test . fun11 ( ) )
let fun12 ( ) = Alcotest . ( check bool ) " fun12 " true ( To_test . fun12 ( ) )
let fun13 ( ) = Alcotest . ( check bool ) " fun13 " true ( To_test . fun13 ( ) )
let test_set = [ " fun00 " , ` Slow , fun00 ; " fun01 " , ` Slow , fun01 ; " fun02 " , ` Slow , fun02 ; " fun03 " , ` Slow , fun03 ; " fun04 " , ` Slow , fun04 ; " fun05 " , ` Slow , fun05 ; " fun06 " , ` Slow , fun06 ; " fun07 " , ` Slow , fun07 ; " fun08 " , ` Slow , fun08 ; " fun09 " , ` Slow , fun09 ; " fun10 " , ` Slow , fun10 ; " fun11 " , ` Slow , fun11 ; " fun12 " , ` Slow , fun12 ; " fun13 " , ` Slow , fun13 ]
let close a b = Maths . ( a - b < F 1e - 5 )
let init_ch = [ | F 0 . ; F 0 . ] |
let rate_adagrad = LR . Adagrad 3 .
let rate_rmsprop = LR . RMSprop ( 3 . , 0 . 9 )
let rate_adam = LR . Adam ( 0 . 001 , 0 . 9 , 0 . 999 )
let test_optimiser rate_fun c g x = let ch = init_ch in let _ = Array . mapi ( fun i ci -> ch . ( i ) <- F ci ) c in let c = ref ch in let x = ref ( F x ) in let g = F g in for i = 1 to 3 do c := LR . update_ch rate_fun g ! c ; let lr = LR . run rate_fun i g ! c in x := Maths . ( ! x - ( lr * g ) ) done ; ! x
module To_test_adagrad = struct let fun00 ( ) = let o = test_optimiser rate_adagrad [ | 0 . 1 ] | 0 . 1 1 . in close o ( F ( - 1 . 6026098728179932 ) ) let fun01 ( ) = let o = test_optimiser rate_adagrad [ | 0 . 1 ] | 0 . 1 2 . in close o ( F ( - 0 . 6026098728179932 ) ) let fun02 ( ) = let o = test_optimiser rate_adagrad [ | 0 . 1 ] | 0 . 01 3 . in close o ( F 2 . 715679168701172 ) let fun03 ( ) = let o = test_optimiser rate_adagrad [ | 0 . 1 ] | 0 . 01 4 . in close o ( F 3 . 715679168701172 ) end
module To_test_rmsprop = struct let fun00 ( ) = let o = test_optimiser rate_rmsprop [ | 1 . ] | 0 . 1 1 . in close o ( F 2 . 91705132e - 04 ) let fun01 ( ) = let o = test_optimiser rate_rmsprop [ | 1 . ] | 0 . 1 2 . in close o ( F 1 . 00029182 ) let fun02 ( ) = let o = test_optimiser rate_rmsprop [ | 1 . ] | 0 . 01 3 . in close o ( F 2 . 89990854 ) let fun03 ( ) = let o = test_optimiser rate_rmsprop [ | 1 . ] | 0 . 01 4 . in close o ( F 3 . 89990854 ) end
module To_test_adam = struct let fun00 ( ) = let o = test_optimiser rate_adam [ | 0 . ; 0 . ] | 0 . 1 1 . in close o ( F 0 . 998 ) let fun01 ( ) = let o = test_optimiser rate_adam [ | 0 . ; 0 . ] | 0 . 1 2 . in close o ( F 1 . 998 ) let fun02 ( ) = let o = test_optimiser rate_adam [ | 0 . ; 0 . ] | 0 . 01 3 . in close o ( F 2 . 999 ) let fun03 ( ) = let o = test_optimiser rate_adam [ | 0 . ; 0 . ] | 0 . 01 4 . in close o ( F 3 . 999 ) end
let fun00 ( ) = Alcotest . ( check bool ) " fun00 " true ( To_test_adagrad . fun00 ( ) )
let fun01 ( ) = Alcotest . ( check bool ) " fun01 " true ( To_test_adagrad . fun01 ( ) )
let fun02 ( ) = Alcotest . ( check bool ) " fun02 " true ( To_test_adagrad . fun02 ( ) )
let fun03 ( ) = Alcotest . ( check bool ) " fun03 " true ( To_test_adagrad . fun03 ( ) )
let fun04 ( ) = Alcotest . ( check bool ) " fun04 " true ( To_test_rmsprop . fun00 ( ) )
let fun05 ( ) = Alcotest . ( check bool ) " fun05 " true ( To_test_rmsprop . fun01 ( ) )
let fun06 ( ) = Alcotest . ( check bool ) " fun06 " true ( To_test_rmsprop . fun02 ( ) )
let fun07 ( ) = Alcotest . ( check bool ) " fun07 " true ( To_test_rmsprop . fun03 ( ) )
let fun08 ( ) = Alcotest . ( check bool ) " fun08 " true ( To_test_adam . fun00 ( ) )
let fun09 ( ) = Alcotest . ( check bool ) " fun09 " true ( To_test_adam . fun01 ( ) )
let fun10 ( ) = Alcotest . ( check bool ) " fun10 " true ( To_test_adam . fun02 ( ) )
let fun11 ( ) = Alcotest . ( check bool ) " fun11 " true ( To_test_adam . fun03 ( ) )
let test_set = [ " fun00 " , ` Slow , fun00 ; " fun01 " , ` Slow , fun01 ; " fun02 " , ` Slow , fun02 ; " fun03 " , ` Slow , fun03 ; " fun04 " , ` Slow , fun04 ; " fun05 " , ` Slow , fun05 ; " fun06 " , ` Slow , fun06 ; " fun07 " , ` Slow , fun07 ; " fun08 " , ` Slow , fun08 ; " fun09 " , ` Slow , fun09 ; " fun10 " , ` Slow , fun10 ; " fun11 " , ` Slow , fun11 ]
let approx_equal a b = let eps = 1e - 6 in Stdlib . ( abs_float ( a . - b ) < eps )
let x0 = Mat . sequential ~ a : 1 . 1 6
let x1 = Mat . sequential ~ a : 1 . 3 3
module To_test = struct let rank ( ) = let x = Mat . sequential 4 4 in M . rank x = 2 let det ( ) = let x = Mat . hadamard 4 in M . det x = 16 . let inv ( ) = let x = Mat . hadamard 4 in M . inv x |> Mat . sum ' = 1 . let vecnorm_01 ( ) = let a = M . vecnorm ~ p : 1 . x0 in approx_equal a 21 . let vecnorm_02 ( ) = let a = M . vecnorm ~ p : 2 . x0 in approx_equal a 9 . 539392014169456 let vecnorm_03 ( ) = let a = M . vecnorm ~ p : 3 . x0 in approx_equal a 7 . 6116626110202441 let vecnorm_04 ( ) = let a = M . vecnorm ~ p : 4 . x0 in approx_equal a 6 . 9062985796189906 let vecnorm_05 ( ) = let a = M . vecnorm ~ p : infinity x0 in approx_equal a 6 . let vecnorm_06 ( ) = let a = M . vecnorm ~ p ( :- 1 . ) x0 in approx_equal a 0 . 40816326530612251 let vecnorm_07 ( ) = let a = M . vecnorm ~ p ( :- 2 . ) x0 in approx_equal a 0 . 81885036774322384 let vecnorm_08 ( ) = let a = M . vecnorm ~ p ( :- 3 . ) x0 in approx_equal a 0 . 94358755060582611 let vecnorm_09 ( ) = let a = M . vecnorm ~ p ( :- 4 . ) x0 in approx_equal a 0 . 98068869669651115 let vecnorm_10 ( ) = let a = M . vecnorm ~ p : neg_infinity x0 in approx_equal a 1 . let norm_01 ( ) = let a = M . norm ~ p : 1 . x1 in approx_equal a 18 . let norm_02 ( ) = let a = M . norm ~ p : 2 . x1 in approx_equal a 16 . 84810335261421 let norm_03 ( ) = let a = M . norm ~ p : infinity x1 in approx_equal a 24 . let norm_04 ( ) = let a = M . norm ~ p ( :- 1 . ) x1 in approx_equal a 12 . let norm_05 ( ) = let a = M . norm ~ p ( :- 2 . ) x1 in approx_equal a 3 . 3347528650314325e - 16 let norm_06 ( ) = let a = M . norm ~ p : neg_infinity x1 in approx_equal a 6 . let is_triu_1 ( ) = let x = Mat . of_array [ | 1 . ; 2 . ; 3 . ; 0 . ; 5 . ; 6 . ; 0 . ; 0 . ; 9 . ] | 3 3 in M . is_triu x = true let is_triu_2 ( ) = let x = Mat . of_array [ | 1 . ; 2 . ; 3 . ; 4 . ; 5 . ; 6 . ; 0 . ; 0 . ; 9 . ] | 3 3 in M . is_triu x = false let is_tril_1 ( ) = let x = Mat . of_array [ | 1 . ; 0 . ; 0 . ; 4 . ; 5 . ; 0 . ; 7 . ; 8 . ; 9 . ] | 3 3 in M . is_tril x = true let is_tril_2 ( ) = let x = Mat . of_array [ | 1 . ; 0 . ; 3 . ; 4 . ; 5 . ; 0 . ; 7 . ; 8 . ; 9 . ] | 3 3 in M . is_tril x = false let is_symmetric_1 ( ) = let x = Mat . of_array [ | 1 . ; 2 . ; 3 . ; 2 . ; 5 . ; 6 . ; 3 . ; 6 . ; 9 . ] | 3 3 in M . is_symmetric x = true let is_symmetric_2 ( ) = let x = Mat . of_array [ | 1 . ; 2 . ; 3 . ; 4 . ; 5 . ; 6 . ; 3 . ; 6 . ; 9 . ] | 3 3 in M . is_symmetric x = false let is_diag_1 ( ) = let x = Mat . of_array [ | 1 . ; 0 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 0 . ; 1 . ] | 3 3 in M . is_diag x = true let is_diag_2 ( ) = let x = Mat . of_array [ | 1 . ; 0 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 1 . ] | 3 3 in M . is_diag x = false let mpow ( ) = let x = Mat . uniform 4 4 in let y = M . mpow x 3 . in let z = Mat . ( dot x ( dot x x ) ) in approx_equal Mat . ( y - z |> sum ' ) 0 . let expm_1 ( ) = let x = Mat . sequential ~ a : 1 . 3 3 in let y = Mat . of_array [ | 1118906 . 6994132 ; 1374815 . 06293582 ; 1630724 . 42645844 ; 2533881 . 04189899 ; 3113415 . 03138058 ; 3692947 . 02086217 ; 3948856 . 38438479 ; 4852012 . 99982535 ; 5755170 . 6152659 ] | 3 3 in let z = M . expm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let expm_2 ( ) = let x = Mat . ( sequential ~ a : 1 . 3 3 /$ 10 . ) in let y = Mat . of_array [ | 1 . 37316027 ; 0 . 53148466 ; 0 . 68980905 ; 1 . 00926035 ; 2 . 2481482 ; 1 . 48703605 ; 1 . 64536043 ; 1 . 96481174 ; 3 . 28426304 ] | 3 3 in let z = M . expm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let expm_3 ( ) = let x = Mat . ( sequential ~ a : 1 . 3 3 /$ 50 . ) in let y = Mat . of_array [ | 1 . 02667783 ; 0 . 04803414 ; 0 . 06939044 ; 0 . 09473789 ; 1 . 11808977 ; 0 . 14144165 ; 0 . 16279795 ; 0 . 1881454 ; 1 . 21349285 ] | 3 3 in let z = M . expm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let expm_4 ( ) = let x = Mat . ( sequential ~ a : 1 . 3 3 /$ 200 . ) in let y = Mat . of_array [ | 1 . 00538495 ; 0 . 01046225 ; 0 . 01553954 ; 0 . 02084758 ; 1 . 02604024 ; 0 . 03123291 ; 0 . 03631021 ; 0 . 04161824 ; 1 . 04692628 ] | 3 3 in let z = M . expm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let sinm ( ) = let x = Mat . sequential ~ a : 1 . 2 2 in let y = Mat . of_array [ | - 0 . 46558149 ; - 0 . 14842446 ; - 0 . 22263669 ; - 0 . 68821818 ] | 2 2 in let z = M . sinm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let cosm ( ) = let x = Mat . sequential ~ a : 1 . 2 2 in let y = Mat . of_array [ | 0 . 85542317 ; - 0 . 11087638 ; - 0 . 16631457 ; 0 . 68910859 ] | 2 2 in let z = M . cosm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let tanm ( ) = let x = Mat . sequential ~ a : 1 . 2 2 in let y = Mat . of_array [ | - 0 . 60507478 ; - 0 . 31274165 ; - 0 . 46911248 ; - 1 . 07418726 ] | 2 2 in let z = M . tanm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let sincosm ( ) = let x = Mat . sequential ~ a : 1 . 2 2 in let s = M . sinm x in let c = M . cosm x in let s ' , c ' = M . sincosm x in approx_equal Mat . ( s - s ' |> sum ' ) 0 . && approx_equal Mat . ( c - c ' |> sum ' ) 0 . let sinhm ( ) = let x = Mat . ( sequential ~ a : 1 . 2 2 /$ 10 . ) in let y = Mat . of_array [ | 0 . 10625636 ; 0 . 20913073 ; 0 . 31369609 ; 0 . 41995246 ] | 2 2 in let z = M . sinhm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let coshm ( ) = let x = Mat . ( sequential ~ a : 1 . 2 2 /$ 10 . ) in let y = Mat . of_array [ | 1 . 03583718 ; 0 . 05122002 ; 0 . 07683003 ; 1 . 11266721 ] | 2 2 in let z = M . coshm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let tanhm ( ) = let x = Mat . ( sequential ~ a : 1 . 2 2 /$ 10 . ) in let y = Mat . of_array [ | 0 . 08894293 ; 0 . 18386007 ; 0 . 2757901 ; 0 . 36473303 ] | 2 2 in let z = M . tanhm x in approx_equal Mat . ( y - z |> sum ' ) 0 . let sinhcoshm ( ) = let x = Mat . ( sequential ~ a : 1 . 2 2 /$ 10 . ) in let s = M . sinhm x in let c = M . coshm x in let s ' , c ' = M . sinhcoshm x in approx_equal Mat . ( s - s ' |> sum ' ) 0 . && approx_equal Mat . ( c - c ' |> sum ' ) 0 . end
let rank ( ) = Alcotest . ( check bool ) " rank " true ( To_test . rank ( ) )
let det ( ) = Alcotest . ( check bool ) " det " true ( To_test . det ( ) )
let inv ( ) = Alcotest . ( check bool ) " inv " true ( To_test . inv ( ) )
let vecnorm_01 ( ) = Alcotest . ( check bool ) " vecnorm_01 " true ( To_test . vecnorm_01 ( ) )
let vecnorm_02 ( ) = Alcotest . ( check bool ) " vecnorm_02 " true ( To_test . vecnorm_02 ( ) )
let vecnorm_03 ( ) = Alcotest . ( check bool ) " vecnorm_03 " true ( To_test . vecnorm_03 ( ) )
let vecnorm_04 ( ) = Alcotest . ( check bool ) " vecnorm_04 " true ( To_test . vecnorm_04 ( ) )
let vecnorm_05 ( ) = Alcotest . ( check bool ) " vecnorm_05 " true ( To_test . vecnorm_05 ( ) )
let vecnorm_06 ( ) = Alcotest . ( check bool ) " vecnorm_06 " true ( To_test . vecnorm_06 ( ) )
let vecnorm_07 ( ) = Alcotest . ( check bool ) " vecnorm_07 " true ( To_test . vecnorm_07 ( ) )
let vecnorm_08 ( ) = Alcotest . ( check bool ) " vecnorm_08 " true ( To_test . vecnorm_08 ( ) )
let vecnorm_09 ( ) = Alcotest . ( check bool ) " vecnorm_09 " true ( To_test . vecnorm_09 ( ) )
let vecnorm_10 ( ) = Alcotest . ( check bool ) " vecnorm_10 " true ( To_test . vecnorm_10 ( ) )
let norm_01 ( ) = Alcotest . ( check bool ) " norm_01 " true ( To_test . norm_01 ( ) )
let norm_02 ( ) = Alcotest . ( check bool ) " norm_02 " true ( To_test . norm_02 ( ) )
let norm_03 ( ) = Alcotest . ( check bool ) " norm_03 " true ( To_test . norm_03 ( ) )
let norm_04 ( ) = Alcotest . ( check bool ) " norm_04 " true ( To_test . norm_04 ( ) )
let norm_05 ( ) = Alcotest . ( check bool ) " norm_05 " true ( To_test . norm_05 ( ) )
let norm_06 ( ) = Alcotest . ( check bool ) " norm_06 " true ( To_test . norm_06 ( ) )
let is_triu_1 ( ) = Alcotest . ( check bool ) " is_triu_1 " true ( To_test . is_triu_1 ( ) )
let is_triu_2 ( ) = Alcotest . ( check bool ) " is_triu_2 " true ( To_test . is_triu_2 ( ) )
let is_tril_1 ( ) = Alcotest . ( check bool ) " is_tril_1 " true ( To_test . is_tril_1 ( ) )
let is_tril_2 ( ) = Alcotest . ( check bool ) " is_tril_2 " true ( To_test . is_tril_2 ( ) )
let is_symmetric_1 ( ) = Alcotest . ( check bool ) " is_symmetric_1 " true ( To_test . is_symmetric_1 ( ) )
let is_symmetric_2 ( ) = Alcotest . ( check bool ) " is_symmetric_2 " true ( To_test . is_symmetric_2 ( ) )
let is_diag_1 ( ) = Alcotest . ( check bool ) " is_diag_1 " true ( To_test . is_diag_1 ( ) )
let is_diag_2 ( ) = Alcotest . ( check bool ) " is_diag_2 " true ( To_test . is_diag_2 ( ) )
let mpow ( ) = Alcotest . ( check bool ) " mpow " true ( To_test . mpow ( ) )
let expm_1 ( ) = Alcotest . ( check bool ) " expm_1 " true ( To_test . expm_1 ( ) )
let expm_2 ( ) = Alcotest . ( check bool ) " expm_2 " true ( To_test . expm_2 ( ) )
let expm_3 ( ) = Alcotest . ( check bool ) " expm_3 " true ( To_test . expm_3 ( ) )
let expm_4 ( ) = Alcotest . ( check bool ) " expm_4 " true ( To_test . expm_4 ( ) )
let sinm ( ) = Alcotest . ( check bool ) " sinm " true ( To_test . sinm ( ) )