package_name
stringlengths 2
45
| version
stringclasses 292
values | license
stringclasses 49
values | homepage
stringclasses 344
values | dev_repo
stringclasses 342
values | file_type
stringclasses 6
values | file_path
stringlengths 6
151
| file_content
stringlengths 0
9.28M
|
|---|---|---|---|---|---|---|---|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
opam
|
base64-3.5.2/base64.opam
|
version: "3.5.2"
opam-version: "2.0"
maintainer: "[email protected]"
authors: [ "Thomas Gazagnaire"
"Anil Madhavapeddy" "Calascibetta Romain"
"Peter Zotov" ]
license: "ISC"
homepage: "https://github.com/mirage/ocaml-base64"
doc: "https://mirage.github.io/ocaml-base64/"
bug-reports: "https://github.com/mirage/ocaml-base64/issues"
dev-repo: "git+https://github.com/mirage/ocaml-base64.git"
synopsis: "Base64 encoding for OCaml"
description: """
Base64 is a group of similar binary-to-text encoding schemes that represent
binary data in an ASCII string format by translating it into a radix-64
representation. It is specified in RFC 4648.
"""
depends: [
"ocaml" {>= "4.07.0"}
"dune" {>= "2.3"}
"fmt" {with-test & >= "0.8.7"}
"bos" {with-test}
"rresult" {with-test}
"alcotest" {with-test}
]
build: [
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
]
x-maintenance-intent: [ "(latest)" ]
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
ml
|
base64-3.5.2/bench/benchmarks.ml
|
module Old_version = struct
let default_alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
let uri_safe_alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
let padding = '='
let of_char ?(alphabet = default_alphabet) x =
if x = padding then 0 else String.index alphabet x
let to_char ?(alphabet = default_alphabet) x = alphabet.[x]
let decode ?alphabet input =
let length = String.length input in
let input =
if length mod 4 = 0
then input
else input ^ String.make (4 - (length mod 4)) padding in
let length = String.length input in
let words = length / 4 in
let padding =
match length with
| 0 -> 0
| _ when input.[length - 2] = padding -> 2
| _ when input.[length - 1] = padding -> 1
| _ -> 0 in
let output = Bytes.make ((words * 3) - padding) '\000' in
for i = 0 to words - 1 do
let a = of_char ?alphabet input.[(4 * i) + 0]
and b = of_char ?alphabet input.[(4 * i) + 1]
and c = of_char ?alphabet input.[(4 * i) + 2]
and d = of_char ?alphabet input.[(4 * i) + 3] in
let n = (a lsl 18) lor (b lsl 12) lor (c lsl 6) lor d in
let x = (n lsr 16) land 255
and y = (n lsr 8) land 255
and z = n land 255 in
Bytes.set output ((3 * i) + 0) (char_of_int x) ;
if i <> words - 1 || padding < 2
then Bytes.set output ((3 * i) + 1) (char_of_int y) ;
if i <> words - 1 || padding < 1
then Bytes.set output ((3 * i) + 2) (char_of_int z)
done ;
Bytes.unsafe_to_string output
let decode_opt ?alphabet input =
try Some (decode ?alphabet input) with Not_found -> None
let encode ?(pad = true) ?alphabet input =
let length = String.length input in
let words = (length + 2) / 3 (* rounded up *) in
let padding_len = if length mod 3 = 0 then 0 else 3 - (length mod 3) in
let output = Bytes.make (words * 4) '\000' in
let get i = if i >= length then 0 else int_of_char input.[i] in
for i = 0 to words - 1 do
let x = get ((3 * i) + 0)
and y = get ((3 * i) + 1)
and z = get ((3 * i) + 2) in
let n = (x lsl 16) lor (y lsl 8) lor z in
let a = (n lsr 18) land 63
and b = (n lsr 12) land 63
and c = (n lsr 6) land 63
and d = n land 63 in
Bytes.set output ((4 * i) + 0) (to_char ?alphabet a) ;
Bytes.set output ((4 * i) + 1) (to_char ?alphabet b) ;
Bytes.set output ((4 * i) + 2) (to_char ?alphabet c) ;
Bytes.set output ((4 * i) + 3) (to_char ?alphabet d)
done ;
for i = 1 to padding_len do
Bytes.set output (Bytes.length output - i) padding
done ;
if pad
then Bytes.unsafe_to_string output
else Bytes.sub_string output 0 (Bytes.length output - padding_len)
end
let random len =
let ic = open_in "/dev/urandom" in
let rs = Bytes.create len in
really_input ic rs 0 len ;
close_in ic ;
Bytes.unsafe_to_string rs
open Core
open Core_bench
let b64_encode_and_decode len =
let input = random len in
Staged.stage @@ fun () ->
let encoded = Base64.encode_exn input in
let _decoded = Base64.decode_exn encoded in
()
let old_encode_and_decode len =
let input = random len in
Staged.stage @@ fun () ->
let encoded = Old_version.encode input in
let _decoded = Old_version.decode encoded in
()
let args = [ 0; 10; 50; 100; 500; 1000; 2500; 5000 ]
let test_b64 =
Bench.Test.create_indexed ~name:"Base64" ~args b64_encode_and_decode
let test_old = Bench.Test.create_indexed ~name:"Old" ~args old_encode_and_decode
let command = Bench.make_command [ test_b64; test_old ]
let () = Command.run command
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
dune
|
base64-3.5.2/bench/dune
|
(executable
(name benchmarks)
(enabled_if
(= %{profile} benchmark))
(libraries base64 core_bench))
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
ml
|
base64-3.5.2/config/config.ml
|
let parse s = Scanf.sscanf s "%d.%d" (fun major minor -> (major, minor))
let () =
let version = parse Sys.ocaml_version in
if version >= (4, 7)
then print_string "unsafe_stable.ml"
else print_string "unsafe_pre407.ml"
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
dune
|
base64-3.5.2/config/dune
|
(executable
(name config))
(rule
(with-stdout-to
which-unsafe-file
(run ./config.exe)))
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
dune
|
base64-3.5.2/fuzz/dune
|
(executable
(name fuzz_rfc2045)
(enabled_if
(= %{profile} fuzz))
(modules fuzz_rfc2045)
(libraries astring crowbar fmt base64.rfc2045))
(executable
(name fuzz_rfc4648)
(enabled_if
(= %{profile} fuzz))
(modules fuzz_rfc4648)
(libraries astring crowbar fmt base64))
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
ml
|
base64-3.5.2/fuzz/fuzz_rfc2045.ml
|
open Crowbar
exception Encode_error of string
exception Decode_error of string
(** Pretty printers *)
let register_printer () =
Printexc.register_printer (function
| Encode_error err -> Some (Fmt.str "(Encoding error: %s)" err)
| Decode_error err -> Some (Fmt.str "(Decoding error: %s)" err)
| _ -> None)
let pp_chr =
let escaped = function ' ' .. '~' as c -> String.make 1 c | _ -> "." in
Fmt.using escaped Fmt.string
let pp_scalar :
type buffer.
get:(buffer -> int -> char) -> length:(buffer -> int) -> buffer Fmt.t =
fun ~get ~length ppf b ->
let l = length b in
for i = 0 to l / 16 do
Fmt.pf ppf "%08x: " (i * 16) ;
let j = ref 0 in
while !j < 16 do
if (i * 16) + !j < l
then Fmt.pf ppf "%02x" (Char.code @@ get b ((i * 16) + !j))
else Fmt.pf ppf " " ;
if !j mod 2 <> 0 then Fmt.pf ppf " " ;
incr j
done ;
Fmt.pf ppf " " ;
j := 0 ;
while !j < 16 do
if (i * 16) + !j < l
then Fmt.pf ppf "%a" pp_chr (get b ((i * 16) + !j))
else Fmt.pf ppf " " ;
incr j
done ;
Fmt.pf ppf "@\n"
done
let pp = pp_scalar ~get:String.get ~length:String.length
(** Encoding and decoding *)
let check_encode str =
let subs = Astring.String.cuts ~sep:"\r\n" str in
let check str =
if String.length str > 78
then raise (Encode_error "too long string returned") in
List.iter check subs ;
str
let encode input =
let buf = Buffer.create 80 in
let encoder = Base64_rfc2045.encoder (`Buffer buf) in
String.iter
(fun c ->
let ret = Base64_rfc2045.encode encoder (`Char c) in
match ret with `Ok -> () | _ -> assert false)
(* XXX(dinosaure): [`Partial] can never occur. *)
input ;
let encode = Base64_rfc2045.encode encoder `End in
match encode with
| `Ok -> Buffer.contents buf |> check_encode
| _ -> (* XXX(dinosaure): [`Partial] can never occur. *) assert false
let decode input =
let decoder = Base64_rfc2045.decoder (`String input) in
let rec go acc =
if Base64_rfc2045.decoder_dangerous decoder
then raise (Decode_error "Dangerous input") ;
match Base64_rfc2045.decode decoder with
| `End -> List.rev acc
| `Flush output -> go (output :: acc)
| `Malformed _ -> raise (Decode_error "Malformed")
| `Wrong_padding -> raise (Decode_error "Wrong padding")
| _ -> (* XXX(dinosaure): [`Await] can never occur. *) assert false in
String.concat "" (go [])
(** String generators *)
let bytes_fixed_range : string gen = dynamic_bind (range 78) bytes_fixed
let char_from_alpha alpha : string gen =
map [ range (String.length alpha) ] (fun i -> alpha.[i] |> String.make 1)
let string_from_alpha n =
let acc = const "" in
let alpha = Base64_rfc2045.default_alphabet in
let rec add_char_from_alpha alpha acc = function
| 0 -> acc
| n ->
add_char_from_alpha alpha
(concat_gen_list (const "") [ acc; char_from_alpha alpha ])
(n - 1) in
add_char_from_alpha alpha acc n
let random_string_from_alpha n = dynamic_bind (range n) string_from_alpha
let bytes_fixed_range_from_alpha : string gen =
dynamic_bind (range 78) bytes_fixed
let set_canonic str =
let l = String.length str in
let to_drop = l * 6 mod 8 in
if to_drop = 6
(* XXX(clecat): Case when we need to drop 6 bits which means a whole letter *)
then String.sub str 0 (l - 1)
else if to_drop <> 0
(* XXX(clecat): Case when we need to drop 2 or 4 bits: we apply a mask droping the bits *)
then (
let buf = Bytes.of_string str in
let value =
String.index Base64_rfc2045.default_alphabet (Bytes.get buf (l - 1)) in
let canonic =
Base64_rfc2045.default_alphabet.[value land lnot ((1 lsl to_drop) - 1)]
in
Bytes.set buf (l - 1) canonic ;
Bytes.unsafe_to_string buf)
else str
let add_padding str =
let str = set_canonic str in
let str = str ^ "===" in
String.sub str 0 (String.length str / 4 * 4)
(** Tests *)
let e2d inputs =
let input = String.concat "\r\n" inputs in
let encode = encode input in
let decode = decode encode in
check_eq ~pp ~cmp:String.compare ~eq:String.equal input decode
let d2e inputs end_input =
let end_input = add_padding end_input in
let inputs = inputs @ [ end_input ] in
let input =
List.fold_left
(fun acc s -> if String.length s <> 0 then acc ^ "\r\n" ^ s else acc)
(List.hd inputs) (List.tl inputs) in
let decode = decode input in
let encode = encode decode in
check_eq ~pp ~cmp:String.compare ~eq:String.equal input encode
let () =
register_printer () ;
add_test ~name:"rfc2045: encode -> decode" [ list bytes_fixed_range ] e2d ;
add_test ~name:"rfc2045: decode -> encode"
[ list (string_from_alpha 76); random_string_from_alpha 76 ]
d2e
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
ml
|
base64-3.5.2/fuzz/fuzz_rfc4648.ml
|
open Crowbar
let pp_chr =
let escaped = function ' ' .. '~' as c -> String.make 1 c | _ -> "." in
Fmt.using escaped Fmt.string
let pp_scalar :
type buffer.
get:(buffer -> int -> char) -> length:(buffer -> int) -> buffer Fmt.t =
fun ~get ~length ppf b ->
let l = length b in
for i = 0 to l / 16 do
Fmt.pf ppf "%08x: " (i * 16) ;
let j = ref 0 in
while !j < 16 do
if (i * 16) + !j < l
then Fmt.pf ppf "%02x" (Char.code @@ get b ((i * 16) + !j))
else Fmt.pf ppf " " ;
if !j mod 2 <> 0 then Fmt.pf ppf " " ;
incr j
done ;
Fmt.pf ppf " " ;
j := 0 ;
while !j < 16 do
if (i * 16) + !j < l
then Fmt.pf ppf "%a" pp_chr (get b ((i * 16) + !j))
else Fmt.pf ppf " " ;
incr j
done ;
Fmt.pf ppf "@\n"
done
let pp = pp_scalar ~get:String.get ~length:String.length
let ( <.> ) f g x = f (g x)
let char_from_alphabet alphabet : string gen =
map [ range 64 ] (String.make 1 <.> String.get (Base64.alphabet alphabet))
let random_string_from_alphabet alphabet len : string gen =
let rec add_char_from_alphabet acc = function
| 0 -> acc
| n ->
add_char_from_alphabet
(concat_gen_list (const "") [ acc; char_from_alphabet alphabet ])
(n - 1) in
add_char_from_alphabet (const "") len
let random_string_from_alphabet ~max alphabet =
dynamic_bind (range max) @@ fun real_len ->
dynamic_bind (random_string_from_alphabet alphabet real_len) @@ fun input ->
if real_len <= 1
then const (input, 0, real_len)
else
dynamic_bind (range (real_len / 2)) @@ fun off ->
map [ range (real_len - off) ] (fun len -> (input, off, len))
let encode_and_decode (input, off, len) =
match Base64.encode ~pad:true ~off ~len input with
| Error (`Msg err) -> fail err
| Ok result ->
match Base64.decode ~pad:true result with
| Error (`Msg err) -> fail err
| Ok result ->
check_eq ~pp ~cmp:String.compare ~eq:String.equal result
(String.sub input off len)
let decode_and_encode (input, off, len) =
match Base64.decode ~pad:true ~off ~len input with
| Error (`Msg err) -> fail err
| Ok result ->
match Base64.encode ~pad:true result with
| Error (`Msg err) -> fail err
| Ok result ->
check_eq ~pp:Fmt.string ~cmp:String.compare ~eq:String.equal result
(String.sub input off len)
let ( // ) x y =
if y < 1 then raise Division_by_zero ;
if x > 0 then 1 + ((x - 1) / y) else 0
[@@inline]
let canonic alphabet =
let dmap = Array.make 256 (-1) in
String.iteri (fun i x -> dmap.(Char.code x) <- i) (Base64.alphabet alphabet) ;
fun (input, off, len) ->
let real_len = String.length input in
let input_len = len in
let normalized_len = input_len // 4 * 4 in
if normalized_len = input_len
then (input, off, input_len)
else if normalized_len - input_len = 3
then (input, off, input_len - 1)
else
let remainder_len = normalized_len - input_len in
let last = input.[off + input_len - 1] in
let output = Bytes.make (max real_len (off + normalized_len)) '=' in
Bytes.blit_string input 0 output 0 (off + input_len) ;
if off + normalized_len < real_len
then
Bytes.blit_string input (off + normalized_len) output
(off + normalized_len)
(real_len - (off + normalized_len)) ;
let mask =
match remainder_len with 1 -> 0x3c | 2 -> 0x30 | _ -> assert false in
let decoded = dmap.(Char.code last) in
let canonic = decoded land mask in
let encoded = (Base64.alphabet alphabet).[canonic] in
Bytes.set output (off + input_len - 1) encoded ;
(Bytes.unsafe_to_string output, off, normalized_len)
let isomorphism0 (input, off, len) =
(* x0 = decode(input) && x1 = decode(encode(x0)) && x0 = x1 *)
match Base64.decode ~pad:false ~off ~len input with
| Error (`Msg err) -> fail err
| Ok result0 -> (
let result1 = Base64.encode_exn result0 in
match Base64.decode ~pad:true result1 with
| Error (`Msg err) -> fail err
| Ok result2 ->
check_eq ~pp ~cmp:String.compare ~eq:String.equal result0 result2)
let isomorphism1 (input, off, len) =
let result0 = Base64.encode_exn ~off ~len input in
match Base64.decode ~pad:true result0 with
| Error (`Msg err) -> fail err
| Ok result1 ->
let result2 = Base64.encode_exn result1 in
check_eq ~pp:Fmt.string ~cmp:String.compare ~eq:String.equal result0
result2
let bytes_and_range : (string * int * int) gen =
dynamic_bind bytes @@ fun t ->
let real_length = String.length t in
if real_length <= 1
then const (t, 0, real_length)
else
dynamic_bind (range (real_length / 2)) @@ fun off ->
map [ range (real_length - off) ] (fun len -> (t, off, len))
let range_of_max max : (int * int) gen =
dynamic_bind (range (max / 2)) @@ fun off ->
map [ range (max - off) ] (fun len -> (off, len))
let failf fmt = Fmt.kstr fail fmt
let no_exception pad off len input =
try
let _ =
Base64.decode ?pad ?off ?len ~alphabet:Base64.default_alphabet input in
()
with exn -> failf "decode fails with: %s." (Printexc.to_string exn)
let () =
add_test ~name:"rfc4648: encode -> decode" [ bytes_and_range ]
encode_and_decode ;
add_test ~name:"rfc4648: decode -> encode"
[ random_string_from_alphabet ~max:1000 Base64.default_alphabet ]
(decode_and_encode <.> canonic Base64.default_alphabet) ;
add_test ~name:"rfc4648: x = decode(encode(x))"
[ random_string_from_alphabet ~max:1000 Base64.default_alphabet ]
isomorphism0 ;
add_test ~name:"rfc4648: x = encode(decode(x))" [ bytes_and_range ]
isomorphism1 ;
add_test ~name:"rfc4648: no exception leak"
[ option bool; option int; option int; bytes ]
no_exception
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
ml
|
base64-3.5.2/src/base64.ml
|
(*
* Copyright (c) 2006-2009 Citrix Systems Inc.
* Copyright (c) 2010 Thomas Gazagnaire <[email protected]>
* Copyright (c) 2014-2016 Anil Madhavapeddy <[email protected]>
* Copyright (c) 2016 David Kaloper Meršinjak
* Copyright (c) 2018 Romain Calascibetta <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)
type alphabet = { emap : int array; dmap : int array }
type sub = string * int * int
let ( // ) x y =
if y < 1 then raise Division_by_zero ;
if x > 0 then 1 + ((x - 1) / y) else 0
[@@inline]
let unsafe_get_uint8 t off = Char.code (String.unsafe_get t off)
let unsafe_set_uint8 t off v = Bytes.unsafe_set t off (Char.chr v)
external unsafe_set_uint16 : bytes -> int -> int -> unit = "%caml_bytes_set16u"
[@@noalloc]
external unsafe_get_uint16 : string -> int -> int = "%caml_string_get16u"
[@@noalloc]
external swap16 : int -> int = "%bswap16" [@@noalloc]
let none = -1
(* We mostly want to have an optional array for [dmap] (e.g. [int option
array]). So we consider the [none] value as [-1]. *)
let make_alphabet alphabet =
if String.length alphabet <> 64
then invalid_arg "Length of alphabet must be 64" ;
if String.contains alphabet '='
then invalid_arg "Alphabet can not contain padding character" ;
let emap =
Array.init (String.length alphabet) (fun i -> Char.code alphabet.[i]) in
let dmap = Array.make 256 none in
String.iteri (fun idx chr -> dmap.(Char.code chr) <- idx) alphabet ;
{ emap; dmap }
let length_alphabet { emap; _ } = Array.length emap
let alphabet { emap; _ } =
String.init (Array.length emap) (fun i -> Char.chr emap.(i))
let default_alphabet =
make_alphabet
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
let uri_safe_alphabet =
make_alphabet
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
let unsafe_set_be_uint16 =
if Sys.big_endian
then fun t off v -> unsafe_set_uint16 t off v
else fun t off v -> unsafe_set_uint16 t off (swap16 v)
(* We make this exception to ensure to keep a control about which exception we
can raise and avoid appearance of unknown exceptions like an ex-nihilo
magic rabbit (or magic money?). *)
exception Out_of_bounds
exception Too_much_input
let get_uint8 t off =
if off < 0 || off >= String.length t then raise Out_of_bounds ;
unsafe_get_uint8 t off
let padding = int_of_char '='
let error_msgf fmt = Format.ksprintf (fun err -> Error (`Msg err)) fmt
let encode_sub pad { emap; _ } ?(off = 0) ?len input =
let len =
match len with Some len -> len | None -> String.length input - off in
if len < 0 || off < 0 || off > String.length input - len
then error_msgf "Invalid bounds"
else
let n = len in
let n' = n // 3 * 4 in
let res = Bytes.create n' in
let emap i = Array.unsafe_get emap i in
let emit b1 b2 b3 i =
unsafe_set_be_uint16 res i
((emap ((b1 lsr 2) land 0x3f) lsl 8)
lor emap ((b1 lsl 4) lor (b2 lsr 4) land 0x3f)) ;
unsafe_set_be_uint16 res (i + 2)
((emap ((b2 lsl 2) lor (b3 lsr 6) land 0x3f) lsl 8)
lor emap (b3 land 0x3f)) in
let rec enc j i =
if i = n
then ()
else if i = n - 1
then emit (unsafe_get_uint8 input (off + i)) 0 0 j
else if i = n - 2
then
emit
(unsafe_get_uint8 input (off + i))
(unsafe_get_uint8 input (off + i + 1))
0 j
else (
emit
(unsafe_get_uint8 input (off + i))
(unsafe_get_uint8 input (off + i + 1))
(unsafe_get_uint8 input (off + i + 2))
j ;
enc (j + 4) (i + 3)) in
let rec unsafe_fix = function
| 0 -> ()
| i ->
unsafe_set_uint8 res (n' - i) padding ;
unsafe_fix (i - 1) in
enc 0 0 ;
let pad_to_write = (3 - (n mod 3)) mod 3 in
if pad
then (
unsafe_fix pad_to_write ;
Ok (Bytes.unsafe_to_string res, 0, n'))
else Ok (Bytes.unsafe_to_string res, 0, n' - pad_to_write)
(* [pad = false], we don't want to write them. *)
let encode ?(pad = true) ?(alphabet = default_alphabet) ?off ?len input =
match encode_sub pad alphabet ?off ?len input with
| Ok (res, off, len) -> Ok (String.sub res off len)
| Error _ as err -> err
let encode_string ?pad ?alphabet input =
match encode ?pad ?alphabet input with
| Ok res -> res
| Error _ -> assert false
let encode_sub ?(pad = true) ?(alphabet = default_alphabet) ?off ?len input =
encode_sub pad alphabet ?off ?len input
let encode_exn ?pad ?alphabet ?off ?len input =
match encode ?pad ?alphabet ?off ?len input with
| Ok v -> v
| Error (`Msg err) -> invalid_arg err
let decode_sub ?(pad = true) { dmap; _ } ?(off = 0) ?len input =
let len =
match len with Some len -> len | None -> String.length input - off in
if len < 0 || off < 0 || off > String.length input - len
then error_msgf "Invalid bounds"
else
let n = len // 4 * 4 in
let n' = n // 4 * 3 in
let res = Bytes.create n' in
let invalid_pad_overflow = pad in
let get_uint8_or_padding =
if pad
then (fun t i ->
if i >= len then raise Out_of_bounds ;
get_uint8 t (off + i))
else
fun t i ->
try if i < len then get_uint8 t (off + i) else padding
with Out_of_bounds -> padding in
let set_be_uint16 t off v =
(* can not write 2 bytes. *)
if off < 0 || off + 1 > Bytes.length t
then () (* can not write 1 byte but can write 1 byte *)
else if off < 0 || off + 2 > Bytes.length t
then unsafe_set_uint8 t off (v lsr 8) (* can write 2 bytes. *)
else unsafe_set_be_uint16 t off v in
let set_uint8 t off v =
if off < 0 || off >= Bytes.length t then () else unsafe_set_uint8 t off v
in
let emit a b c d j =
let x = (a lsl 18) lor (b lsl 12) lor (c lsl 6) lor d in
set_be_uint16 res j (x lsr 8) ;
set_uint8 res (j + 2) (x land 0xff) in
let dmap i =
let x = Array.unsafe_get dmap i in
if x = none then raise Not_found ;
x in
let only_padding pad idx =
(* because we round length of [res] to the upper bound of how many
characters we should have from [input], we got at this stage only padding
characters and we need to delete them, so for each [====], we delete 3
bytes. *)
let pad = ref (pad + 3) in
let idx = ref idx in
while !idx + 4 < len do
(* use [unsafe_get_uint16] instead [unsafe_get_uint32] to avoid allocation
of [int32]. Of course, [3d3d3d3d] is [====]. *)
if unsafe_get_uint16 input (off + !idx) <> 0x3d3d
|| unsafe_get_uint16 input (off + !idx + 2) <> 0x3d3d
then raise Not_found ;
(* We got something bad, should be a valid character according to
[alphabet] but outside the scope. *)
idx := !idx + 4 ;
pad := !pad + 3
done ;
while !idx < len do
if unsafe_get_uint8 input (off + !idx) <> padding then raise Not_found ;
incr idx
done ;
!pad in
let rec dec j i =
if i = n
then 0
else
let d, pad =
let x = get_uint8_or_padding input (i + 3) in
try (dmap x, 0) with Not_found when x = padding -> (0, 1) in
(* [Not_found] iff [x ∉ alphabet and x <> '='] can leak. *)
let c, pad =
let x = get_uint8_or_padding input (i + 2) in
try (dmap x, pad)
with Not_found when x = padding && pad = 1 -> (0, 2) in
(* [Not_found] iff [x ∉ alphabet and x <> '='] can leak. *)
let b, pad =
let x = get_uint8_or_padding input (i + 1) in
try (dmap x, pad)
with Not_found when x = padding && pad = 2 -> (0, 3) in
(* [Not_found] iff [x ∉ alphabet and x <> '='] can leak. *)
let a, pad =
let x = get_uint8_or_padding input i in
try (dmap x, pad)
with Not_found when x = padding && pad = 3 -> (0, 4) in
(* [Not_found] iff [x ∉ alphabet and x <> '='] can leak. *)
emit a b c d j ;
if i + 4 = n (* end of input in anyway *)
then
match pad with
| 0 -> 0
| 4 ->
(* assert (invalid_pad_overflow = false) ; *)
3
(* [get_uint8] lies and if we get [4], that mean we got one or more (at
most 4) padding character. In this situation, because we round length
of [res] (see [n // 4]), we need to delete 3 bytes. *)
| pad -> pad
else
match pad with
| 0 -> dec (j + 3) (i + 4)
| 4 ->
(* assert (invalid_pad_overflow = false) ; *)
only_padding 3 (i + 4)
(* Same situation than above but we should get only more padding
characters then. *)
| pad ->
if invalid_pad_overflow = true then raise Too_much_input ;
only_padding pad (i + 4) in
match dec 0 0 with
| 0 -> Ok (Bytes.unsafe_to_string res, 0, n')
| pad -> Ok (Bytes.unsafe_to_string res, 0, n' - pad)
| exception Out_of_bounds ->
error_msgf "Wrong padding"
(* appear only when [pad = true] and when length of input is not a multiple of 4. *)
| exception Not_found ->
(* appear when one character of [input] ∉ [alphabet] and this character <> '=' *)
error_msgf "Malformed input"
| exception Too_much_input -> error_msgf "Too much input"
let decode ?pad ?(alphabet = default_alphabet) ?off ?len input =
match decode_sub ?pad alphabet ?off ?len input with
| Ok (res, off, len) -> Ok (String.sub res off len)
| Error _ as err -> err
let decode_sub ?pad ?(alphabet = default_alphabet) ?off ?len input =
decode_sub ?pad alphabet ?off ?len input
let decode_exn ?pad ?alphabet ?off ?len input =
match decode ?pad ?alphabet ?off ?len input with
| Ok res -> res
| Error (`Msg err) -> invalid_arg err
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
mli
|
base64-3.5.2/src/base64.mli
|
(*
* Copyright (c) 2006-2009 Citrix Systems Inc.
* Copyright (c) 2010 Thomas Gazagnaire <[email protected]>
* Copyright (c) 2014-2016 Anil Madhavapeddy <[email protected]>
* Copyright (c) 2018 Romain Calascibetta <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)
(** Base64 RFC4648 implementation.
Base64 is a group of similar binary-to-text encoding schemes that represent
binary data in an ASCII string format by translating it into a radix-64
representation. It is specified in RFC 4648.
{e Release v3.5.2 - https://github.com/mirage/ocaml-base64} *)
type alphabet
(** Type of alphabet. *)
type sub = string * int * int
(** Type of sub-string: [str, off, len]. *)
val default_alphabet : alphabet
(** A 64-character alphabet specifying the regular Base64 alphabet. *)
val uri_safe_alphabet : alphabet
(** A 64-character alphabet specifying the URI- and filename-safe Base64
alphabet. *)
val make_alphabet : string -> alphabet
(** Make a new alphabet. *)
val length_alphabet : alphabet -> int
(** Returns length of the alphabet, should be 64. *)
val alphabet : alphabet -> string
(** Returns the alphabet. *)
val decode_exn :
?pad:bool -> ?alphabet:alphabet -> ?off:int -> ?len:int -> string -> string
(** [decode_exn ?off ?len s] decodes [len] bytes (defaults to
[String.length s - off]) of the string [s] starting from [off] (defaults to
[0]) that is encoded in Base64 format. Will leave trailing NULLs on the
string, padding it out to a multiple of 3 characters. [alphabet] defaults to
{!default_alphabet}. [pad = true] specifies to check if [s] is padded or
not, otherwise, it raises an exception.
Decoder can fail when character of [s] is not a part of [alphabet] or is not
[padding] character. If input is not padded correctly, decoder does the
best-effort but it does not ensure [decode_exn (encode ~pad:false x) = x].
@raise if Invalid_argument [s] is not a valid Base64 string. *)
val decode_sub :
?pad:bool ->
?alphabet:alphabet ->
?off:int ->
?len:int ->
string ->
(sub, [> `Msg of string ]) result
(** Same as {!decode_exn} but it returns a result type instead to raise an
exception. Then, it returns a {!sub} string. Decoded input [(str, off, len)]
will starting to [off] and will have [len] bytes - by this way, we ensure to
allocate only one time result. *)
val decode :
?pad:bool ->
?alphabet:alphabet ->
?off:int ->
?len:int ->
string ->
(string, [> `Msg of string ]) result
(** Same as {!decode_exn}, but returns an explicit error message {!result} if it
fails. *)
val encode :
?pad:bool ->
?alphabet:alphabet ->
?off:int ->
?len:int ->
string ->
(string, [> `Msg of string ]) result
(** [encode s] encodes the string [s] into base64. If [pad] is false, no
trailing padding is added. [pad] defaults to [true], and [alphabet] to
{!default_alphabet}.
[encode] fails when [off] and [len] do not designate a valid range of [s]. *)
val encode_string : ?pad:bool -> ?alphabet:alphabet -> string -> string
(** [encode_string s] encodes the string [s] into base64. If [pad] is false, no
trailing padding is added. [pad] defaults to [true], and [alphabet] to
{!default_alphabet}. *)
val encode_sub :
?pad:bool ->
?alphabet:alphabet ->
?off:int ->
?len:int ->
string ->
(sub, [> `Msg of string ]) result
(** Same as {!encode} but return a {!sub}-string instead a plain result. By this
way, we ensure to allocate only one time result. *)
val encode_exn :
?pad:bool -> ?alphabet:alphabet -> ?off:int -> ?len:int -> string -> string
(** Same as {!encode} but raises an invalid argument exception if we retrieve an
error. *)
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
ml
|
base64-3.5.2/src/base64_rfc2045.ml
|
(*
* Copyright (c) 2018 Romain Calascibetta <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)
let default_alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
let io_buffer_size = 65536
let invalid_arg fmt = Format.ksprintf (fun s -> invalid_arg s) fmt
let invalid_bounds off len =
invalid_arg "Invalid bounds (off: %d, len: %d)" off len
let malformed chr = `Malformed (String.make 1 chr)
let unsafe_byte source off pos = Bytes.unsafe_get source (off + pos)
let unsafe_blit = Bytes.unsafe_blit
let unsafe_chr = Char.unsafe_chr
let unsafe_set_chr source off chr = Bytes.unsafe_set source off chr
type state = { quantum : int; size : int; buffer : Bytes.t }
let continue state (quantum, size) = `Continue { state with quantum; size }
let flush state = `Flush { state with quantum = 0; size = 0 }
let table =
"\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\062\255\255\255\063\052\053\054\055\056\057\058\059\060\061\255\255\255\255\255\255\255\000\001\002\003\004\005\006\007\008\009\010\011\012\013\014\015\016\017\018\019\020\021\022\023\024\025\255\255\255\255\255\255\026\027\028\029\030\031\032\033\034\035\036\037\038\039\040\041\042\043\044\045\046\047\048\049\050\051\255\255\255\255\255"
let r_repr ({ quantum; size; _ } as state) chr =
(* assert (0 <= off && 0 <= len && off + len <= String.length source); *)
(* assert (len >= 1); *)
let code = Char.code table.[Char.code chr] in
match size with
| 0 -> continue state (code, 1)
| 1 -> continue state ((quantum lsl 6) lor code, 2)
| 2 -> continue state ((quantum lsl 6) lor code, 3)
| 3 ->
unsafe_set_chr state.buffer 0 (unsafe_chr ((quantum lsr 10) land 255)) ;
unsafe_set_chr state.buffer 1 (unsafe_chr ((quantum lsr 2) land 255)) ;
unsafe_set_chr state.buffer 2
(unsafe_chr ((quantum lsl 6) lor code land 255)) ;
flush state
| _ -> malformed chr
type src = [ `Channel of in_channel | `String of string | `Manual ]
type decode =
[ `Await | `End | `Wrong_padding | `Malformed of string | `Flush of string ]
type input =
[ `Line_break | `Wsp | `Padding | `Malformed of string | `Flush of state ]
type decoder = {
src : src;
mutable i : Bytes.t;
mutable i_off : int;
mutable i_pos : int;
mutable i_len : int;
mutable s : state;
mutable padding : int;
mutable unsafe : bool;
mutable byte_count : int;
mutable limit_count : int;
mutable pp : decoder -> input -> decode;
mutable k : decoder -> decode;
}
let i_rem decoder = decoder.i_len - decoder.i_pos + 1
let end_of_input decoder =
decoder.i <- Bytes.empty ;
decoder.i_off <- 0 ;
decoder.i_pos <- 0 ;
decoder.i_len <- min_int
let src decoder source off len =
if off < 0 || len < 0 || off + len > Bytes.length source
then invalid_bounds off len
else if len = 0
then end_of_input decoder
else (
decoder.i <- source ;
decoder.i_off <- off ;
decoder.i_pos <- 0 ;
decoder.i_len <- len - 1)
let refill k decoder =
match decoder.src with
| `Manual ->
decoder.k <- k ;
`Await
| `String _ ->
end_of_input decoder ;
k decoder
| `Channel ic ->
let len = input ic decoder.i 0 (Bytes.length decoder.i) in
src decoder decoder.i 0 len ;
k decoder
let dangerous decoder v = decoder.unsafe <- v
let reset decoder = decoder.limit_count <- 0
let ret k v byte_count decoder =
decoder.k <- k ;
decoder.byte_count <- decoder.byte_count + byte_count ;
decoder.limit_count <- decoder.limit_count + byte_count ;
if decoder.limit_count > 78 then dangerous decoder true ;
decoder.pp decoder v
type flush_and_malformed = [ `Flush of state | `Malformed of string ]
let padding { size; _ } padding =
match (size, padding) with
| 0, 0 -> true
| 1, _ -> false
| 2, 2 -> true
| 3, 1 -> true
| _ -> false
let t_flush { quantum; size; buffer } =
match size with
| 0 | 1 -> `Flush { quantum; size; buffer = Bytes.empty }
| 2 ->
let quantum = quantum lsr 4 in
`Flush
{ quantum; size; buffer = Bytes.make 1 (unsafe_chr (quantum land 255)) }
| 3 ->
let quantum = quantum lsr 2 in
unsafe_set_chr buffer 0 (unsafe_chr ((quantum lsr 8) land 255)) ;
unsafe_set_chr buffer 1 (unsafe_chr (quantum land 255)) ;
`Flush { quantum; size; buffer = Bytes.sub buffer 0 2 }
| _ -> assert false
(* this branch is impossible, size can only ever be in the range [0..3]. *)
let wrong_padding decoder =
let k _ = `End in
decoder.k <- k ;
`Wrong_padding
let rec t_decode_base64 chr decoder =
if decoder.padding = 0
then
let rec go pos = function
| `Continue state ->
if decoder.i_len - (decoder.i_pos + pos) + 1 > 0
then (
match unsafe_byte decoder.i decoder.i_off (decoder.i_pos + pos) with
| ('A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '+' | '/') as chr ->
go (succ pos) (r_repr state chr)
| '=' ->
decoder.padding <- decoder.padding + 1 ;
decoder.i_pos <- decoder.i_pos + pos + 1 ;
decoder.s <- state ;
ret decode_base64 `Padding (pos + 1) decoder
| ' ' | '\t' ->
decoder.i_pos <- decoder.i_pos + pos + 1 ;
decoder.s <- state ;
ret decode_base64 `Wsp (pos + 1) decoder
| '\r' ->
decoder.i_pos <- decoder.i_pos + pos + 1 ;
decoder.s <- state ;
decode_base64_lf_after_cr decoder
| chr ->
decoder.i_pos <- decoder.i_pos + pos + 1 ;
decoder.s <- state ;
ret decode_base64 (malformed chr) (pos + 1) decoder)
else (
decoder.i_pos <- decoder.i_pos + pos ;
decoder.byte_count <- decoder.byte_count + pos ;
decoder.limit_count <- decoder.limit_count + pos ;
decoder.s <- state ;
refill decode_base64 decoder)
| #flush_and_malformed as v ->
decoder.i_pos <- decoder.i_pos + pos ;
ret decode_base64 v pos decoder in
go 1 (r_repr decoder.s chr)
else (
decoder.i_pos <- decoder.i_pos + 1 ;
ret decode_base64 (malformed chr) 1 decoder)
and decode_base64_lf_after_cr decoder =
let rem = i_rem decoder in
if rem < 0
then ret decode_base64 (malformed '\r') 1 decoder
else if rem = 0
then refill decode_base64_lf_after_cr decoder
else
match unsafe_byte decoder.i decoder.i_off decoder.i_pos with
| '\n' ->
decoder.i_pos <- decoder.i_pos + 1 ;
ret decode_base64 `Line_break 2 decoder
| _ -> ret decode_base64 (malformed '\r') 1 decoder
and decode_base64 decoder =
let rem = i_rem decoder in
if rem <= 0
then
if rem < 0
then
ret
(fun decoder ->
if padding decoder.s decoder.padding
then `End
else wrong_padding decoder)
(t_flush decoder.s) 0 decoder
else refill decode_base64 decoder
else
match unsafe_byte decoder.i decoder.i_off decoder.i_pos with
| ('A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '+' | '/') as chr ->
t_decode_base64 chr decoder
| '=' ->
decoder.padding <- decoder.padding + 1 ;
decoder.i_pos <- decoder.i_pos + 1 ;
ret decode_base64 `Padding 1 decoder
| ' ' | '\t' ->
decoder.i_pos <- decoder.i_pos + 1 ;
ret decode_base64 `Wsp 1 decoder
| '\r' ->
decoder.i_pos <- decoder.i_pos + 1 ;
decode_base64_lf_after_cr decoder
| chr ->
decoder.i_pos <- decoder.i_pos + 1 ;
ret decode_base64 (malformed chr) 1 decoder
let pp_base64 decoder = function
| `Line_break ->
reset decoder ;
decoder.k decoder
| `Wsp | `Padding -> decoder.k decoder
| `Flush state ->
decoder.s <- state ;
`Flush (Bytes.to_string state.buffer)
| `Malformed _ as v -> v
let decoder src =
let pp = pp_base64 in
let k = decode_base64 in
let i, i_off, i_pos, i_len =
match src with
| `Manual -> (Bytes.empty, 0, 1, 0)
| `Channel _ -> (Bytes.create io_buffer_size, 0, 1, 0)
| `String s -> (Bytes.unsafe_of_string s, 0, 0, String.length s - 1) in
{
src;
i_off;
i_pos;
i_len;
i;
s = { quantum = 0; size = 0; buffer = Bytes.create 3 };
padding = 0;
unsafe = false;
byte_count = 0;
limit_count = 0;
pp;
k;
}
let decode decoder = decoder.k decoder
let decoder_byte_count decoder = decoder.byte_count
let decoder_src decoder = decoder.src
let decoder_dangerous decoder = decoder.unsafe
(* / *)
let invalid_encode () = invalid_arg "Expected `Await encode"
type dst = [ `Channel of out_channel | `Buffer of Buffer.t | `Manual ]
type encode = [ `Await | `End | `Char of char ]
type encoder = {
dst : dst;
mutable o : Bytes.t;
mutable o_off : int;
mutable o_pos : int;
mutable o_len : int;
mutable c_col : int;
i : Bytes.t;
mutable s : int;
t : Bytes.t;
mutable t_pos : int;
mutable t_len : int;
mutable k : encoder -> encode -> [ `Ok | `Partial ];
}
let o_rem encoder = encoder.o_len - encoder.o_pos + 1
let dst encoder source off len =
if off < 0 || len < 0 || off + len > Bytes.length source
then invalid_bounds off len ;
encoder.o <- source ;
encoder.o_off <- off ;
encoder.o_pos <- 0 ;
encoder.o_len <- len - 1
let dst_rem = o_rem
let partial k encoder = function
| `Await -> k encoder
| `Char _ | `End -> invalid_encode ()
let flush k encoder =
match encoder.dst with
| `Manual ->
encoder.k <- partial k ;
`Partial
| `Channel oc ->
output oc encoder.o encoder.o_off encoder.o_pos ;
encoder.o_pos <- 0 ;
k encoder
| `Buffer b ->
let o = Bytes.unsafe_to_string encoder.o in
Buffer.add_substring b o encoder.o_off encoder.o_pos ;
encoder.o_pos <- 0 ;
k encoder
let t_range encoder len =
encoder.t_pos <- 0 ;
encoder.t_len <- len
let rec t_flush k encoder =
let blit encoder len =
unsafe_blit encoder.t encoder.t_pos encoder.o encoder.o_pos len ;
encoder.o_pos <- encoder.o_pos + len ;
encoder.t_pos <- encoder.t_pos + len in
let rem = o_rem encoder in
let len = encoder.t_len - encoder.t_pos + 1 in
if rem < len
then (
blit encoder rem ;
flush (t_flush k) encoder)
else (
blit encoder len ;
k encoder)
let rec encode_line_break k encoder =
let rem = o_rem encoder in
let s, j, k =
if rem < 2
then (
t_range encoder 2 ;
(encoder.t, 0, t_flush k))
else
let j = encoder.o_pos in
encoder.o_pos <- encoder.o_pos + 2 ;
(encoder.o, encoder.o_off + j, k) in
unsafe_set_chr s j '\r' ;
unsafe_set_chr s (j + 1) '\n' ;
encoder.c_col <- 0 ;
k encoder
and encode_char chr k (encoder : encoder) =
if encoder.s >= 2
then (
let a, b, c = (unsafe_byte encoder.i 0 0, unsafe_byte encoder.i 0 1, chr) in
encoder.s <- 0 ;
let quantum = (Char.code a lsl 16) + (Char.code b lsl 8) + Char.code c in
let a = quantum lsr 18 in
let b = (quantum lsr 12) land 63 in
let c = (quantum lsr 6) land 63 in
let d = quantum land 63 in
let rem = o_rem encoder in
let s, j, k =
if rem < 4
then (
t_range encoder 4 ;
(encoder.t, 0, t_flush (k 4)))
else
let j = encoder.o_pos in
encoder.o_pos <- encoder.o_pos + 4 ;
(encoder.o, encoder.o_off + j, k 4) in
unsafe_set_chr s j default_alphabet.[a] ;
unsafe_set_chr s (j + 1) default_alphabet.[b] ;
unsafe_set_chr s (j + 2) default_alphabet.[c] ;
unsafe_set_chr s (j + 3) default_alphabet.[d] ;
flush k encoder)
else (
unsafe_set_chr encoder.i encoder.s chr ;
encoder.s <- encoder.s + 1 ;
k 0 encoder)
and encode_trailing k encoder =
match encoder.s with
| 2 ->
let b, c = (unsafe_byte encoder.i 0 0, unsafe_byte encoder.i 0 1) in
encoder.s <- 0 ;
let quantum = (Char.code b lsl 10) + (Char.code c lsl 2) in
let b = (quantum lsr 12) land 63 in
let c = (quantum lsr 6) land 63 in
let d = quantum land 63 in
let rem = o_rem encoder in
let s, j, k =
if rem < 4
then (
t_range encoder 4 ;
(encoder.t, 0, t_flush (k 4)))
else
let j = encoder.o_pos in
encoder.o_pos <- encoder.o_pos + 4 ;
(encoder.o, encoder.o_off + j, k 4) in
unsafe_set_chr s j default_alphabet.[b] ;
unsafe_set_chr s (j + 1) default_alphabet.[c] ;
unsafe_set_chr s (j + 2) default_alphabet.[d] ;
unsafe_set_chr s (j + 3) '=' ;
flush k encoder
| 1 ->
let c = unsafe_byte encoder.i 0 0 in
encoder.s <- 0 ;
let quantum = Char.code c lsl 4 in
let c = (quantum lsr 6) land 63 in
let d = quantum land 63 in
let rem = o_rem encoder in
let s, j, k =
if rem < 4
then (
t_range encoder 4 ;
(encoder.t, 0, t_flush (k 4)))
else
let j = encoder.o_pos in
encoder.o_pos <- encoder.o_pos + 4 ;
(encoder.o, encoder.o_off + j, k 4) in
unsafe_set_chr s j default_alphabet.[c] ;
unsafe_set_chr s (j + 1) default_alphabet.[d] ;
unsafe_set_chr s (j + 2) '=' ;
unsafe_set_chr s (j + 3) '=' ;
flush k encoder
| 0 -> k 0 encoder
| _ -> assert false
and encode_base64 encoder v =
let k col_count encoder =
encoder.c_col <- encoder.c_col + col_count ;
encoder.k <- encode_base64 ;
`Ok in
match v with
| `Await -> k 0 encoder
| `End ->
if encoder.c_col = 76
then encode_line_break (fun encoder -> encode_base64 encoder v) encoder
else encode_trailing k encoder
| `Char chr ->
let rem = o_rem encoder in
if rem < 1
then flush (fun encoder -> encode_base64 encoder v) encoder
else if encoder.c_col = 76
then encode_line_break (fun encoder -> encode_base64 encoder v) encoder
else encode_char chr k encoder
let encoder dst =
let o, o_off, o_pos, o_len =
match dst with
| `Manual -> (Bytes.empty, 1, 0, 0)
| `Buffer _ | `Channel _ ->
(Bytes.create io_buffer_size, 0, 0, io_buffer_size - 1) in
{
dst;
o_off;
o_pos;
o_len;
o;
t = Bytes.create 4;
t_pos = 1;
t_len = 0;
c_col = 0;
i = Bytes.create 3;
s = 0;
k = encode_base64;
}
let encode encoder = encoder.k encoder
let encoder_dst encoder = encoder.dst
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
mli
|
base64-3.5.2/src/base64_rfc2045.mli
|
(*
* Copyright (c) 2014-2016 Anil Madhavapeddy <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)
(** Decode *)
val default_alphabet : string
(** A 64-character string specifying the regular Base64 alphabet. *)
type decoder
(** The type for decoders. *)
type src = [ `Manual | `Channel of in_channel | `String of string ]
(** The type for input sources. With a [`Manual] source the client must provide
input with {!src}. *)
type decode =
[ `Await | `End | `Flush of string | `Malformed of string | `Wrong_padding ]
val src : decoder -> Bytes.t -> int -> int -> unit
(** [src d s j l] provides [d] with [l] bytes to read, starting at [j] in [s].
This byte range is read by calls to {!decode} with [d] until [`Await] is
returned. To signal the end of input, call the function with [l = 0]. *)
val decoder : src -> decoder
(** [decoder src] is a decoder that inputs from [src]. *)
val decode : decoder -> decode
(** [decode d] is:
- [`Await] if [d] has a [`Manual] input source and awaits for more input.
The client must use {!src} to provide it.
- [`End] if the end of input was reached
- [`Malformed bytes] if the [bytes] sequence is malformed according to the
decoded base64 encoding scheme. If you are interested in a best-effort
decoding, you can still continue to decode after an error until the decode
synchronizes again on valid bytes.
- [`Flush data] if a [data] sequence value was decoded.
- [`Wrong_padding] if decoder retrieve a wrong padding at the end of the
input.
{b Note}. Repeated invocation always eventually returns [`End], even in case
of errors. *)
val decoder_byte_count : decoder -> int
(** [decoder_byte_count d] is the number of characters already decoded on [d]
(included malformed ones). This is the last {!decode}'s end output offset
counting from beginning of the stream. *)
val decoder_src : decoder -> src
(** [decoder_src d] is [d]'s input source. *)
val decoder_dangerous : decoder -> bool
(** [decoder_dangerous d] returns [true] if encoded input does not respect the
80-columns rule. If your are interested in a best-effort decoding you can
still continue to decode even if [decoder_dangerous d] returns [true].
Nothing grow automatically internally in this state. *)
type dst = [ `Channel of out_channel | `Buffer of Buffer.t | `Manual ]
(** The type for output destinations. With a [`Manual] destination the client
must provide output storage with {!dst}. *)
type encode = [ `Await | `End | `Char of char ]
type encoder
(** The type for Base64 (RFC2045) encoder. *)
val encoder : dst -> encoder
(** [encoder dst] is an encoder for Base64 (RFC2045) that outputs to [dst]. *)
val encode : encoder -> encode -> [ `Ok | `Partial ]
(** [encode e v]: is
- [`Partial] iff [e] has a [`Manual] destination and needs more output
storage. The client must use {!dst} to provide a new buffer and then call
{!encode} with [`Await] until [`Ok] is returned.
- [`Ok] when the encoder is ready to encode a new [`Char] or [`End]
For [`Manual] destination, encoding [`End] always return [`Partial], the
client should continue as usual with [`Await] until [`Ok] is returned at
which point {!dst_rem} [encoder] is guaranteed to be the size of the last
provided buffer (i.e. nothing was written).
{b Raises.} [Invalid_argument] if a [`Char] or [`End] is encoded after a
[`Partial] encode. *)
val encoder_dst : encoder -> dst
(** [encoder_dst encoder] is [encoder]'s output destination. *)
val dst : encoder -> Bytes.t -> int -> int -> unit
(** [dst e s j l] provides [e] with [l] bytes to write, starting at [j] in [s].
This byte range is written by calls to {!encode} with [e] until [`Partial]
is returned. Use {!dst_rem} to know the remaining number of non-written free
bytes in [s]. *)
val dst_rem : encoder -> int
(** [dst_rem e] is the remaining number of non-written, free bytes in the last
buffer provided with {!dst}. *)
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
dune
|
base64-3.5.2/src/dune
|
(library
(name base64)
(modules base64)
(public_name base64))
(library
(name base64_rfc2045)
(modules base64_rfc2045)
(public_name base64.rfc2045))
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
dune
|
base64-3.5.2/test/dune
|
(executable
(modes byte exe)
(name test)
(libraries base64 base64.rfc2045 rresult alcotest bos))
(rule
(alias runtest)
(deps
(:exe test.exe))
(action
(run %{exe} --color=always)))
|
base64
|
3.5.2
|
ISC
|
https://github.com/mirage/ocaml-base64
|
git+https://github.com/mirage/ocaml-base64.git
|
ml
|
base64-3.5.2/test/test.ml
|
(*
* Copyright (c) 2016 Anil Madhavapeddy <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)
open Printf
open Rresult
(* Test vectors from RFC4648
BASE64("") = ""
BASE64("f") = "Zg=="
BASE64("fo") = "Zm8="
BASE64("foo") = "Zm9v"
BASE64("foob") = "Zm9vYg=="
BASE64("fooba") = "Zm9vYmE="
BASE64("foobar") = "Zm9vYmFy"
*)
let rfc4648_tests =
[
("", "");
("f", "Zg==");
("fo", "Zm8=");
("foo", "Zm9v");
("foob", "Zm9vYg==");
("fooba", "Zm9vYmE=");
("foobar", "Zm9vYmFy");
]
let hannes_tests =
[
("dummy", "ZHVtbXk=");
("dummy", "ZHVtbXk");
("dummy", "ZHVtbXk==");
("dummy", "ZHVtbXk===");
("dummy", "ZHVtbXk====");
("dummy", "ZHVtbXk=====");
("dummy", "ZHVtbXk======");
]
let php_tests =
[
( "πάντα χωρεῖ καὶ οὐδὲν μένει …",
"z4DOrM69z4TOsSDPh8-Jz4HOteG_liDOus6x4b22IM6_4b2QzrThvbLOvSDOvM6tzr3Otc65IOKApg"
);
]
let rfc3548_tests =
[
("\x14\xfb\x9c\x03\xd9\x7e", "FPucA9l+");
("\x14\xfb\x9c\x03\xd9", "FPucA9k=");
("\x14\xfb\x9c\x03", "FPucAw==");
]
let cfcs_tests =
[
(0, 2, "\004", "BB");
(1, 2, "\004", "ABB");
(1, 2, "\004", "ABBA");
(2, 2, "\004", "AABBA");
(2, 2, "\004", "AABBAA");
(0, 0, "", "BB");
(1, 0, "", "BB");
(2, 0, "", "BB");
]
let nocrypto_tests =
[
("\x00\x5a\x6d\x39\x76", None);
("\x5a\x6d\x39\x76", Some "\x66\x6f\x6f");
("\x5a\x6d\x39\x76\x76", None);
("\x5a\x6d\x39\x76\x76\x76", None);
("\x5a\x6d\x39\x76\x76\x76\x76", None);
("\x5a\x6d\x39\x76\x00", None);
("\x5a\x6d\x39\x76\x62\x77\x3d\x3d", Some "\x66\x6f\x6f\x6f");
("\x5a\x6d\x39\x76\x62\x77\x3d\x3d\x00", None);
("\x5a\x6d\x39\x76\x62\x77\x3d\x3d\x00\x01", None);
("\x5a\x6d\x39\x76\x62\x77\x3d\x3d\x00\x01\x02", None);
("\x5a\x6d\x39\x76\x62\x77\x3d\x3d\x00\x01\x02\x03", None);
("\x5a\x6d\x39\x76\x62\x32\x38\x3d", Some "\x66\x6f\x6f\x6f\x6f");
("\x5a\x6d\x39\x76\x62\x32\x39\x76", Some "\x66\x6f\x6f\x6f\x6f\x6f");
("YWE=", Some "aa");
("YWE==", None);
("YWE===", None);
("YWE=====", None);
("YWE======", None);
]
let alphabet_size () =
List.iter
(fun (name, alphabet) ->
Alcotest.(check int)
(sprintf "Alphabet size %s = 64" name)
64
(Base64.length_alphabet alphabet))
[
("default", Base64.default_alphabet);
("uri_safe", Base64.uri_safe_alphabet);
]
(* Encode using OpenSSL `base64` utility *)
let openssl_encode buf =
Bos.(
OS.Cmd.in_string buf
|> OS.Cmd.run_io (Cmd.v "base64")
|> OS.Cmd.to_string ~trim:true)
|> function
| Ok r ->
prerr_endline r ;
r
| Error (`Msg e) -> raise (Failure (sprintf "OpenSSL decode: %s" e))
(* Encode using this library *)
let lib_encode buf = Base64.encode_exn ~pad:true buf
let test_rfc4648 () =
List.iter
(fun (c, r) ->
(* Base64 vs openssl *)
Alcotest.(check string)
(sprintf "encode %s" c) (openssl_encode c) (lib_encode c) ;
(* Base64 vs test cases above *)
Alcotest.(check string) (sprintf "encode rfc4648 %s" c) r (lib_encode c) ;
(* Base64 decode vs library *)
Alcotest.(check string) (sprintf "decode %s" r) c (Base64.decode_exn r))
rfc4648_tests
let test_rfc3548 () =
List.iter
(fun (c, r) ->
(* Base64 vs openssl *)
Alcotest.(check string)
(sprintf "encode %s" c) (openssl_encode c) (lib_encode c) ;
(* Base64 vs test cases above *)
Alcotest.(check string) (sprintf "encode rfc3548 %s" c) r (lib_encode c) ;
(* Base64 decode vs library *)
Alcotest.(check string) (sprintf "decode %s" r) c (Base64.decode_exn r))
rfc3548_tests
let test_hannes () =
List.iter
(fun (c, r) ->
(* Base64 vs test cases above *)
Alcotest.(check string)
(sprintf "decode %s" r) c
(Base64.decode_exn ~pad:false r))
hannes_tests
let test_php () =
List.iter
(fun (c, r) ->
Alcotest.(check string)
(sprintf "decode %s" r) c
(Base64.decode_exn ~pad:false ~alphabet:Base64.uri_safe_alphabet r))
php_tests
let test_cfcs () =
List.iter
(fun (off, len, c, r) ->
Alcotest.(check string)
(sprintf "decode %s" r) c
(Base64.decode_exn ~pad:false ~off ~len r))
cfcs_tests
let test_nocrypto () =
List.iter
(fun (input, res) ->
let res' =
match Base64.decode ~pad:true input with
| Ok v -> Some v
| Error _ -> None in
Alcotest.(check (option string)) (sprintf "decode %S" input) res' res)
nocrypto_tests
exception Malformed
exception Wrong_padding
let strict_base64_rfc2045_of_string x =
let decoder = Base64_rfc2045.decoder (`String x) in
let res = Buffer.create 16 in
let rec go () =
match Base64_rfc2045.decode decoder with
| `End -> ()
| `Wrong_padding -> raise Wrong_padding
| `Malformed _ -> raise Malformed
| `Flush x ->
Buffer.add_string res x ;
go ()
| `Await -> Alcotest.failf "Retrieve impossible case: `Await" in
Base64_rfc2045.src decoder (Bytes.unsafe_of_string x) 0 (String.length x) ;
go () ;
Buffer.contents res
let relaxed_base64_rfc2045_of_string x =
let decoder = Base64_rfc2045.decoder (`String x) in
let res = Buffer.create 16 in
let rec go () =
match Base64_rfc2045.decode decoder with
| `End -> ()
| `Wrong_padding -> go ()
| `Malformed _ -> go ()
| `Flush x ->
Buffer.add_string res x ;
go ()
| `Await -> Alcotest.failf "Retrieve impossible case: `Await" in
Base64_rfc2045.src decoder (Bytes.unsafe_of_string x) 0 (String.length x) ;
go () ;
Buffer.contents res
let test_strict_rfc2045 =
[
( "c2FsdXQgbGVzIGNvcGFpbnMgZmF1dCBhYnNvbHVtZW50IHF1ZSBqZSBkw6lwYXNzZSBsZXMgODAg\r\n\
Y2hhcmFjdGVycyBwb3VyIHZvaXIgc2kgbW9uIGVuY29kZXIgZml0cyBiaWVuIGRhbnMgbGVzIGxp\r\n\
bWl0ZXMgZGUgbGEgUkZDIDIwNDUgLi4u",
"salut les copains faut absolument que je dépasse les 80 characters \
pour voir si mon encoder fits bien dans les limites de la RFC 2045 ..."
);
("", "");
("Zg==", "f");
("Zm8=", "fo");
("Zm9v", "foo");
("Zm9vYg==", "foob");
("Zm9vYmE=", "fooba");
("Zm9vYmFy", "foobar");
]
let test_relaxed_rfc2045 =
[
("Zg", "f");
("Zm\n8", "fo");
("Zm\r9v", "foo");
("Zm9 vYg", "foob");
("Zm9\r\n vYmE", "fooba");
("Zm9évYmFy", "foobar");
]
let strict_base64_rfc2045_to_string x =
let res = Buffer.create 16 in
let encoder = Base64_rfc2045.encoder (`Buffer res) in
String.iter
(fun chr ->
match Base64_rfc2045.encode encoder (`Char chr) with
| `Ok -> ()
| `Partial ->
Alcotest.failf "Retrieve impossible case for (`Char %02x): `Partial"
(Char.code chr))
x ;
match Base64_rfc2045.encode encoder `End with
| `Ok -> Buffer.contents res
| `Partial -> Alcotest.fail "Retrieve impossible case for `End: `Partial"
let test_strict_with_malformed_input_rfc2045 =
List.mapi
(fun i (has, _) ->
Alcotest.test_case (Fmt.str "strict rfc2045 - %02d" i) `Quick @@ fun () ->
try
let _ = strict_base64_rfc2045_of_string has in
Alcotest.failf "Strict parser valids malformed input: %S" has
with Malformed | Wrong_padding -> ())
test_relaxed_rfc2045
let test_strict_rfc2045 =
List.mapi
(fun i (has, expect) ->
Alcotest.test_case (Fmt.str "strict rfc2045 - %02d" i) `Quick @@ fun () ->
try
let res0 = strict_base64_rfc2045_of_string has in
let res1 = strict_base64_rfc2045_to_string res0 in
Alcotest.(check string) "encode(decode(x)) = x" res1 has ;
Alcotest.(check string) "decode(x)" res0 expect
with Malformed | Wrong_padding -> Alcotest.failf "Invalid input %S" has)
test_strict_rfc2045
let test_relaxed_rfc2045 =
List.mapi
(fun i (has, expect) ->
Alcotest.test_case (Fmt.str "relaxed rfc2045 - %02d" i) `Quick
@@ fun () ->
let res0 = relaxed_base64_rfc2045_of_string has in
Alcotest.(check string) "decode(x)" res0 expect)
test_relaxed_rfc2045
let test_invariants = [ ("Alphabet size", `Quick, alphabet_size) ]
let test_codec =
[
("RFC4648 test vectors", `Quick, test_rfc4648);
("RFC3548 test vectors", `Quick, test_rfc3548);
("Hannes test vectors", `Quick, test_hannes);
("Cfcs test vectors", `Quick, test_cfcs);
("PHP test vectors", `Quick, test_php);
("Nocrypto test vectors", `Quick, test_nocrypto);
]
let () =
Alcotest.run "Base64"
[
("invariants", test_invariants);
("codec", test_codec);
("rfc2045 (0)", test_strict_rfc2045);
("rfc2045 (1)", test_strict_with_malformed_input_rfc2045);
("rfc2045 (2)", test_relaxed_rfc2045);
]
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-camlboy/output_results.ml
|
let () =
Format.printf
{|{ "name": "%s",
"results":
[ { "name": "Camlboy",
"metrics":
[ { "name": "Frames per second",
"units": "Hz",
"value": %s } ] } ] }@.|}
Sys.argv.(1)
(read_line ())
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/bigarrays/bench.ml
|
let pi = 4. *. atan 1.
let deltay = 40_000. /. 360. /. 3600. *. 1000.
let deltax = deltay *. cos (44. *. pi /. 180.)
let precompute tile_height tile_width tile =
let normals =
Bigarray.(Array3.create Int8_signed C_layout) (tile_height - 2) (tile_width - 2) 3
in
let heights =
Bigarray.(Array2.create Float32 C_layout) (tile_height - 2) (tile_width - 2)
in
for y = 1 to tile_height - 2 do
for x = 1 to tile_width - 2 do
let nx = (tile.{y, x - 1} -. tile.{y, x + 1}) *. deltay in
let ny = (tile.{y - 1, x} -. tile.{y + 1, x}) *. deltax in
let nz = 2. *. deltax *. deltay in
let n = 127. /. sqrt ((nx *. nx) +. (ny *. ny) +. (nz *. nz)) in
normals.{tile_height - 2 - y, x - 1, 0} <- truncate (nx *. n);
normals.{tile_height - 2 - y, x - 1, 1} <- truncate (ny *. n);
normals.{tile_height - 2 - y, x - 1, 2} <- truncate (nz *. n);
heights.{tile_height - 2 - y, x - 1} <- tile.{y, x}
done
done
let tile_height = 1024
let tile_width = 1024
let tile = Bigarray.(Array2.create Float32 C_layout) tile_height tile_width
let () =
for _ = 1 to 30 do
precompute tile_height tile_width tile
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/bin_prot/bench.ml
|
open Bin_prot.Std
type element =
{ a : string
; b : string
; c : string
; d : bool
; e : bool
; f : bool
; g : string option
; h : bool
; i : bool
; j : bool
; k : bool
; l : bool
; m : bool
; n : bool
; o : string option
; p : bool
; q : bool
; r : int
; s : int
; t : int
; u : int
; v : string list (* these are small - 1-5 *)
}
[@@deriving bin_io]
let s = "abcdefabcdefabcdef"
let v = [ s; s; s; s ]
let x =
{ a = s
; b = s
; c = s
; d = true
; e = true
; f = true
; g = Some s
; h = true
; i = true
; j = true
; k = true
; l = true
; m = true
; n = true
; o = Some s
; p = true
; q = true
; r = 65537
; s = 65537
; t = 65537
; u = 65537
; v
}
type t = element list [@@deriving bin_io]
let rec f acc n = if n = 0 then acc else f (x :: acc) (n - 1)
let () =
if Array.length Sys.argv > 1
then (
let count = int_of_string Sys.argv.(1) in
let l = f [] count in
let len = [%bin_size: t] l in
let b = Bin_prot.Common.create_buf len in
ignore ([%bin_write: t] b ~pos:0 l : int);
let s = Bytes.create len in
Bin_prot.Common.blit_buf_string ~src_pos:0 b ~dst_pos:0 s ~len;
Out_channel.with_open_bin "data" @@ fun ch -> Out_channel.output_bytes ch s)
else
let s = In_channel.with_open_bin "data" @@ In_channel.input_all in
let len = String.length s in
let b = Bin_prot.Common.create_buf len in
Bin_prot.Common.blit_string_buf ~src_pos:0 s ~dst_pos:0 b ~len;
let t = Unix.gettimeofday () in
for _ = 0 to 4 do
ignore ([%bin_read: t] b ~pos_ref:(ref 0) : t)
done;
let t' = Unix.gettimeofday () in
Format.printf "%.2f@." (t' -. t)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/bin_prot/dune
|
(executables
(names bench)
(modes js wasm)
(js_of_ocaml
(flags --opt 2))
(wasm_of_ocaml
(flags --opt 2))
(preprocess
(pps ppx_bin_prot))
(libraries unix))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/dune
|
; Ignore subdirectories
(dirs)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/date.ml
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
type date = int
type gregorian = {
year : int;
month : int;
day : int;
hour : int;
minute : int
}
let hours_in_day = 24
let minutes_in_day = hours_in_day * 60
let fminutes_in_day = float minutes_in_day
let minutes_to_noon = (hours_in_day / 2) * 60
(*
Communications of the ACM by Henry F. Fliegel and Thomas C. Van Flandern,
``A Machine Algorithm for Processing Calendar Dates'',
CACM, volume 11, number 10, October 1968, p. 657
*)
let date_of_gregorian {year = y; month = m; day = d; hour = hr; minute = mn} =
(
(match m with
| 1 | 2 ->
( 1461 * ( y + 4800 - 1 ) ) / 4 +
( 367 * ( m + 10 ) ) / 12 -
( 3 * ( ( y + 4900 - 1 ) / 100 ) ) / 4
| _ ->
( 1461 * ( y + 4800 ) ) / 4 +
( 367 * ( m - 2 ) ) / 12 -
( 3 * ( ( y + 4900 ) / 100 ) ) / 4)
+ d - 32075 - 2444238) * minutes_in_day
+ hr * 60 + mn
let gregorian_of_date minutes_since_epoch =
let jul = minutes_since_epoch / minutes_in_day in
let l = jul + 68569 + 2444238 in
let n = ( 4 * l ) / 146097 in
let l = l - ( 146097 * n + 3 ) / 4 in
let i = ( 4000 * ( l + 1 ) ) / 1461001 in
let l = l - ( 1461 * i ) / 4 + 31 in
let j = ( 80 * l ) / 2447 in
let d = l - ( 2447 * j ) / 80 in
let l = j / 11 in
let m = j + 2 - ( 12 * l ) in
let y = 100 * ( n - 49 ) + i + l in
let daytime = minutes_since_epoch mod minutes_in_day in
if daytime = minutes_to_noon
then {year = y; month = m; day = d; hour = 12; minute = 0}
else {year = y; month = m; day = d; hour = daytime / 60; minute = daytime mod 60}
let check_date ~year ~month ~day =
1 <= day &&
1 <= month && month <= 12 &&
1980 <= year && year <= 2299 &&
begin
day <= 28 ||
match month with
| 2 -> day = 29 && year mod 4 = 0 && (year = 2000 || (year mod 100 <> 0))
(* we don't check y mod 400 because 2000 is ok and we don't support
neither 1600 nor 2400. *)
| 4 | 6 | 9 | 11 -> day <= 30
| _ -> day <= 31
end
let of_string s : date =
let sub ofs len =
let rec sub acc ofs len =
if len = 0
then acc
else sub (acc * 10 + int_of_char(String.unsafe_get s ofs) - 48) (ofs + 1) (len - 1)
in
sub (int_of_char(String.unsafe_get s ofs) - 48) (ofs + 1) (len - 1)
in
if String.length s < 10 then invalid_arg "date_of_string";
let year = sub 0 4 in
let month = sub 5 2 in
let day = sub 8 2 in
(* minimal coherence check of the date, just what is needed more than what the lexer is doing *)
if check_date ~year ~month ~day then
if String.length s < 16
then date_of_gregorian{year; month; day; hour=12; minute=0}
else date_of_gregorian{year; month; day; hour=sub 11 2; minute=sub 14 2}
else invalid_arg "date_of_string"
let days_between t1 t2 =
float (t1 - t2) /. fminutes_in_day
let act_365 t1 t2 = (days_between t1 t2) /. 365.
let leap y = (y mod 4 = 0) && ((y mod 100 <> 0) || (y mod 400 = 0))
let end_of_month year month =
match month with
| 2 when leap year -> 29
| 2 -> 28
| 4 | 6 | 9 | 11 -> 30
| _ -> 31
let add_months date nbmonths =
let {year = y; month = m; day = d; hour = _; minute = _;} as date = gregorian_of_date date in
let m = m + nbmonths in
let y, m = y + (m-1) / 12, ((m-1) mod 12) + 1 in
let y, m = if m <= 0 then y - 1, m + 12 else y, m in
date_of_gregorian {date with year = y; month = m; day = min d (end_of_month y m)}
let add_years date nbyears = add_months date (nbyears * 12)
let max_date = of_string "2299-12-31T23:59:59"
let min_date = of_string "1980-01-01T12:00:00"
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/date.mli
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
type date
val max_date: date
val min_date: date
val of_string: string -> date
val days_between: date -> date -> float
val act_365: date -> date -> float
val add_months: date -> int -> date
val add_years: date -> int -> date
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/dune
|
(executable
(name main)
(js_of_ocaml
(flags --opt 2))
(wasm_of_ocaml
(flags --opt 2))
(modes js wasm))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/g2pp_calibration.ml
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
(* A 2-factor interest-rate model. Reference book: Brigo and Mercurio "Interest Rate Models" 2005 *)
open Date
let pi = 2. *. asin 1.
type extended_swaption =
{
maturity: date;
strike: float;
swap_schedule: (date * date) list;
}
type swap_frequency =
| Freq_3M
| Freq_6M
| Freq_1Y
type swaption =
{
swaption_maturity_in_year: int;
swap_frequency: swap_frequency;
swap_term_in_year: int;
}
let extended_swaption_of_swaption ~today ~zc {swaption_maturity_in_year; swap_frequency; swap_term_in_year} =
let maturity = add_years today swaption_maturity_in_year in
let frq =
match swap_frequency with
| Freq_3M -> 3
| Freq_6M -> 6
| Freq_1Y -> 12
in
let nschedule = 12 * swap_term_in_year / frq in
let swap_schedule = Array.init nschedule (fun i -> add_months maturity (i * frq), add_months maturity ((i + 1) * frq)) in
let swap_schedule = Array.to_list swap_schedule in
let lvl, t0, tn =
List.fold_left
(fun (acc_lvl, acc_t0, acc_tn) (tf, tp) ->
acc_lvl +. zc tp *. (act_365 tp tf), min acc_t0 tf, max acc_tn tp
) (0., max_date, min_date) swap_schedule
in
let strike = (zc t0 -. zc tn) /. lvl in (* atm strike *)
{maturity; swap_schedule; strike}
type parameters =
{
g_a : float;
g_b : float;
g_sigma : float;
g_nu : float;(* nu is eta in Brigo and Mercurio *)
g_rho : float;
}
(* Places with ** comments should take account of sigma=0 case *)
let b_fun z tau = (* ** *)
(1. -. exp (-. z *. tau)) /. z
exception Sdomain
(* \var(\int_t^T [x(u)+y(u)]du) *)
let bigv {g_a; g_b; g_rho; g_nu; g_sigma} tau = (* 4.10 p 135 *)
let t sigma x =
let expxtau = exp (-. x *. tau) in (* ** *)
let exp2xtau = expxtau *. expxtau in (* ** *)
sigma *. sigma /. (x *. x) *.
(tau +. 2. /. x *. expxtau -. 1. /. (2. *. x) *. exp2xtau -. 3. /. (2. *. x))
in
let t1 = t g_sigma g_a in
let t2 = t g_nu g_b in
let ba = b_fun g_a tau in
let bb = b_fun g_b tau in
let t3 = (* ** *)
2. *. g_rho *. g_nu *. g_sigma /. (g_a *. g_b) *.
(tau -. ba -. bb +. b_fun (g_a +. g_b) tau)
in
t1 +. t2 +. t3, ba, bb
(* x drift term in tmat-forward measure *)
let bigmx {g_a; g_b; g_rho; g_nu; g_sigma} today tmat s t =
let ts = act_365 t s in
let tmatt = act_365 tmat t in
let tmat0 = act_365 tmat today in
let tmats = act_365 tmat s in
let t0 = act_365 t today in
let s0 = act_365 s today in
(g_sigma *. g_sigma /. (g_a *. g_a) +. g_sigma *. g_rho *. g_nu /. (g_a *. g_b)) *. (1. -. exp (-. g_a *. ts)) -.
(g_sigma *. g_sigma /. (2. *. g_a *. g_a) *. (exp (-. g_a *. tmatt) -. exp (-. g_a *. (tmats +. ts)))) -.
g_rho *. g_sigma *. g_nu /. (g_b *. (g_a +. g_b)) *. (exp (-. g_b *. tmatt) -. exp (-. g_b *. tmat0 -. g_a *. t0 +. (g_a +. g_b) *. s0))
(* y drift term in tmat-forward measure *)
let bigmy {g_a; g_b; g_rho; g_nu; g_sigma} today tmat s t =
let ts = act_365 t s in
let tmatt = act_365 tmat t in
let tmat0 = act_365 tmat today in
let tmats = act_365 tmat s in
let t0 = act_365 t today in
let s0 = act_365 s today in
(g_nu *. g_nu /. (g_b *. g_b) +. g_sigma *. g_rho *. g_nu /. (g_a *. g_b)) *. (1. -. exp (-. g_b *. ts)) -.
(g_nu *. g_nu /. (2. *. g_b *. g_b) *. (exp (-. g_b *. tmatt) -. exp (-. g_b *. (tmats +. ts)))) -.
g_rho *. g_sigma *. g_nu /. (g_a *. (g_a +. g_b)) *. (exp (-. g_a *. tmatt) -. exp (-. g_a *. tmat0 -. g_b *. t0 +. (g_a +. g_b) *. s0))
let x_quadrature, w_quadrature = Math.Gaussian_quadrature.gauss_hermite_coefficients
let nquadrature = Array.length x_quadrature
let pricer_of_swaption ~today ~zc swaption =
let swaption = extended_swaption_of_swaption ~today ~zc swaption in
let maturity = swaption.maturity in
let strike = swaption.strike in
let tmat0 = act_365 maturity today in
let schedulei = Array.of_list swaption.swap_schedule in
let lastindex = Array.length schedulei - 1 in
let taui = Array.map (fun (start_date, end_date) -> act_365 end_date start_date) schedulei in
let ci =
Array.mapi
(fun i tau -> if i = lastindex then 1. +. tau *. strike else tau *. strike)
taui
in
let n_schedi = Array.length schedulei in
let bai = Array.make n_schedi 0. in
let bbi = Array.make n_schedi 0. in
let aici = Array.make n_schedi 0. in
let log_aici = Array.make n_schedi 0. in
let scales = Array.make n_schedi 0. in
let t1_cst = Array.make n_schedi 0. in
let scale = Array.make n_schedi 0. in
fun params ->
let {g_a; g_b; g_rho; g_nu; g_sigma} = params in
let v0_mat, _, _ = bigv params (act_365 maturity today) in
let zc_mat = zc maturity in
let a_fun end_date = (* defined top p138 *)
let v0_end, _, _ = bigv params (act_365 end_date today) in
let vt_end, ba, bb = bigv params (act_365 end_date maturity) in
zc end_date /. zc_mat *. exp (0.5 *. (vt_end -. v0_end +. v0_mat)), ba, bb
in
let sigmax = g_sigma *. sqrt (b_fun (2. *. g_a) tmat0) in
let sigmay = g_nu *. sqrt (b_fun (2. *. g_b) tmat0) in
let rhoxy = g_rho *. g_sigma *. g_nu /. (sigmax *. sigmay) *. (b_fun (g_a +. g_b) tmat0) in
let rhoxyc = 1. -. rhoxy *. rhoxy in
let rhoxycs = sqrt rhoxyc in
let t2 = rhoxy /. (sigmax *. rhoxycs) in
let sigmay_rhoxycs = sigmay *. rhoxycs in
let t4 = rhoxy *. sigmay /. sigmax in
let mux = -. bigmx params today maturity today maturity in
let muy = -. bigmy params today maturity today maturity in
for i = 0 to n_schedi - 1 do
let a, ba, bb = a_fun (snd schedulei.(i)) in
let x = ci.(i) *. a in
let log_ac = log x in
aici.(i) <- x;
log_aici.(i) <- log_ac;
bai.(i) <- ba;
bbi.(i) <- bb;
let t3 = muy -. 0.5 *. rhoxyc *. sigmay *. sigmay *. bb in
let cst = bb *. (mux *. t4 -. t3) in
t1_cst.(i) <- x *. exp cst;
scale.(i) <- -. (ba +. bb *. t4);
done;
let k = (-3.71901648545568) in (* ugaussian_Pinv 1e-4 *)
let exact_yhat x =
(* y_lo x <= yhat x <= y_up x*)
let lo = ref neg_infinity in
let up = ref 0. in
for i = 0 to n_schedi - 1 do
let baix = bai.(i) *. x in
lo := max !lo ((log_aici.(i) -. baix) /. bbi.(i));
up := !up +. aici.(i) *. exp (-. baix)
done;
let lo = !lo and s_up = !up in
if n_schedi = 1 then lo
else
let open Math.Rootfinder in
let up =
let log_s = log s_up in
let tmp = log_s /. bbi.(n_schedi - 1) in
if tmp <= 0. then tmp
else let tmp = log_s /. bbi.(0) in if 0. <= tmp then tmp
(* This case happens when all ai * ci are too close to 0. or x to high => to_solve x y is close to -1 for all y,
thus the root is reached for y negative with high absolute value (tosolve x is a decreasing function of y) *)
else neg_infinity
in
let yl = lo -. 1e-5 in
let yu = up +. 1e-5 in
(* y01 x = y0, y1 / phi(h_i(x, y0)) <= epsilon, 1 - phi(h_i(x, y1)) <= epsilon *)
let y0 = sigmay *. (rhoxy *. (x -. mux) /. sigmax +. k *. rhoxycs) -. rhoxyc /. g_b +. muy in
let y1 = sigmay *. (rhoxy *. (x -. mux) /. sigmax -. k *. rhoxycs) +. muy in
if y1 <= yl then y1 +. 1. (* yhat is greater than y1 => 1 - phi(h_i(x, yhat)) < epsilon *)
else if yu <= y0 then y0 -. 1. (* yhat is lower than y0 => phi(h_i(x, yhat)) < epsilon *)
else try
for i = 0 to n_schedi - 1 do
scales.(i) <- aici.(i) *. exp (-. bai.(i) *. x);
done;
let to_solve yhat = (* eqn at bottom p148 *)
let sum = ref (-1.) in
for i = 0 to n_schedi - 1 do
sum := !sum +. scales.(i) *. exp (-. bbi.(i) *. yhat);
done;
assert(!sum = !sum);
!sum
in
brent (max yl y0) (min yu y1) to_solve 1e-4
with
| Rootfinder NotbracketedBelow -> y0 -. 1.
| Rootfinder NotbracketedAbove -> y1 +. 1.
in
let yhat =
let eps = 0.5 *. sigmax in
let f = exact_yhat mux in
let df = 0.5 *. (exact_yhat (mux +. eps) -. exact_yhat (mux -. eps)) /. eps in
fun x -> f +. df *. (x -. mux)
in
let integrand x =
let t1 = exp (-. 0.5 *. ((x -. mux) /. sigmax) ** 2.) in
let yhat = yhat x in
let h1 =
let t1 = (yhat -. muy) /. sigmay_rhoxycs in
t1 -. t2 *. (x -. mux)
in
let t2 = Math.ugaussian_P (-.h1) in
let acc = ref 0. in
for i = 0 to n_schedi - 1 do
let h2 = h1 +. bbi.(i) *. sigmay_rhoxycs in
acc := !acc +. t1_cst.(i) *. exp (scale.(i) *. x) *. Math.ugaussian_P (-.h2)
done;
t1 *. (t2 -. !acc)
in
let integral =
let sqrt2sigmax = sqrt 2. *. sigmax in
let sum = ref 0. in
for i = 0 to nquadrature - 1 do
sum := !sum +. w_quadrature.(i) *. integrand (sqrt2sigmax *. x_quadrature.(i) +. mux)
done;
!sum /. (sqrt pi)
in
zc_mat *. integral
let black_price ~today ~zc swaption vol =
let swaption = extended_swaption_of_swaption ~today ~zc swaption in
let {swap_schedule; strike; maturity; _} = swaption in
let sqrtt = act_365 maturity today in
let lvl, t0, tn =
List.fold_left
(fun (acc_lvl, acc_t0, acc_tn) (tf, tp) ->
acc_lvl +. zc tp *. (act_365 tp tf), min acc_t0 tf, max acc_tn tp
) (0., max_date, min_date) swap_schedule
in
let s0 = (zc t0 -. zc tn) /. lvl in
let d1 = log (s0 /. strike) /. (vol *. sqrtt) +. 0.5 *. vol *. sqrtt in
let d2 = d1 -. vol *. sqrtt in
lvl *. (s0 *. Math.ugaussian_P d1 -. strike *. Math.ugaussian_P d2)
let calibrate ?feedback ~max_global ~today ~swaption_quotes ~variables ~zc () =
assert(Array.length variables = 5);
let quotes = Array.map (fun (sw, q) -> black_price ~today ~zc sw q) swaption_quotes in
let parameters_of_vector x =
let g_a = x.(0) in
let g_b = x.(1) in
let g_sigma = x.(2) in
let g_nu = x.(3) in
let g_rho = x.(4) in
{g_a; g_b; g_sigma; g_nu; g_rho}
in
let pricers = Array.map (fun (sw, _) -> pricer_of_swaption ~today ~zc sw) swaption_quotes in
let pricer params h =
try
for i = 0 to Array.length pricers - 1 do
h.(i) <- pricers.(i) params
done
with Sdomain -> raise Optimization.Infeasible
in
Optimization.least_squares ?feedback ~max_global ~parameters_of_vector ~pricer ~variables quotes
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/g2pp_calibration.mli
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
(** G2++ 2-factors affine interest rate model. See Brigo and Mercurio
(2006), chapter 4.2 p142 for more details. *)
open Date
type swap_frequency =
| Freq_3M
| Freq_6M
| Freq_1Y
type swaption =
{
swaption_maturity_in_year: int;
swap_frequency: swap_frequency;
swap_term_in_year: int;
}
type parameters =
{
g_a : float;
g_b : float;
g_sigma : float;
g_nu : float;
g_rho : float;
}
(** A point in the calibration space of the G2++ model.
The model parameters of the G2++ model, with mean reversion parameters
[a] and [b], volatility parameters [sigma] and [nu] and correlation
coefficient [rho]. *)
exception Sdomain
(** This exception is raised by [swaption] if the numerical integration used in the
price calculation does not converge (indicating that the model parameters are
malformed). *)
val pricer_of_swaption: today: date -> zc:(date -> float) -> swaption -> (parameters -> float)
val black_price: today: date -> zc: (date -> float) -> swaption -> (float -> float)
val calibrate:
?feedback:(string -> unit) ->
max_global:int ->
today: date ->
swaption_quotes: (swaption * float) array ->
variables:Optimization.optimization_variable array ->
zc: (date -> float) ->
unit -> parameters Optimization.calibration_result
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/main.ml
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
open G2pp_calibration
open Date
let swaption_quotes =
[|
{swaption_maturity_in_year = 1; swap_term_in_year = 1; swap_frequency = Freq_6M}, 1.052;
{swaption_maturity_in_year = 2; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.81485;
{swaption_maturity_in_year = 3; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.6165;
{swaption_maturity_in_year = 4; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.46995;
{swaption_maturity_in_year = 5; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.38295;
{swaption_maturity_in_year = 6; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.3325;
{swaption_maturity_in_year = 7; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.3016;
{swaption_maturity_in_year = 8; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.2815;
{swaption_maturity_in_year = 9; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.26435;
{swaption_maturity_in_year = 10; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.2496;
{swaption_maturity_in_year = 15; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.2516;
{swaption_maturity_in_year = 20; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.28835;
{swaption_maturity_in_year = 25; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.27155;
{swaption_maturity_in_year = 30; swap_term_in_year = 1; swap_frequency = Freq_6M}, 0.23465;
{swaption_maturity_in_year = 1; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.61445;
{swaption_maturity_in_year = 2; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.54805;
{swaption_maturity_in_year = 3; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.46795;
{swaption_maturity_in_year = 4; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.3919;
{swaption_maturity_in_year = 5; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.3434;
{swaption_maturity_in_year = 6; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.3083;
{swaption_maturity_in_year = 7; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.28655;
{swaption_maturity_in_year = 8; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.2697;
{swaption_maturity_in_year = 9; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.25775;
{swaption_maturity_in_year = 10; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.2443;
{swaption_maturity_in_year = 15; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.26495;
{swaption_maturity_in_year = 20; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.28195;
{swaption_maturity_in_year = 25; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.26845;
{swaption_maturity_in_year = 30; swap_term_in_year = 2; swap_frequency = Freq_6M}, 0.20995;
{swaption_maturity_in_year = 1; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.5835;
{swaption_maturity_in_year = 2; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.49255;
{swaption_maturity_in_year = 3; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.42825;
{swaption_maturity_in_year = 4; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.3695;
{swaption_maturity_in_year = 5; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.329;
{swaption_maturity_in_year = 6; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.3022;
{swaption_maturity_in_year = 7; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.28165;
{swaption_maturity_in_year = 8; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.26615;
{swaption_maturity_in_year = 9; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.25485;
{swaption_maturity_in_year = 10; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.24375;
{swaption_maturity_in_year = 15; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.2718;
{swaption_maturity_in_year = 20; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.28135;
{swaption_maturity_in_year = 25; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.26865;
{swaption_maturity_in_year = 30; swap_term_in_year = 3; swap_frequency = Freq_6M}, 0.2131;
{swaption_maturity_in_year = 1; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.5415;
{swaption_maturity_in_year = 2; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.46235;
{swaption_maturity_in_year = 3; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.403;
{swaption_maturity_in_year = 4; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.3559;
{swaption_maturity_in_year = 5; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.3232;
{swaption_maturity_in_year = 6; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.29675;
{swaption_maturity_in_year = 7; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.27715;
{swaption_maturity_in_year = 8; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.26385;
{swaption_maturity_in_year = 9; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.254;
{swaption_maturity_in_year = 10; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.2454;
{swaption_maturity_in_year = 15; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.27845;
{swaption_maturity_in_year = 20; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.2821;
{swaption_maturity_in_year = 25; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.2678;
{swaption_maturity_in_year = 30; swap_term_in_year = 4; swap_frequency = Freq_6M}, 0.2131;
{swaption_maturity_in_year = 1; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.517;
{swaption_maturity_in_year = 2; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.446;
{swaption_maturity_in_year = 3; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.3903;
{swaption_maturity_in_year = 4; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.34755;
{swaption_maturity_in_year = 5; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.3166;
{swaption_maturity_in_year = 6; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.29305;
{swaption_maturity_in_year = 7; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.2745;
{swaption_maturity_in_year = 8; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.2639;
{swaption_maturity_in_year = 9; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.2534;
{swaption_maturity_in_year = 10; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.2499;
{swaption_maturity_in_year = 15; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.28315;
{swaption_maturity_in_year = 20; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.2825;
{swaption_maturity_in_year = 25; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.277;
{swaption_maturity_in_year = 30; swap_term_in_year = 5; swap_frequency = Freq_6M}, 0.21175;
{swaption_maturity_in_year = 1; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.478;
{swaption_maturity_in_year = 2; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.42105;
{swaption_maturity_in_year = 3; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.37715;
{swaption_maturity_in_year = 4; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.3378;
{swaption_maturity_in_year = 5; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.311;
{swaption_maturity_in_year = 6; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.2895;
{swaption_maturity_in_year = 7; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.2745;
{swaption_maturity_in_year = 8; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.264;
{swaption_maturity_in_year = 9; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.2573;
{swaption_maturity_in_year = 10; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.25475;
{swaption_maturity_in_year = 15; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.28815;
{swaption_maturity_in_year = 20; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.28195;
{swaption_maturity_in_year = 25; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.26015;
{swaption_maturity_in_year = 30; swap_term_in_year = 6; swap_frequency = Freq_6M}, 0.2097;
{swaption_maturity_in_year = 1; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.452;
{swaption_maturity_in_year = 2; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.4074;
{swaption_maturity_in_year = 3; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.368;
{swaption_maturity_in_year = 4; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.3307;
{swaption_maturity_in_year = 5; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.30645;
{swaption_maturity_in_year = 6; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.2877;
{swaption_maturity_in_year = 7; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.27475;
{swaption_maturity_in_year = 8; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.2664;
{swaption_maturity_in_year = 9; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.26155;
{swaption_maturity_in_year = 10; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.26035;
{swaption_maturity_in_year = 15; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.292;
{swaption_maturity_in_year = 20; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.2825;
{swaption_maturity_in_year = 25; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.25685;
{swaption_maturity_in_year = 30; swap_term_in_year = 7; swap_frequency = Freq_6M}, 0.2081;
{swaption_maturity_in_year = 1; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.43395;
{swaption_maturity_in_year = 2; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.39445;
{swaption_maturity_in_year = 3; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.35885;
{swaption_maturity_in_year = 4; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.3281;
{swaption_maturity_in_year = 5; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.30395;
{swaption_maturity_in_year = 6; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.28745;
{swaption_maturity_in_year = 7; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.2767;
{swaption_maturity_in_year = 8; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.27065;
{swaption_maturity_in_year = 9; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.26625;
{swaption_maturity_in_year = 10; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.26625;
{swaption_maturity_in_year = 15; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.2921;
{swaption_maturity_in_year = 20; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.2814;
{swaption_maturity_in_year = 25; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.25265;
{swaption_maturity_in_year = 30; swap_term_in_year = 8; swap_frequency = Freq_6M}, 0.2083;
{swaption_maturity_in_year = 1; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.42285;
{swaption_maturity_in_year = 2; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.3857;
{swaption_maturity_in_year = 3; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.3521;
{swaption_maturity_in_year = 4; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.3239;
{swaption_maturity_in_year = 5; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.30285;
{swaption_maturity_in_year = 6; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.2895;
{swaption_maturity_in_year = 7; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.2799;
{swaption_maturity_in_year = 8; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.27485;
{swaption_maturity_in_year = 9; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.2712;
{swaption_maturity_in_year = 10; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.27205;
{swaption_maturity_in_year = 15; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.29205;
{swaption_maturity_in_year = 20; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.27855;
{swaption_maturity_in_year = 25; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.24945;
{swaption_maturity_in_year = 30; swap_term_in_year = 9; swap_frequency = Freq_6M}, 0.219;
{swaption_maturity_in_year = 1; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.41765;
{swaption_maturity_in_year = 2; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.38095;
{swaption_maturity_in_year = 3; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.34795;
{swaption_maturity_in_year = 4; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.3217;
{swaption_maturity_in_year = 5; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.30365;
{swaption_maturity_in_year = 6; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.2916;
{swaption_maturity_in_year = 7; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.2842;
{swaption_maturity_in_year = 8; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.27985;
{swaption_maturity_in_year = 9; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.2769;
{swaption_maturity_in_year = 10; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.2775;
{swaption_maturity_in_year = 15; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.306;
{swaption_maturity_in_year = 20; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.2763;
{swaption_maturity_in_year = 25; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.2458;
{swaption_maturity_in_year = 30; swap_term_in_year = 10; swap_frequency = Freq_6M}, 0.22;
{swaption_maturity_in_year = 1; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.37905;
{swaption_maturity_in_year = 2; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.35465;
{swaption_maturity_in_year = 3; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.33505;
{swaption_maturity_in_year = 4; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.31725;
{swaption_maturity_in_year = 5; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.3008;
{swaption_maturity_in_year = 6; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.29075;
{swaption_maturity_in_year = 7; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.28365;
{swaption_maturity_in_year = 8; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.2787;
{swaption_maturity_in_year = 9; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.27385;
{swaption_maturity_in_year = 10; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.2709;
{swaption_maturity_in_year = 15; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.2689;
{swaption_maturity_in_year = 20; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.24225;
{swaption_maturity_in_year = 25; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.2096;
{swaption_maturity_in_year = 30; swap_term_in_year = 15; swap_frequency = Freq_6M}, 0.18285;
{swaption_maturity_in_year = 1; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.37975;
{swaption_maturity_in_year = 2; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.3605;
{swaption_maturity_in_year = 3; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.3407;
{swaption_maturity_in_year = 4; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.321;
{swaption_maturity_in_year = 5; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.3063;
{swaption_maturity_in_year = 6; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.29315;
{swaption_maturity_in_year = 7; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.28395;
{swaption_maturity_in_year = 8; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.2777;
{swaption_maturity_in_year = 9; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.27205;
{swaption_maturity_in_year = 10; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.26675;
{swaption_maturity_in_year = 15; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.24875;
{swaption_maturity_in_year = 20; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.21735;
{swaption_maturity_in_year = 25; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.1939;
{swaption_maturity_in_year = 30; swap_term_in_year = 20; swap_frequency = Freq_6M}, 0.17205;
{swaption_maturity_in_year = 1; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.38115;
{swaption_maturity_in_year = 2; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.3627;
{swaption_maturity_in_year = 3; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.34425;
{swaption_maturity_in_year = 4; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.3222;
{swaption_maturity_in_year = 5; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.3084;
{swaption_maturity_in_year = 6; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.2941;
{swaption_maturity_in_year = 7; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.28285;
{swaption_maturity_in_year = 8; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.2751;
{swaption_maturity_in_year = 9; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.2663;
{swaption_maturity_in_year = 10; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.26055;
{swaption_maturity_in_year = 15; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.2338;
{swaption_maturity_in_year = 20; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.20735;
{swaption_maturity_in_year = 25; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.1823;
{swaption_maturity_in_year = 30; swap_term_in_year = 25; swap_frequency = Freq_6M}, 0.1686;
{swaption_maturity_in_year = 1; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.38285;
{swaption_maturity_in_year = 2; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.3633;
{swaption_maturity_in_year = 3; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.34125;
{swaption_maturity_in_year = 4; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.3188;
{swaption_maturity_in_year = 5; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.30305;
{swaption_maturity_in_year = 6; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.2888;
{swaption_maturity_in_year = 7; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.2748;
{swaption_maturity_in_year = 8; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.26725;
{swaption_maturity_in_year = 9; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.25985;
{swaption_maturity_in_year = 10; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.25165;
{swaption_maturity_in_year = 15; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.2267;
{swaption_maturity_in_year = 20; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.1989;
{swaption_maturity_in_year = 25; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.18115;
{swaption_maturity_in_year = 30; swap_term_in_year = 30; swap_frequency = Freq_6M}, 0.16355;
|]
let named_variables =
let open Optimization in
[|
("a", Optimize_value {lower_bound = 0.; upper_bound = 1.; initial_value = 0.02});
("b", Optimize_value {lower_bound = 0.; upper_bound = 1.; initial_value = 0.02});
("sigma", Optimize_value {lower_bound = 0.; upper_bound = 0.2; initial_value = 0.04});
("nu", Optimize_value {lower_bound = 0.; upper_bound = 0.2; initial_value = 0.01});
("rho", Optimize_value {lower_bound = -1.; upper_bound = 1.; initial_value = 0.0});
|]
let variables = Array.map snd named_variables
let r = 0.03
let today = Date.of_string "2012-01-01"
let zc t = exp (-.0.03 *. (act_365 t today))
let sq x = x *. x
let () =
let {Optimization.cr_parameters = params; cr_root_mean_squared_error; cr_quoted_prices = _; cr_calibrated_prices = _} =
calibrate ~feedback: print_endline ~max_global: 2000 ~today ~swaption_quotes ~variables ~zc ()
in
let {g_a; g_b; g_sigma; g_nu; g_rho} = params in
let l = Array.to_list swaption_quotes in
let rms =
List.fold_left
(fun acc (swaption, quote) ->
let g2pp_price = pricer_of_swaption ~today ~zc swaption params in
let market_price = black_price ~today ~zc swaption quote in
Printf.printf "%dY%dY Swaption Calibrated Price: %.2f Market Price: %.2f\n" swaption.swaption_maturity_in_year swaption.swap_term_in_year (10000. *. g2pp_price) (10000. *. market_price);
acc +. sq ((g2pp_price -. market_price) /. market_price)
) 0. l;
in
let rms = 100. *. sqrt (rms /. (float (List.length l))) in
Printf.printf "a = %.5f, b = %.5f, sigma = %.5f, nu = %.5f, rho = %.5f\n" g_a g_b g_sigma g_nu g_rho;
Printf.printf "RMS = %.5f%%, re calculated RMS = %.5f%%\n" cr_root_mean_squared_error rms
let () =
try
let fn = Sys.getenv "OCAML_GC_STATS" in
let oc = open_out fn in
Gc.print_stat oc
with _ -> ()
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/math.ml
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
let p, a1, a2, a3, a4, a5 = 0.3275911, 0.254829592, (-0.284496736), 1.421413741, (-1.453152027), 1.061405429
let erf x =
let t = 1. /. (1. +. p *. x) in
let t2 = t *. t in
let t3 = t *. t2 in
let t4 = t *.t3 in
let t5 = t *. t4 in
1. -. (a1 *. t +. a2 *. t2 +. a3 *. t3 +. a4 *. t4 +. a5 *. t5) *. exp (-.x *. x)
(** Unit gaussian CDF. *)
let ugaussian_P x =
let u = x /. sqrt 2. in
let erf = if u < 0. then -.erf (-.u) else erf u in
0.5 *. (1. +. erf)
module Rootfinder = struct
type error =
| NotbracketedBelow
| NotbracketedAbove
let string_of_error = function
| NotbracketedBelow -> "Interval borders have both negative values."
| NotbracketedAbove -> "Interval borders have both positive values."
exception Rootfinder of error
let brent a b eval eps =
if a > b then invalid_arg "Math.brent: arguments should verify xlo <= xhi.";
let fa, fb = eval a, eval b in
if 0. < fa *. fb then raise(Rootfinder(if fa < 0. then NotbracketedBelow else NotbracketedAbove));
assert (0. <= eps);
let maxit = 10_000 in
let a, fa, b, fb = if abs_float fa < abs_float fb then b, fb, a, fa else a, fa, b, fb in
(* The root is between a and b, such that |f(b)| < |f(a)| *)
let rec iter i ~a ~b ~c ~d ~fa ~fb ~fc mflag =
if abs_float (b -. a) < eps || fb = 0. || maxit < i then b (* stop condition *)
else
let s =
if fa <> fc && fb <> fc then
a *. fb *. fc /. ((fa -. fb) *. (fa -. fc)) +. b *. fa *. fc /. ((fb -. fa) *. (fb -. fc)) +. c *. fa *. fb /. ((fc -. fa) *. (fc -. fb)) (* inverse quadratic interpolation *)
else
b -. fb *. (b -. a) /. (fb -. fa) (* secant rule *)
in
let s, mflag =
if
(4. *. s < 3. *. a +. b || b < s) ||
(mflag && 2. *. abs_float (s -. b) >= abs_float (b -. c)) ||
(not mflag && 2. *. abs_float (s -. b) >= abs_float (c -. d)) ||
(mflag && abs_float (b -. c) < eps) ||
(not mflag && abs_float (c -. d) < eps)
then 0.5 *. (a +. b), true else s, false
in
let fs = eval s in
(* d <- c; c <- b; *)
if fa *. fs < 0. then (* in this case, b <- s *)
if abs_float fa < abs_float fs then iter (i + 1) ~a: s ~b: a ~c: b ~d: c ~fa: fs ~fb: fa ~fc: fb mflag (* switch a, b *)
else iter (i + 1) ~a ~b: s ~c: b ~d: c ~fa ~fb: fs ~fc: fb mflag
else (* in this case, a <- s *)
if abs_float fs < abs_float fb then iter (i + 1) ~a: b ~b: s ~c: b ~d: c ~fa: fb ~fb: fs ~fc: fb mflag (* switch a, b *)
else iter (i + 1) ~a: s ~b ~c: b ~d: c ~fa: fs ~fb ~fc: fb mflag
in
iter 0 ~a ~b ~c: a ~d: nan ~fa ~fb ~fc: fa true
end
module Gaussian_quadrature =
struct
let gauss_hermite_coefficients =
[|
0.; 0.6568095668820999044613; -0.6568095668820997934390; -1.3265570844949334805563; 1.3265570844949330364670; 2.0259480158257567872226;
-2.0259480158257558990442; -2.7832900997816496513337; 2.7832900997816474308877; 3.6684708465595856630159; -3.6684708465595838866591
|],
[|
0.6547592869145917315876; 0.6609604194409607336169; 0.6609604194409606225946; 0.6812118810666693002887; 0.6812118810666689672217; 0.7219536247283847574252;
0.7219536247283852015144; 0.8025168688510405656800; 0.8025168688510396775015; 1.0065267861723647957461; 1.0065267861723774522886
|]
end
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/math.mli
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
val ugaussian_P : float -> float
(** The cumulative distribution function for a normal variate with mean 0 and
variance 1. [ugaussian_P x] returns the probability that a variate takes a
value less than or equal to [x]. *)
module Rootfinder: sig
type error =
| NotbracketedBelow (** The function is below zero on both the given brackets. *)
| NotbracketedAbove (** The function is above zero on both the given brackets. *)
val string_of_error: error -> string
(** Pretty-printing of error. *)
exception Rootfinder of error
val brent: float -> float -> (float -> float) -> float -> float
(** [brent xlo xhi f eps] finds a root of function [f] given that
it is bracketed by [xlo, xhi]. [eps] is the absolute error on the
returned root. Raises {!Rootfinder.Rootfinder} exception when an error is encountered.
The root is found using brent's method (http://en.wikipedia.org/wiki/Brent's_method).
Requires [xlo < xhi]. *)
end
module Gaussian_quadrature:
sig
val gauss_hermite_coefficients: float array * float array
(** [gauss_hermite_coefficients nb_points] returns two arrays [x] and [w] such that
for all [f], the integral of [f] over \]-infty; infty\[ is approximated by \sum w_i f(x_i).
the approximation is good if [f(x)] is close to [exp(-x^2) * P(x)] with [P] a polynomial, and is exact
if [P] is a polynomial of degree less or equal to [2 * nb_points - 1]
*)
end
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/optimization.ml
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
(* Optimizations algorithm. *)
type termination =
{
maxit: int;
maxf: int;
target: float;
}
type status =
| Maxit_reached
| Maxf_reached
| Target_reached
type result =
{
x0: float array;
f: float;
nb_feval: int;
status: status;
}
let ( ** ) (x, f) r = match x with | None -> r | Some x -> f r x
exception Infeasible
let f_incr f ncalls x =
let f =
try
f x
with
| Infeasible -> infinity
in
incr ncalls;
f
module Rand = Random.State
module DE =
struct
type t =
{
np: int; (* Population size *)
cr: float; (* Crossover probability, in [0; 1] *)
}
let default_parameters n = {np = min (10 * n) 40; cr = 0.9;}
let parameters ?np ?cr n =
(cr, fun r cr -> {r with cr}) **
(np, fun r np -> {r with np}) **
default_parameters n
let optimize {np; cr;} ~f ~lower_bounds ~upper_bounds ~call_back ~termination =
let n = Array.length lower_bounds in
let rng = Rand.make [| 0 |] in
let ncalls = ref 0 in
let f = f_incr f ncalls in
let {maxit; maxf; target;} = termination in
let fx = Array.make np 0. in
let fx0 = ref infinity in (* current min *)
let v = Array.make_matrix np n 0. in (* potential mutations *)
let best_idx = ref 0 in (* index of x0 in x *)
(* initialize current population *)
let x =
Array.init np
(fun i ->
let x_i = Array.init n
(fun j ->
let blo = lower_bounds.(j) in
let db = upper_bounds.(j) -. blo in
blo +. db *. Rand.float rng 1.)
in
let f = f x_i in
fx.(i) <- f;
if f < !fx0 then
begin
best_idx := i;
fx0 := f;
call_back !ncalls f
end;
x_i)
in
let x0 = Array.copy x.(!best_idx) in
let mutation difw i x_i v_i =
(* draw successively _different_ random integers in [0; np - 1] \ {i} *)
let drawn = ref [i] in
let range = ref (np - 1) in
let rand () =
let res = ref 0 in
let rec adjust v = function
| drawn :: others when drawn <= v -> drawn :: adjust (v + 1) others
| drawn -> res := v; v :: drawn
in
drawn := adjust (Rand.int rng !range) !drawn;
decr range;
x.(!res)
in
let x_r1 = if Rand.float rng 1. <= 0.5 then x.(!best_idx) else rand () in
let x_r2 = rand () in
let x_r3 = rand () in
let j0 = Rand.int rng n in
for j = 0 to n - 1 do
let v =
let aux = x_r1.(j) +. difw *. (x_r2.(j) -. x_r3.(j)) in
if (j = j0 || Rand.float rng 1. <= cr) && lower_bounds.(j) <= aux && aux <= upper_bounds.(j) then
aux
else
x_i.(j)
in
v_i.(j) <- v
done
in
let recombination () =
Array.iteri
(fun i v_i ->
let f = f v_i in
if f < fx.(i) then
begin
fx.(i) <- f;
Array.blit v_i 0 x.(i) 0 n;
if f < !fx0 then
begin
best_idx := i;
fx0 := f;
call_back !ncalls f;
Array.blit v_i 0 x0 0 n
end;
end;
)
v
in
let rec iter nb_it =
let differential_weight = 0.5 +. Rand.float rng 0.5 in (* As recommanded on http://www.icsi.berkeley.edu/~storn/code.html#prac *)
Array.iteri (fun i x_i -> mutation differential_weight i x_i v.(i)) x;
recombination ();
let res status = {x0; f = !fx0; nb_feval = !ncalls; status} in
if !fx0 <= target then res Target_reached
else if maxf < !ncalls then res Maxf_reached
else if nb_it = 0 then res Maxit_reached
else iter (nb_it - 1)
in
iter maxit
end
type range =
{
lower_bound: float;
upper_bound: float;
initial_value: float;
}
type optimization_variable =
| Fixed_value of float
| Optimize_value of range
type 'a calibration_result =
{
cr_parameters: 'a;
cr_root_mean_squared_error: float; (* Calibrated rms. *)
cr_quoted_prices: float array; (* i.e. quoted_prices. *)
cr_calibrated_prices: float array; (* Closed-form prices obtained with calibrated parameters. *)
}
let least_squares
?absolute
?feedback
~max_global
~parameters_of_vector
~pricer
~variables
quotes
=
begin
match feedback with
| Some feedback -> feedback "Calibrating"
| _ -> ()
end;
let free_var_index_to_var_index, strict_subset, x, lower_bounds, upper_bounds =
let _i, free_vars_to_vars, strict_subset, x, lo, up =
Array.fold_left
(fun (i, free_vars_to_vars, strict_subset, x, lo, up) -> function
| Fixed_value _ -> i + 1, free_vars_to_vars, true, x, lo, up
| Optimize_value{initial_value; lower_bound; upper_bound} -> i + 1, i :: free_vars_to_vars, strict_subset, initial_value :: x, lower_bound :: lo, upper_bound :: up
)
(0, [], false, [], [], [])
variables
in
Array.of_list(List.rev free_vars_to_vars), strict_subset, x, Array.of_list(List.rev lo), Array.of_list(List.rev up)
in
let parameters_of_active_vars = match strict_subset with
| false -> parameters_of_vector
| true ->
let all_vars = Array.map (function | Fixed_value x -> x | Optimize_value _ -> nan) variables in
fun x ->
Array.iteri (fun i x -> all_vars.(free_var_index_to_var_index.(i)) <- x) x;
parameters_of_vector all_vars
in
let m = Array.length quotes in
let prices = Array.make m 0. in
let norm = match absolute with
| None -> fun acc price quote -> let rel = (price -. quote) /. quote in acc +. rel *. rel
| Some() -> fun acc price quote -> let dif = price -. quote in acc +. dif *. dif
in
let quotes_idx = Array.(init (length quotes) (fun i -> i)) in
let distance prices = Array.fold_left (fun acc i -> norm acc prices.(i) quotes.(i)) 0. quotes_idx in (* objective is L_2 norm *)
let rms_of_error =
let div = 10000. /. float_of_int m in
fun err -> sqrt (err *. div) in
(* Initial guess either from global optimization or argument of the calibration routine. *)
let x =
if max_global > 0 then
let call_back =
match feedback with
| None -> fun _ _ -> ()
| Some f -> (fun evals dist -> Printf.ksprintf f "Global Optimizer Evals: %5i RMS: %12.8g%%" evals (rms_of_error dist))
in
let f x =
pricer (parameters_of_active_vars x) prices;
distance prices
in
let {x0; _} = DE.optimize (DE.default_parameters (Array.length lower_bounds)) ~f ~lower_bounds ~upper_bounds ~call_back ~termination: {maxit = max_int; maxf = max_global; target = 0.;} in
x0
else
Array.of_list(List.rev x)
in
let cr_quoted_prices = quotes in
let cr_parameters = parameters_of_active_vars x in
pricer cr_parameters prices;
{
cr_parameters;
cr_root_mean_squared_error = rms_of_error (distance prices);
cr_quoted_prices;
cr_calibrated_prices = prices;
}
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/benchmarks/benchmark-others/lexifi-g2pp/optimization.mli
|
(***************************************************************************)
(* Copyright (C) 2000-2013 LexiFi SAS. All rights reserved. *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published *)
(* by the Free Software Foundation, either version 3 of the License, *)
(* or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(***************************************************************************)
type termination =
{
maxit: int;
maxf: int;
target: float;
}
type status =
| Maxit_reached
| Maxf_reached
| Target_reached
type result =
{
x0: float array;
f: float;
nb_feval: int;
status: status;
}
module DE:
(** Implementation based on Differential Evolution - A Simple and Efficient Heuristic for Global Optimization over Continuous Spaces,
Rainer Storn and Kenneth Price.
Implemented srategies is a mixture of DE/rand/1/bin and DE/best/1/bin. The mutatant is lambda *. DE/rand/1/bin +. (1. -. lambda) *. DE/best/1/bin
where lambda is randomly choosen for each generation.
*)
sig
type t
val default_parameters: int -> t
val parameters: ?np: int -> ?cr: float -> int -> t
end
(** {2 Least Square Minimization} *)
exception Infeasible
(** To be raised by optimization callback functions to indicate that a point is infeasible. *)
type 'a calibration_result =
{
cr_parameters: 'a;
cr_root_mean_squared_error: float;
cr_quoted_prices: float array;
cr_calibrated_prices: float array;
}
(** General calibration result. It contains the model parameters of type ['a]
and some optional additional informations:
- [cr_parameters]. The optimal model parameter set
- [cr_root_mean_squared_error]. Root-mean-squared error of optimal fit
- [cr_quoted_prices]. Quotes to be fitted
- [cr_calibrated_prices]. Optimal model price of each quote
*)
type range = {
lower_bound: float;
upper_bound: float;
initial_value: float;
}
type optimization_variable =
| Fixed_value of float
| Optimize_value of range
val least_squares:
?absolute: unit ->
?feedback: (string -> unit) ->
max_global:int ->
parameters_of_vector:(float array -> 'parameters) ->
pricer:('parameters -> float array -> unit) ->
variables:optimization_variable array ->
float array ->
'parameters calibration_result
(** [least_squares ~pricer ~lo ~up quotes] outputs a vector of calibrated parameters. These calibrated parameters
correspond to the least square fitting of quotes from the [quotes] list and results of applying the [price] function.
This optimization is done first using Direct as a global optimizer then using Minpack as a local optimizer.
The input are:
- [pricer] is the pricer function; it takes as input a vector of parameters (to be optimized) and a price vector.
The price vector is filled by this function in order to be compared to quotes from the [quotes] list.
- [x] is the original value for the parameters. This is only used if no global optimization is performed, i.e. if [max_global] is 0.
- [lo] contains lower bounds for each parameters.
- [up] contains upper bounds for each parameters.
- [quotes] is the list of quotes to be matched by the least-square algorithm.
Optional parameters are:
- [absolute] is an optional parameter. If set, the distance is the absolute difference, not the default relative one.
- [feedback] is a feedback function that can be used to print the current RMS.
- [max_global] is the maximum number of steps performed in the global optimization (DE).
- [max_local] is the maximum number of steps performed in the local optimization (Minpack).
Note that [x], [lo], and [up] must have the same size. This size is the number of parameters, it is also equal to the size of
the vector in the output and should be equal to the size of the vector used as the first argument of the [price] function.
The size of the second argument of the [price] function should be equal to the length of the [quotes] list.
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/benchmark-partial-render-table/summarize_results.ml
|
let delim = Str.regexp_string "│"
let geometric_mean l =
exp (List.fold_left ( +. ) 0. (List.map log l) /. float (List.length l))
let parse s =
Scanf.sscanf (String.trim s) "%f%s"
@@ fun f u ->
match u with
| "ns" -> f *. 1e-6
| "us" -> f *. 1e-3
| "ms" -> f
| "s" -> f *. 1e3
| _ -> assert false
let () =
let measures = ref [] in
(try
while true do
let l = read_line () in
if String.starts_with ~prefix:"├" l
then
let l = read_line () |> Str.split delim |> List.tl |> List.map parse in
measures := l @ !measures
done
with End_of_file -> ());
Format.printf
{|{ "name": "%s",
"results":
[ { "name": "Partial Render Table",
"metrics":
[ { "name": "Execution time (geometric mean)",
"units": "ms",
"value": %f } ] } ] }@.|}
(String.capitalize_ascii Sys.argv.(1))
(geometric_mean !measures)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/common.ml
|
(* Js_of_ocaml benchmarks
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2011 Jérôme Vouillon
* Laboratoire PPS - CNRS Université Paris Diderot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open StdLabels
let split_on_char ~sep s =
let r = ref [] in
let j = ref (String.length s) in
for i = String.length s - 1 downto 0 do
if String.unsafe_get s i = sep
then (
r := String.sub s ~pos:(i + 1) ~len:(!j - i - 1) :: !r;
j := i)
done;
String.sub s ~pos:0 ~len:!j :: !r
let mean a =
let s = ref 0. in
for i = 0 to Array.length a - 1 do
s := !s +. a.(i)
done;
!s /. float (Array.length a)
let mean_variance a =
let m = mean a in
let s = ref 0. in
for i = 0 to Array.length a - 1 do
let d = a.(i) -. m in
s := !s +. (d *. d)
done;
(* https://en.wikipedia.org/wiki/Unbiased_estimation_of_standard_deviation
https://en.wikipedia.org/wiki/Bessel%27s_correction *)
m, !s /. float (Array.length a - 1)
(* 90% 95% 98% 99% 99.5% 99.8% 99.9%*)
let tinv_table =
[| 1, [| 6.314; 12.71; 31.82; 63.66; 127.3; 318.3; 636.6 |]
; 2, [| 2.920; 4.303; 6.965; 9.925; 14.09; 22.33; 31.60 |]
; 3, [| 2.353; 3.182; 4.541; 5.841; 7.453; 10.21; 12.92 |]
; 4, [| 2.132; 2.776; 3.747; 4.604; 5.598; 7.173; 8.610 |]
; 5, [| 2.015; 2.571; 3.365; 4.032; 4.773; 5.893; 6.869 |]
; 6, [| 1.943; 2.447; 3.143; 3.707; 4.317; 5.208; 5.959 |]
; 7, [| 1.895; 2.365; 2.998; 3.499; 4.029; 4.785; 5.408 |]
; 8, [| 1.860; 2.306; 2.896; 3.355; 3.833; 4.501; 5.041 |]
; 9, [| 1.833; 2.262; 2.821; 3.250; 3.690; 4.297; 4.781 |]
; 10, [| 1.812; 2.228; 2.764; 3.169; 3.581; 4.144; 4.587 |]
; 11, [| 1.796; 2.201; 2.718; 3.106; 3.497; 4.025; 4.437 |]
; 12, [| 1.782; 2.179; 2.681; 3.055; 3.428; 3.930; 4.318 |]
; 13, [| 1.771; 2.160; 2.650; 3.012; 3.372; 3.852; 4.221 |]
; 14, [| 1.761; 2.145; 2.624; 2.977; 3.326; 3.787; 4.140 |]
; 15, [| 1.753; 2.131; 2.602; 2.947; 3.286; 3.733; 4.073 |]
; 16, [| 1.746; 2.120; 2.583; 2.921; 3.252; 3.686; 4.015 |]
; 17, [| 1.740; 2.110; 2.567; 2.898; 3.222; 3.646; 3.965 |]
; 18, [| 1.734; 2.101; 2.552; 2.878; 3.197; 3.610; 3.922 |]
; 19, [| 1.729; 2.093; 2.539; 2.861; 3.174; 3.579; 3.883 |]
; 20, [| 1.725; 2.086; 2.528; 2.845; 3.153; 3.552; 3.850 |]
; 21, [| 1.721; 2.080; 2.518; 2.831; 3.135; 3.527; 3.819 |]
; 22, [| 1.717; 2.074; 2.508; 2.819; 3.119; 3.505; 3.792 |]
; 23, [| 1.714; 2.069; 2.500; 2.807; 3.104; 3.485; 3.767 |]
; 24, [| 1.711; 2.064; 2.492; 2.797; 3.091; 3.467; 3.745 |]
; 25, [| 1.708; 2.060; 2.485; 2.787; 3.078; 3.450; 3.725 |]
; 26, [| 1.706; 2.056; 2.479; 2.779; 3.067; 3.435; 3.707 |]
; 27, [| 1.703; 2.052; 2.473; 2.771; 3.057; 3.421; 3.690 |]
; 28, [| 1.701; 2.048; 2.467; 2.763; 3.047; 3.408; 3.674 |]
; 29, [| 1.699; 2.045; 2.462; 2.756; 3.038; 3.396; 3.659 |]
; 30, [| 1.697; 2.042; 2.457; 2.750; 3.030; 3.385; 3.646 |]
; 40, [| 1.684; 2.021; 2.423; 2.704; 2.971; 3.307; 3.551 |]
; 50, [| 1.676; 2.009; 2.403; 2.678; 2.937; 3.261; 3.496 |]
; 60, [| 1.671; 2.000; 2.390; 2.660; 2.915; 3.232; 3.460 |]
; 80, [| 1.664; 1.990; 2.374; 2.639; 2.887; 3.195; 3.416 |]
; 100, [| 1.660; 1.984; 2.364; 2.626; 2.871; 3.174; 3.390 |]
; 120, [| 1.658; 1.980; 2.358; 2.617; 2.860; 3.160; 3.373 |]
|]
let tinv_row n =
let i = ref 1 in
let l = Array.length tinv_table in
while !i < l && fst tinv_table.(!i) <= n do
incr i
done;
snd tinv_table.(!i - 1)
let tinv95 n = (tinv_row n).(1)
let tinv98 n = (tinv_row n).(2)
let tinv99 n = (tinv_row n).(3)
let mean_with_confidence a =
let m, v = mean_variance a in
let l = Array.length a in
m, sqrt v /. sqrt (float l) *. tinv98 (l - 1)
let src = "sources"
let code = "build"
let hostname = Unix.gethostname ()
module Measure = struct
type t =
{ name : string
; units : string
; description : string option
; trend : string option
; path : string
; color : string option
}
end
let times =
Measure.
{ name = "execution-time"
; units = "s"
; description = Some "Execution time"
; trend = Some "lower-is-better"
; path = Filename.concat "results/times" hostname
; color = None
}
let sizes =
Measure.
{ name = "code-size"
; units = "B"
; description = Some "Code size"
; trend = Some "lower-is-better"
; path = "results/sizes"
; color = None
}
let compiletimes =
Measure.
{ name = "compile-time"
; units = "s"
; description = Some "Compile time"
; trend = Some "lower-is-better"
; path = Filename.concat "results/compiletimes" hostname
; color = None
}
module Spec : sig
type t
val name : t -> string
val create : string -> string -> t
val dir : root:string -> t -> string
val file : root:string -> t -> string -> string
val no_ext : t -> t
val sub_spec : t -> string -> t
val find_names : root:string -> t -> string list
val ml : t
val js : t
val byte : t
val opt : t
val js_of_ocaml : t
val js_of_ocaml_o3 : t
val js_of_ocaml_js_string : t
val wasm_of_ocaml : t
val byte_unsafe : t
val opt_unsafe : t
val js_of_ocaml_unsafe : t
val js_of_ocaml_inline : t
val js_of_ocaml_deadcode : t
val js_of_ocaml_compact : t
val js_of_ocaml_call : t
val js_of_ocaml_effects_cps : t
val js_of_ocaml_effects_double_translation : t
end = struct
type t =
{ dir : string
; ext : string
}
let name { dir; _ } = dir
let create dir ext = { dir; ext }
let no_ext { dir; _ } = { dir; ext = "" }
let file ~root { dir; ext } nm = Format.sprintf "%s/%s/%s%s" root dir nm ext
let dir ~root { dir; _ } = Format.sprintf "%s/%s" root dir
let sub_spec { dir; ext } loc = { dir = Format.sprintf "%s/%s" dir loc; ext }
let find_names ~root spec =
let dir = dir ~root spec in
Sys.readdir dir
|> Array.to_list
|> List.filter ~f:(fun nm ->
let open Unix in
match stat (dir ^ "/" ^ nm) with
| { st_kind = S_REG | S_LNK; _ } -> true
| _ -> false)
|> (if spec.ext = ""
then fun x -> x
else
fun x ->
x
|> List.filter ~f:(fun nm -> Filename.check_suffix nm spec.ext)
|> List.map ~f:Filename.chop_extension)
|> List.sort ~cmp:compare
let ml = create "ml" ".ml"
let js = create "js" ".js"
let byte = create "byte" ""
let opt = create "opt" ""
let js_of_ocaml = create "js_of_ocaml" ".js"
let js_of_ocaml_o3 = create "o3" ".js"
let js_of_ocaml_js_string = create "jsstring" ".js"
let wasm_of_ocaml = create "wasm_of_ocaml" ".js"
let byte_unsafe = create "unsafe/byte" ""
let opt_unsafe = create "unsafe/opt" ""
let js_of_ocaml_unsafe = create "unsafe/js_of_ocaml" ".js"
let js_of_ocaml_inline = create "noinline" ".js"
let js_of_ocaml_deadcode = create "nodeadcode" ".js"
let js_of_ocaml_compact = create "notcompact" ".js"
let js_of_ocaml_call = create "nooptcall" ".js"
let js_of_ocaml_effects_cps = create "effects-cps" ".js"
let js_of_ocaml_effects_double_translation = create "effects-double-translation" ".js"
end
let rec mkdir d =
if not (Sys.file_exists d)
then (
mkdir (Filename.dirname d);
Unix.mkdir d 0o777)
let need_update src dst =
try
let d = Unix.stat dst in
d.Unix.st_kind <> Unix.S_REG
||
let s = Unix.stat src in
d.Unix.st_mtime < s.Unix.st_mtime
with Unix.Unix_error (Unix.ENOENT, _, _) -> true
let measures_need_update code meas spec nm =
let p = Spec.file ~root:code spec nm in
let m = Spec.file ~root:meas.Measure.path (Spec.no_ext spec) nm in
need_update p m
let read_measures path spec nm =
let m = Spec.file ~root:path (Spec.no_ext spec) nm in
let l = ref [] in
if Sys.file_exists m
then (
let ch = open_in m in
(try
while true do
l := float_of_string (input_line ch) :: !l
done
with End_of_file -> ());
close_in ch;
!l)
else []
let write_measures meas spec nm l =
let m = Spec.file ~root:meas.Measure.path (Spec.no_ext spec) nm in
let tmp = Spec.file ~root:meas.Measure.path (Spec.no_ext spec) "_tmp_" in
mkdir (Spec.dir ~root:meas.Measure.path spec);
let ch = open_out tmp in
List.iter ~f:(fun t -> Printf.fprintf ch "%f\n" t) (List.rev l);
close_out ch;
Sys.rename tmp m
let read_interpreter_config file =
if not (Sys.file_exists file)
then (
Format.eprintf "Configuration file '%s' not found!@." file;
exit 1);
let i = ref [] in
let ch = open_in file in
(try
while true do
let line = String.trim (input_line ch) in
if line.[0] <> '#'
then
match
List.filter
~f:(function
| "" -> false
| _ -> true)
(split_on_char line ~sep:' ')
with
| "interpreter" :: nm :: rem -> i := (String.concat ~sep:" " rem, nm) :: !i
| [ "interpreter" ] ->
Format.eprintf "Malformed config option '%s'@." line;
exit 1
| kind :: _ ->
Format.eprintf "Unknown config option '%s'@." kind;
exit 1
| [] ->
Format.eprintf "Bad config line '%s'@." line;
exit 1
done
with End_of_file -> ());
close_in ch;
List.rev !i
let read_report_config ?(column_ref = -1) file =
if not (Sys.file_exists file)
then (
Format.eprintf "Configuration file '%s' not found!@." file;
exit 1);
let fullinfo = ref [] in
let info = ref [] in
let i = ref 0 in
let reference = ref false in
let ch = open_in file in
let split_at_space l =
try
let i = String.index l ' ' in
String.sub l ~pos:0 ~len:i, String.sub l ~pos:(i + 1) ~len:(String.length l - i - 1)
with Not_found -> l, ""
in
let get_info measure rem refe =
let dir0 = measure.Measure.path in
let dir1, rem = split_at_space rem in
let dir2, rem = split_at_space rem in
let color, title = split_at_space rem in
let dir1 = if dir1 = "\"\"" then dir0 else dir0 ^ "/" ^ dir1 in
let name = String.concat ~sep:"-" [ measure.Measure.name; title ] in
let description =
match measure.Measure.description with
| None -> None
| Some d -> Some (String.concat ~sep:", " [ d; title ])
in
let measure = Measure.{ measure with name; description; color = Some color } in
info := Some (dir1, dir2, measure, refe) :: !info
in
(try
while true do
let l = input_line ch in
if String.length l = 0
then (
if !info <> []
then (
fullinfo := List.rev !info :: !fullinfo;
info := [];
i := 0))
else if l.[0] <> '#'
then (
incr i;
reference := column_ref = !i;
let kind, rem = split_at_space l in
let kind2, rem = split_at_space rem in
(match kind with
| "histogram" -> ()
| "histogramref" when column_ref < 0 -> reference := true
| _ ->
Format.eprintf "Unknown config options '%s'@." kind;
exit 1);
match kind2 with
| "blank" -> info := None :: !info
| "times" -> get_info times rem !reference
| "compiletimes" -> get_info compiletimes rem !reference
| "sizes" -> get_info sizes rem !reference
| _ ->
Format.eprintf "Unknown config options '%s'@." kind2;
exit 1)
done
with End_of_file -> ());
close_in ch;
if !info <> [] then fullinfo := List.rev !info :: !fullinfo;
List.rev !fullinfo
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/benchmarks/dune
|
(executables
(names report run stripdebug)
(libraries unix compiler-libs.bytecomp yojson))
(alias
(name default)
(deps report.exe run.exe))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/report.ml
|
(* Js_of_ocaml benchmarks
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2011 Jérôme Vouillon
* Laboratoire PPS - CNRS Université Paris Diderot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open StdLabels
open Common
let reference = ref None
let maximum = ref (-1.)
let minimum = ref 0.
let omitted = ref []
let appended = ref []
let errors = ref false
let svg = ref false
let svgfontsize = ref 7
let svgwidth = ref 500
let svgheight = ref 150
let edgecaption = ref false
let ylabel = ref ""
let rec merge f l1 l2 =
match l1, l2 with
| [], _ | _, [] -> []
| (n1, v1) :: r1, (n2, v2) :: r2 ->
if n1 < n2
then merge f r1 l2
else if n1 > n2
then merge f l1 r2
else (n1, f v1 v2) :: merge f r1 r2
let merge_blank = List.map ~f:(fun (n2, v2) -> n2, (0.0, 0.0) :: v2)
let read_column ~measure path spec refe :
(Measure.t option list * (string * (float * float) list) list) option =
let l =
List.map
(Spec.find_names ~root:path (Spec.no_ext spec))
~f:(fun nm ->
let l = read_measures path spec nm in
let a = Array.of_list l in
let m, i = mean_with_confidence a in
nm, [ m, i ])
in
if refe then reference := Some l;
Some ([ Some measure ], l)
let read_blank_column () = None
let rec list_create n a = if n = 0 then [] else a :: list_create (n - 1) a
let merge_columns l old_table =
let rec aux = function
| [] | [ None ] -> [], []
| [ Some c ] -> c
| Some (h, c) :: r ->
let h', t = aux r in
h @ h', merge (fun v1 v2 -> v1 @ v2) c t
| None :: r ->
let h', t = aux r in
(*VVV utile ? *)
None :: h', merge_blank t
in
let rec remove_head_blank = function
| None :: l ->
let n, ll = remove_head_blank l in
n + 1, ll
| l -> 0, l
in
let add_blanks n (h, t) =
if n = 0
then h, t
else
let zeros = list_create n (0.0, 0.0) in
(*VVV utile ? *)
let nodisplays = list_create n None in
h @ nodisplays, List.map t ~f:(fun (a, l) -> a, l @ zeros)
in
(* if there was an old table, we keep only the lines corresponding
to entries in that table *)
let l =
match l, old_table with
| [], _ -> []
| _, None -> l
| Some (h, c) :: ll, Some o -> Some (h, merge (fun v1 _v2 -> v1) c o) :: ll
| None :: ll, Some o ->
Some ([ None ], List.map o ~f:(fun (nm, _) -> nm, [ 0.0, 0.0 ])) :: ll
in
let nb_blanks, l = remove_head_blank (List.rev l) in
let l = List.rev l in
add_blanks nb_blanks (aux l)
let normalize (h, t) =
match !reference with
| None -> h, t
| Some rr ->
( h
, List.map t ~f:(fun (nm, l) ->
let r, _ = List.hd (List.assoc nm rr) in
if r <> r
then (
Format.eprintf "No reference available for '%s'@." nm;
exit 1);
nm, List.map l ~f:(fun (v, i) -> v /. r, i /. r)) )
let stats (h, t) =
for i = 0 to List.length h - 1 do
match List.nth h i with
| Some Measure.{ name = nm; _ } ->
let l = List.map t ~f:(fun (_, l) -> fst (List.nth l i)) in
let a = Array.of_list l in
Array.sort a ~cmp:compare;
let p = List.fold_right l ~f:(fun x p -> x *. p) ~init:1. in
Format.eprintf
"%s:@. %f %f@."
nm
(p ** (1. /. float (List.length l)))
a.(Array.length a / 2)
| None -> ()
done
let escape_name_for_gnuplot s =
let b = Buffer.create (String.length s) in
String.iter s ~f:(function
| '_' -> Buffer.add_string b {|\\\_|}
| c -> Buffer.add_char b c);
Buffer.contents b
let text_output _no_header (h, t) =
Format.printf "-";
List.iter h ~f:(fun v ->
let nm =
match v with
| Some Measure.{ name; _ } -> name
| None -> ""
in
Format.printf " - \"%s\"" nm);
Format.printf "@.";
List.iter t ~f:(fun (nm, l) ->
Format.printf "%s" nm;
List.iter l ~f:(fun (m, i) -> Format.printf " %f %f" m i);
Format.printf "@.")
let gnuplot_output ch no_header (h, t) =
let n = List.length (snd (List.hd t)) in
if not no_header
then (
if !svg
then
Printf.fprintf
ch
"set terminal svg size %d %d font 'Arial,%d'\n"
!svgwidth
!svgheight
!svgfontsize;
if !edgecaption
then Printf.fprintf ch "set key tmargin horizontal Left left reverse\n";
Printf.fprintf
ch
"set multiplot\n\
set style data histograms\n\
set style fill solid 1 border rgb 'black'\n\
set style histogram errorbars gap 1%s\n\
set xtics border in scale 0,0 nomirror rotate by -30 offset character 0, 0, 0\n"
(if !errors then " lw 1" else "");
if !ylabel <> "" then Printf.fprintf ch "set ylabel \"%s\"\n" !ylabel;
if !maximum > 0.
then Printf.fprintf ch "set yrange [%f:%f]\n" !minimum !maximum
else Printf.fprintf ch "set yrange [0:]\n");
(* labels *)
for i = 0 to n - 1 do
let nn = ref 0. in
List.iter t ~f:(fun (_nm, l) ->
let v, _ii = List.nth l i in
if !maximum > 0. && v > !maximum
then
Printf.fprintf
ch
"set label font \",5\" \"%.2f\" at %f,%f center\n"
v
(!nn +. (float i /. float n) -. 0.5) (* why? *)
((!maximum *. 1.04) +. 0.01);
nn := !nn +. 1.)
done;
Printf.fprintf ch "plot";
for i = 0 to n - 1 do
match List.nth h i with
| Some Measure.{ color; _ } -> (
if i > 0
then Printf.fprintf ch ", \"-\" using 2:3 title columnhead lw 0"
else Printf.fprintf ch " \"-\" using 2:3:xtic(1) title columnhead lw 0";
match color with
| Some c -> Printf.fprintf ch " lc rgb '%s'" c
| None -> ())
| None ->
if i > 0
then Printf.fprintf ch ", \"-\" using 2:3 title columnhead lw 0"
else Printf.fprintf ch " \"-\" using 2:3:xtic(1) title columnhead lw 0"
(* notitle does not work ... I don't know why ... *)
done;
Printf.fprintf ch "\n";
for i = 0 to n - 1 do
let nm =
match List.nth h i with
| Some Measure.{ name; _ } -> name
| None -> ""
in
Printf.fprintf ch "- \"%s\"\n" (escape_name_for_gnuplot nm);
List.iter t ~f:(fun (nm, l) ->
let v, ii = List.nth l i in
Printf.fprintf
ch
"\"%s\" %f %f\n"
(escape_name_for_gnuplot nm)
v
(if ii <> ii then 0. else ii));
Printf.fprintf ch "e\n"
done
let filter (h, t) =
let l1 =
List.filter t ~f:(fun (nm, _) ->
not (List.mem nm ~set:!appended || List.mem nm ~set:!omitted))
in
let app =
List.fold_left !appended ~init:[] ~f:(fun beg nm ->
try (nm, List.assoc nm t) :: beg with Not_found -> beg)
in
h, l1 @ app
let output_table =
let old_table = ref None in
fun (l : (Measure.t option list * _) option list) f ->
let t = merge_columns l !old_table in
old_table := Some (snd t);
let t = filter t in
let t = normalize t in
stats t;
f t
let rec transpose (l : (string * 'a list) list) : (string * 'a) list list =
match l with
| (_, _ :: _) :: _ ->
List.map ~f:(fun (label, data) -> label, List.hd data) l
:: transpose (List.map ~f:(fun (label, data) -> label, List.tl data) l)
| (_, []) :: _ | [] -> []
let geometric_mean l =
exp
(List.fold_left ~f:( +. ) ~init:0. (List.map l ~f:(fun (_, (v, _)) -> log v))
/. float (List.length l))
let current_bench_output
(ch : out_channel)
(_no_header : bool)
((header : Measure.t option list), (t : (string * (float * float) list) list)) =
let suite_name = !ylabel in
let measure_descs =
(* Filter out blank columns *)
List.filter_map header ~f:Fun.id
in
let measures = transpose t in
assert (List.length measures = List.length measure_descs);
let summary =
let metrics =
List.map2 measure_descs measures ~f:(fun desc measures ->
let description =
Option.value desc.Measure.description ~default:desc.Measure.name
in
let mean = geometric_mean measures in
`Assoc
[ "name", `String description
; "value", `Float mean
; "units", `String desc.Measure.units
])
in
`Assoc
[ "name", `String "Microbenchmarks - summary (geometric means)"
; "metrics", `List metrics
]
in
let results =
List.map2 measure_descs measures ~f:(fun desc measures ->
let description =
Option.value desc.Measure.description ~default:desc.Measure.name
in
let metrics : Yojson.Basic.t list =
List.map measures ~f:(fun (test_name, (m, _confidence_itvl)) ->
`Assoc
[ "name", `String test_name
; "value", `Float m
; "units", `String desc.Measure.units
])
in
`Assoc
[ "name", `String (String.concat ~sep:" - " [ "Microbenchmarks"; description ])
; "metrics", `List metrics
])
in
let json =
`Assoc [ "name", `String suite_name; "results", `List (summary :: results) ]
in
Yojson.Basic.to_channel ch json;
output_char ch '\n'
let output ~format conf =
let output_function, close =
match format with
| `Text -> text_output, fun () -> ()
| `Gnuplot_script -> gnuplot_output stdout, fun () -> ()
| `Gnuplot ->
let ch = Unix.open_process_out "gnuplot -persist" in
gnuplot_output ch, fun () -> close_out ch
| `Current_bench -> current_bench_output stdout, fun () -> ()
in
let no_header = ref false in
List.iter conf ~f:(fun conf ->
output_table
(List.map conf ~f:(function
| None -> read_blank_column ()
| Some (dir1, dir2, measure, refe) ->
read_column ~measure dir1 (Spec.create dir2 "") refe))
(output_function !no_header);
no_header := true);
close ()
let _ =
let conf = ref "report.config" in
let format : [ `Gnuplot | `Gnuplot_script | `Text | `Current_bench ] ref =
ref `Gnuplot
in
let script = ref false in
let nreference = ref None in
let options =
[ ( "-ref"
, Arg.Int (fun i -> nreference := Some i)
, "<col> use column <col> as the baseline. Overrides histogramref." )
; "-max", Arg.Set_float maximum, "<m> truncate graph at level <max>"
; "-min", Arg.Set_float minimum, "<m> truncate graph below level <min>"
; ( "-format"
, Arg.Symbol
( [ "gnuplot"; "table"; "current-bench" ]
, function
| "gnuplot" -> format := `Gnuplot
| "table" -> format := `Text
| "current-bench" -> format := `Current_bench
| _ -> assert false )
, " output format: a Gnuplot graph, a text table, or a JSON object for use by \
current-bench (default gnuplot)" )
; ( "-omit"
, Arg.String (fun s -> omitted := split_on_char s ~sep:',' @ !omitted)
, " omit the given benchmark" )
; ( "-append"
, Arg.String (fun s -> appended := split_on_char s ~sep:',' @ !appended)
, " append the given benchmark at the end" )
; "-errors", Arg.Set errors, " display error bars"
; "-config", Arg.Set_string conf, "<file> use <file> as a config file"
; "-script", Arg.Set script, " output gnuplot script"
; ( "-svg"
, Arg.Tuple
[ Arg.Set svg
; Arg.Set_int svgfontsize
; Arg.Set_int svgwidth
; Arg.Set_int svgheight
]
, "<fontsize> <width> <height> svg output" )
; "-edgecaption", Arg.Set edgecaption, " display caption outside the diagram"
; "-ylabel", Arg.Set_string ylabel, " Y axis label"
]
in
Arg.parse
(Arg.align options)
(fun s -> raise (Arg.Bad (Format.sprintf "unknown option `%s'" s)))
(Format.sprintf "Usage: %s [options]" Sys.argv.(0));
let format =
match !format, !script with
| `Gnuplot, true -> `Gnuplot_script
| `Gnuplot, false -> `Gnuplot
| _, true ->
Printf.eprintf "-script only work with gnuplot format";
exit 2
| ((`Gnuplot_script | `Text | `Current_bench) as x), false -> x
in
let conf = read_report_config ?column_ref:!nreference !conf in
output ~format conf
(*
http://hacks.mozilla.org/2009/07/tracemonkey-overview/
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/run.ml
|
(* Js_of_ocaml benchmarks
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2011 Jérôme Vouillon
* Laboratoire PPS - CNRS Université Paris Diderot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open StdLabels
open Common
module Param = struct
type t =
{ warm_up_time : float
; min_measures : int
; max_confidence : float
; max_duration : float
; verbose : bool
}
let default =
{ warm_up_time = 1.0
; min_measures = 10
; max_confidence = 0.03
; max_duration = 120.
; verbose = false
}
let fast x = { x with min_measures = 5; max_confidence = 0.15; max_duration = 20. }
let ffast x = { x with min_measures = 2; max_confidence = 42.; max_duration = 20. }
let verbose x = { x with verbose = true }
end
let run_command ~verbose cmd =
if verbose then Format.printf "+ %s@." cmd;
match Unix.system cmd with
| Unix.WEXITED res when res <> 0 ->
failwith (Printf.sprintf "Command '%s' failed with exit code %d." cmd res)
| Unix.WSIGNALED s ->
failwith (Format.sprintf "Command '%s' killed with signal %d." cmd s)
| _ -> ()
let time ~verbose cmd =
let t1 = (Unix.times ()).Unix.tms_cutime in
run_command ~verbose cmd;
let t2 = (Unix.times ()).Unix.tms_cutime in
t2 -. t1
let compile_gen
(param : Param.t)
~comptime
prog
src_dir
(src_spec : Spec.t)
dst_dir
dst_spec =
mkdir (Spec.dir ~root:dst_dir dst_spec);
List.iter (Spec.find_names ~root:src_dir src_spec) ~f:(fun nm ->
let src = Spec.file ~root:src_dir src_spec nm in
let dst = Spec.file ~root:dst_dir dst_spec nm in
if need_update src dst
then
let cmd = prog ~src ~dst in
try
if comptime
then write_measures compiletimes dst_spec nm [ time ~verbose:param.verbose cmd ]
else run_command ~verbose:param.verbose cmd
with Failure s -> Format.eprintf "Failure: %s@." s)
let compile param ~comptime prog =
compile_gen param ~comptime (fun ~src ~dst -> Printf.sprintf "%s %s -o %s" prog src dst)
(****)
let need_more ~print (param : Param.t) l =
let a = Array.of_list l in
let n = Array.length a in
if n = 0
then true
else
let m, i = mean_with_confidence a in
if print then Format.eprintf "==> %f +/- %f / %f %d\r%!" m i (i /. m) n;
n < param.min_measures || i /. m > param.max_confidence /. 2.
let warm_up (param : Param.t) cmd =
let t = ref 0. in
while !t < param.warm_up_time do
let t' =
time ~verbose:param.verbose (Printf.sprintf "timeout %f %s" param.max_duration cmd)
in
if t' > param.max_duration
then failwith (Printf.sprintf "Warmup took too long %.1fs" t');
t := !t +. t'
done
let rec measure_rec ~print (param : Param.t) cmd l =
let t = time ~verbose:param.verbose cmd in
let l = t :: l in
if need_more ~print param l then measure_rec ~print param cmd l else l
let measure_one param code (meas : Measure.t) spec nm cmd =
let l =
if measures_need_update code meas spec nm
then []
else read_measures meas.Measure.path spec nm
in
if need_more ~print:false param l
then (
Format.eprintf "warming up ...\r%!";
warm_up param cmd;
let l = measure_rec ~print:true param cmd l in
write_measures meas spec nm l;
Format.eprintf "\n%!";
l)
else l
let measure ~param ~code ~(meas : Measure.t) ~spec cmd =
List.iter (Spec.find_names ~root:code spec) ~f:(fun nm ->
let cmd = if cmd = "" then cmd else cmd ^ " " in
let cmd = Format.sprintf "%s%s" cmd (Spec.file ~root:code spec nm) in
Format.eprintf "Measure %s@." cmd;
try ignore (measure_one param code meas spec nm cmd)
with Failure s -> Format.eprintf "Failure: %s@." s)
(****)
let compile_no_ext param ~comptime prog src_dir src_spec dst_dir dst_spec =
compile_gen param ~comptime prog src_dir src_spec dst_dir (Spec.no_ext dst_spec)
let ml_size param =
compile_no_ext param ~comptime:false (fun ~src ~dst ->
Format.sprintf
"perl ./utils/remove_comments.pl %s | sed 's/^ *//g' | wc -c > %s"
src
dst)
let file_size ?(wasm = false) param =
compile_no_ext param ~comptime:false (fun ~src ~dst ->
let files =
if wasm then src ^ " " ^ Filename.remove_extension src ^ ".assets/*" else src
in
Format.sprintf "cat %s | wc -c > %s" files dst)
let compr_file_size ?(wasm = false) param =
compile_no_ext param ~comptime:false (fun ~src ~dst ->
let input =
if wasm
then
Printf.sprintf
"echo %s %s | xargs gzip -c"
src
(Filename.remove_extension src ^ ".assets/*")
else Printf.sprintf "sed 's/^ *//g' %s | gzip -c" src
in
Format.sprintf "%s | wc -c > %s" input dst)
let bzip2_file_size ?(wasm = false) param =
compile_no_ext param ~comptime:false (fun ~src ~dst ->
let input =
if wasm
then
Printf.sprintf
"echo %s %s | xargs bzip2 -c"
src
(Filename.remove_extension src ^ ".assets/*")
else Printf.sprintf "sed 's/^ *//g' %s | bzip2 -c" src
in
Format.sprintf "%s | wc -c > %s" input dst)
let runtime_size param =
compile_no_ext param ~comptime:false (fun ~src ~dst ->
Format.sprintf
{|awk -vRS="--MARK--start-of-jsoo-gen--MARK--" '{print length($0)}' %s | head -n1 > %s|}
src
dst)
let gen_size param =
compile_no_ext param ~comptime:false (fun ~src ~dst ->
Format.sprintf
{|awk -vRS="--MARK--start-of-jsoo-gen--MARK--" '{print length($0)}' %s | tail -n1 > %s|}
src
dst)
(****)
let _ =
let compile_only = ref false in
let full = ref false in
let interpreter_config = ref "run.config" in
let param = ref Param.default in
let reports = ref [] in
let fast_run () = param := Param.fast !param in
let ffast_run () = param := Param.ffast !param in
let verbose () = param := Param.verbose !param in
let options =
[ "-compile", Arg.Set compile_only, " only compiles"
; "-all", Arg.Set full, " run all benchmarks"
; "-config", Arg.Set_string interpreter_config, "<file> use <file> as a config file"
; "-fast", Arg.Unit fast_run, " perform less iterations"
; "-ffast", Arg.Unit ffast_run, " perform very few iterations"
; "-verbose", Arg.Unit verbose, " verbose"
]
in
Arg.parse
(Arg.align options)
(fun report -> reports := report :: !reports)
(Format.sprintf "Usage: %s [options] [REPORTS.config]*" Sys.argv.(0));
let compile_only = !compile_only in
let full = !full in
let param = !param in
let interpreters = read_interpreter_config !interpreter_config in
let filtered, filter_bench =
match !reports with
| [] -> false, fun (_, _) -> true
| reports ->
List.map reports ~f:read_report_config
|> List.concat_map ~f:(fun l ->
List.concat_map l ~f:(fun l ->
List.concat_map l ~f:(function
| None -> []
| Some (p1, p2, _measure, _) -> (
match String.split_on_char ~sep:'/' p1 with
| [ "results"; "times"; _host; interpreter ] ->
[ interpreter, p2 ]
| _ -> []))))
|> List.sort_uniq ~cmp:compare
|> fun required ->
true, fun (interp, suite) -> List.mem (interp, Spec.name suite) ~set:required
in
let compile = compile param ~comptime:true in
let compile_jsoo ?(effects = `None) opts =
compile
(Format.sprintf
"js_of_ocaml -q --target-env browser --debug mark-runtime-gen %s %s"
opts
(match effects with
| `None -> "--effects=disabled"
| `Cps -> "--effects=cps"
| `Double_translation -> "--effects=double-translation"))
in
let compile_wasmoo ?(effects = `None) opts =
compile
(Format.sprintf
"wasm_of_ocaml -q %s %s"
opts
(match effects with
| `None -> ""
| `Cps -> "--effects=cps"))
in
Format.eprintf "Compile@.";
compile "ocamlc" src Spec.ml code Spec.byte;
compile "ocamlopt" src Spec.ml code Spec.opt;
compile_wasmoo "--opt=2" code Spec.byte code Spec.wasm_of_ocaml;
compile_jsoo "--opt=2" code Spec.byte code Spec.js_of_ocaml;
compile_jsoo "--opt=3" code Spec.byte code Spec.js_of_ocaml_o3;
compile_jsoo "--enable=use-js-string" code Spec.byte code Spec.js_of_ocaml_js_string;
compile_jsoo "--disable inline" code Spec.byte code Spec.js_of_ocaml_inline;
compile_jsoo "--disable deadcode" code Spec.byte code Spec.js_of_ocaml_deadcode;
compile_jsoo "--disable compact" code Spec.byte code Spec.js_of_ocaml_compact;
compile_jsoo "--disable optcall" code Spec.byte code Spec.js_of_ocaml_call;
compile_jsoo ~effects:`Cps "" code Spec.byte code Spec.js_of_ocaml_effects_cps;
compile_jsoo
~effects:`Double_translation
""
code
Spec.byte
code
Spec.js_of_ocaml_effects_double_translation;
compile "ocamlc -unsafe" src Spec.ml code Spec.byte_unsafe;
compile "ocamlopt" src Spec.ml code Spec.opt_unsafe;
compile_jsoo "" code Spec.byte_unsafe code Spec.js_of_ocaml_unsafe;
Format.eprintf "Sizes@.";
let sizes = sizes.Measure.path in
ml_size param src Spec.ml sizes Spec.ml;
file_size param code Spec.byte sizes Spec.byte;
file_size param code Spec.js_of_ocaml sizes (Spec.sub_spec Spec.js_of_ocaml "full");
file_size
~wasm:true
param
code
Spec.wasm_of_ocaml
sizes
(Spec.sub_spec Spec.wasm_of_ocaml "full");
compr_file_size
param
code
Spec.js_of_ocaml
sizes
(Spec.sub_spec Spec.js_of_ocaml "gzipped");
compr_file_size
param
code
Spec.js_of_ocaml_effects_cps
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects_cps "gzipped");
compr_file_size
param
code
Spec.js_of_ocaml_effects_double_translation
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects_double_translation "gzipped");
compr_file_size
~wasm:true
param
code
Spec.wasm_of_ocaml
sizes
(Spec.sub_spec Spec.wasm_of_ocaml "gzipped");
bzip2_file_size
param
code
Spec.js_of_ocaml_effects_cps
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects_cps "bzip2");
bzip2_file_size
param
code
Spec.js_of_ocaml_effects_double_translation
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects_double_translation "bzip2");
bzip2_file_size
param
code
Spec.js_of_ocaml
sizes
(Spec.sub_spec Spec.js_of_ocaml "bzip2");
bzip2_file_size
~wasm:true
param
code
Spec.wasm_of_ocaml
sizes
(Spec.sub_spec Spec.wasm_of_ocaml "bzip2");
runtime_size
param
code
Spec.js_of_ocaml
sizes
(Spec.sub_spec Spec.js_of_ocaml "runtime");
gen_size param code Spec.js_of_ocaml sizes (Spec.sub_spec Spec.js_of_ocaml "generated");
gen_size param code Spec.js_of_ocaml_o3 sizes Spec.js_of_ocaml_o3;
gen_size param code Spec.js_of_ocaml_js_string sizes Spec.js_of_ocaml_js_string;
gen_size param code Spec.js_of_ocaml_inline sizes Spec.js_of_ocaml_inline;
gen_size param code Spec.js_of_ocaml_deadcode sizes Spec.js_of_ocaml_deadcode;
gen_size param code Spec.js_of_ocaml_compact sizes Spec.js_of_ocaml_compact;
gen_size param code Spec.js_of_ocaml_call sizes Spec.js_of_ocaml_call;
gen_size param code Spec.js_of_ocaml_effects_cps sizes Spec.js_of_ocaml_effects_cps;
gen_size
param
code
Spec.js_of_ocaml_effects_double_translation
sizes
Spec.js_of_ocaml_effects_double_translation;
if compile_only then exit 0;
Format.eprintf "Measure@.";
if filter_bench ("", Spec.opt) then measure ~param ~code ~meas:times ~spec:Spec.opt "";
if filter_bench ("", Spec.byte) then measure ~param ~code ~meas:times ~spec:Spec.byte "";
let all_spec =
[ Some Spec.js_of_ocaml
; Some Spec.js_of_ocaml_o3
; Some Spec.js_of_ocaml_js_string
; Some Spec.js_of_ocaml_unsafe
; Some Spec.js_of_ocaml_inline
; Some Spec.js_of_ocaml_deadcode
; Some Spec.js_of_ocaml_compact
; Some Spec.js_of_ocaml_call
; Some Spec.js_of_ocaml_effects_cps
; Some Spec.js_of_ocaml_effects_double_translation
; Some Spec.wasm_of_ocaml
]
in
let interpreters, suites =
if full || filtered
then interpreters, all_spec
else
( (match interpreters with
| i :: _ -> [ i ]
| [] -> [])
, [ Some Spec.js_of_ocaml; Some Spec.wasm_of_ocaml ] )
in
List.iter interpreters ~f:(fun (comp, dir) ->
(* Measure the time taken by an implementation in Javascript for comparison *)
if filter_bench (dir, Spec.js)
then
measure
~param
~code:src
~meas:Measure.{ times with path = Filename.concat times.path dir }
~spec:Spec.js
comp;
List.iter suites ~f:(function
| None -> ()
| Some suite ->
if filter_bench (dir, suite)
then
measure
~param
~code
~meas:Measure.{ times with path = Filename.concat times.path dir }
~spec:suite
comp))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/almabench.ml
|
(*
* ALMABENCH 1.0.1
* Objective Caml version
*
* A number-crunching benchmark designed for cross-language and vendor
* comparisons.
*
* Written by Shawn Wagner, from Scott Robert Ladd's versions for
* C++ and java.
*
* No rights reserved. This is public domain software, for use by anyone.
*
* This program calculates the daily ephemeris (at noon) for the years
* 2000-2099 using an algorithm developed by J.L. Simon, P. Bretagnon, J.
* Chapront, M. Chapront-Touze, G. Francou and J. Laskar of the Bureau des
* Longitudes, Paris, France), as detailed in Astronomy & Astrophysics
* 282, 663 (1994)
*
* Note that the code herein is design for the purpose of testing
* computational performance; error handling and other such "niceties"
* is virtually non-existent.
*
* Actual (and oft-updated) benchmark results can be found at:
* http://www.coyotegulch.com
*
* Please do not use this information or algorithm in any way that might
* upset the balance of the universe or otherwise cause planets to impact
* upon one another.
*)
let pic = 3.14159265358979323846
and j2000 = 2451545.0
and jcentury = 36525.0
and jmillenia = 365250.0
let twopi = 2.0 *. pic
and a2r = pic /. 648000.0
and r2h = 12.0 /. pic
and r2d = 180.0 /. pic
and gaussk = 0.01720209895
(* number of days to include in test *)
let test_loops = 5
(* was: 20 *)
and test_length = 36525
(* sin and cos of j2000 mean obliquity (iau 1976) *)
and sineps = 0.3977771559319137
and coseps = 0.9174820620691818
and amas =
[| 6023600.0; 408523.5; 328900.5; 3098710.0; 1047.355; 3498.5; 22869.0; 19314.0 |]
(*
* tables giving the mean keplerian elements, limited to t**2 terms:
* a semi-major axis (au)
* dlm mean longitude (degree and arcsecond)
* e eccentricity
* pi longitude of the perihelion (degree and arcsecond)
* dinc inclination (degree and arcsecond)
* omega longitude of the ascending node (degree and arcsecond)
*)
and a =
[| [| 0.3870983098; 0.0; 0.0 |]
; [| 0.7233298200; 0.0; 0.0 |]
; [| 1.0000010178; 0.0; 0.0 |]
; [| 1.5236793419; 3e-10; 0.0 |]
; [| 5.2026032092; 19132e-10; -39e-10 |]
; [| 9.5549091915; -0.0000213896; 444e-10 |]
; [| 19.2184460618; -3716e-10; 979e-10 |]
; [| 30.1103868694; -16635e-10; 686e-10 |]
|]
and dlm =
[| [| 252.25090552; 5381016286.88982; -1.92789 |]
; [| 181.97980085; 2106641364.33548; 0.59381 |]
; [| 100.46645683; 1295977422.83429; -2.04411 |]
; [| 355.43299958; 689050774.93988; 0.94264 |]
; [| 34.35151874; 109256603.77991; -30.60378 |]
; [| 50.07744430; 43996098.55732; 75.61614 |]
; [| 314.05500511; 15424811.93933; -1.75083 |]
; [| 304.34866548; 7865503.20744; 0.21103 |]
|]
and e =
[| [| 0.2056317526; 0.0002040653; -28349e-10 |]
; [| 0.0067719164; -0.0004776521; 98127e-10 |]
; [| 0.0167086342; -0.0004203654; -0.0000126734 |]
; [| 0.0934006477; 0.0009048438; -80641e-10 |]
; [| 0.0484979255; 0.0016322542; -0.0000471366 |]
; [| 0.0555481426; -0.0034664062; -0.0000643639 |]
; [| 0.0463812221; -0.0002729293; 0.0000078913 |]
; [| 0.0094557470; 0.0000603263; 0.0 |]
|]
and pi =
[| [| 77.45611904; 5719.11590; -4.83016 |]
; [| 131.56370300; 175.48640; -498.48184 |]
; [| 102.93734808; 11612.35290; 53.27577 |]
; [| 336.06023395; 15980.45908; -62.32800 |]
; [| 14.33120687; 7758.75163; 259.95938 |]
; [| 93.05723748; 20395.49439; 190.25952 |]
; [| 173.00529106; 3215.56238; -34.09288 |]
; [| 48.12027554; 1050.71912; 27.39717 |]
|]
and dinc =
[| [| 7.00498625; -214.25629; 0.28977 |]
; [| 3.39466189; -30.84437; -11.67836 |]
; [| 0.0; 469.97289; -3.35053 |]
; [| 1.84972648; -293.31722; -8.11830 |]
; [| 1.30326698; -71.55890; 11.95297 |]
; [| 2.48887878; 91.85195; -17.66225 |]
; [| 0.77319689; -60.72723; 1.25759 |]
; [| 1.76995259; 8.12333; 0.08135 |]
|]
and omega =
[| [| 48.33089304; -4515.21727; -31.79892 |]
; [| 76.67992019; -10008.48154; -51.32614 |]
; [| 174.87317577; -8679.27034; 15.34191 |]
; [| 49.55809321; -10620.90088; -230.57416 |]
; [| 100.46440702; 6362.03561; 326.52178 |]
; [| 113.66550252; -9240.19942; -66.23743 |]
; [| 74.00595701; 2669.15033; 145.93964 |]
; [| 131.78405702; -221.94322; -0.78728 |]
|]
(* tables for trigonometric terms to be added to the mean elements
of the semi-major axes. *)
and kp =
[| [| 69613.0; 75645.0; 88306.0; 59899.0; 15746.0; 71087.0; 142173.0; 3086.0; 0.0 |]
; [| 21863.0; 32794.0; 26934.0; 10931.0; 26250.0; 43725.0; 53867.0; 28939.0; 0.0 |]
; [| 16002.0; 21863.0; 32004.0; 10931.0; 14529.0; 16368.0; 15318.0; 32794.0; 0.0 |]
; [| 6345.0; 7818.0; 15636.0; 7077.0; 8184.0; 14163.0; 1107.0; 4872.0; 0.0 |]
; [| 1760.0; 1454.0; 1167.0; 880.0; 287.0; 2640.0; 19.0; 2047.0; 1454.0 |]
; [| 574.0; 0.0; 880.0; 287.0; 19.0; 1760.0; 1167.0; 306.0; 574.0 |]
; [| 204.0; 0.0; 177.0; 1265.0; 4.0; 385.0; 200.0; 208.0; 204.0 |]
; [| 0.0; 102.0; 106.0; 4.0; 98.0; 1367.0; 487.0; 204.0; 0.0 |]
|]
and ca =
[| [| 4.0; -13.0; 11.0; -9.0; -9.0; -3.0; -1.0; 4.0; 0.0 |]
; [| -156.0; 59.0; -42.0; 6.0; 19.0; -20.0; -10.0; -12.0; 0.0 |]
; [| 64.0; -152.0; 62.0; -8.0; 32.0; -41.0; 19.0; -11.0; 0.0 |]
; [| 124.0; 621.0; -145.0; 208.0; 54.0; -57.0; 30.0; 15.0; 0.0 |]
; [| -23437.0; -2634.0; 6601.0; 6259.0; -1507.0; -1821.0; 2620.0; -2115.0; -1489.0 |]
; [| 62911.0
; -119919.0
; 79336.0
; 17814.0
; -24241.0
; 12068.0
; 8306.0
; -4893.0
; 8902.0
|]
; [| 389061.0
; -262125.0
; -44088.0
; 8387.0
; -22976.0
; -2093.0
; -615.0
; -9720.0
; 6633.0
|]
; [| -412235.0; -157046.0; -31430.0; 37817.0; -9740.0; -13.0; -7449.0; 9644.0; 0.0 |]
|]
and sa =
[| [| -29.0; -1.0; 9.0; 6.0; -6.0; 5.0; 4.0; 0.0; 0.0 |]
; [| -48.0; -125.0; -26.0; -37.0; 18.0; -13.0; -20.0; -2.0; 0.0 |]
; [| -150.0; -46.0; 68.0; 54.0; 14.0; 24.0; -28.0; 22.0; 0.0 |]
; [| -621.0; 532.0; -694.0; -20.0; 192.0; -94.0; 71.0; -73.0; 0.0 |]
; [| -14614.0; -19828.0; -5869.0; 1881.0; -4372.0; -2255.0; 782.0; 930.0; 913.0 |]
; [| 139737.0; 0.0; 24667.0; 51123.0; -5102.0; 7429.0; -4095.0; -1976.0; -9566.0 |]
; [| -138081.0
; 0.0
; 37205.0
; -49039.0
; -41901.0
; -33872.0
; -27037.0
; -12474.0
; 18797.0
|]
; [| 0.0; 28492.0; 133236.0; 69654.0; 52322.0; -49577.0; -26430.0; -3593.0; 0.0 |]
|]
(* tables giving the trigonometric terms to be added to the mean elements of
the mean longitudes . *)
and kq =
[| [| 3086.0; 15746.0; 69613.0; 59899.0; 75645.0; 88306.0; 12661.0; 2658.0; 0.0; 0.0 |]
; [| 21863.0; 32794.0; 10931.0; 73.0; 4387.0; 26934.0; 1473.0; 2157.0; 0.0; 0.0 |]
; [| 10.0; 16002.0; 21863.0; 10931.0; 1473.0; 32004.0; 4387.0; 73.0; 0.0; 0.0 |]
; [| 10.0; 6345.0; 7818.0; 1107.0; 15636.0; 7077.0; 8184.0; 532.0; 10.0; 0.0 |]
; [| 19.0; 1760.0; 1454.0; 287.0; 1167.0; 880.0; 574.0; 2640.0; 19.0; 1454.0 |]
; [| 19.0; 574.0; 287.0; 306.0; 1760.0; 12.0; 31.0; 38.0; 19.0; 574.0 |]
; [| 4.0; 204.0; 177.0; 8.0; 31.0; 200.0; 1265.0; 102.0; 4.0; 204.0 |]
; [| 4.0; 102.0; 106.0; 8.0; 98.0; 1367.0; 487.0; 204.0; 4.0; 102.0 |]
|]
and cl =
[| [| 21.0; -95.0; -157.0; 41.0; -5.0; 42.0; 23.0; 30.0; 0.0; 0.0 |]
; [| -160.0; -313.0; -235.0; 60.0; -74.0; -76.0; -27.0; 34.0; 0.0; 0.0 |]
; [| -325.0; -322.0; -79.0; 232.0; -52.0; 97.0; 55.0; -41.0; 0.0; 0.0 |]
; [| 2268.0; -979.0; 802.0; 602.0; -668.0; -33.0; 345.0; 201.0; -55.0; 0.0 |]
; [| 7610.0
; -4997.0
; -7689.0
; -5841.0
; -2617.0
; 1115.0
; -748.0
; -607.0
; 6074.0
; 354.0
|]
; [| -18549.0
; 30125.0
; 20012.0
; -730.0
; 824.0
; 23.0
; 1289.0
; -352.0
; -14767.0
; -2062.0
|]
; [| -135245.0
; -14594.0
; 4197.0
; -4030.0
; -5630.0
; -2898.0
; 2540.0
; -306.0
; 2939.0
; 1986.0
|]
; [| 89948.0; 2103.0; 8963.0; 2695.0; 3682.0; 1648.0; 866.0; -154.0; -1963.0; -283.0 |]
|]
and sl =
[| [| -342.0; 136.0; -23.0; 62.0; 66.0; -52.0; -33.0; 17.0; 0.0; 0.0 |]
; [| 524.0; -149.0; -35.0; 117.0; 151.0; 122.0; -71.0; -62.0; 0.0; 0.0 |]
; [| -105.0; -137.0; 258.0; 35.0; -116.0; -88.0; -112.0; -80.0; 0.0; 0.0 |]
; [| 854.0; -205.0; -936.0; -240.0; 140.0; -341.0; -97.0; -232.0; 536.0; 0.0 |]
; [| -56980.0; 8016.0; 1012.0; 1448.0; -3024.0; -3710.0; 318.0; 503.0; 3767.0; 577.0 |]
; [| 138606.0
; -13478.0
; -4964.0
; 1441.0
; -1319.0
; -1482.0
; 427.0
; 1236.0
; -9167.0
; -1918.0
|]
; [| 71234.0
; -41116.0
; 5334.0
; -4935.0
; -1848.0
; 66.0
; 434.0
; -1748.0
; 3780.0
; -701.0
|]
; [| -47645.0; 11647.0; 2166.0; 3194.0; 679.0; 0.0; -244.0; -419.0; -2531.0; 48.0 |]
|]
(* Normalize angle into the range -pi <= A < +pi. *)
let anpm a =
let w = mod_float a twopi in
if abs_float w >= pic then if a < 0.0 then w +. twopi else w -. twopi else w
(* The reference frame is equatorial and is with respect to the
* mean equator and equinox of epoch j2000. *)
let planetpv epoch np pv =
(* time: julian millennia since j2000. *)
let t = (epoch.(0) -. j2000 +. epoch.(1)) /. jmillenia in
(* compute the mean elements. *)
let da = ref (a.(np).(0) +. ((a.(np).(1) +. (a.(np).(2) *. t)) *. t))
and dl =
ref (((3600.0 *. dlm.(np).(0)) +. ((dlm.(np).(1) +. (dlm.(np).(2) *. t)) *. t)) *. a2r)
and de = e.(np).(0) +. ((e.(np).(1) +. (e.(np).(2) *. t)) *. t)
and dp =
anpm (((3600.0 *. pi.(np).(0)) +. ((pi.(np).(1) +. (pi.(np).(2) *. t)) *. t)) *. a2r)
and di =
((3600.0 *. dinc.(np).(0)) +. ((dinc.(np).(1) +. (dinc.(np).(2) *. t)) *. t)) *. a2r
and doh =
anpm
(((3600.0 *. omega.(np).(0)) +. ((omega.(np).(1) +. (omega.(np).(2) *. t)) *. t))
*. a2r)
(* apply the trigonometric terms. *)
and dmu = 0.35953620 *. t in
(* loop invariant *)
let kp = kp.(np)
and kq = kq.(np)
and ca = ca.(np)
and sa = sa.(np)
and cl = cl.(np)
and sl = sl.(np) in
for k = 0 to 7 do
let arga = kp.(k) *. dmu and argl = kq.(k) *. dmu in
da := !da +. (((ca.(k) *. cos arga) +. (sa.(k) *. sin arga)) *. 0.0000001);
dl := !dl +. (((cl.(k) *. cos argl) +. (sl.(k) *. sin argl)) *. 0.0000001)
done;
(let arga = kp.(8) *. dmu in
da := !da +. (t *. ((ca.(8) *. cos arga) +. (sa.(8) *. sin arga)) *. 0.0000001);
for k = 8 to 9 do
let argl = kq.(k) *. dmu in
dl := !dl +. (t *. ((cl.(k) *. cos argl) +. (sl.(k) *. sin argl)) *. 0.0000001)
done);
dl := mod_float !dl twopi;
(* iterative solution of kepler's equation to get eccentric anomaly. *)
let am = !dl -. dp in
let ae = ref (am +. (de *. sin am)) and k = ref 0 in
let dae = ref ((am -. !ae +. (de *. sin !ae)) /. (1.0 -. (de *. cos !ae))) in
ae := !ae +. !dae;
incr k;
while !k < 10 || abs_float !dae >= 1e-12 do
dae := (am -. !ae +. (de *. sin !ae)) /. (1.0 -. (de *. cos !ae));
ae := !ae +. !dae;
incr k
done;
(* true anomaly. *)
let ae2 = !ae /. 2.0 in
let at = 2.0 *. atan2 (sqrt ((1.0 +. de) /. (1.0 -. de)) *. sin ae2) (cos ae2)
(* distance (au) and speed (radians per day). *)
and r = !da *. (1.0 -. (de *. cos !ae))
and v = gaussk *. sqrt ((1.0 +. (1.0 /. amas.(np))) /. (!da *. !da *. !da))
and si2 = sin (di /. 2.0) in
let xq = si2 *. cos doh and xp = si2 *. sin doh and tl = at +. dp in
let xsw = sin tl and xcw = cos tl in
let xm2 = 2.0 *. ((xp *. xcw) -. (xq *. xsw))
and xf = !da /. sqrt (1.0 -. (de *. de))
and ci2 = cos (di /. 2.0) in
let xms = ((de *. sin dp) +. xsw) *. xf
and xmc = ((de *. cos dp) +. xcw) *. xf
and xpxq2 = 2.0 *. xp *. xq in
(* position (j2000 ecliptic x,y,z in au). *)
let x = r *. (xcw -. (xm2 *. xp))
and y = r *. (xsw +. (xm2 *. xq))
and z = r *. (-.xm2 *. ci2) in
(* rotate to equatorial. *)
pv.(0).(0) <- x;
pv.(0).(1) <- (y *. coseps) -. (z *. sineps);
pv.(0).(2) <- (y *. sineps) +. (z *. coseps);
(* velocity (j2000 ecliptic xdot,ydot,zdot in au/d). *)
let x = v *. (((-1.0 +. (2.0 *. xp *. xp)) *. xms) +. (xpxq2 *. xmc))
and y = v *. (((1.0 -. (2.0 *. xq *. xq)) *. xmc) -. (xpxq2 *. xms))
and z = v *. (2.0 *. ci2 *. ((xp *. xms) +. (xq *. xmc))) in
(* rotate to equatorial *)
pv.(1).(0) <- x;
pv.(1).(1) <- (y *. coseps) -. (z *. sineps);
pv.(1).(2) <- (y *. sineps) +. (z *. coseps)
(* Computes RA, Declination, and distance from a state vector returned by
* planetpv. *)
let radecdist state rdd =
(* Distance *)
rdd.(2) <-
sqrt
((state.(0).(0) *. state.(0).(0))
+. (state.(0).(1) *. state.(0).(1))
+. (state.(0).(2) *. state.(0).(2)));
(* RA *)
rdd.(0) <- atan2 state.(0).(1) state.(0).(0) *. r2h;
if rdd.(0) < 0.0 then rdd.(0) <- rdd.(0) +. 24.0;
(* Declination *)
rdd.(1) <- asin (state.(0).(2) /. rdd.(2)) *. r2d
(* Entry point. Calculate RA and Dec for noon on every day in 1900-2100 *)
let _ =
let jd = [| 0.0; 0.0 |]
and pv = [| [| 0.0; 0.0; 0.0 |]; [| 0.0; 0.0; 0.0 |] |]
and position = [| 0.0; 0.0; 0.0 |] in
(* Test *)
jd.(0) <- j2000;
jd.(1) <- 1.0;
for p = 0 to 7 do
planetpv jd p pv;
radecdist pv position
(* Printf.printf "%d %.2f %.2f\n%!" p position.(0) position.(1)*)
done;
(* Benchmark *)
for _ = 0 to test_loops - 1 do
jd.(0) <- j2000;
jd.(1) <- 0.0;
for _ = 0 to test_length - 1 do
jd.(0) <- jd.(0) +. 1.0;
for p = 0 to 7 do
planetpv jd p pv;
radecdist pv position
done
done
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/bdd.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: bdd.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
(* Translated to Caml by Xavier Leroy *)
(* Original code written in SML by ... *)
type bdd =
| One
| Zero
| Node of bdd * int * int * bdd
let rec eval bdd vars =
match bdd with
| Zero -> false
| One -> true
| Node (l, v, _, h) -> if vars.(v) then eval h vars else eval l vars
let getId bdd =
match bdd with
| Node (_, _, id, _) -> id
| Zero -> 0
| One -> 1
let initSize_1 = (8 * 1024) - 1
let nodeC = ref 1
let sz_1 = ref initSize_1
let htab = ref (Array.make (!sz_1 + 1) [])
let n_items = ref 0
let hashVal x y v = (x lsl 1) + y + (v lsl 2)
let resize newSize =
let arr = !htab in
let newSz_1 = newSize - 1 in
let newArr = Array.make newSize [] in
let rec copyBucket bucket =
match bucket with
| [] -> ()
| n :: ns -> (
match n with
| Node (l, v, _, h) ->
let ind = hashVal (getId l) (getId h) v land newSz_1 in
newArr.(ind) <- n :: newArr.(ind);
copyBucket ns
| _ -> assert false)
in
for n = 0 to !sz_1 do
copyBucket arr.(n)
done;
htab := newArr;
sz_1 := newSz_1
let insert idl idh v ind bucket newNode =
if !n_items <= !sz_1
then (
!htab.(ind) <- newNode :: bucket;
incr n_items)
else (
resize (!sz_1 + !sz_1 + 2);
let ind = hashVal idl idh v land !sz_1 in
!htab.(ind) <- newNode :: !htab.(ind))
let resetUnique () =
sz_1 := initSize_1;
htab := Array.make (!sz_1 + 1) [];
n_items := 0;
nodeC := 1
let mkNode low v high =
let idl = getId low in
let idh = getId high in
if idl = idh
then low
else
let ind = hashVal idl idh v land !sz_1 in
let bucket = !htab.(ind) in
let rec lookup b =
match b with
| [] ->
let n =
Node
( low
, v
, (incr nodeC;
!nodeC)
, high )
in
insert (getId low) (getId high) v ind bucket n;
n
| n :: ns -> (
match n with
| Node (l, v', _id, h) ->
if v = v' && idl = getId l && idh = getId h then n else lookup ns
| _ -> assert false)
in
lookup bucket
type ordering =
| LESS
| EQUAL
| GREATER
let cmpVar (x : int) (y : int) = if x < y then LESS else if x > y then GREATER else EQUAL
let zero = Zero
let one = One
let mkVar x = mkNode zero x one
let cacheSize = 1999
let andslot1 = Array.make cacheSize 0
let andslot2 = Array.make cacheSize 0
let andslot3 = Array.make cacheSize zero
let xorslot1 = Array.make cacheSize 0
let xorslot2 = Array.make cacheSize 0
let xorslot3 = Array.make cacheSize zero
let notslot1 = Array.make cacheSize 0
let notslot2 = Array.make cacheSize one
let hash x y = ((x lsl 1) + y) mod cacheSize
let rec not n =
match n with
| Zero -> One
| One -> Zero
| Node (l, v, id, r) ->
let h = id mod cacheSize in
if id = notslot1.(h)
then notslot2.(h)
else
let f = mkNode (not l) v (not r) in
notslot1.(h) <- id;
notslot2.(h) <- f;
f
let rec and2 n1 n2 =
match n1 with
| Node (l1, v1, i1, r1) -> (
match n2 with
| Node (l2, v2, i2, r2) ->
let h = hash i1 i2 in
if i1 = andslot1.(h) && i2 = andslot2.(h)
then andslot3.(h)
else
let f =
match cmpVar v1 v2 with
| EQUAL -> mkNode (and2 l1 l2) v1 (and2 r1 r2)
| LESS -> mkNode (and2 l1 n2) v1 (and2 r1 n2)
| GREATER -> mkNode (and2 n1 l2) v2 (and2 n1 r2)
in
andslot1.(h) <- i1;
andslot2.(h) <- i2;
andslot3.(h) <- f;
f
| Zero -> Zero
| One -> n1)
| Zero -> Zero
| One -> n2
let rec xor n1 n2 =
match n1 with
| Node (l1, v1, i1, r1) -> (
match n2 with
| Node (l2, v2, i2, r2) ->
let h = hash i1 i2 in
if i1 = andslot1.(h) && i2 = andslot2.(h)
then andslot3.(h)
else
let f =
match cmpVar v1 v2 with
| EQUAL -> mkNode (xor l1 l2) v1 (xor r1 r2)
| LESS -> mkNode (xor l1 n2) v1 (xor r1 n2)
| GREATER -> mkNode (xor n1 l2) v2 (xor n1 r2)
in
andslot1.(h) <- i1;
andslot2.(h) <- i2;
andslot3.(h) <- f;
f
| Zero -> n1
| One -> not n1)
| Zero -> n2
| One -> not n2
let hwb n =
let rec h i j =
if i = j
then mkVar i
else xor (and2 (not (mkVar j)) (h i (j - 1))) (and2 (mkVar j) (g i (j - 1)))
and g i j =
if i = j
then mkVar i
else xor (and2 (not (mkVar i)) (h (i + 1) j)) (and2 (mkVar i) (g (i + 1) j))
in
h 0 (n - 1)
(* Testing *)
let seed = ref 0
let random () =
seed := (!seed * 25173) + 17431;
!seed land 1 > 0
let random_vars n =
let vars = Array.make n false in
for i = 0 to n - 1 do
vars.(i) <- random ()
done;
vars
let test_hwb bdd vars =
(* We should have
eval bdd vars = vars.(n-1) if n > 0
eval bdd vars = false if n = 0
where n is the number of "true" elements in vars. *)
let ntrue = ref 0 in
for i = 0 to Array.length vars - 1 do
if vars.(i) then incr ntrue
done;
eval bdd vars = if !ntrue > 0 then vars.(!ntrue - 1) else false
let main () =
let n = if Array.length Sys.argv >= 2 then int_of_string Sys.argv.(1) else 22 in
let ntests = if Array.length Sys.argv >= 3 then int_of_string Sys.argv.(2) else 100 in
let bdd = hwb n in
let succeeded = ref true in
for _ = 1 to ntests do
succeeded := !succeeded && test_hwb bdd (random_vars n)
done;
assert !succeeded
(*
if !succeeded
then print_string "OK\n"
else print_string "FAILED\n";
Format.eprintf "%d@." !nodeC;
exit 0
*)
let _ = main ()
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/binary_trees.ml
|
(* The Computer Language Benchmarks Game
* http://shootout.alioth.debian.org/
*
* Contributed by Troestler Christophe
* Modified by Fabrice Le Fessant
*)
type 'a tree =
| Empty
| Node of 'a tree * 'a * 'a tree
let rec make i d =
(* if d = 0 then Empty *)
if d = 0
then Node (Empty, i, Empty)
else
let i2 = 2 * i and d = d - 1 in
Node (make (i2 - 1) d, i, make i2 d)
let rec check = function
| Empty -> 0
| Node (l, i, r) -> i + check l - check r
let min_depth = 4
let max_depth =
let n = try int_of_string Sys.argv.(1) with _ -> 17 in
max (min_depth + 2) n
let stretch_depth = max_depth + 1
let () =
(* Gc.set { (Gc.get()) with Gc.minor_heap_size = 1024 * 1024; max_overhead = -1; }; *)
let _c = check (make 0 stretch_depth) in
( (*
Printf.printf "stretch tree of depth %i\t check: %i\n" stretch_depth c
*) )
let long_lived_tree = make 0 max_depth
let rec loop_depths depth max_depth =
if depth <= max_depth
then (
let niter = 1 lsl (max_depth - depth + min_depth) in
let c = ref 0 in
for i = 1 to niter do
c := !c + check (make i depth) + check (make (-i) depth)
done;
( (*
Printf.printf "%i\t trees of depth %i\t check: %i\n" (2 * niter) d !c;
*) );
loop_depths (depth + 2) max_depth)
let () =
(*
flush stdout;
*)
loop_depths min_depth max_depth
(* Printf.printf
"long lived tree of depth %i\t check: %i\n"
max_depth
(check long_lived_tree)
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/boyer.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: boyer.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
(* Manipulations over terms *)
type term =
| Var of int
| Prop of head * term list
and head =
{ name : string
; mutable props : (term * term) list
}
let rec print_term = function
| Var v ->
print_string "v";
print_int v
| Prop (head, argl) ->
print_string "(";
print_string head.name;
List.iter
(fun t ->
print_string " ";
print_term t)
argl;
print_string ")"
let lemmas = ref ([] : head list)
(* Replacement for property lists *)
let get name =
let rec get_rec = function
| hd1 :: hdl -> if hd1.name = name then hd1 else get_rec hdl
| [] ->
let entry = { name; props = [] } in
lemmas := entry :: !lemmas;
entry
in
get_rec !lemmas
let add_lemma = function
| Prop (_, [ (Prop (headl, _) as left); right ]) ->
headl.props <- (left, right) :: headl.props
| _ -> assert false
(* Substitutions *)
type subst = Bind of int * term
let get_binding v list =
let rec get_rec = function
| [] -> failwith "unbound"
| Bind (w, t) :: rest -> if v = w then t else get_rec rest
in
get_rec list
let apply_subst alist term =
let rec as_rec = function
| Var v -> ( try get_binding v alist with Failure _ -> term)
| Prop (head, argl) -> Prop (head, List.map as_rec argl)
in
as_rec term
exception Unify
let rec unify term1 term2 = unify1 term1 term2 []
and unify1 term1 term2 unify_subst =
match term2 with
| Var v -> (
try if get_binding v unify_subst = term1 then unify_subst else raise Unify
with Failure _ -> Bind (v, term1) :: unify_subst)
| Prop (head2, argl2) -> (
match term1 with
| Var _ -> raise Unify
| Prop (head1, argl1) ->
if head1 == head2 then unify1_lst argl1 argl2 unify_subst else raise Unify)
and unify1_lst l1 l2 unify_subst =
match l1, l2 with
| [], [] -> unify_subst
| h1 :: r1, h2 :: r2 -> unify1_lst r1 r2 (unify1 h1 h2 unify_subst)
| _ -> raise Unify
let rec rewrite = function
| Var _ as term -> term
| Prop (head, argl) ->
rewrite_with_lemmas (Prop (head, List.map rewrite argl)) head.props
and rewrite_with_lemmas term lemmas =
match lemmas with
| [] -> term
| (t1, t2) :: rest -> (
try rewrite (apply_subst (unify term t1) t2)
with Unify -> rewrite_with_lemmas term rest)
type cterm =
| CVar of int
| CProp of string * cterm list
let rec cterm_to_term = function
| CVar v -> Var v
| CProp (p, l) -> Prop (get p, List.map cterm_to_term l)
let add t = add_lemma (cterm_to_term t)
let _ =
add
(CProp
( "equal"
, [ CProp ("compile", [ CVar 5 ])
; CProp
( "reverse"
, [ CProp ("codegen", [ CProp ("optimize", [ CVar 5 ]); CProp ("nil", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("eqp", [ CVar 23; CVar 24 ])
; CProp ("equal", [ CProp ("fix", [ CVar 23 ]); CProp ("fix", [ CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("gt", [ CVar 23; CVar 24 ]); CProp ("lt", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("le", [ CVar 23; CVar 24 ]); CProp ("ge", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("ge", [ CVar 23; CVar 24 ]); CProp ("le", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("boolean", [ CVar 23 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("true", []) ])
; CProp ("equal", [ CVar 23; CProp ("false", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("iff", [ CVar 23; CVar 24 ])
; CProp
( "and"
, [ CProp ("implies", [ CVar 23; CVar 24 ])
; CProp ("implies", [ CVar 24; CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("even1", [ CVar 23 ])
; CProp
( "if"
, [ CProp ("zerop", [ CVar 23 ])
; CProp ("true", [])
; CProp ("odd", [ CProp ("sub1", [ CVar 23 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("countps_", [ CVar 11; CVar 15 ])
; CProp ("countps_loop", [ CVar 11; CVar 15; CProp ("zero", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("fact_", [ CVar 8 ])
; CProp ("fact_loop", [ CVar 8; CProp ("one", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse_", [ CVar 23 ])
; CProp ("reverse_loop", [ CVar 23; CProp ("nil", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("divides", [ CVar 23; CVar 24 ])
; CProp ("zerop", [ CProp ("remainder", [ CVar 24; CVar 23 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("assume_true", [ CVar 21; CVar 0 ])
; CProp ("cons", [ CProp ("cons", [ CVar 21; CProp ("true", []) ]); CVar 0 ])
] ));
add
(CProp
( "equal"
, [ CProp ("assume_false", [ CVar 21; CVar 0 ])
; CProp ("cons", [ CProp ("cons", [ CVar 21; CProp ("false", []) ]); CVar 0 ])
] ));
add
(CProp
( "equal"
, [ CProp ("tautology_checker", [ CVar 23 ])
; CProp ("tautologyp", [ CProp ("normalize", [ CVar 23 ]); CProp ("nil", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("falsify", [ CVar 23 ])
; CProp ("falsify1", [ CProp ("normalize", [ CVar 23 ]); CProp ("nil", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("prime", [ CVar 23 ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 23 ]) ])
; CProp
( "not"
, [ CProp ("equal", [ CVar 23; CProp ("add1", [ CProp ("zero", []) ]) ])
] )
; CProp ("prime1", [ CVar 23; CProp ("sub1", [ CVar 23 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("and", [ CVar 15; CVar 16 ])
; CProp
( "if"
, [ CVar 15
; CProp ("if", [ CVar 16; CProp ("true", []); CProp ("false", []) ])
; CProp ("false", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("or", [ CVar 15; CVar 16 ])
; CProp
( "if"
, [ CVar 15
; CProp ("true", [])
; CProp ("if", [ CVar 16; CProp ("true", []); CProp ("false", []) ])
; CProp ("false", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("not", [ CVar 15 ])
; CProp ("if", [ CVar 15; CProp ("false", []); CProp ("true", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("implies", [ CVar 15; CVar 16 ])
; CProp
( "if"
, [ CVar 15
; CProp ("if", [ CVar 16; CProp ("true", []); CProp ("false", []) ])
; CProp ("true", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("fix", [ CVar 23 ])
; CProp ("if", [ CProp ("numberp", [ CVar 23 ]); CVar 23; CProp ("zero", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("if", [ CProp ("if", [ CVar 0; CVar 1; CVar 2 ]); CVar 3; CVar 4 ])
; CProp
( "if"
, [ CVar 0
; CProp ("if", [ CVar 1; CVar 3; CVar 4 ])
; CProp ("if", [ CVar 2; CVar 3; CVar 4 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("zerop", [ CVar 23 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("zero", []) ])
; CProp ("not", [ CProp ("numberp", [ CVar 23 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("plus", [ CProp ("plus", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp ("plus", [ CVar 23; CProp ("plus", [ CVar 24; CVar 25 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("plus", [ CVar 0; CVar 1 ]); CProp ("zero", []) ])
; CProp ("and", [ CProp ("zerop", [ CVar 0 ]); CProp ("zerop", [ CVar 1 ]) ])
] ));
add
(CProp ("equal", [ CProp ("difference", [ CVar 23; CVar 23 ]); CProp ("zero", []) ]));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("plus", [ CVar 0; CVar 1 ]); CProp ("plus", [ CVar 0; CVar 2 ]) ]
)
; CProp ("equal", [ CProp ("fix", [ CVar 1 ]); CProp ("fix", [ CVar 2 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
("equal", [ CProp ("zero", []); CProp ("difference", [ CVar 23; CVar 24 ]) ])
; CProp ("not", [ CProp ("gt", [ CVar 24; CVar 23 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CVar 23; CProp ("difference", [ CVar 23; CVar 24 ]) ])
; CProp
( "and"
, [ CProp ("numberp", [ CVar 23 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("zero", []) ])
; CProp ("zerop", [ CVar 24 ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "meaning"
, [ CProp ("plus_tree", [ CProp ("append", [ CVar 23; CVar 24 ]) ]); CVar 0 ]
)
; CProp
( "plus"
, [ CProp ("meaning", [ CProp ("plus_tree", [ CVar 23 ]); CVar 0 ])
; CProp ("meaning", [ CProp ("plus_tree", [ CVar 24 ]); CVar 0 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "meaning"
, [ CProp ("plus_tree", [ CProp ("plus_fringe", [ CVar 23 ]) ]); CVar 0 ] )
; CProp ("fix", [ CProp ("meaning", [ CVar 23; CVar 0 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("append", [ CProp ("append", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp ("append", [ CVar 23; CProp ("append", [ CVar 24; CVar 25 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse", [ CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
("append", [ CProp ("reverse", [ CVar 1 ]); CProp ("reverse", [ CVar 0 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CVar 23; CProp ("plus", [ CVar 24; CVar 25 ]) ])
; CProp
( "plus"
, [ CProp ("times", [ CVar 23; CVar 24 ])
; CProp ("times", [ CVar 23; CVar 25 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CProp ("times", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp ("times", [ CVar 23; CProp ("times", [ CVar 24; CVar 25 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("times", [ CVar 23; CVar 24 ]); CProp ("zero", []) ])
; CProp ("or", [ CProp ("zerop", [ CVar 23 ]); CProp ("zerop", [ CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("exec", [ CProp ("append", [ CVar 23; CVar 24 ]); CVar 15; CVar 4 ])
; CProp
("exec", [ CVar 24; CProp ("exec", [ CVar 23; CVar 15; CVar 4 ]); CVar 4 ])
] ));
add
(CProp
( "equal"
, [ CProp ("mc_flatten", [ CVar 23; CVar 24 ])
; CProp ("append", [ CProp ("flatten", [ CVar 23 ]); CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("member", [ CVar 23; CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
( "or"
, [ CProp ("member", [ CVar 23; CVar 0 ])
; CProp ("member", [ CVar 23; CVar 1 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("member", [ CVar 23; CProp ("reverse", [ CVar 24 ]) ])
; CProp ("member", [ CVar 23; CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("length", [ CProp ("reverse", [ CVar 23 ]) ])
; CProp ("length", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp ("member", [ CVar 0; CProp ("intersect", [ CVar 1; CVar 2 ]) ])
; CProp
( "and"
, [ CProp ("member", [ CVar 0; CVar 1 ])
; CProp ("member", [ CVar 0; CVar 2 ])
] )
] ));
add
(CProp ("equal", [ CProp ("nth", [ CProp ("zero", []); CVar 8 ]); CProp ("zero", []) ]));
add
(CProp
( "equal"
, [ CProp ("exp", [ CVar 8; CProp ("plus", [ CVar 9; CVar 10 ]) ])
; CProp
( "times"
, [ CProp ("exp", [ CVar 8; CVar 9 ]); CProp ("exp", [ CVar 8; CVar 10 ]) ]
)
] ));
add
(CProp
( "equal"
, [ CProp ("exp", [ CVar 8; CProp ("times", [ CVar 9; CVar 10 ]) ])
; CProp ("exp", [ CProp ("exp", [ CVar 8; CVar 9 ]); CVar 10 ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse_loop", [ CVar 23; CVar 24 ])
; CProp ("append", [ CProp ("reverse", [ CVar 23 ]); CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse_loop", [ CVar 23; CProp ("nil", []) ])
; CProp ("reverse", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp ("count_list", [ CVar 25; CProp ("sort_lp", [ CVar 23; CVar 24 ]) ])
; CProp
( "plus"
, [ CProp ("count_list", [ CVar 25; CVar 23 ])
; CProp ("count_list", [ CVar 25; CVar 24 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("append", [ CVar 0; CVar 1 ])
; CProp ("append", [ CVar 0; CVar 2 ])
] )
; CProp ("equal", [ CVar 1; CVar 2 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "plus"
, [ CProp ("remainder", [ CVar 23; CVar 24 ])
; CProp ("times", [ CVar 24; CProp ("quotient", [ CVar 23; CVar 24 ]) ])
] )
; CProp ("fix", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp
("power_eval", [ CProp ("big_plus", [ CVar 11; CVar 8; CVar 1 ]); CVar 1 ])
; CProp ("plus", [ CProp ("power_eval", [ CVar 11; CVar 1 ]); CVar 8 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "power_eval"
, [ CProp ("big_plus", [ CVar 23; CVar 24; CVar 8; CVar 1 ]); CVar 1 ] )
; CProp
( "plus"
, [ CVar 8
; CProp
( "plus"
, [ CProp ("power_eval", [ CVar 23; CVar 1 ])
; CProp ("power_eval", [ CVar 24; CVar 1 ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("remainder", [ CVar 24; CProp ("one", []) ]); CProp ("zero", []) ] ));
add
(CProp
( "equal"
, [ CProp ("lt", [ CProp ("remainder", [ CVar 23; CVar 24 ]); CVar 24 ])
; CProp ("not", [ CProp ("zerop", [ CVar 24 ]) ])
] ));
add (CProp ("equal", [ CProp ("remainder", [ CVar 23; CVar 23 ]); CProp ("zero", []) ]));
add
(CProp
( "equal"
, [ CProp ("lt", [ CProp ("quotient", [ CVar 8; CVar 9 ]); CVar 8 ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 8 ]) ])
; CProp
( "or"
, [ CProp ("zerop", [ CVar 9 ])
; CProp ("not", [ CProp ("equal", [ CVar 9; CProp ("one", []) ]) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("lt", [ CProp ("remainder", [ CVar 23; CVar 24 ]); CVar 23 ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 24 ]) ])
; CProp ("not", [ CProp ("zerop", [ CVar 23 ]) ])
; CProp ("not", [ CProp ("lt", [ CVar 23; CVar 24 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("power_eval", [ CProp ("power_rep", [ CVar 8; CVar 1 ]); CVar 1 ])
; CProp ("fix", [ CVar 8 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "power_eval"
, [ CProp
( "big_plus"
, [ CProp ("power_rep", [ CVar 8; CVar 1 ])
; CProp ("power_rep", [ CVar 9; CVar 1 ])
; CProp ("zero", [])
; CVar 1
] )
; CVar 1
] )
; CProp ("plus", [ CVar 8; CVar 9 ])
] ));
add
(CProp
( "equal"
, [ CProp ("gcd", [ CVar 23; CVar 24 ]); CProp ("gcd", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("nth", [ CProp ("append", [ CVar 0; CVar 1 ]); CVar 8 ])
; CProp
( "append"
, [ CProp ("nth", [ CVar 0; CVar 8 ])
; CProp
( "nth"
, [ CVar 1
; CProp ("difference", [ CVar 8; CProp ("length", [ CVar 0 ]) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("difference", [ CProp ("plus", [ CVar 23; CVar 24 ]); CVar 23 ])
; CProp ("fix", [ CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("difference", [ CProp ("plus", [ CVar 24; CVar 23 ]); CVar 23 ])
; CProp ("fix", [ CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("plus", [ CVar 23; CVar 24 ])
; CProp ("plus", [ CVar 23; CVar 25 ])
] )
; CProp ("difference", [ CVar 24; CVar 25 ])
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CVar 23; CProp ("difference", [ CVar 2; CVar 22 ]) ])
; CProp
( "difference"
, [ CProp ("times", [ CVar 2; CVar 23 ])
; CProp ("times", [ CVar 22; CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("remainder", [ CProp ("times", [ CVar 23; CVar 25 ]); CVar 25 ])
; CProp ("zero", [])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("plus", [ CVar 1; CProp ("plus", [ CVar 0; CVar 2 ]) ]); CVar 0 ]
)
; CProp ("plus", [ CVar 1; CVar 2 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("add1", [ CProp ("plus", [ CVar 24; CVar 25 ]) ]); CVar 25 ] )
; CProp ("add1", [ CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "lt"
, [ CProp ("plus", [ CVar 23; CVar 24 ])
; CProp ("plus", [ CVar 23; CVar 25 ])
] )
; CProp ("lt", [ CVar 24; CVar 25 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "lt"
, [ CProp ("times", [ CVar 23; CVar 25 ])
; CProp ("times", [ CVar 24; CVar 25 ])
] )
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 25 ]) ])
; CProp ("lt", [ CVar 23; CVar 24 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("lt", [ CVar 24; CProp ("plus", [ CVar 23; CVar 24 ]) ])
; CProp ("not", [ CProp ("zerop", [ CVar 23 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
( "gcd"
, [ CProp ("times", [ CVar 23; CVar 25 ])
; CProp ("times", [ CVar 24; CVar 25 ])
] )
; CProp ("times", [ CVar 25; CProp ("gcd", [ CVar 23; CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("value", [ CProp ("normalize", [ CVar 23 ]); CVar 0 ])
; CProp ("value", [ CVar 23; CVar 0 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("flatten", [ CVar 23 ])
; CProp ("cons", [ CVar 24; CProp ("nil", []) ])
] )
; CProp
( "and"
, [ CProp ("nlistp", [ CVar 23 ]); CProp ("equal", [ CVar 23; CVar 24 ]) ] )
] ));
add
(CProp
( "equal"
, [ CProp ("listp", [ CProp ("gother", [ CVar 23 ]) ])
; CProp ("listp", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp ("samefringe", [ CVar 23; CVar 24 ])
; CProp
("equal", [ CProp ("flatten", [ CVar 23 ]); CProp ("flatten", [ CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("greatest_factor", [ CVar 23; CVar 24 ]); CProp ("zero", []) ] )
; CProp
( "and"
, [ CProp
( "or"
, [ CProp ("zerop", [ CVar 24 ])
; CProp ("equal", [ CVar 24; CProp ("one", []) ])
] )
; CProp ("equal", [ CVar 23; CProp ("zero", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("greatest_factor", [ CVar 23; CVar 24 ]); CProp ("one", []) ] )
; CProp ("equal", [ CVar 23; CProp ("one", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("numberp", [ CProp ("greatest_factor", [ CVar 23; CVar 24 ]) ])
; CProp
( "not"
, [ CProp
( "and"
, [ CProp
( "or"
, [ CProp ("zerop", [ CVar 24 ])
; CProp ("equal", [ CVar 24; CProp ("one", []) ])
] )
; CProp ("not", [ CProp ("numberp", [ CVar 23 ]) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("times_list", [ CProp ("append", [ CVar 23; CVar 24 ]) ])
; CProp
( "times"
, [ CProp ("times_list", [ CVar 23 ]); CProp ("times_list", [ CVar 24 ]) ] )
] ));
add
(CProp
( "equal"
, [ CProp ("prime_list", [ CProp ("append", [ CVar 23; CVar 24 ]) ])
; CProp
( "and"
, [ CProp ("prime_list", [ CVar 23 ]); CProp ("prime_list", [ CVar 24 ]) ] )
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CVar 25; CProp ("times", [ CVar 22; CVar 25 ]) ])
; CProp
( "and"
, [ CProp ("numberp", [ CVar 25 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 25; CProp ("zero", []) ])
; CProp ("equal", [ CVar 22; CProp ("one", []) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("ge", [ CVar 23; CVar 24 ])
; CProp ("not", [ CProp ("lt", [ CVar 23; CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CVar 23; CProp ("times", [ CVar 23; CVar 24 ]) ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("zero", []) ])
; CProp
( "and"
, [ CProp ("numberp", [ CVar 23 ])
; CProp ("equal", [ CVar 24; CProp ("one", []) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("remainder", [ CProp ("times", [ CVar 24; CVar 23 ]); CVar 24 ])
; CProp ("zero", [])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("times", [ CVar 0; CVar 1 ]); CProp ("one", []) ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("equal", [ CVar 0; CProp ("zero", []) ]) ])
; CProp ("not", [ CProp ("equal", [ CVar 1; CProp ("zero", []) ]) ])
; CProp ("numberp", [ CVar 0 ])
; CProp ("numberp", [ CVar 1 ])
; CProp ("equal", [ CProp ("sub1", [ CVar 0 ]); CProp ("zero", []) ])
; CProp ("equal", [ CProp ("sub1", [ CVar 1 ]); CProp ("zero", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "lt"
, [ CProp ("length", [ CProp ("delete", [ CVar 23; CVar 11 ]) ])
; CProp ("length", [ CVar 11 ])
] )
; CProp ("member", [ CVar 23; CVar 11 ])
] ));
add
(CProp
( "equal"
, [ CProp ("sort2", [ CProp ("delete", [ CVar 23; CVar 11 ]) ])
; CProp ("delete", [ CVar 23; CProp ("sort2", [ CVar 11 ]) ])
] ));
add (CProp ("equal", [ CProp ("dsort", [ CVar 23 ]); CProp ("sort2", [ CVar 23 ]) ]));
add
(CProp
( "equal"
, [ CProp
( "length"
, [ CProp
( "cons"
, [ CVar 0
; CProp
( "cons"
, [ CVar 1
; CProp
( "cons"
, [ CVar 2
; CProp
( "cons"
, [ CVar 3
; CProp
( "cons"
, [ CVar 4
; CProp ("cons", [ CVar 5; CVar 6 ])
] )
] )
] )
] )
] )
] )
; CProp ("plus", [ CProp ("six", []); CProp ("length", [ CVar 6 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("add1", [ CProp ("add1", [ CVar 23 ]) ]); CProp ("two", []) ] )
; CProp ("fix", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "quotient"
, [ CProp ("plus", [ CVar 23; CProp ("plus", [ CVar 23; CVar 24 ]) ])
; CProp ("two", [])
] )
; CProp ("plus", [ CVar 23; CProp ("quotient", [ CVar 24; CProp ("two", []) ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("sigma", [ CProp ("zero", []); CVar 8 ])
; CProp
( "quotient"
, [ CProp ("times", [ CVar 8; CProp ("add1", [ CVar 8 ]) ])
; CProp ("two", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("plus", [ CVar 23; CProp ("add1", [ CVar 24 ]) ])
; CProp
( "if"
, [ CProp ("numberp", [ CVar 24 ])
; CProp ("add1", [ CProp ("plus", [ CVar 23; CVar 24 ]) ])
; CProp ("add1", [ CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("difference", [ CVar 23; CVar 24 ])
; CProp ("difference", [ CVar 25; CVar 24 ])
] )
; CProp
( "if"
, [ CProp ("lt", [ CVar 23; CVar 24 ])
; CProp ("not", [ CProp ("lt", [ CVar 24; CVar 25 ]) ])
; CProp
( "if"
, [ CProp ("lt", [ CVar 25; CVar 24 ])
; CProp ("not", [ CProp ("lt", [ CVar 24; CVar 23 ]) ])
; CProp
( "equal"
, [ CProp ("fix", [ CVar 23 ]); CProp ("fix", [ CVar 25 ]) ] )
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "meaning"
, [ CProp ("plus_tree", [ CProp ("delete", [ CVar 23; CVar 24 ]) ]); CVar 0 ]
)
; CProp
( "if"
, [ CProp ("member", [ CVar 23; CVar 24 ])
; CProp
( "difference"
, [ CProp ("meaning", [ CProp ("plus_tree", [ CVar 24 ]); CVar 0 ])
; CProp ("meaning", [ CVar 23; CVar 0 ])
] )
; CProp ("meaning", [ CProp ("plus_tree", [ CVar 24 ]); CVar 0 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CVar 23; CProp ("add1", [ CVar 24 ]) ])
; CProp
( "if"
, [ CProp ("numberp", [ CVar 24 ])
; CProp
( "plus"
, [ CVar 23
; CProp ("times", [ CVar 23; CVar 24 ])
; CProp ("fix", [ CVar 23 ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("nth", [ CProp ("nil", []); CVar 8 ])
; CProp
("if", [ CProp ("zerop", [ CVar 8 ]); CProp ("nil", []); CProp ("zero", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("last", [ CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 1 ])
; CProp ("last", [ CVar 1 ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 0 ])
; CProp
( "cons"
, [ CProp ("car", [ CProp ("last", [ CVar 0 ]) ]); CVar 1 ] )
; CVar 1
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("lt", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp
( "if"
, [ CProp ("lt", [ CVar 23; CVar 24 ])
; CProp ("equal", [ CProp ("true", []); CVar 25 ])
; CProp ("equal", [ CProp ("false", []); CVar 25 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("assignment", [ CVar 23; CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
( "if"
, [ CProp ("assignedp", [ CVar 23; CVar 0 ])
; CProp ("assignment", [ CVar 23; CVar 0 ])
; CProp ("assignment", [ CVar 23; CVar 1 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("car", [ CProp ("gother", [ CVar 23 ]) ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 23 ])
; CProp ("car", [ CProp ("flatten", [ CVar 23 ]) ])
; CProp ("zero", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("flatten", [ CProp ("cdr", [ CProp ("gother", [ CVar 23 ]) ]) ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 23 ])
; CProp ("cdr", [ CProp ("flatten", [ CVar 23 ]) ])
; CProp ("cons", [ CProp ("zero", []); CProp ("nil", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("quotient", [ CProp ("times", [ CVar 24; CVar 23 ]); CVar 24 ])
; CProp
( "if"
, [ CProp ("zerop", [ CVar 24 ])
; CProp ("zero", [])
; CProp ("fix", [ CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("get", [ CVar 9; CProp ("set", [ CVar 8; CVar 21; CVar 12 ]) ])
; CProp
( "if"
, [ CProp ("eqp", [ CVar 9; CVar 8 ])
; CVar 21
; CProp ("get", [ CVar 9; CVar 12 ])
] )
] ))
(* Tautology checker *)
let truep x lst =
match x with
| Prop (head, _) -> head.name = "true" || List.mem x lst
| _ -> List.mem x lst
and falsep x lst =
match x with
| Prop (head, _) -> head.name = "false" || List.mem x lst
| _ -> List.mem x lst
let rec tautologyp x true_lst false_lst =
if truep x true_lst
then true
else if falsep x false_lst
then false
else
(*
print_term x; print_newline();
*)
match x with
| Var _ -> false
| Prop (head, [ test; yes; no ]) ->
if head.name = "if"
then
if truep test true_lst
then tautologyp yes true_lst false_lst
else if falsep test false_lst
then tautologyp no true_lst false_lst
else
tautologyp yes (test :: true_lst) false_lst
&& tautologyp no true_lst (test :: false_lst)
else false
| _ -> assert false
let tautp x =
(* print_term x; print_string"\n"; *)
let y = rewrite x in
(* print_term y; print_string "\n"; *)
tautologyp y [] []
(* the benchmark *)
let subst =
[ Bind
( 23
, cterm_to_term
(CProp
( "f"
, [ CProp
( "plus"
, [ CProp ("plus", [ CVar 0; CVar 1 ])
; CProp ("plus", [ CVar 2; CProp ("zero", []) ])
] )
] )) )
; Bind
( 24
, cterm_to_term
(CProp
( "f"
, [ CProp
( "times"
, [ CProp ("times", [ CVar 0; CVar 1 ])
; CProp ("plus", [ CVar 2; CVar 3 ])
] )
] )) )
; Bind
( 25
, cterm_to_term
(CProp
( "f"
, [ CProp
( "reverse"
, [ CProp
( "append"
, [ CProp ("append", [ CVar 0; CVar 1 ]); CProp ("nil", []) ] )
] )
] )) )
; Bind
( 20
, cterm_to_term
(CProp
( "equal"
, [ CProp ("plus", [ CVar 0; CVar 1 ])
; CProp ("difference", [ CVar 23; CVar 24 ])
] )) )
; Bind
( 22
, cterm_to_term
(CProp
( "lt"
, [ CProp ("remainder", [ CVar 0; CVar 1 ])
; CProp ("member", [ CVar 0; CProp ("length", [ CVar 1 ]) ])
] )) )
]
let term =
cterm_to_term
(CProp
( "implies"
, [ CProp
( "and"
, [ CProp ("implies", [ CVar 23; CVar 24 ])
; CProp
( "and"
, [ CProp ("implies", [ CVar 24; CVar 25 ])
; CProp
( "and"
, [ CProp ("implies", [ CVar 25; CVar 20 ])
; CProp ("implies", [ CVar 20; CVar 22 ])
] )
] )
] )
; CProp ("implies", [ CVar 23; CVar 22 ])
] ))
let _ =
let ok = ref true in
for _ = 1 to 50 do
if not (tautp (apply_subst subst term)) then ok := false
done;
assert !ok
(*
if !ok then
print_string "Proved!\n"
else
print_string "Cannot prove!\n";
exit 0
*)
(*********
with
failure s ->
print_string "Exception failure("; print_string s; print_string ")\n"
| Unify ->
print_string "Exception Unify\n"
| match_failure(file,start,stop) ->
print_string "Exception match_failure(";
print_string file;
print_string ",";
print_int start;
print_string ",";
print_int stop;
print_string ")\n"
| _ ->
print_string "Exception ?\n"
**********)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/boyer_no_exc.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: boyer.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
(* Manipulations over terms *)
type term =
| Var of int
| Prop of head * term list
and head =
{ name : string
; mutable props : (term * term) list
}
let rec print_term = function
| Var v ->
print_string "v";
print_int v
| Prop (head, argl) ->
print_string "(";
print_string head.name;
List.iter
(fun t ->
print_string " ";
print_term t)
argl;
print_string ")"
let lemmas = ref ([] : head list)
(* Replacement for property lists *)
let get name =
let rec get_rec = function
| hd1 :: hdl -> if hd1.name = name then hd1 else get_rec hdl
| [] ->
let entry = { name; props = [] } in
lemmas := entry :: !lemmas;
entry
in
get_rec !lemmas
let add_lemma = function
| Prop (_, [ (Prop (headl, _) as left); right ]) ->
headl.props <- (left, right) :: headl.props
| _ -> assert false
(* Substitutions *)
type subst = Bind of int * term
let get_binding v list =
let rec get_rec = function
| [] -> None
| Bind (w, t) :: rest -> if v = w then Some t else get_rec rest
in
get_rec list
let apply_subst alist term =
let rec as_rec = function
| Var v -> (
match get_binding v alist with
| Some t -> t
| None -> term)
| Prop (head, argl) -> Prop (head, List.map as_rec argl)
in
as_rec term
exception Unify
let rec unify term1 term2 = unify1 term1 term2 []
and unify1 term1 term2 unify_subst =
match term2 with
| Var v -> (
match get_binding v unify_subst with
| Some t when t = term1 -> Some unify_subst
| Some _ -> None
| None -> Some (Bind (v, term1) :: unify_subst))
| Prop (head2, argl2) -> (
match term1 with
| Var _ -> None
| Prop (head1, argl1) ->
if head1 == head2 then unify1_lst argl1 argl2 unify_subst else None)
and unify1_lst l1 l2 unify_subst =
match l1, l2 with
| [], [] -> Some unify_subst
| h1 :: r1, h2 :: r2 -> (
match unify1 h1 h2 unify_subst with
| Some unify_subst -> unify1_lst r1 r2 unify_subst
| None -> None)
| _ -> None
let rec rewrite = function
| Var _ as term -> term
| Prop (head, argl) ->
rewrite_with_lemmas (Prop (head, List.map rewrite argl)) head.props
and rewrite_with_lemmas term lemmas =
match lemmas with
| [] -> term
| (t1, t2) :: rest -> (
match unify term t1 with
| Some unify_subst -> rewrite (apply_subst unify_subst t2)
| None -> rewrite_with_lemmas term rest)
type cterm =
| CVar of int
| CProp of string * cterm list
let rec cterm_to_term = function
| CVar v -> Var v
| CProp (p, l) -> Prop (get p, List.map cterm_to_term l)
let add t = add_lemma (cterm_to_term t)
let _ =
add
(CProp
( "equal"
, [ CProp ("compile", [ CVar 5 ])
; CProp
( "reverse"
, [ CProp ("codegen", [ CProp ("optimize", [ CVar 5 ]); CProp ("nil", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("eqp", [ CVar 23; CVar 24 ])
; CProp ("equal", [ CProp ("fix", [ CVar 23 ]); CProp ("fix", [ CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("gt", [ CVar 23; CVar 24 ]); CProp ("lt", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("le", [ CVar 23; CVar 24 ]); CProp ("ge", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("ge", [ CVar 23; CVar 24 ]); CProp ("le", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("boolean", [ CVar 23 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("true", []) ])
; CProp ("equal", [ CVar 23; CProp ("false", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("iff", [ CVar 23; CVar 24 ])
; CProp
( "and"
, [ CProp ("implies", [ CVar 23; CVar 24 ])
; CProp ("implies", [ CVar 24; CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("even1", [ CVar 23 ])
; CProp
( "if"
, [ CProp ("zerop", [ CVar 23 ])
; CProp ("true", [])
; CProp ("odd", [ CProp ("sub1", [ CVar 23 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("countps_", [ CVar 11; CVar 15 ])
; CProp ("countps_loop", [ CVar 11; CVar 15; CProp ("zero", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("fact_", [ CVar 8 ])
; CProp ("fact_loop", [ CVar 8; CProp ("one", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse_", [ CVar 23 ])
; CProp ("reverse_loop", [ CVar 23; CProp ("nil", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("divides", [ CVar 23; CVar 24 ])
; CProp ("zerop", [ CProp ("remainder", [ CVar 24; CVar 23 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("assume_true", [ CVar 21; CVar 0 ])
; CProp ("cons", [ CProp ("cons", [ CVar 21; CProp ("true", []) ]); CVar 0 ])
] ));
add
(CProp
( "equal"
, [ CProp ("assume_false", [ CVar 21; CVar 0 ])
; CProp ("cons", [ CProp ("cons", [ CVar 21; CProp ("false", []) ]); CVar 0 ])
] ));
add
(CProp
( "equal"
, [ CProp ("tautology_checker", [ CVar 23 ])
; CProp ("tautologyp", [ CProp ("normalize", [ CVar 23 ]); CProp ("nil", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("falsify", [ CVar 23 ])
; CProp ("falsify1", [ CProp ("normalize", [ CVar 23 ]); CProp ("nil", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("prime", [ CVar 23 ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 23 ]) ])
; CProp
( "not"
, [ CProp ("equal", [ CVar 23; CProp ("add1", [ CProp ("zero", []) ]) ])
] )
; CProp ("prime1", [ CVar 23; CProp ("sub1", [ CVar 23 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("and", [ CVar 15; CVar 16 ])
; CProp
( "if"
, [ CVar 15
; CProp ("if", [ CVar 16; CProp ("true", []); CProp ("false", []) ])
; CProp ("false", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("or", [ CVar 15; CVar 16 ])
; CProp
( "if"
, [ CVar 15
; CProp ("true", [])
; CProp ("if", [ CVar 16; CProp ("true", []); CProp ("false", []) ])
; CProp ("false", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("not", [ CVar 15 ])
; CProp ("if", [ CVar 15; CProp ("false", []); CProp ("true", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("implies", [ CVar 15; CVar 16 ])
; CProp
( "if"
, [ CVar 15
; CProp ("if", [ CVar 16; CProp ("true", []); CProp ("false", []) ])
; CProp ("true", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("fix", [ CVar 23 ])
; CProp ("if", [ CProp ("numberp", [ CVar 23 ]); CVar 23; CProp ("zero", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("if", [ CProp ("if", [ CVar 0; CVar 1; CVar 2 ]); CVar 3; CVar 4 ])
; CProp
( "if"
, [ CVar 0
; CProp ("if", [ CVar 1; CVar 3; CVar 4 ])
; CProp ("if", [ CVar 2; CVar 3; CVar 4 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("zerop", [ CVar 23 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("zero", []) ])
; CProp ("not", [ CProp ("numberp", [ CVar 23 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("plus", [ CProp ("plus", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp ("plus", [ CVar 23; CProp ("plus", [ CVar 24; CVar 25 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("plus", [ CVar 0; CVar 1 ]); CProp ("zero", []) ])
; CProp ("and", [ CProp ("zerop", [ CVar 0 ]); CProp ("zerop", [ CVar 1 ]) ])
] ));
add
(CProp ("equal", [ CProp ("difference", [ CVar 23; CVar 23 ]); CProp ("zero", []) ]));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("plus", [ CVar 0; CVar 1 ]); CProp ("plus", [ CVar 0; CVar 2 ]) ]
)
; CProp ("equal", [ CProp ("fix", [ CVar 1 ]); CProp ("fix", [ CVar 2 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
("equal", [ CProp ("zero", []); CProp ("difference", [ CVar 23; CVar 24 ]) ])
; CProp ("not", [ CProp ("gt", [ CVar 24; CVar 23 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CVar 23; CProp ("difference", [ CVar 23; CVar 24 ]) ])
; CProp
( "and"
, [ CProp ("numberp", [ CVar 23 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("zero", []) ])
; CProp ("zerop", [ CVar 24 ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "meaning"
, [ CProp ("plus_tree", [ CProp ("append", [ CVar 23; CVar 24 ]) ]); CVar 0 ]
)
; CProp
( "plus"
, [ CProp ("meaning", [ CProp ("plus_tree", [ CVar 23 ]); CVar 0 ])
; CProp ("meaning", [ CProp ("plus_tree", [ CVar 24 ]); CVar 0 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "meaning"
, [ CProp ("plus_tree", [ CProp ("plus_fringe", [ CVar 23 ]) ]); CVar 0 ] )
; CProp ("fix", [ CProp ("meaning", [ CVar 23; CVar 0 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("append", [ CProp ("append", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp ("append", [ CVar 23; CProp ("append", [ CVar 24; CVar 25 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse", [ CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
("append", [ CProp ("reverse", [ CVar 1 ]); CProp ("reverse", [ CVar 0 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CVar 23; CProp ("plus", [ CVar 24; CVar 25 ]) ])
; CProp
( "plus"
, [ CProp ("times", [ CVar 23; CVar 24 ])
; CProp ("times", [ CVar 23; CVar 25 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CProp ("times", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp ("times", [ CVar 23; CProp ("times", [ CVar 24; CVar 25 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("times", [ CVar 23; CVar 24 ]); CProp ("zero", []) ])
; CProp ("or", [ CProp ("zerop", [ CVar 23 ]); CProp ("zerop", [ CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("exec", [ CProp ("append", [ CVar 23; CVar 24 ]); CVar 15; CVar 4 ])
; CProp
("exec", [ CVar 24; CProp ("exec", [ CVar 23; CVar 15; CVar 4 ]); CVar 4 ])
] ));
add
(CProp
( "equal"
, [ CProp ("mc_flatten", [ CVar 23; CVar 24 ])
; CProp ("append", [ CProp ("flatten", [ CVar 23 ]); CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("member", [ CVar 23; CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
( "or"
, [ CProp ("member", [ CVar 23; CVar 0 ])
; CProp ("member", [ CVar 23; CVar 1 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("member", [ CVar 23; CProp ("reverse", [ CVar 24 ]) ])
; CProp ("member", [ CVar 23; CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("length", [ CProp ("reverse", [ CVar 23 ]) ])
; CProp ("length", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp ("member", [ CVar 0; CProp ("intersect", [ CVar 1; CVar 2 ]) ])
; CProp
( "and"
, [ CProp ("member", [ CVar 0; CVar 1 ])
; CProp ("member", [ CVar 0; CVar 2 ])
] )
] ));
add
(CProp ("equal", [ CProp ("nth", [ CProp ("zero", []); CVar 8 ]); CProp ("zero", []) ]));
add
(CProp
( "equal"
, [ CProp ("exp", [ CVar 8; CProp ("plus", [ CVar 9; CVar 10 ]) ])
; CProp
( "times"
, [ CProp ("exp", [ CVar 8; CVar 9 ]); CProp ("exp", [ CVar 8; CVar 10 ]) ]
)
] ));
add
(CProp
( "equal"
, [ CProp ("exp", [ CVar 8; CProp ("times", [ CVar 9; CVar 10 ]) ])
; CProp ("exp", [ CProp ("exp", [ CVar 8; CVar 9 ]); CVar 10 ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse_loop", [ CVar 23; CVar 24 ])
; CProp ("append", [ CProp ("reverse", [ CVar 23 ]); CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("reverse_loop", [ CVar 23; CProp ("nil", []) ])
; CProp ("reverse", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp ("count_list", [ CVar 25; CProp ("sort_lp", [ CVar 23; CVar 24 ]) ])
; CProp
( "plus"
, [ CProp ("count_list", [ CVar 25; CVar 23 ])
; CProp ("count_list", [ CVar 25; CVar 24 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("append", [ CVar 0; CVar 1 ])
; CProp ("append", [ CVar 0; CVar 2 ])
] )
; CProp ("equal", [ CVar 1; CVar 2 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "plus"
, [ CProp ("remainder", [ CVar 23; CVar 24 ])
; CProp ("times", [ CVar 24; CProp ("quotient", [ CVar 23; CVar 24 ]) ])
] )
; CProp ("fix", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp
("power_eval", [ CProp ("big_plus", [ CVar 11; CVar 8; CVar 1 ]); CVar 1 ])
; CProp ("plus", [ CProp ("power_eval", [ CVar 11; CVar 1 ]); CVar 8 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "power_eval"
, [ CProp ("big_plus", [ CVar 23; CVar 24; CVar 8; CVar 1 ]); CVar 1 ] )
; CProp
( "plus"
, [ CVar 8
; CProp
( "plus"
, [ CProp ("power_eval", [ CVar 23; CVar 1 ])
; CProp ("power_eval", [ CVar 24; CVar 1 ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("remainder", [ CVar 24; CProp ("one", []) ]); CProp ("zero", []) ] ));
add
(CProp
( "equal"
, [ CProp ("lt", [ CProp ("remainder", [ CVar 23; CVar 24 ]); CVar 24 ])
; CProp ("not", [ CProp ("zerop", [ CVar 24 ]) ])
] ));
add (CProp ("equal", [ CProp ("remainder", [ CVar 23; CVar 23 ]); CProp ("zero", []) ]));
add
(CProp
( "equal"
, [ CProp ("lt", [ CProp ("quotient", [ CVar 8; CVar 9 ]); CVar 8 ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 8 ]) ])
; CProp
( "or"
, [ CProp ("zerop", [ CVar 9 ])
; CProp ("not", [ CProp ("equal", [ CVar 9; CProp ("one", []) ]) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("lt", [ CProp ("remainder", [ CVar 23; CVar 24 ]); CVar 23 ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 24 ]) ])
; CProp ("not", [ CProp ("zerop", [ CVar 23 ]) ])
; CProp ("not", [ CProp ("lt", [ CVar 23; CVar 24 ]) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("power_eval", [ CProp ("power_rep", [ CVar 8; CVar 1 ]); CVar 1 ])
; CProp ("fix", [ CVar 8 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "power_eval"
, [ CProp
( "big_plus"
, [ CProp ("power_rep", [ CVar 8; CVar 1 ])
; CProp ("power_rep", [ CVar 9; CVar 1 ])
; CProp ("zero", [])
; CVar 1
] )
; CVar 1
] )
; CProp ("plus", [ CVar 8; CVar 9 ])
] ));
add
(CProp
( "equal"
, [ CProp ("gcd", [ CVar 23; CVar 24 ]); CProp ("gcd", [ CVar 24; CVar 23 ]) ] ));
add
(CProp
( "equal"
, [ CProp ("nth", [ CProp ("append", [ CVar 0; CVar 1 ]); CVar 8 ])
; CProp
( "append"
, [ CProp ("nth", [ CVar 0; CVar 8 ])
; CProp
( "nth"
, [ CVar 1
; CProp ("difference", [ CVar 8; CProp ("length", [ CVar 0 ]) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("difference", [ CProp ("plus", [ CVar 23; CVar 24 ]); CVar 23 ])
; CProp ("fix", [ CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp ("difference", [ CProp ("plus", [ CVar 24; CVar 23 ]); CVar 23 ])
; CProp ("fix", [ CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("plus", [ CVar 23; CVar 24 ])
; CProp ("plus", [ CVar 23; CVar 25 ])
] )
; CProp ("difference", [ CVar 24; CVar 25 ])
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CVar 23; CProp ("difference", [ CVar 2; CVar 22 ]) ])
; CProp
( "difference"
, [ CProp ("times", [ CVar 2; CVar 23 ])
; CProp ("times", [ CVar 22; CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("remainder", [ CProp ("times", [ CVar 23; CVar 25 ]); CVar 25 ])
; CProp ("zero", [])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("plus", [ CVar 1; CProp ("plus", [ CVar 0; CVar 2 ]) ]); CVar 0 ]
)
; CProp ("plus", [ CVar 1; CVar 2 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("add1", [ CProp ("plus", [ CVar 24; CVar 25 ]) ]); CVar 25 ] )
; CProp ("add1", [ CVar 24 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "lt"
, [ CProp ("plus", [ CVar 23; CVar 24 ])
; CProp ("plus", [ CVar 23; CVar 25 ])
] )
; CProp ("lt", [ CVar 24; CVar 25 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "lt"
, [ CProp ("times", [ CVar 23; CVar 25 ])
; CProp ("times", [ CVar 24; CVar 25 ])
] )
; CProp
( "and"
, [ CProp ("not", [ CProp ("zerop", [ CVar 25 ]) ])
; CProp ("lt", [ CVar 23; CVar 24 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("lt", [ CVar 24; CProp ("plus", [ CVar 23; CVar 24 ]) ])
; CProp ("not", [ CProp ("zerop", [ CVar 23 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
( "gcd"
, [ CProp ("times", [ CVar 23; CVar 25 ])
; CProp ("times", [ CVar 24; CVar 25 ])
] )
; CProp ("times", [ CVar 25; CProp ("gcd", [ CVar 23; CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("value", [ CProp ("normalize", [ CVar 23 ]); CVar 0 ])
; CProp ("value", [ CVar 23; CVar 0 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("flatten", [ CVar 23 ])
; CProp ("cons", [ CVar 24; CProp ("nil", []) ])
] )
; CProp
( "and"
, [ CProp ("nlistp", [ CVar 23 ]); CProp ("equal", [ CVar 23; CVar 24 ]) ] )
] ));
add
(CProp
( "equal"
, [ CProp ("listp", [ CProp ("gother", [ CVar 23 ]) ])
; CProp ("listp", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp ("samefringe", [ CVar 23; CVar 24 ])
; CProp
("equal", [ CProp ("flatten", [ CVar 23 ]); CProp ("flatten", [ CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("greatest_factor", [ CVar 23; CVar 24 ]); CProp ("zero", []) ] )
; CProp
( "and"
, [ CProp
( "or"
, [ CProp ("zerop", [ CVar 24 ])
; CProp ("equal", [ CVar 24; CProp ("one", []) ])
] )
; CProp ("equal", [ CVar 23; CProp ("zero", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("greatest_factor", [ CVar 23; CVar 24 ]); CProp ("one", []) ] )
; CProp ("equal", [ CVar 23; CProp ("one", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("numberp", [ CProp ("greatest_factor", [ CVar 23; CVar 24 ]) ])
; CProp
( "not"
, [ CProp
( "and"
, [ CProp
( "or"
, [ CProp ("zerop", [ CVar 24 ])
; CProp ("equal", [ CVar 24; CProp ("one", []) ])
] )
; CProp ("not", [ CProp ("numberp", [ CVar 23 ]) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("times_list", [ CProp ("append", [ CVar 23; CVar 24 ]) ])
; CProp
( "times"
, [ CProp ("times_list", [ CVar 23 ]); CProp ("times_list", [ CVar 24 ]) ] )
] ));
add
(CProp
( "equal"
, [ CProp ("prime_list", [ CProp ("append", [ CVar 23; CVar 24 ]) ])
; CProp
( "and"
, [ CProp ("prime_list", [ CVar 23 ]); CProp ("prime_list", [ CVar 24 ]) ] )
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CVar 25; CProp ("times", [ CVar 22; CVar 25 ]) ])
; CProp
( "and"
, [ CProp ("numberp", [ CVar 25 ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 25; CProp ("zero", []) ])
; CProp ("equal", [ CVar 22; CProp ("one", []) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("ge", [ CVar 23; CVar 24 ])
; CProp ("not", [ CProp ("lt", [ CVar 23; CVar 24 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CVar 23; CProp ("times", [ CVar 23; CVar 24 ]) ])
; CProp
( "or"
, [ CProp ("equal", [ CVar 23; CProp ("zero", []) ])
; CProp
( "and"
, [ CProp ("numberp", [ CVar 23 ])
; CProp ("equal", [ CVar 24; CProp ("one", []) ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("remainder", [ CProp ("times", [ CVar 24; CVar 23 ]); CVar 24 ])
; CProp ("zero", [])
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("times", [ CVar 0; CVar 1 ]); CProp ("one", []) ])
; CProp
( "and"
, [ CProp ("not", [ CProp ("equal", [ CVar 0; CProp ("zero", []) ]) ])
; CProp ("not", [ CProp ("equal", [ CVar 1; CProp ("zero", []) ]) ])
; CProp ("numberp", [ CVar 0 ])
; CProp ("numberp", [ CVar 1 ])
; CProp ("equal", [ CProp ("sub1", [ CVar 0 ]); CProp ("zero", []) ])
; CProp ("equal", [ CProp ("sub1", [ CVar 1 ]); CProp ("zero", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "lt"
, [ CProp ("length", [ CProp ("delete", [ CVar 23; CVar 11 ]) ])
; CProp ("length", [ CVar 11 ])
] )
; CProp ("member", [ CVar 23; CVar 11 ])
] ));
add
(CProp
( "equal"
, [ CProp ("sort2", [ CProp ("delete", [ CVar 23; CVar 11 ]) ])
; CProp ("delete", [ CVar 23; CProp ("sort2", [ CVar 11 ]) ])
] ));
add (CProp ("equal", [ CProp ("dsort", [ CVar 23 ]); CProp ("sort2", [ CVar 23 ]) ]));
add
(CProp
( "equal"
, [ CProp
( "length"
, [ CProp
( "cons"
, [ CVar 0
; CProp
( "cons"
, [ CVar 1
; CProp
( "cons"
, [ CVar 2
; CProp
( "cons"
, [ CVar 3
; CProp
( "cons"
, [ CVar 4
; CProp ("cons", [ CVar 5; CVar 6 ])
] )
] )
] )
] )
] )
] )
; CProp ("plus", [ CProp ("six", []); CProp ("length", [ CVar 6 ]) ])
] ));
add
(CProp
( "equal"
, [ CProp
( "difference"
, [ CProp ("add1", [ CProp ("add1", [ CVar 23 ]) ]); CProp ("two", []) ] )
; CProp ("fix", [ CVar 23 ])
] ));
add
(CProp
( "equal"
, [ CProp
( "quotient"
, [ CProp ("plus", [ CVar 23; CProp ("plus", [ CVar 23; CVar 24 ]) ])
; CProp ("two", [])
] )
; CProp ("plus", [ CVar 23; CProp ("quotient", [ CVar 24; CProp ("two", []) ]) ])
] ));
add
(CProp
( "equal"
, [ CProp ("sigma", [ CProp ("zero", []); CVar 8 ])
; CProp
( "quotient"
, [ CProp ("times", [ CVar 8; CProp ("add1", [ CVar 8 ]) ])
; CProp ("two", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("plus", [ CVar 23; CProp ("add1", [ CVar 24 ]) ])
; CProp
( "if"
, [ CProp ("numberp", [ CVar 24 ])
; CProp ("add1", [ CProp ("plus", [ CVar 23; CVar 24 ]) ])
; CProp ("add1", [ CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "equal"
, [ CProp ("difference", [ CVar 23; CVar 24 ])
; CProp ("difference", [ CVar 25; CVar 24 ])
] )
; CProp
( "if"
, [ CProp ("lt", [ CVar 23; CVar 24 ])
; CProp ("not", [ CProp ("lt", [ CVar 24; CVar 25 ]) ])
; CProp
( "if"
, [ CProp ("lt", [ CVar 25; CVar 24 ])
; CProp ("not", [ CProp ("lt", [ CVar 24; CVar 23 ]) ])
; CProp
( "equal"
, [ CProp ("fix", [ CVar 23 ]); CProp ("fix", [ CVar 25 ]) ] )
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp
( "meaning"
, [ CProp ("plus_tree", [ CProp ("delete", [ CVar 23; CVar 24 ]) ]); CVar 0 ]
)
; CProp
( "if"
, [ CProp ("member", [ CVar 23; CVar 24 ])
; CProp
( "difference"
, [ CProp ("meaning", [ CProp ("plus_tree", [ CVar 24 ]); CVar 0 ])
; CProp ("meaning", [ CVar 23; CVar 0 ])
] )
; CProp ("meaning", [ CProp ("plus_tree", [ CVar 24 ]); CVar 0 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("times", [ CVar 23; CProp ("add1", [ CVar 24 ]) ])
; CProp
( "if"
, [ CProp ("numberp", [ CVar 24 ])
; CProp
( "plus"
, [ CVar 23
; CProp ("times", [ CVar 23; CVar 24 ])
; CProp ("fix", [ CVar 23 ])
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("nth", [ CProp ("nil", []); CVar 8 ])
; CProp
("if", [ CProp ("zerop", [ CVar 8 ]); CProp ("nil", []); CProp ("zero", []) ])
] ));
add
(CProp
( "equal"
, [ CProp ("last", [ CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 1 ])
; CProp ("last", [ CVar 1 ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 0 ])
; CProp
( "cons"
, [ CProp ("car", [ CProp ("last", [ CVar 0 ]) ]); CVar 1 ] )
; CVar 1
] )
] )
] ));
add
(CProp
( "equal"
, [ CProp ("equal", [ CProp ("lt", [ CVar 23; CVar 24 ]); CVar 25 ])
; CProp
( "if"
, [ CProp ("lt", [ CVar 23; CVar 24 ])
; CProp ("equal", [ CProp ("true", []); CVar 25 ])
; CProp ("equal", [ CProp ("false", []); CVar 25 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("assignment", [ CVar 23; CProp ("append", [ CVar 0; CVar 1 ]) ])
; CProp
( "if"
, [ CProp ("assignedp", [ CVar 23; CVar 0 ])
; CProp ("assignment", [ CVar 23; CVar 0 ])
; CProp ("assignment", [ CVar 23; CVar 1 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("car", [ CProp ("gother", [ CVar 23 ]) ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 23 ])
; CProp ("car", [ CProp ("flatten", [ CVar 23 ]) ])
; CProp ("zero", [])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("flatten", [ CProp ("cdr", [ CProp ("gother", [ CVar 23 ]) ]) ])
; CProp
( "if"
, [ CProp ("listp", [ CVar 23 ])
; CProp ("cdr", [ CProp ("flatten", [ CVar 23 ]) ])
; CProp ("cons", [ CProp ("zero", []); CProp ("nil", []) ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("quotient", [ CProp ("times", [ CVar 24; CVar 23 ]); CVar 24 ])
; CProp
( "if"
, [ CProp ("zerop", [ CVar 24 ])
; CProp ("zero", [])
; CProp ("fix", [ CVar 23 ])
] )
] ));
add
(CProp
( "equal"
, [ CProp ("get", [ CVar 9; CProp ("set", [ CVar 8; CVar 21; CVar 12 ]) ])
; CProp
( "if"
, [ CProp ("eqp", [ CVar 9; CVar 8 ])
; CVar 21
; CProp ("get", [ CVar 9; CVar 12 ])
] )
] ))
(* Tautology checker *)
let truep x lst =
match x with
| Prop (head, _) -> head.name = "true" || List.mem x lst
| _ -> List.mem x lst
and falsep x lst =
match x with
| Prop (head, _) -> head.name = "false" || List.mem x lst
| _ -> List.mem x lst
let rec tautologyp x true_lst false_lst =
if truep x true_lst
then true
else if falsep x false_lst
then false
else
(*
print_term x; print_newline();
*)
match x with
| Var _ -> false
| Prop (head, [ test; yes; no ]) ->
if head.name = "if"
then
if truep test true_lst
then tautologyp yes true_lst false_lst
else if falsep test false_lst
then tautologyp no true_lst false_lst
else
tautologyp yes (test :: true_lst) false_lst
&& tautologyp no true_lst (test :: false_lst)
else false
| _ -> assert false
let tautp x =
(* print_term x; print_string"\n"; *)
let y = rewrite x in
(* print_term y; print_string "\n"; *)
tautologyp y [] []
(* the benchmark *)
let subst =
[ Bind
( 23
, cterm_to_term
(CProp
( "f"
, [ CProp
( "plus"
, [ CProp ("plus", [ CVar 0; CVar 1 ])
; CProp ("plus", [ CVar 2; CProp ("zero", []) ])
] )
] )) )
; Bind
( 24
, cterm_to_term
(CProp
( "f"
, [ CProp
( "times"
, [ CProp ("times", [ CVar 0; CVar 1 ])
; CProp ("plus", [ CVar 2; CVar 3 ])
] )
] )) )
; Bind
( 25
, cterm_to_term
(CProp
( "f"
, [ CProp
( "reverse"
, [ CProp
( "append"
, [ CProp ("append", [ CVar 0; CVar 1 ]); CProp ("nil", []) ] )
] )
] )) )
; Bind
( 20
, cterm_to_term
(CProp
( "equal"
, [ CProp ("plus", [ CVar 0; CVar 1 ])
; CProp ("difference", [ CVar 23; CVar 24 ])
] )) )
; Bind
( 22
, cterm_to_term
(CProp
( "lt"
, [ CProp ("remainder", [ CVar 0; CVar 1 ])
; CProp ("member", [ CVar 0; CProp ("length", [ CVar 1 ]) ])
] )) )
]
let term =
cterm_to_term
(CProp
( "implies"
, [ CProp
( "and"
, [ CProp ("implies", [ CVar 23; CVar 24 ])
; CProp
( "and"
, [ CProp ("implies", [ CVar 24; CVar 25 ])
; CProp
( "and"
, [ CProp ("implies", [ CVar 25; CVar 20 ])
; CProp ("implies", [ CVar 20; CVar 22 ])
] )
] )
] )
; CProp ("implies", [ CVar 23; CVar 22 ])
] ))
let _ =
let ok = ref true in
for _ = 1 to 50 do
if not (tautp (apply_subst subst term)) then ok := false
done;
assert !ok
(*
if !ok then
print_string "Proved!\n"
else
print_string "Cannot prove!\n";
exit 0
*)
(*********
with
failure s ->
print_string "Exception failure("; print_string s; print_string ")\n"
| Unify ->
print_string "Exception Unify\n"
| match_failure(file,start,stop) ->
print_string "Exception match_failure(";
print_string file;
print_string ",";
print_int start;
print_string ",";
print_int stop;
print_string ")\n"
| _ ->
print_string "Exception ?\n"
**********)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/dune
|
(executables
(names
almabench
bdd
binary_trees
boyer
boyer_no_exc
fannkuch_redux_2
fannkuch_redux
fft
fib
hamming
kb
kb_no_exc
loop
nucleic
quicksort
raytrace
soli
splay
takc
taku))
(alias
(name benchmark)
(deps
almabench.exe
bdd.exe
binary_trees.exe
boyer.exe
boyer_no_exc.exe
fannkuch_redux_2.exe
fannkuch_redux.exe
fft.exe
fib.exe
hamming.exe
kb.exe
kb_no_exc.exe
loop.exe
nucleic.exe
quicksort.exe
raytrace.exe
soli.exe
splay.exe
takc.exe
taku.exe))
(env
(_
(flags
(:standard -w -32-34-38-69))))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/fannkuch_redux.ml
|
(* The Computer Language Benchmarks Game
http://shootout.alioth.debian.org/
from Scala version by Otto Bommer, August 2010
*)
let fannkuch n =
let perm1 = Array.make n 0 in
for i = 0 to n - 1 do
perm1.(i) <- i
done;
let perm = Array.make n 0 in
let count = Array.make n 0 in
let flips = ref 0
and maxflips = ref 0
and checksum = ref 0
and nperm = ref 0
and r = ref n in
while !r > 0 do
(* Printf.printf "perm="; i := 0; while !i < n do Printf.printf "%d " perm1.(!i); i := !i +1; done; Printf.printf "\n"; *)
for i = 0 to n - 1 do
perm.(i) <- perm1.(i)
done;
while !r != 1 do
count.(!r - 1) <- !r;
r := !r - 1
done;
flips := 0;
let k = ref perm.(0) in
while !k != 0 do
let t = ref 0 in
for i = 0 to !k / 2 do
t := perm.(i);
perm.(i) <- perm.(!k - i);
perm.(!k - i) <- !t
done;
k := perm.(0);
flips := !flips + 1
done;
maxflips := max !maxflips !flips;
checksum := !checksum + (!flips * (1 - ((!nperm land 1) lsl 1)));
let go = ref true in
let t = ref 0 in
while !go do
if !r == n
then (
go := false;
r := 0)
else (
t := perm1.(0);
for i = 0 to !r - 1 do
perm1.(i) <- perm1.(i + 1)
done;
perm1.(!r) <- !t;
count.(!r) <- count.(!r) - 1;
if count.(!r) > 0 then go := false else r := !r + 1)
done;
incr nperm
done;
!maxflips, !checksum
let _ =
let n = 10 in
let _maxflips, _checksum = fannkuch n in
( (*
Printf.printf "%d\nPfannkuchen(%d) = %d\n" checksum n maxflips
*) )
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/fannkuch_redux_2.ml
|
(* The Computer Language Benchmarks Game
http://shootout.alioth.debian.org/
contributed by Isaac Gouy, transliterated from Mike Pall's Lua program
*)
let fannkuch n =
let p = Array.make n 0 in
let q = Array.make n 0 in
let s = Array.make n 0 in
let sign = ref 1 in
let maxflips = ref 0 in
let sum = ref 0 in
for i = 0 to n - 1 do
p.(i) <- i;
q.(i) <- i;
s.(i) <- i
done;
while true do
let q0 = ref p.(0) in
if !q0 <> 0
then (
for i = 1 to n - 1 do
q.(i) <- p.(i)
done;
let flips = ref 1 in
while
let qq = q.(!q0) in
if qq = 0
then (
sum := !sum + (!sign * !flips);
if !flips > !maxflips then maxflips := !flips;
false)
else true
do
let qq = q.(!q0) in
q.(!q0) <- !q0;
(if !q0 >= 3
then
let i = ref 1 in
let j = ref (!q0 - 1) in
while
let t = q.(!i) in
q.(!i) <- q.(!j);
q.(!j) <- t;
incr i;
decr j;
!i < !j
do
()
done);
q0 := qq;
incr flips
done);
if !sign = 1
then (
let t = p.(1) in
p.(1) <- p.(0);
p.(0) <- t;
sign := -1)
else
let t = p.(1) in
p.(1) <- p.(2);
p.(2) <- t;
sign := 1;
try
for i = 2 to n - 1 do
let sx = s.(i) in
if sx <> 0
then (
s.(i) <- sx - 1;
raise Exit);
if i = n - 1
then (
if false then Format.eprintf "%d %d@." !sum !maxflips;
exit 0);
s.(i) <- i;
let t = p.(0) in
for j = 0 to i do
p.(j) <- p.(j + 1)
done;
p.(i + 1) <- t
done
with Exit -> ()
done
let n = 10
let pf = fannkuch n
(*
//print(pf[0] + "\n" + "Pfannkuchen(" + n + ") = " + pf[1]);
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/fft.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: fft.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
let pi = 3.14159265358979323846
let tpi = 2.0 *. pi
let fft px py np =
let i = ref 2 in
let m = ref 1 in
while !i < np do
i := !i + !i;
m := !m + 1
done;
let n = !i in
if n <> np
then
for i = np + 1 to n do
px.(i) <- 0.0;
py.(i) <- 0.0
(*
print_string "Use "; print_int n;
print_string " point fft"; print_newline()
*)
done;
let n2 = ref (n + n) in
for _ = 1 to !m - 1 do
n2 := !n2 / 2;
let n4 = !n2 / 4 in
let e = tpi /. float !n2 in
for j = 1 to n4 do
let a = e *. float (j - 1) in
let a3 = 3.0 *. a in
let cc1 = cos a in
let ss1 = sin a in
let cc3 = cos a3 in
let ss3 = sin a3 in
let is = ref j in
let id = ref (2 * !n2) in
while !is < n do
let i0r = ref !is in
while !i0r < n do
let i0 = !i0r in
let i1 = i0 + n4 in
let i2 = i1 + n4 in
let i3 = i2 + n4 in
let r1 = px.(i0) -. px.(i2) in
px.(i0) <- px.(i0) +. px.(i2);
let r2 = px.(i1) -. px.(i3) in
px.(i1) <- px.(i1) +. px.(i3);
let s1 = py.(i0) -. py.(i2) in
py.(i0) <- py.(i0) +. py.(i2);
let s2 = py.(i1) -. py.(i3) in
py.(i1) <- py.(i1) +. py.(i3);
let s3 = r1 -. s2 in
let r1 = r1 +. s2 in
let s2 = r2 -. s1 in
let r2 = r2 +. s1 in
px.(i2) <- (r1 *. cc1) -. (s2 *. ss1);
py.(i2) <- (-.s2 *. cc1) -. (r1 *. ss1);
px.(i3) <- (s3 *. cc3) +. (r2 *. ss3);
py.(i3) <- (r2 *. cc3) -. (s3 *. ss3);
i0r := i0 + !id
done;
is := (2 * !id) - !n2 + j;
id := 4 * !id
done
done
done;
(************************************)
(* Last stage, length=2 butterfly *)
(************************************)
let is = ref 1 in
let id = ref 4 in
while !is < n do
let i0r = ref !is in
while !i0r <= n do
let i0 = !i0r in
let i1 = i0 + 1 in
let r1 = px.(i0) in
px.(i0) <- r1 +. px.(i1);
px.(i1) <- r1 -. px.(i1);
let r1 = py.(i0) in
py.(i0) <- r1 +. py.(i1);
py.(i1) <- r1 -. py.(i1);
i0r := i0 + !id
done;
is := (2 * !id) - 1;
id := 4 * !id
done;
(*************************)
(* Bit reverse counter *)
(*************************)
let j = ref 1 in
for i = 1 to n - 1 do
if i < !j
then (
let xt = px.(!j) in
px.(!j) <- px.(i);
px.(i) <- xt;
let xt = py.(!j) in
py.(!j) <- py.(i);
py.(i) <- xt);
let k = ref (n / 2) in
while !k < !j do
j := !j - !k;
k := !k / 2
done;
j := !j + !k
done;
n
let test np =
(* print_int np; print_string "... "; flush stdout;*)
let enp = float np in
let npm = (np / 2) - 1 in
let pxr = Array.make (np + 2) 0.0 and pxi = Array.make (np + 2) 0.0 in
let t = pi /. enp in
pxr.(1) <- (enp -. 1.0) *. 0.5;
pxi.(1) <- 0.0;
let n2 = np / 2 in
pxr.(n2 + 1) <- -0.5;
pxi.(n2 + 1) <- 0.0;
for i = 1 to npm do
let j = np - i in
pxr.(i + 1) <- -0.5;
pxr.(j + 1) <- -0.5;
let z = t *. float i in
let y = -0.5 *. (cos z /. sin z) in
pxi.(i + 1) <- y;
pxi.(j + 1) <- -.y
done;
(*
print_newline();
for i=0 to 15 do Printf.printf "%d %f %f\n" i pxr.(i+1) pxi.(i+1) done;
*)
let _ = fft pxr pxi np in
(*
for i=0 to 15 do Printf.printf "%d %f %f\n" i pxr.(i+1) pxi.(i+1) done;
*)
let zr = ref 0.0 in
let zi = ref 0.0 in
let kr = ref 0 in
let ki = ref 0 in
for i = 0 to np - 1 do
let a = abs_float (pxr.(i + 1) -. float i) in
if !zr < a
then (
zr := a;
kr := i);
let a = abs_float pxi.(i + 1) in
if !zi < a
then (
zi := a;
ki := i)
done;
(*print !zr; print !zi;*)
if abs_float !zr <= 1e-8 && abs_float !zi <= 1e-8
then ( (*print_string "ok"*) )
else assert false (*print_string "ERROR"*);
( (* print_newline()*) )
let _ =
let np = ref 16 in
for _ = 1 to 19 do
test !np;
np := !np * 2
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/fib.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: fib.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
let rec fib n = if n < 2 then 1 else fib (n - 1) + fib (n - 2)
let _ =
let n = 40 in
(*
if Array.length Sys.argv >= 2
then int_of_string Sys.argv.(1)
else 40 in
*)
assert (fib n = 165580141)
(*; print_newline(); exit 0*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/hamming.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Damien Doligez, projet Moscova, INRIA Rocquencourt *)
(* *)
(* Copyright 2002 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: hamming.ml 4303 2002-01-23 17:50:20Z doligez $ *)
(* We cannot use bignums because we don't do custom runtimes, but
int64 is a bit short, so we roll our own 37-digit numbers...
*)
let n0 = Int64.of_int 0
let n1 = Int64.of_int 1
let n2 = Int64.of_int 2
let n3 = Int64.of_int 3
let n5 = Int64.of_int 5
let ( % ) = Int64.rem
let ( * ) = Int64.mul
let ( / ) = Int64.div
let ( + ) = Int64.add
let digit = Int64.of_string "1000000000000000000"
let mul n (pl, ph) = n * pl % digit, (n * ph) + (n * pl / digit)
let cmp (nl, nh) (pl, ph) =
if nh < ph
then -1
else if nh > ph
then 1
else if nl < pl
then -1
else if nl > pl
then 1
else 0
let x2 p = mul n2 p
let x3 p = mul n3 p
let x5 p = mul n5 p
let nn1 = n1, n0
let pr (_nl, _nh) =
( (*
if compare nh n0 = 0
then Printf.printf "%Ld\n" nl
else Printf.printf "%Ld%018Ld\n" nh nl
*) )
(*
(* bignum version *)
open Num;;
let nn1 = num_of_int 1;;
let x2 = fun p -> (num_of_int 2) */ p;;
let x3 = fun p -> (num_of_int 3) */ p;;
let x5 = fun p -> (num_of_int 5) */ p;;
let cmp n p = sign_num (n -/ p);;
let pr n = Printf.printf "%s\n" (string_of_num n);;
*)
(* This is where the interesting stuff begins. *)
open Lazy
type 'a lcons = Cons of 'a * 'a lcons Lazy.t
type 'a llist = 'a lcons Lazy.t
let rec map f l =
lazy
(match force l with
| Cons (x, ll) -> Cons (f x, map f ll))
let rec merge cmp l1 l2 =
lazy
(match force l1, force l2 with
| Cons (x1, ll1), Cons (x2, ll2) ->
let c = cmp x1 x2 in
if c = 0
then Cons (x1, merge cmp ll1 ll2)
else if c < 0
then Cons (x1, merge cmp ll1 l2)
else Cons (x2, merge cmp l1 ll2))
let rec iter_interval f l (start, stop) =
if stop = 0
then ()
else
match force l with
| Cons (x, ll) ->
if start <= 0 then f x;
iter_interval f ll (start - 1, stop - 1)
let rec hamming = lazy (Cons (nn1, merge cmp ham2 (merge cmp ham3 ham5)))
and ham2 = lazy (force (map x2 hamming))
and ham3 = lazy (force (map x3 hamming))
and ham5 = lazy (force (map x5 hamming))
;;
iter_interval pr hamming (88000, 88100)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/kb.ml
|
let print_string _ = ()
let print_int _ = ()
let print_newline _ = ()
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: terms.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(****************** Term manipulations *****************)
type term =
| Var of int
| Term of string * term list
let rec union l1 l2 =
match l1 with
| [] -> l2
| a :: r -> if List.mem a l2 then union r l2 else a :: union r l2
let rec vars = function
| Var n -> [ n ]
| Term (_, l) -> vars_of_list l
and vars_of_list = function
| [] -> []
| t :: r -> union (vars t) (vars_of_list r)
let rec substitute subst = function
| Term (oper, sons) -> Term (oper, List.map (substitute subst) sons)
| Var n as t -> ( try List.assoc n subst with Not_found -> t)
(* Term replacement: replace M u N is M[u<-N]. *)
let rec replace m u n =
match u, m with
| [], _ -> n
| i :: u, Term (oper, sons) -> Term (oper, replace_nth i sons u n)
| _ -> failwith "replace"
and replace_nth i sons u n =
match sons with
| s :: r -> if i = 1 then replace s u n :: r else s :: replace_nth (i - 1) r u n
| [] -> failwith "replace_nth"
(* Term matching. *)
let matching term1 term2 =
let rec match_rec subst t1 t2 =
match t1, t2 with
| Var v, _ ->
if List.mem_assoc v subst
then if t2 = List.assoc v subst then subst else failwith "matching"
else (v, t2) :: subst
| Term (op1, sons1), Term (op2, sons2) ->
if op1 = op2
then List.fold_left2 match_rec subst sons1 sons2
else failwith "matching"
| _ -> failwith "matching"
in
match_rec [] term1 term2
(* A naive unification algorithm. *)
let compsubst subst1 subst2 =
List.map (fun (v, t) -> v, substitute subst1 t) subst2 @ subst1
let rec occurs n = function
| Var m -> m = n
| Term (_, sons) -> List.exists (occurs n) sons
let rec unify term1 term2 =
match term1, term2 with
| Var n1, _ ->
if term1 = term2
then []
else if occurs n1 term2
then failwith "unify"
else [ n1, term2 ]
| term1, Var n2 -> if occurs n2 term1 then failwith "unify" else [ n2, term1 ]
| Term (op1, sons1), Term (op2, sons2) ->
if op1 = op2
then
List.fold_left2
(fun s t1 t2 -> compsubst (unify (substitute s t1) (substitute s t2)) s)
[]
sons1
sons2
else failwith "unify"
(* We need to print terms with variables independently from input terms
obtained by parsing. We give arbitrary names v1,v2,... to their variables.
*)
let infixes = [ "+"; "*" ]
let pretty_term _ = ()
let pretty_close _ = ()
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: equations.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(****************** Equation manipulations *************)
type rule =
{ number : int
; numvars : int
; lhs : term
; rhs : term
}
(* standardizes an equation so its variables are 1,2,... *)
let mk_rule num m n =
let all_vars = union (vars m) (vars n) in
let counter = ref 0 in
let subst =
List.map
(fun v ->
incr counter;
v, Var !counter)
(List.rev all_vars)
in
{ number = num; numvars = !counter; lhs = substitute subst m; rhs = substitute subst n }
(* checks that rules are numbered in sequence and returns their number *)
let check_rules rules =
let counter = ref 0 in
List.iter
(fun r ->
incr counter;
if r.number <> !counter then failwith "Rule numbers not in sequence")
rules;
!counter
let pretty_rule rule =
print_int rule.number;
print_string " : ";
pretty_term rule.lhs;
print_string " = ";
pretty_term rule.rhs;
print_newline ()
let pretty_rules rules = List.iter pretty_rule rules
(****************** Rewriting **************************)
(* Top-level rewriting. Let eq:L=R be an equation, M be a term such that L<=M.
With sigma = matching L M, we define the image of M by eq as sigma(R) *)
let reduce l m r = substitute (matching l m) r
(* Test whether m can be reduced by l, i.e. m contains an instance of l. *)
let can_match l m =
try
let _ = matching l m in
true
with Failure _ -> false
let rec reducible l m =
can_match l m
||
match m with
| Term (_, sons) -> List.exists (reducible l) sons
| _ -> false
(* Top-level rewriting with multiple rules. *)
let rec mreduce rules m =
match rules with
| [] -> failwith "mreduce"
| rule :: rest -> ( try reduce rule.lhs m rule.rhs with Failure _ -> mreduce rest m)
(* One step of rewriting in leftmost-outermost strategy,
with multiple rules. Fails if no redex is found *)
let rec mrewrite1 rules m =
try mreduce rules m
with Failure _ -> (
match m with
| Var _ -> failwith "mrewrite1"
| Term (f, sons) -> Term (f, mrewrite1_sons rules sons))
and mrewrite1_sons rules = function
| [] -> failwith "mrewrite1"
| son :: rest -> (
try mrewrite1 rules son :: rest with Failure _ -> son :: mrewrite1_sons rules rest)
(* Iterating rewrite1. Returns a normal form. May loop forever *)
let rec mrewrite_all rules m =
try mrewrite_all rules (mrewrite1 rules m) with Failure _ -> m
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: orderings.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(*********************** Recursive Path Ordering ****************************)
type ordering =
| Greater
| Equal
| NotGE
let ge_ord order pair =
match order pair with
| NotGE -> false
| _ -> true
and gt_ord order pair =
match order pair with
| Greater -> true
| _ -> false
and eq_ord order pair =
match order pair with
| Equal -> true
| _ -> false
let rec rem_eq equiv x = function
| [] -> failwith "rem_eq"
| y :: l -> if equiv (x, y) then l else y :: rem_eq equiv x l
let diff_eq equiv (x, y) =
let rec diffrec = function
| ([], _) as p -> p
| h :: t, y -> (
try diffrec (t, rem_eq equiv h y)
with Failure _ ->
let x', y' = diffrec (t, y) in
h :: x', y')
in
if List.length x > List.length y then diffrec (y, x) else diffrec (x, y)
(* Multiset extension of order *)
let mult_ext order = function
| Term (_, sons1), Term (_, sons2) -> (
match diff_eq (eq_ord order) (sons1, sons2) with
| [], [] -> Equal
| l1, l2 ->
if List.for_all (fun n -> List.exists (fun m -> gt_ord order (m, n)) l1) l2
then Greater
else NotGE)
| _ -> failwith "mult_ext"
(* Lexicographic extension of order *)
let lex_ext order = function
| (Term (_, sons1) as m), (Term (_, sons2) as n) ->
let rec lexrec = function
| [], [] -> Equal
| [], _ -> NotGE
| _, [] -> Greater
| x1 :: l1, x2 :: l2 -> (
match order (x1, x2) with
| Greater ->
if List.for_all (fun n' -> gt_ord order (m, n')) l2
then Greater
else NotGE
| Equal -> lexrec (l1, l2)
| NotGE ->
if List.exists (fun m' -> ge_ord order (m', n)) l1 then Greater else NotGE
)
in
lexrec (sons1, sons2)
| _ -> failwith "lex_ext"
(* Recursive path ordering *)
let rpo op_order ext =
let rec rporec (m, n) =
if m = n
then Equal
else
match m with
| Var _ -> NotGE
| Term (op1, sons1) -> (
match n with
| Var vn -> if occurs vn m then Greater else NotGE
| Term (op2, sons2) -> (
match op_order op1 op2 with
| Greater ->
if List.for_all (fun n' -> gt_ord rporec (m, n')) sons2
then Greater
else NotGE
| Equal -> ext rporec (m, n)
| NotGE ->
if List.exists (fun m' -> ge_ord rporec (m', n)) sons1
then Greater
else NotGE))
in
rporec
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: kb.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(****************** Critical pairs *********************)
(* All (u,subst) such that N/u (&var) unifies with M,
with principal unifier subst *)
let rec super m = function
| Term (_, sons) as n -> (
let rec collate n = function
| [] -> []
| son :: rest ->
List.map (fun (u, subst) -> n :: u, subst) (super m son)
@ collate (n + 1) rest
in
let insides = collate 1 sons in
try ([], unify m n) :: insides with Failure _ -> insides)
| _ -> []
(* Ex :
let (m,_) = <<F(A,B)>>
and (n,_) = <<H(F(A,x),F(x,y))>> in super m n
==> [[1],[2,Term ("B",[])]; x <- B
[2],[2,Term ("A",[]); 1,Term ("B",[])]] x <- A y <- B
*)
(* All (u,subst), u&[], such that n/u unifies with m *)
let super_strict m = function
| Term (_, sons) ->
let rec collate n = function
| [] -> []
| son :: rest ->
List.map (fun (u, subst) -> n :: u, subst) (super m son)
@ collate (n + 1) rest
in
collate 1 sons
| _ -> []
(* Critical pairs of l1=r1 with l2=r2 *)
(* critical_pairs : term_pair -> term_pair -> term_pair list *)
let critical_pairs (l1, r1) (l2, r2) =
let mk_pair (u, subst) = substitute subst (replace l2 u r1), substitute subst r2 in
List.map mk_pair (super l1 l2)
(* Strict critical pairs of l1=r1 with l2=r2 *)
(* strict_critical_pairs : term_pair -> term_pair -> term_pair list *)
let strict_critical_pairs (l1, r1) (l2, r2) =
let mk_pair (u, subst) = substitute subst (replace l2 u r1), substitute subst r2 in
List.map mk_pair (super_strict l1 l2)
(* All critical pairs of eq1 with eq2 *)
let mutual_critical_pairs eq1 eq2 = strict_critical_pairs eq1 eq2 @ critical_pairs eq2 eq1
(* Renaming of variables *)
let rename n (t1, t2) =
let rec ren_rec = function
| Var k -> Var (k + n)
| Term (op, sons) -> Term (op, List.map ren_rec sons)
in
ren_rec t1, ren_rec t2
(************************ Completion ******************************)
let deletion_message rule =
print_string "Rule ";
print_int rule.number;
print_string " deleted";
print_newline ()
(* Generate failure message *)
let non_orientable (m, n) =
pretty_term m;
print_string " = ";
pretty_term n;
print_newline ()
let rec partition p = function
| [] -> [], []
| x :: l ->
let l1, l2 = partition p l in
if p x then x :: l1, l2 else l1, x :: l2
let rec get_rule n = function
| [] -> raise Not_found
| r :: l -> if n = r.number then r else get_rule n l
(* Improved Knuth-Bendix completion procedure *)
let kb_completion greater =
let rec kbrec j rules =
let rec process failures (k, l) eqs =
(*
{[
print_string "***kb_completion "; print_int j; print_newline();
pretty_rules rules;
List.iter non_orientable failures;
print_int k; print_string " "; print_int l; print_newline();
List.iter non_orientable eqs;
]}
*)
match eqs with
| [] -> (
if k < l
then next_criticals failures (k + 1, l)
else if l < j
then next_criticals failures (1, l + 1)
else
match failures with
| [] -> rules (* successful completion *)
| _ ->
print_string "Non-orientable equations :";
print_newline ();
List.iter non_orientable failures;
failwith "kb_completion")
| (m, n) :: eqs ->
let m' = mrewrite_all rules m
and n' = mrewrite_all rules n
and enter_rule (left, right) =
let new_rule = mk_rule (j + 1) left right in
pretty_rule new_rule;
let left_reducible rule = reducible left rule.lhs in
let redl, irredl = partition left_reducible rules in
List.iter deletion_message redl;
let right_reduce rule =
mk_rule rule.number rule.lhs (mrewrite_all (new_rule :: rules) rule.rhs)
in
let irreds = List.map right_reduce irredl in
let eqs' = List.map (fun rule -> rule.lhs, rule.rhs) redl in
kbrec (j + 1) (new_rule :: irreds) [] (k, l) (eqs @ eqs' @ failures)
in
(* {[
print_string "--- Considering "; non_orientable (m', n');
]}
*)
if m' = n'
then process failures (k, l) eqs
else if greater (m', n')
then enter_rule (m', n')
else if greater (n', m')
then enter_rule (n', m')
else process ((m', n') :: failures) (k, l) eqs
and next_criticals failures (k, l) =
(* {[
print_string "***next_criticals ";
print_int k; print_string " "; print_int l ; print_newline();
]}
*)
try
let rl = get_rule l rules in
let el = rl.lhs, rl.rhs in
if k = l
then process failures (k, l) (strict_critical_pairs el (rename rl.numvars el))
else
try
let rk = get_rule k rules in
let ek = rk.lhs, rk.rhs in
process failures (k, l) (mutual_critical_pairs el (rename rl.numvars ek))
with Not_found -> next_criticals failures (k + 1, l)
with Not_found -> next_criticals failures (1, l + 1)
in
process
in
kbrec
(* complete_rules is assumed locally confluent, and checked Noetherian with
ordering greater, rules is any list of rules *)
let kb_complete greater complete_rules rules =
let n = check_rules complete_rules
and eqs = List.map (fun rule -> rule.lhs, rule.rhs) rules in
let completed_rules = kb_completion greater n complete_rules [] (n, n) eqs in
print_string "Canonical set found :";
print_newline ();
pretty_rules (List.rev completed_rules)
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: kbmain.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
(****
let group_rules = [
{ number = 1; numvars = 1;
lhs = Term("*", [Term("U",[]); Var 1]); rhs = Var 1 };
{ number = 2; numvars = 1;
lhs = Term("*", [Term("I",[Var 1]); Var 1]); rhs = Term("U",[]) };
{ number = 3; numvars = 3;
lhs = Term("*", [Term("*", [Var 1; Var 2]); Var 3]);
rhs = Term("*", [Var 1; Term("*", [Var 2; Var 3])]) }
]
****)
let geom_rules =
[ { number = 1; numvars = 1; lhs = Term ("*", [ Term ("U", []); Var 1 ]); rhs = Var 1 }
; { number = 2
; numvars = 1
; lhs = Term ("*", [ Term ("I", [ Var 1 ]); Var 1 ])
; rhs = Term ("U", [])
}
; { number = 3
; numvars = 3
; lhs = Term ("*", [ Term ("*", [ Var 1; Var 2 ]); Var 3 ])
; rhs = Term ("*", [ Var 1; Term ("*", [ Var 2; Var 3 ]) ])
}
; { number = 4
; numvars = 0
; lhs = Term ("*", [ Term ("A", []); Term ("B", []) ])
; rhs = Term ("*", [ Term ("B", []); Term ("A", []) ])
}
; { number = 5
; numvars = 0
; lhs = Term ("*", [ Term ("C", []); Term ("C", []) ])
; rhs = Term ("U", [])
}
; { number = 6
; numvars = 0
; lhs =
Term
( "*"
, [ Term ("C", [])
; Term ("*", [ Term ("A", []); Term ("I", [ Term ("C", []) ]) ])
] )
; rhs = Term ("I", [ Term ("A", []) ])
}
; { number = 7
; numvars = 0
; lhs =
Term
( "*"
, [ Term ("C", [])
; Term ("*", [ Term ("B", []); Term ("I", [ Term ("C", []) ]) ])
] )
; rhs = Term ("B", [])
}
]
let group_rank = function
| "U" -> 0
| "*" -> 1
| "I" -> 2
| "B" -> 3
| "C" -> 4
| "A" -> 5
| _ -> assert false
let group_precedence op1 op2 =
let r1 = group_rank op1 and r2 = group_rank op2 in
if r1 = r2 then Equal else if r1 > r2 then Greater else NotGE
let group_order = rpo group_precedence lex_ext
let greater pair =
match group_order pair with
| Greater -> true
| _ -> false
let _ =
for _ = 1 to 20 do
kb_complete greater [] geom_rules
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/kb_no_exc.ml
|
let print_string _ = ()
let print_int _ = ()
let print_newline _ = ()
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: terms.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(****************** Term manipulations *****************)
type term =
| Var of int
| Term of string * term list
let rec union l1 l2 =
match l1 with
| [] -> l2
| a :: r -> if List.mem a l2 then union r l2 else a :: union r l2
let rec vars = function
| Var n -> [ n ]
| Term (_, l) -> vars_of_list l
and vars_of_list = function
| [] -> []
| t :: r -> union (vars t) (vars_of_list r)
let rec substitute subst = function
| Term (oper, sons) -> Term (oper, List.map (substitute subst) sons)
| Var n as t -> ( try List.assoc n subst with Not_found -> t)
(* Term replacement: replace M u N is M[u<-N]. *)
let rec replace m u n =
match u, m with
| [], _ -> n
| i :: u, Term (oper, sons) -> Term (oper, replace_nth i sons u n)
| _ -> failwith "replace"
and replace_nth i sons u n =
match sons with
| s :: r -> if i = 1 then replace s u n :: r else s :: replace_nth (i - 1) r u n
| [] -> failwith "replace_nth"
(* Term matching. *)
let rec fold_left2_opt f accu l1 l2 =
match l1, l2 with
| [], [] -> Some accu
| a1 :: l1, a2 :: l2 -> (
match f accu a1 a2 with
| None -> None
| Some accu' -> fold_left2_opt f accu' l1 l2)
| _, _ -> invalid_arg "List.fold_left2"
let rec match_rec subst t1 t2 =
match t1, t2 with
| Var v, _ ->
if List.mem_assoc v subst
then if t2 = List.assoc v subst then Some subst else None
else Some ((v, t2) :: subst)
| Term (op1, sons1), Term (op2, sons2) ->
if op1 = op2 then fold_left2_opt match_rec subst sons1 sons2 else None
| _ -> None
let matching term1 term2 = match_rec [] term1 term2
(* A naive unification algorithm. *)
let compsubst subst1 subst2 =
List.map (fun (v, t) -> v, substitute subst1 t) subst2 @ subst1
let rec occurs n = function
| Var m -> m = n
| Term (_, sons) -> List.exists (occurs n) sons
let rec unify term1 term2 =
match term1, term2 with
| Var n1, _ ->
if term1 = term2
then []
else if occurs n1 term2
then failwith "unify"
else [ n1, term2 ]
| term1, Var n2 -> if occurs n2 term1 then failwith "unify" else [ n2, term1 ]
| Term (op1, sons1), Term (op2, sons2) ->
if op1 = op2
then
List.fold_left2
(fun s t1 t2 -> compsubst (unify (substitute s t1) (substitute s t2)) s)
[]
sons1
sons2
else failwith "unify"
(* We need to print terms with variables independently from input terms
obtained by parsing. We give arbitrary names v1,v2,... to their variables.
*)
let infixes = [ "+"; "*" ]
let rec pretty_term = function
| Var n ->
print_string "v";
print_int n
| Term (oper, sons) ->
if List.mem oper infixes
then
match sons with
| [ s1; s2 ] ->
pretty_close s1;
print_string oper;
pretty_close s2
| _ -> failwith "pretty_term : infix arity <> 2"
else (
print_string oper;
match sons with
| [] -> ()
| t :: lt ->
print_string "(";
pretty_term t;
List.iter
(fun t ->
print_string ",";
pretty_term t)
lt;
print_string ")")
and pretty_close = function
| Term (oper, _) as m ->
if List.mem oper infixes
then (
print_string "(";
pretty_term m;
print_string ")")
else pretty_term m
| m -> pretty_term m
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: equations.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(****************** Equation manipulations *************)
type rule =
{ number : int
; numvars : int
; lhs : term
; rhs : term
}
(* standardizes an equation so its variables are 1,2,... *)
let mk_rule num m n =
let all_vars = union (vars m) (vars n) in
let counter = ref 0 in
let subst =
List.map
(fun v ->
incr counter;
v, Var !counter)
(List.rev all_vars)
in
{ number = num; numvars = !counter; lhs = substitute subst m; rhs = substitute subst n }
(* checks that rules are numbered in sequence and returns their number *)
let check_rules rules =
let counter = ref 0 in
List.iter
(fun r ->
incr counter;
if r.number <> !counter then failwith "Rule numbers not in sequence")
rules;
!counter
let pretty_rule rule =
print_int rule.number;
print_string " : ";
pretty_term rule.lhs;
print_string " = ";
pretty_term rule.rhs;
print_newline ()
let pretty_rules rules = List.iter pretty_rule rules
(****************** Rewriting **************************)
(* Top-level rewriting. Let eq:L=R be an equation, M be a term such that L<=M.
With sigma = matching L M, we define the image of M by eq as sigma(R) *)
let reduce l m r =
match matching l m with
| Some s -> Some (substitute s r)
| None -> None
(* Test whether m can be reduced by l, i.e. m contains an instance of l. *)
let can_match l m =
match matching l m with
| Some _ -> true
| None -> false
let rec reducible l m =
can_match l m
||
match m with
| Term (_, sons) -> List.exists (reducible l) sons
| _ -> false
(* Top-level rewriting with multiple rules. *)
let rec mreduce rules m =
match rules with
| [] -> None
| rule :: rest -> (
match reduce rule.lhs m rule.rhs with
| Some _ as v -> v
| None -> mreduce rest m)
(* One step of rewriting in leftmost-outermost strategy,
with multiple rules. Fails if no redex is found *)
let rec mrewrite1 rules m =
match mreduce rules m with
| Some v -> v
| None -> (
match m with
| Var _ -> failwith "mrewrite1"
| Term (f, sons) -> Term (f, mrewrite1_sons rules sons))
and mrewrite1_sons rules = function
| [] -> failwith "mrewrite1"
| son :: rest -> (
try mrewrite1 rules son :: rest with Failure _ -> son :: mrewrite1_sons rules rest)
(* Iterating rewrite1. Returns a normal form. May loop forever *)
let rec mrewrite_all rules m =
try mrewrite_all rules (mrewrite1 rules m) with Failure _ -> m
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: orderings.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(*********************** Recursive Path Ordering ****************************)
type ordering =
| Greater
| Equal
| NotGE
let ge_ord order pair =
match order pair with
| NotGE -> false
| _ -> true
and gt_ord order pair =
match order pair with
| Greater -> true
| _ -> false
and eq_ord order pair =
match order pair with
| Equal -> true
| _ -> false
let rec rem_eq equiv x = function
| [] -> failwith "rem_eq"
| y :: l -> if equiv (x, y) then l else y :: rem_eq equiv x l
let diff_eq equiv (x, y) =
let rec diffrec = function
| ([], _) as p -> p
| h :: t, y -> (
try diffrec (t, rem_eq equiv h y)
with Failure _ ->
let x', y' = diffrec (t, y) in
h :: x', y')
in
if List.length x > List.length y then diffrec (y, x) else diffrec (x, y)
(* Multiset extension of order *)
let mult_ext order = function
| Term (_, sons1), Term (_, sons2) -> (
match diff_eq (eq_ord order) (sons1, sons2) with
| [], [] -> Equal
| l1, l2 ->
if List.for_all (fun n -> List.exists (fun m -> gt_ord order (m, n)) l1) l2
then Greater
else NotGE)
| _ -> failwith "mult_ext"
(* Lexicographic extension of order *)
let lex_ext order = function
| (Term (_, sons1) as m), (Term (_, sons2) as n) ->
let rec lexrec = function
| [], [] -> Equal
| [], _ -> NotGE
| _, [] -> Greater
| x1 :: l1, x2 :: l2 -> (
match order (x1, x2) with
| Greater ->
if List.for_all (fun n' -> gt_ord order (m, n')) l2
then Greater
else NotGE
| Equal -> lexrec (l1, l2)
| NotGE ->
if List.exists (fun m' -> ge_ord order (m', n)) l1 then Greater else NotGE
)
in
lexrec (sons1, sons2)
| _ -> failwith "lex_ext"
(* Recursive path ordering *)
let rpo op_order ext =
let rec rporec (m, n) =
if m = n
then Equal
else
match m with
| Var _ -> NotGE
| Term (op1, sons1) -> (
match n with
| Var vn -> if occurs vn m then Greater else NotGE
| Term (op2, sons2) -> (
match op_order op1 op2 with
| Greater ->
if List.for_all (fun n' -> gt_ord rporec (m, n')) sons2
then Greater
else NotGE
| Equal -> ext rporec (m, n)
| NotGE ->
if List.exists (fun m' -> ge_ord rporec (m', n)) sons1
then Greater
else NotGE))
in
rporec
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: kb.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
(****************** Critical pairs *********************)
(* All (u,subst) such that N/u (&var) unifies with M,
with principal unifier subst *)
let rec super m = function
| Term (_, sons) as n -> (
let rec collate n = function
| [] -> []
| son :: rest ->
List.map (fun (u, subst) -> n :: u, subst) (super m son)
@ collate (n + 1) rest
in
let insides = collate 1 sons in
try ([], unify m n) :: insides with Failure _ -> insides)
| _ -> []
(* Ex :
let (m,_) = <<F(A,B)>>
and (n,_) = <<H(F(A,x),F(x,y))>> in super m n
==> [[1],[2,Term ("B",[])]; x <- B
[2],[2,Term ("A",[]); 1,Term ("B",[])]] x <- A y <- B
*)
(* All (u,subst), u&[], such that n/u unifies with m *)
let super_strict m = function
| Term (_, sons) ->
let rec collate n = function
| [] -> []
| son :: rest ->
List.map (fun (u, subst) -> n :: u, subst) (super m son)
@ collate (n + 1) rest
in
collate 1 sons
| _ -> []
(* Critical pairs of l1=r1 with l2=r2 *)
(* critical_pairs : term_pair -> term_pair -> term_pair list *)
let critical_pairs (l1, r1) (l2, r2) =
let mk_pair (u, subst) = substitute subst (replace l2 u r1), substitute subst r2 in
List.map mk_pair (super l1 l2)
(* Strict critical pairs of l1=r1 with l2=r2 *)
(* strict_critical_pairs : term_pair -> term_pair -> term_pair list *)
let strict_critical_pairs (l1, r1) (l2, r2) =
let mk_pair (u, subst) = substitute subst (replace l2 u r1), substitute subst r2 in
List.map mk_pair (super_strict l1 l2)
(* All critical pairs of eq1 with eq2 *)
let mutual_critical_pairs eq1 eq2 = strict_critical_pairs eq1 eq2 @ critical_pairs eq2 eq1
(* Renaming of variables *)
let rename n (t1, t2) =
let rec ren_rec = function
| Var k -> Var (k + n)
| Term (op, sons) -> Term (op, List.map ren_rec sons)
in
ren_rec t1, ren_rec t2
(************************ Completion ******************************)
let deletion_message rule =
print_string "Rule ";
print_int rule.number;
print_string " deleted";
print_newline ()
(* Generate failure message *)
let non_orientable (m, n) =
pretty_term m;
print_string " = ";
pretty_term n;
print_newline ()
let rec partition p = function
| [] -> [], []
| x :: l ->
let l1, l2 = partition p l in
if p x then x :: l1, l2 else l1, x :: l2
let rec get_rule n = function
| [] -> raise Not_found
| r :: l -> if n = r.number then r else get_rule n l
(* Improved Knuth-Bendix completion procedure *)
let kb_completion greater =
let rec kbrec j rules =
let rec process failures (k, l) eqs =
(* {[
print_string "***kb_completion "; print_int j; print_newline();
pretty_rules rules;
List.iter non_orientable failures;
print_int k; print_string " "; print_int l; print_newline();
List.iter non_orientable eqs;
]}
*)
match eqs with
| [] -> (
if k < l
then next_criticals failures (k + 1, l)
else if l < j
then next_criticals failures (1, l + 1)
else
match failures with
| [] -> rules (* successful completion *)
| _ ->
print_string "Non-orientable equations :";
print_newline ();
List.iter non_orientable failures;
failwith "kb_completion")
| (m, n) :: eqs ->
let m' = mrewrite_all rules m
and n' = mrewrite_all rules n
and enter_rule (left, right) =
let new_rule = mk_rule (j + 1) left right in
pretty_rule new_rule;
let left_reducible rule = reducible left rule.lhs in
let redl, irredl = partition left_reducible rules in
List.iter deletion_message redl;
let right_reduce rule =
mk_rule rule.number rule.lhs (mrewrite_all (new_rule :: rules) rule.rhs)
in
let irreds = List.map right_reduce irredl in
let eqs' = List.map (fun rule -> rule.lhs, rule.rhs) redl in
kbrec (j + 1) (new_rule :: irreds) [] (k, l) (eqs @ eqs' @ failures)
in
(* {[
print_string "--- Considering "; non_orientable (m', n');
]}
*)
if m' = n'
then process failures (k, l) eqs
else if greater (m', n')
then enter_rule (m', n')
else if greater (n', m')
then enter_rule (n', m')
else process ((m', n') :: failures) (k, l) eqs
and next_criticals failures (k, l) =
(*
{[
print_string "***next_criticals ";
print_int k; print_string " "; print_int l ; print_newline();
]}
*)
try
let rl = get_rule l rules in
let el = rl.lhs, rl.rhs in
if k = l
then process failures (k, l) (strict_critical_pairs el (rename rl.numvars el))
else
try
let rk = get_rule k rules in
let ek = rk.lhs, rk.rhs in
process failures (k, l) (mutual_critical_pairs el (rename rl.numvars ek))
with Not_found -> next_criticals failures (k + 1, l)
with Not_found -> next_criticals failures (1, l + 1)
in
process
in
kbrec
(* complete_rules is assumed locally confluent, and checked Noetherian with
ordering greater, rules is any list of rules *)
let kb_complete greater complete_rules rules =
let n = check_rules complete_rules
and eqs = List.map (fun rule -> rule.lhs, rule.rhs) rules in
let completed_rules = kb_completion greater n complete_rules [] (n, n) eqs in
print_string "Canonical set found :";
print_newline ();
pretty_rules (List.rev completed_rules)
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: kbmain.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
(*
{[
let group_rules = [
{ number = 1; numvars = 1;
lhs = Term("*", [Term("U",[]); Var 1]); rhs = Var 1 };
{ number = 2; numvars = 1;
lhs = Term("*", [Term("I",[Var 1]); Var 1]); rhs = Term("U",[]) };
{ number = 3; numvars = 3;
lhs = Term("*", [Term("*", [Var 1; Var 2]); Var 3]);
rhs = Term("*", [Var 1; Term("*", [Var 2; Var 3])]) }
]
]}
*)
let geom_rules =
[ { number = 1; numvars = 1; lhs = Term ("*", [ Term ("U", []); Var 1 ]); rhs = Var 1 }
; { number = 2
; numvars = 1
; lhs = Term ("*", [ Term ("I", [ Var 1 ]); Var 1 ])
; rhs = Term ("U", [])
}
; { number = 3
; numvars = 3
; lhs = Term ("*", [ Term ("*", [ Var 1; Var 2 ]); Var 3 ])
; rhs = Term ("*", [ Var 1; Term ("*", [ Var 2; Var 3 ]) ])
}
; { number = 4
; numvars = 0
; lhs = Term ("*", [ Term ("A", []); Term ("B", []) ])
; rhs = Term ("*", [ Term ("B", []); Term ("A", []) ])
}
; { number = 5
; numvars = 0
; lhs = Term ("*", [ Term ("C", []); Term ("C", []) ])
; rhs = Term ("U", [])
}
; { number = 6
; numvars = 0
; lhs =
Term
( "*"
, [ Term ("C", [])
; Term ("*", [ Term ("A", []); Term ("I", [ Term ("C", []) ]) ])
] )
; rhs = Term ("I", [ Term ("A", []) ])
}
; { number = 7
; numvars = 0
; lhs =
Term
( "*"
, [ Term ("C", [])
; Term ("*", [ Term ("B", []); Term ("I", [ Term ("C", []) ]) ])
] )
; rhs = Term ("B", [])
}
]
let group_rank = function
| "U" -> 0
| "*" -> 1
| "I" -> 2
| "B" -> 3
| "C" -> 4
| "A" -> 5
| _ -> assert false
let group_precedence op1 op2 =
let r1 = group_rank op1 and r2 = group_rank op2 in
if r1 = r2 then Equal else if r1 > r2 then Greater else NotGE
let group_order = rpo group_precedence lex_ext
let greater pair =
match group_order pair with
| Greater -> true
| _ -> false
let _ =
for _ = 1 to 20 do
kb_complete greater [] geom_rules
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/loop.ml
|
for _ = 1 to 1000000000 do
()
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/nucleic.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: nucleic.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
[@@@ocaml.warning "-27"]
(* Use floating-point arithmetic *)
external ( + ) : float -> float -> float = "%addfloat"
external ( - ) : float -> float -> float = "%subfloat"
external ( * ) : float -> float -> float = "%mulfloat"
external ( / ) : float -> float -> float = "%divfloat"
(* -- MATH UTILITIES --------------------------------------------------------*)
let constant_pi = 3.14159265358979323846
let constant_minus_pi = -3.14159265358979323846
let constant_pi2 = 1.57079632679489661923
let constant_minus_pi2 = -1.57079632679489661923
(* -- POINTS ----------------------------------------------------------------*)
type pt =
{ x : float
; y : float
; z : float
}
let pt_sub p1 p2 = { x = p1.x - p2.x; y = p1.y - p2.y; z = p1.z - p2.z }
let pt_dist p1 p2 =
let dx = p1.x - p2.x and dy = p1.y - p2.y and dz = p1.z - p2.z in
sqrt ((dx * dx) + (dy * dy) + (dz * dz))
let pt_phi p =
let b = atan2 p.x p.z in
atan2 ((cos b * p.z) + (sin b * p.x)) p.y
let pt_theta p = atan2 p.x p.z
(* -- COORDINATE TRANSFORMATIONS --------------------------------------------*)
(*
The notation for the transformations follows "Paul, R.P. (1981) Robot
Manipulators. MIT Press." with the exception that our transformation
matrices don't have the perspective terms and are the transpose of
Paul's one. See also "M\"antyl\"a, M. (1985) An Introduction to
Solid Modeling, Computer Science Press" Appendix A.
The components of a transformation matrix are named like this:
a b c
d e f
g h i
tx ty tz
The components tx, ty, and tz are the translation vector.
*)
type tfo =
{ a : float
; b : float
; c : float
; d : float
; e : float
; f : float
; g : float
; h : float
; i : float
; tx : float
; ty : float
; tz : float
}
let tfo_id =
{ a = 1.0
; b = 0.0
; c = 0.0
; d = 0.0
; e = 1.0
; f = 0.0
; g = 0.0
; h = 0.0
; i = 1.0
; tx = 0.0
; ty = 0.0
; tz = 0.0
}
(*
The function "tfo-apply" multiplies a transformation matrix, tfo, by a
point vector, p. The result is a new point.
*)
let tfo_apply t p =
{ x = (p.x * t.a) + (p.y * t.d) + (p.z * t.g) + t.tx
; y = (p.x * t.b) + (p.y * t.e) + (p.z * t.h) + t.ty
; z = (p.x * t.c) + (p.y * t.f) + (p.z * t.i) + t.tz
}
(*
The function "tfo-combine" multiplies two transformation matrices A and B.
The result is a new matrix which cumulates the transformations described
by A and B.
*)
let tfo_combine a b =
(* <HAND_CSE> *)
(* Hand elimination of common subexpressions.
Assumes lots of float registers (32 is perfect, 16 still OK).
Loses on the I386, of course. *)
let a_a = a.a
and a_b = a.b
and a_c = a.c
and a_d = a.d
and a_e = a.e
and a_f = a.f
and a_g = a.g
and a_h = a.h
and a_i = a.i
and a_tx = a.tx
and a_ty = a.ty
and a_tz = a.tz
and b_a = b.a
and b_b = b.b
and b_c = b.c
and b_d = b.d
and b_e = b.e
and b_f = b.f
and b_g = b.g
and b_h = b.h
and b_i = b.i
and b_tx = b.tx
and b_ty = b.ty
and b_tz = b.tz in
{ a = (a_a * b_a) + (a_b * b_d) + (a_c * b_g)
; b = (a_a * b_b) + (a_b * b_e) + (a_c * b_h)
; c = (a_a * b_c) + (a_b * b_f) + (a_c * b_i)
; d = (a_d * b_a) + (a_e * b_d) + (a_f * b_g)
; e = (a_d * b_b) + (a_e * b_e) + (a_f * b_h)
; f = (a_d * b_c) + (a_e * b_f) + (a_f * b_i)
; g = (a_g * b_a) + (a_h * b_d) + (a_i * b_g)
; h = (a_g * b_b) + (a_h * b_e) + (a_i * b_h)
; i = (a_g * b_c) + (a_h * b_f) + (a_i * b_i)
; tx = (a_tx * b_a) + (a_ty * b_d) + (a_tz * b_g) + b_tx
; ty = (a_tx * b_b) + (a_ty * b_e) + (a_tz * b_h) + b_ty
; tz = (a_tx * b_c) + (a_ty * b_f) + (a_tz * b_i) + b_tz
}
(* </HAND_CSE> *)
(* Original without CSE *)
(* <NO_CSE> *)
(***
{ a = ((a.a * b.a) + (a.b * b.d) + (a.c * b.g));
b = ((a.a * b.b) + (a.b * b.e) + (a.c * b.h));
c = ((a.a * b.c) + (a.b * b.f) + (a.c * b.i));
d = ((a.d * b.a) + (a.e * b.d) + (a.f * b.g));
e = ((a.d * b.b) + (a.e * b.e) + (a.f * b.h));
f = ((a.d * b.c) + (a.e * b.f) + (a.f * b.i));
g = ((a.g * b.a) + (a.h * b.d) + (a.i * b.g));
h = ((a.g * b.b) + (a.h * b.e) + (a.i * b.h));
i = ((a.g * b.c) + (a.h * b.f) + (a.i * b.i));
tx = ((a.tx * b.a) + (a.ty * b.d) + (a.tz * b.g) + b.tx);
ty = ((a.tx * b.b) + (a.ty * b.e) + (a.tz * b.h) + b.ty);
tz = ((a.tx * b.c) + (a.ty * b.f) + (a.tz * b.i) + b.tz)
}
***)
(* </NO_CSE> *)
(*
The function "tfo-inv-ortho" computes the inverse of a homogeneous
transformation matrix.
*)
let tfo_inv_ortho t =
{ a = t.a
; b = t.d
; c = t.g
; d = t.b
; e = t.e
; f = t.h
; g = t.c
; h = t.f
; i = t.i
; tx = -.((t.a * t.tx) + (t.b * t.ty) + (t.c * t.tz))
; ty = -.((t.d * t.tx) + (t.e * t.ty) + (t.f * t.tz))
; tz = -.((t.g * t.tx) + (t.h * t.ty) + (t.i * t.tz))
}
(*
Given three points p1, p2, and p3, the function "tfo-align" computes
a transformation matrix such that point p1 gets mapped to (0,0,0), p2 gets
mapped to the Y axis and p3 gets mapped to the YZ plane.
*)
let tfo_align p1 p2 p3 =
let x31 = p3.x - p1.x in
let y31 = p3.y - p1.y in
let z31 = p3.z - p1.z in
let rotpy = pt_sub p2 p1 in
let phi = pt_phi rotpy in
let theta = pt_theta rotpy in
let sinp = sin phi in
let sint = sin theta in
let cosp = cos phi in
let cost = cos theta in
let sinpsint = sinp * sint in
let sinpcost = sinp * cost in
let cospsint = cosp * sint in
let cospcost = cosp * cost in
let rotpz =
{ x = (cost * x31) - (sint * z31)
; y = (sinpsint * x31) + (cosp * y31) + (sinpcost * z31)
; z = (cospsint * x31) + -.(sinp * y31) + (cospcost * z31)
}
in
let rho = pt_theta rotpz in
let cosr = cos rho in
let sinr = sin rho in
let x = -.(p1.x * cost) + (p1.z * sint) in
let y = -.(p1.x * sinpsint) - (p1.y * cosp) - (p1.z * sinpcost) in
let z = -.(p1.x * cospsint) + (p1.y * sinp) - (p1.z * cospcost) in
{ a = (cost * cosr) - (cospsint * sinr)
; b = sinpsint
; c = (cost * sinr) + (cospsint * cosr)
; d = sinp * sinr
; e = cosp
; f = -.(sinp * cosr)
; g = -.(sint * cosr) - (cospcost * sinr)
; h = sinpcost
; i = -.(sint * sinr) + (cospcost * cosr)
; tx = (x * cosr) - (z * sinr)
; ty = y
; tz = (x * sinr) + (z * cosr)
}
(* -- NUCLEIC ACID CONFORMATIONS DATA BASE ----------------------------------*)
(*
Numbering of atoms follows the paper:
IUPAC-IUB Joint Commission on Biochemical Nomenclature (JCBN)
(1983) Abbreviations and Symbols for the Description of
Conformations of Polynucleotide Chains. Eur. J. Biochem 131,
9-15.
*)
(* Define remaining atoms for each nucleotide type. *)
type nuc_specific =
| A of pt * pt * pt * pt * pt * pt * pt * pt
| C of pt * pt * pt * pt * pt * pt
| G of pt * pt * pt * pt * pt * pt * pt * pt * pt
| U of pt * pt * pt * pt * pt
(*
A n6 n7 n9 c8 h2 h61 h62 h8
C n4 o2 h41 h42 h5 h6
G n2 n7 n9 c8 o6 h1 h21 h22 h8
U o2 o4 h3 h5 h6
*)
(* Define part common to all 4 nucleotide types. *)
type nuc =
| N of
tfo
* tfo
* tfo
* tfo
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* pt
* nuc_specific
(*
dgf_base_tfo ; defines the standard position for wc and wc_dumas
p_o3'_275_tfo ; defines the standard position for the connect function
p_o3'_180_tfo
p_o3'_60_tfo
p o1p o2p o5' c5' h5' h5'' c4' h4' o4' c1' h1' c2' h2'' o2' h2' c3'
h3' o3' n1 n3 c2 c4 c5 c6
*)
let is_A = function
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, A (_, _, _, _, _, _, _, _) ) -> true
| _ -> false
let is_C = function
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, C (_, _, _, _, _, _) ) -> true
| _ -> false
let is_G = function
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, G (_, _, _, _, _, _, _, _, _) ) -> true
| _ -> false
let nuc_C1'
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
c1'
let nuc_C2
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
c2
let nuc_C3'
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
c3'
let nuc_C4
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
c4
let nuc_C4'
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
c4'
let nuc_N1
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
n1
let nuc_O3'
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
o3'
let nuc_P
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
p
let nuc_dgf_base_tfo
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
dgf_base_tfo
let nuc_p_o3'_180_tfo
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
p_o3'_180_tfo
let nuc_p_o3'_275_tfo
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
p_o3'_275_tfo
let nuc_p_o3'_60_tfo
(N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, _ )) =
p_o3'_60_tfo
let rA_N9 = function
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, A (n6, n7, n9, c8, h2, h61, h62, h8) ) -> n9
| _ -> assert false
let rG_N9 = function
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, G (n2, n7, n9, c8, o6, h1, h21, h22, h8) ) -> n9
| _ -> assert false
(* Database of nucleotide conformations: *)
let rA =
N
( { a = -0.0018
; b = -0.8207
; c = 0.5714
; (* dgf_base_tfo *)
d = 0.2679
; e = -0.5509
; f = -0.7904
; g = 0.9634
; h = 0.1517
; i = 0.2209
; tx = 0.0073
; ty = 8.4030
; tz = 0.6232
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 5.4550; y = 8.2120; z = -2.8810 }
, (* C5' *)
{ x = 5.4546; y = 8.8508; z = -1.9978 }
, (* H5' *)
{ x = 5.7588; y = 8.6625; z = -3.8259 }
, (* H5'' *)
{ x = 6.4970; y = 7.1480; z = -2.5980 }
, (* C4' *)
{ x = 7.4896; y = 7.5919; z = -2.5214 }
, (* H4' *)
{ x = 6.1630; y = 6.4860; z = -1.3440 }
, (* O4' *)
{ x = 6.5400; y = 5.1200; z = -1.4190 }
, (* C1' *)
{ x = 7.2763; y = 4.9681; z = -0.6297 }
, (* H1' *)
{ x = 7.1940; y = 4.8830; z = -2.7770 }
, (* C2' *)
{ x = 6.8667; y = 3.9183; z = -3.1647 }
, (* H2'' *)
{ x = 8.5860; y = 5.0910; z = -2.6140 }
, (* O2' *)
{ x = 8.9510; y = 4.7626; z = -1.7890 }
, (* H2' *)
{ x = 6.5720; y = 6.0040; z = -3.6090 }
, (* C3' *)
{ x = 5.5636; y = 5.7066; z = -3.8966 }
, (* H3' *)
{ x = 7.3801; y = 6.3562; z = -4.7350 }
, (* O3' *)
{ x = 4.7150; y = 0.4910; z = -0.1360 }
, (* N1 *)
{ x = 6.3490; y = 2.1730; z = -0.6020 }
, (* N3 *)
{ x = 5.9530; y = 0.9650; z = -0.2670 }
, (* C2 *)
{ x = 5.2900; y = 2.9790; z = -0.8260 }
, (* C4 *)
{ x = 3.9720; y = 2.6390; z = -0.7330 }
, (* C5 *)
{ x = 3.6770; y = 1.3160; z = -0.3660 }
, (* C6 *)
A
( { x = 2.4280; y = 0.8450; z = -0.2360 }
, (* N6 *)
{ x = 3.1660; y = 3.7290; z = -1.0360 }
, (* N7 *)
{ x = 5.3170; y = 4.2990; z = -1.1930 }
, (* N9 *)
{ x = 4.0100; y = 4.6780; z = -1.2990 }
, (* C8 *)
{ x = 6.6890; y = 0.1903; z = -0.0518 }
, (* H2 *)
{ x = 1.6470; y = 1.4460; z = -0.4040 }
, (* H61 *)
{ x = 2.2780; y = -0.1080; z = -0.0280 }
, (* H62 *)
{ x = 3.4421; y = 5.5744; z = -1.5482 } ) )
(* H8 *)
let rA01 =
N
( { a = -0.0043
; b = -0.8175
; c = 0.5759
; (* dgf_base_tfo *)
d = 0.2617
; e = -0.5567
; f = -0.7884
; g = 0.9651
; h = 0.1473
; i = 0.2164
; tx = 0.0359
; ty = 8.3929
; tz = 0.5532
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 5.4352; y = 8.2183; z = -2.7757 }
, (* C5' *)
{ x = 5.3830; y = 8.7883; z = -1.8481 }
, (* H5' *)
{ x = 5.7729; y = 8.7436; z = -3.6691 }
, (* H5'' *)
{ x = 6.4830; y = 7.1518; z = -2.5252 }
, (* C4' *)
{ x = 7.4749; y = 7.5972; z = -2.4482 }
, (* H4' *)
{ x = 6.1626; y = 6.4620; z = -1.2827 }
, (* O4' *)
{ x = 6.5431; y = 5.0992; z = -1.3905 }
, (* C1' *)
{ x = 7.2871; y = 4.9328; z = -0.6114 }
, (* H1' *)
{ x = 7.1852; y = 4.8935; z = -2.7592 }
, (* C2' *)
{ x = 6.8573; y = 3.9363; z = -3.1645 }
, (* H2'' *)
{ x = 8.5780; y = 5.1025; z = -2.6046 }
, (* O2' *)
{ x = 8.9516; y = 4.7577; z = -1.7902 }
, (* H2' *)
{ x = 6.5522; y = 6.0300; z = -3.5612 }
, (* C3' *)
{ x = 5.5420; y = 5.7356; z = -3.8459 }
, (* H3' *)
{ x = 7.3487; y = 6.4089; z = -4.6867 }
, (* O3' *)
{ x = 4.7442; y = 0.4514; z = -0.1390 }
, (* N1 *)
{ x = 6.3687; y = 2.1459; z = -0.5926 }
, (* N3 *)
{ x = 5.9795; y = 0.9335; z = -0.2657 }
, (* C2 *)
{ x = 5.3052; y = 2.9471; z = -0.8125 }
, (* C4 *)
{ x = 3.9891; y = 2.5987; z = -0.7230 }
, (* C5 *)
{ x = 3.7016; y = 1.2717; z = -0.3647 }
, (* C6 *)
A
( { x = 2.4553; y = 0.7925; z = -0.2390 }
, (* N6 *)
{ x = 3.1770; y = 3.6859; z = -1.0198 }
, (* N7 *)
{ x = 5.3247; y = 4.2695; z = -1.1710 }
, (* N9 *)
{ x = 4.0156; y = 4.6415; z = -1.2759 }
, (* C8 *)
{ x = 6.7198; y = 0.1618; z = -0.0547 }
, (* H2 *)
{ x = 1.6709; y = 1.3900; z = -0.4039 }
, (* H61 *)
{ x = 2.3107; y = -0.1627; z = -0.0373 }
, (* H62 *)
{ x = 3.4426; y = 5.5361; z = -1.5199 } ) )
(* H8 *)
let rA02 =
N
( { a = 0.5566
; b = 0.0449
; c = 0.8296
; (* dgf_base_tfo *)
d = 0.5125
; e = 0.7673
; f = -0.3854
; g = -0.6538
; h = 0.6397
; i = 0.4041
; tx = -9.1161
; ty = -3.7679
; tz = -2.9968
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.5778; y = 6.6594; z = -4.0364 }
, (* C5' *)
{ x = 4.9220; y = 7.1963; z = -4.9204 }
, (* H5' *)
{ x = 3.7996; y = 5.9091; z = -4.1764 }
, (* H5'' *)
{ x = 5.7873; y = 5.8869; z = -3.5482 }
, (* C4' *)
{ x = 6.0405; y = 5.0875; z = -4.2446 }
, (* H4' *)
{ x = 6.9135; y = 6.8036; z = -3.4310 }
, (* O4' *)
{ x = 7.7293; y = 6.4084; z = -2.3392 }
, (* C1' *)
{ x = 8.7078; y = 6.1815; z = -2.7624 }
, (* H1' *)
{ x = 7.1305; y = 5.1418; z = -1.7347 }
, (* C2' *)
{ x = 7.2040; y = 5.1982; z = -0.6486 }
, (* H2'' *)
{ x = 7.7417; y = 4.0392; z = -2.3813 }
, (* O2' *)
{ x = 8.6785; y = 4.1443; z = -2.5630 }
, (* H2' *)
{ x = 5.6666; y = 5.2728; z = -2.1536 }
, (* C3' *)
{ x = 5.1747; y = 5.9805; z = -1.4863 }
, (* H3' *)
{ x = 4.9997; y = 4.0086; z = -2.1973 }
, (* O3' *)
{ x = 10.3245; y = 8.5459; z = 1.5467 }
, (* N1 *)
{ x = 9.8051; y = 6.9432; z = -0.1497 }
, (* N3 *)
{ x = 10.5175; y = 7.4328; z = 0.8408 }
, (* C2 *)
{ x = 8.7523; y = 7.7422; z = -0.4228 }
, (* C4 *)
{ x = 8.4257; y = 8.9060; z = 0.2099 }
, (* C5 *)
{ x = 9.2665; y = 9.3242; z = 1.2540 }
, (* C6 *)
A
( { x = 9.0664; y = 10.4462; z = 1.9610 }
, (* N6 *)
{ x = 7.2750; y = 9.4537; z = -0.3428 }
, (* N7 *)
{ x = 7.7962; y = 7.5519; z = -1.3859 }
, (* N9 *)
{ x = 6.9479; y = 8.6157; z = -1.2771 }
, (* C8 *)
{ x = 11.4063; y = 6.9047; z = 1.1859 }
, (* H2 *)
{ x = 8.2845; y = 11.0341; z = 1.7552 }
, (* H61 *)
{ x = 9.6584; y = 10.6647; z = 2.7198 }
, (* H62 *)
{ x = 6.0430; y = 8.9853; z = -1.7594 } ) )
(* H8 *)
let rA03 =
N
( { a = -0.5021
; b = 0.0731
; c = 0.8617
; (* dgf_base_tfo *)
d = -0.8112
; e = 0.3054
; f = -0.4986
; g = -0.2996
; h = -0.9494
; i = -0.0940
; tx = 6.4273
; ty = -5.1944
; tz = -3.7807
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.1214; y = 6.7116; z = -1.9049 }
, (* C5' *)
{ x = 3.3465; y = 5.9610; z = -2.0607 }
, (* H5' *)
{ x = 4.0789; y = 7.2928; z = -0.9837 }
, (* H5'' *)
{ x = 5.4170; y = 5.9293; z = -1.8186 }
, (* C4' *)
{ x = 5.4506; y = 5.3400; z = -0.9023 }
, (* H4' *)
{ x = 5.5067; y = 5.0417; z = -2.9703 }
, (* O4' *)
{ x = 6.8650; y = 4.9152; z = -3.3612 }
, (* C1' *)
{ x = 7.1090; y = 3.8577; z = -3.2603 }
, (* H1' *)
{ x = 7.7152; y = 5.7282; z = -2.3894 }
, (* C2' *)
{ x = 8.5029; y = 6.2356; z = -2.9463 }
, (* H2'' *)
{ x = 8.1036; y = 4.8568; z = -1.3419 }
, (* O2' *)
{ x = 8.3270; y = 3.9651; z = -1.6184 }
, (* H2' *)
{ x = 6.7003; y = 6.7565; z = -1.8911 }
, (* C3' *)
{ x = 6.5898; y = 7.5329; z = -2.6482 }
, (* H3' *)
{ x = 7.0505; y = 7.2878; z = -0.6105 }
, (* O3' *)
{ x = 9.6740; y = 4.7656; z = -7.6614 }
, (* N1 *)
{ x = 9.0739; y = 4.3013; z = -5.3941 }
, (* N3 *)
{ x = 9.8416; y = 4.2192; z = -6.4581 }
, (* C2 *)
{ x = 7.9885; y = 5.0632; z = -5.6446 }
, (* C4 *)
{ x = 7.6822; y = 5.6856; z = -6.8194 }
, (* C5 *)
{ x = 8.5831; y = 5.5215; z = -7.8840 }
, (* C6 *)
A
( { x = 8.4084; y = 6.0747; z = -9.0933 }
, (* N6 *)
{ x = 6.4857; y = 6.3816; z = -6.7035 }
, (* N7 *)
{ x = 6.9740; y = 5.3703; z = -4.7760 }
, (* N9 *)
{ x = 6.1133; y = 6.1613; z = -5.4808 }
, (* C8 *)
{ x = 10.7627; y = 3.6375; z = -6.4220 }
, (* H2 *)
{ x = 7.6031; y = 6.6390; z = -9.2733 }
, (* H61 *)
{ x = 9.1004; y = 5.9708; z = -9.7893 }
, (* H62 *)
{ x = 5.1705; y = 6.6830; z = -5.3167 } ) )
(* H8 *)
let rA04 =
N
( { a = -0.5426
; b = -0.8175
; c = 0.1929
; (* dgf_base_tfo *)
d = 0.8304
; e = -0.5567
; f = -0.0237
; g = 0.1267
; h = 0.1473
; i = 0.9809
; tx = -0.5075
; ty = 8.3929
; tz = 0.2229
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 5.4352; y = 8.2183; z = -2.7757 }
, (* C5' *)
{ x = 5.3830; y = 8.7883; z = -1.8481 }
, (* H5' *)
{ x = 5.7729; y = 8.7436; z = -3.6691 }
, (* H5'' *)
{ x = 6.4830; y = 7.1518; z = -2.5252 }
, (* C4' *)
{ x = 7.4749; y = 7.5972; z = -2.4482 }
, (* H4' *)
{ x = 6.1626; y = 6.4620; z = -1.2827 }
, (* O4' *)
{ x = 6.5431; y = 5.0992; z = -1.3905 }
, (* C1' *)
{ x = 7.2871; y = 4.9328; z = -0.6114 }
, (* H1' *)
{ x = 7.1852; y = 4.8935; z = -2.7592 }
, (* C2' *)
{ x = 6.8573; y = 3.9363; z = -3.1645 }
, (* H2'' *)
{ x = 8.5780; y = 5.1025; z = -2.6046 }
, (* O2' *)
{ x = 8.9516; y = 4.7577; z = -1.7902 }
, (* H2' *)
{ x = 6.5522; y = 6.0300; z = -3.5612 }
, (* C3' *)
{ x = 5.5420; y = 5.7356; z = -3.8459 }
, (* H3' *)
{ x = 7.3487; y = 6.4089; z = -4.6867 }
, (* O3' *)
{ x = 3.6343; y = 2.6680; z = 2.0783 }
, (* N1 *)
{ x = 5.4505; y = 3.9805; z = 1.2446 }
, (* N3 *)
{ x = 4.7540; y = 3.3816; z = 2.1851 }
, (* C2 *)
{ x = 4.8805; y = 3.7951; z = 0.0354 }
, (* C4 *)
{ x = 3.7416; y = 3.0925; z = -0.2305 }
, (* C5 *)
{ x = 3.0873; y = 2.4980; z = 0.8606 }
, (* C6 *)
A
( { x = 1.9600; y = 1.7805; z = 0.7462 }
, (* N6 *)
{ x = 3.4605; y = 3.1184; z = -1.5906 }
, (* N7 *)
{ x = 5.3247; y = 4.2695; z = -1.1710 }
, (* N9 *)
{ x = 4.4244; y = 3.8244; z = -2.0953 }
, (* C8 *)
{ x = 5.0814; y = 3.4352; z = 3.2234 }
, (* H2 *)
{ x = 1.5423; y = 1.6454; z = -0.1520 }
, (* H61 *)
{ x = 1.5716; y = 1.3398; z = 1.5392 }
, (* H62 *)
{ x = 4.2675; y = 3.8876; z = -3.1721 } ) )
(* H8 *)
let rA05 =
N
( { a = -0.5891
; b = 0.0449
; c = 0.8068
; (* dgf_base_tfo *)
d = 0.5375
; e = 0.7673
; f = 0.3498
; g = -0.6034
; h = 0.6397
; i = -0.4762
; tx = -0.3019
; ty = -3.7679
; tz = -9.5913
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.5778; y = 6.6594; z = -4.0364 }
, (* C5' *)
{ x = 4.9220; y = 7.1963; z = -4.9204 }
, (* H5' *)
{ x = 3.7996; y = 5.9091; z = -4.1764 }
, (* H5'' *)
{ x = 5.7873; y = 5.8869; z = -3.5482 }
, (* C4' *)
{ x = 6.0405; y = 5.0875; z = -4.2446 }
, (* H4' *)
{ x = 6.9135; y = 6.8036; z = -3.4310 }
, (* O4' *)
{ x = 7.7293; y = 6.4084; z = -2.3392 }
, (* C1' *)
{ x = 8.7078; y = 6.1815; z = -2.7624 }
, (* H1' *)
{ x = 7.1305; y = 5.1418; z = -1.7347 }
, (* C2' *)
{ x = 7.2040; y = 5.1982; z = -0.6486 }
, (* H2'' *)
{ x = 7.7417; y = 4.0392; z = -2.3813 }
, (* O2' *)
{ x = 8.6785; y = 4.1443; z = -2.5630 }
, (* H2' *)
{ x = 5.6666; y = 5.2728; z = -2.1536 }
, (* C3' *)
{ x = 5.1747; y = 5.9805; z = -1.4863 }
, (* H3' *)
{ x = 4.9997; y = 4.0086; z = -2.1973 }
, (* O3' *)
{ x = 10.2594; y = 10.6774; z = -1.0056 }
, (* N1 *)
{ x = 9.7528; y = 8.7080; z = -2.2631 }
, (* N3 *)
{ x = 10.4471; y = 9.7876; z = -1.9791 }
, (* C2 *)
{ x = 8.7271; y = 8.5575; z = -1.3991 }
, (* C4 *)
{ x = 8.4100; y = 9.3803; z = -0.3580 }
, (* C5 *)
{ x = 9.2294; y = 10.5030; z = -0.1574 }
, (* C6 *)
A
( { x = 9.0349; y = 11.3951; z = 0.8250 }
, (* N6 *)
{ x = 7.2891; y = 8.9068; z = 0.3121 }
, (* N7 *)
{ x = 7.7962; y = 7.5519; z = -1.3859 }
, (* N9 *)
{ x = 6.9702; y = 7.8292; z = -0.3353 }
, (* C8 *)
{ x = 11.3132; y = 10.0537; z = -2.5851 }
, (* H2 *)
{ x = 8.2741; y = 11.2784; z = 1.4629 }
, (* H61 *)
{ x = 9.6733; y = 12.1368; z = 0.9529 }
, (* H62 *)
{ x = 6.0888; y = 7.3990; z = 0.1403 } ) )
(* H8 *)
let rA06 =
N
( { a = -0.9815
; b = 0.0731
; c = -0.1772
; (* dgf_base_tfo *)
d = 0.1912
; e = 0.3054
; f = -0.9328
; g = -0.0141
; h = -0.9494
; i = -0.3137
; tx = 5.7506
; ty = -5.1944
; tz = 4.7470
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.1214; y = 6.7116; z = -1.9049 }
, (* C5' *)
{ x = 3.3465; y = 5.9610; z = -2.0607 }
, (* H5' *)
{ x = 4.0789; y = 7.2928; z = -0.9837 }
, (* H5'' *)
{ x = 5.4170; y = 5.9293; z = -1.8186 }
, (* C4' *)
{ x = 5.4506; y = 5.3400; z = -0.9023 }
, (* H4' *)
{ x = 5.5067; y = 5.0417; z = -2.9703 }
, (* O4' *)
{ x = 6.8650; y = 4.9152; z = -3.3612 }
, (* C1' *)
{ x = 7.1090; y = 3.8577; z = -3.2603 }
, (* H1' *)
{ x = 7.7152; y = 5.7282; z = -2.3894 }
, (* C2' *)
{ x = 8.5029; y = 6.2356; z = -2.9463 }
, (* H2'' *)
{ x = 8.1036; y = 4.8568; z = -1.3419 }
, (* O2' *)
{ x = 8.3270; y = 3.9651; z = -1.6184 }
, (* H2' *)
{ x = 6.7003; y = 6.7565; z = -1.8911 }
, (* C3' *)
{ x = 6.5898; y = 7.5329; z = -2.6482 }
, (* H3' *)
{ x = 7.0505; y = 7.2878; z = -0.6105 }
, (* O3' *)
{ x = 6.6624; y = 3.5061; z = -8.2986 }
, (* N1 *)
{ x = 6.5810; y = 3.2570; z = -5.9221 }
, (* N3 *)
{ x = 6.5151; y = 2.8263; z = -7.1625 }
, (* C2 *)
{ x = 6.8364; y = 4.5817; z = -5.8882 }
, (* C4 *)
{ x = 7.0116; y = 5.4064; z = -6.9609 }
, (* C5 *)
{ x = 6.9173; y = 4.8260; z = -8.2361 }
, (* C6 *)
A
( { x = 7.0668; y = 5.5163; z = -9.3763 }
, (* N6 *)
{ x = 7.2573; y = 6.7070; z = -6.5394 }
, (* N7 *)
{ x = 6.9740; y = 5.3703; z = -4.7760 }
, (* N9 *)
{ x = 7.2238; y = 6.6275; z = -5.2453 }
, (* C8 *)
{ x = 6.3146; y = 1.7741; z = -7.3641 }
, (* H2 *)
{ x = 7.2568; y = 6.4972; z = -9.3456 }
, (* H61 *)
{ x = 7.0437; y = 5.0478; z = -10.2446 }
, (* H62 *)
{ x = 7.4108; y = 7.6227; z = -4.8418 } ) )
(* H8 *)
let rA07 =
N
( { a = 0.2379
; b = 0.1310
; c = -0.9624
; (* dgf_base_tfo *)
d = -0.5876
; e = -0.7696
; f = -0.2499
; g = -0.7734
; h = 0.6249
; i = -0.1061
; tx = 30.9870
; ty = -26.9344
; tz = 42.6416
}
, { a = 0.7529
; b = 0.1548
; c = 0.6397
; (* P_O3'_275_tfo *)
d = 0.2952
; e = -0.9481
; f = -0.1180
; g = 0.5882
; h = 0.2777
; i = -0.7595
; tx = -58.8919
; ty = -11.3095
; tz = 6.0866
}
, { a = -0.0239
; b = 0.9667
; c = -0.2546
; (* P_O3'_180_tfo *)
d = 0.9731
; e = -0.0359
; f = -0.2275
; g = -0.2290
; h = -0.2532
; i = -0.9399
; tx = 3.5401
; ty = -29.7913
; tz = 52.2796
}
, { a = -0.8912
; b = -0.4531
; c = 0.0242
; (* P_O3'_60_tfo *)
d = -0.1183
; e = 0.1805
; f = -0.9764
; g = 0.4380
; h = -0.8730
; i = -0.2145
; tx = 19.9023
; ty = 54.8054
; tz = 15.2799
}
, { x = 41.8210; y = 8.3880; z = 43.5890 }
, (* P *)
{ x = 42.5400; y = 8.0450; z = 44.8330 }
, (* O1P *)
{ x = 42.2470; y = 9.6920; z = 42.9910 }
, (* O2P *)
{ x = 40.2550; y = 8.2030; z = 43.7340 }
, (* O5' *)
{ x = 39.3505; y = 8.4697; z = 42.6565 }
, (* C5' *)
{ x = 39.1377; y = 7.5433; z = 42.1230 }
, (* H5' *)
{ x = 39.7203; y = 9.3119; z = 42.0717 }
, (* H5'' *)
{ x = 38.0405; y = 8.9195; z = 43.2869 }
, (* C4' *)
{ x = 37.3687; y = 9.3036; z = 42.5193 }
, (* H4' *)
{ x = 37.4319; y = 7.8146; z = 43.9387 }
, (* O4' *)
{ x = 37.1959; y = 8.1354; z = 45.3237 }
, (* C1' *)
{ x = 36.1788; y = 8.5202; z = 45.3970 }
, (* H1' *)
{ x = 38.1721; y = 9.2328; z = 45.6504 }
, (* C2' *)
{ x = 39.1555; y = 8.7939; z = 45.8188 }
, (* H2'' *)
{ x = 37.7862; y = 10.0617; z = 46.7013 }
, (* O2' *)
{ x = 37.3087; y = 9.6229; z = 47.4092 }
, (* H2' *)
{ x = 38.1844; y = 10.0268; z = 44.3367 }
, (* C3' *)
{ x = 39.1578; y = 10.5054; z = 44.2289 }
, (* H3' *)
{ x = 37.0547; y = 10.9127; z = 44.3441 }
, (* O3' *)
{ x = 34.8811; y = 4.2072; z = 47.5784 }
, (* N1 *)
{ x = 35.1084; y = 6.1336; z = 46.1818 }
, (* N3 *)
{ x = 34.4108; y = 5.1360; z = 46.7207 }
, (* C2 *)
{ x = 36.3908; y = 6.1224; z = 46.6053 }
, (* C4 *)
{ x = 36.9819; y = 5.2334; z = 47.4697 }
, (* C5 *)
{ x = 36.1786; y = 4.1985; z = 48.0035 }
, (* C6 *)
A
( { x = 36.6103; y = 3.2749; z = 48.8452 }
, (* N6 *)
{ x = 38.3236; y = 5.5522; z = 47.6595 }
, (* N7 *)
{ x = 37.3887; y = 7.0024; z = 46.2437 }
, (* N9 *)
{ x = 38.5055; y = 6.6096; z = 46.9057 }
, (* C8 *)
{ x = 33.3553; y = 5.0152; z = 46.4771 }
, (* H2 *)
{ x = 37.5730; y = 3.2804; z = 49.1507 }
, (* H61 *)
{ x = 35.9775; y = 2.5638; z = 49.1828 }
, (* H62 *)
{ x = 39.5461; y = 6.9184; z = 47.0041 } ) )
(* H8 *)
let rA08 =
N
( { a = 0.1084
; b = -0.0895
; c = -0.9901
; (* dgf_base_tfo *)
d = 0.9789
; e = -0.1638
; f = 0.1220
; g = -0.1731
; h = -0.9824
; i = 0.0698
; tx = -2.9039
; ty = 47.2655
; tz = 33.0094
}
, { a = 0.7529
; b = 0.1548
; c = 0.6397
; (* P_O3'_275_tfo *)
d = 0.2952
; e = -0.9481
; f = -0.1180
; g = 0.5882
; h = 0.2777
; i = -0.7595
; tx = -58.8919
; ty = -11.3095
; tz = 6.0866
}
, { a = -0.0239
; b = 0.9667
; c = -0.2546
; (* P_O3'_180_tfo *)
d = 0.9731
; e = -0.0359
; f = -0.2275
; g = -0.2290
; h = -0.2532
; i = -0.9399
; tx = 3.5401
; ty = -29.7913
; tz = 52.2796
}
, { a = -0.8912
; b = -0.4531
; c = 0.0242
; (* P_O3'_60_tfo *)
d = -0.1183
; e = 0.1805
; f = -0.9764
; g = 0.4380
; h = -0.8730
; i = -0.2145
; tx = 19.9023
; ty = 54.8054
; tz = 15.2799
}
, { x = 41.8210; y = 8.3880; z = 43.5890 }
, (* P *)
{ x = 42.5400; y = 8.0450; z = 44.8330 }
, (* O1P *)
{ x = 42.2470; y = 9.6920; z = 42.9910 }
, (* O2P *)
{ x = 40.2550; y = 8.2030; z = 43.7340 }
, (* O5' *)
{ x = 39.4850; y = 8.9301; z = 44.6977 }
, (* C5' *)
{ x = 39.0638; y = 9.8199; z = 44.2296 }
, (* H5' *)
{ x = 40.0757; y = 9.0713; z = 45.6029 }
, (* H5'' *)
{ x = 38.3102; y = 8.0414; z = 45.0789 }
, (* C4' *)
{ x = 37.7842; y = 8.4637; z = 45.9351 }
, (* H4' *)
{ x = 37.4200; y = 7.9453; z = 43.9769 }
, (* O4' *)
{ x = 37.2249; y = 6.5609; z = 43.6273 }
, (* C1' *)
{ x = 36.3360; y = 6.2168; z = 44.1561 }
, (* H1' *)
{ x = 38.4347; y = 5.8414; z = 44.1590 }
, (* C2' *)
{ x = 39.2688; y = 5.9974; z = 43.4749 }
, (* H2'' *)
{ x = 38.2344; y = 4.4907; z = 44.4348 }
, (* O2' *)
{ x = 37.6374; y = 4.0386; z = 43.8341 }
, (* H2' *)
{ x = 38.6926; y = 6.6079; z = 45.4637 }
, (* C3' *)
{ x = 39.7585; y = 6.5640; z = 45.6877 }
, (* H3' *)
{ x = 37.8238; y = 6.0705; z = 46.4723 }
, (* O3' *)
{ x = 33.9162; y = 6.2598; z = 39.7758 }
, (* N1 *)
{ x = 34.6709; y = 6.5759; z = 42.0215 }
, (* N3 *)
{ x = 33.7257; y = 6.5186; z = 41.0858 }
, (* C2 *)
{ x = 35.8935; y = 6.3324; z = 41.5018 }
, (* C4 *)
{ x = 36.2105; y = 6.0601; z = 40.1932 }
, (* C5 *)
{ x = 35.1538; y = 6.0151; z = 39.2537 }
, (* C6 *)
A
( { x = 35.3088; y = 5.7642; z = 37.9649 }
, (* N6 *)
{ x = 37.5818; y = 5.8677; z = 40.0507 }
, (* N7 *)
{ x = 37.0932; y = 6.3197; z = 42.1810 }
, (* N9 *)
{ x = 38.0509; y = 6.0354; z = 41.2635 }
, (* C8 *)
{ x = 32.6830; y = 6.6898; z = 41.3532 }
, (* H2 *)
{ x = 36.2305; y = 5.5855; z = 37.5925 }
, (* H61 *)
{ x = 34.5056; y = 5.7512; z = 37.3528 }
, (* H62 *)
{ x = 39.1318; y = 5.8993; z = 41.2285 } ) )
(* H8 *)
let rA09 =
N
( { a = 0.8467
; b = 0.4166
; c = -0.3311
; (* dgf_base_tfo *)
d = -0.3962
; e = 0.9089
; f = 0.1303
; g = 0.3552
; h = 0.0209
; i = 0.9346
; tx = -42.7319
; ty = -26.6223
; tz = -29.8163
}
, { a = 0.7529
; b = 0.1548
; c = 0.6397
; (* P_O3'_275_tfo *)
d = 0.2952
; e = -0.9481
; f = -0.1180
; g = 0.5882
; h = 0.2777
; i = -0.7595
; tx = -58.8919
; ty = -11.3095
; tz = 6.0866
}
, { a = -0.0239
; b = 0.9667
; c = -0.2546
; (* P_O3'_180_tfo *)
d = 0.9731
; e = -0.0359
; f = -0.2275
; g = -0.2290
; h = -0.2532
; i = -0.9399
; tx = 3.5401
; ty = -29.7913
; tz = 52.2796
}
, { a = -0.8912
; b = -0.4531
; c = 0.0242
; (* P_O3'_60_tfo *)
d = -0.1183
; e = 0.1805
; f = -0.9764
; g = 0.4380
; h = -0.8730
; i = -0.2145
; tx = 19.9023
; ty = 54.8054
; tz = 15.2799
}
, { x = 41.8210; y = 8.3880; z = 43.5890 }
, (* P *)
{ x = 42.5400; y = 8.0450; z = 44.8330 }
, (* O1P *)
{ x = 42.2470; y = 9.6920; z = 42.9910 }
, (* O2P *)
{ x = 40.2550; y = 8.2030; z = 43.7340 }
, (* O5' *)
{ x = 39.3505; y = 8.4697; z = 42.6565 }
, (* C5' *)
{ x = 39.1377; y = 7.5433; z = 42.1230 }
, (* H5' *)
{ x = 39.7203; y = 9.3119; z = 42.0717 }
, (* H5'' *)
{ x = 38.0405; y = 8.9195; z = 43.2869 }
, (* C4' *)
{ x = 37.6479; y = 8.1347; z = 43.9335 }
, (* H4' *)
{ x = 38.2691; y = 10.0933; z = 44.0524 }
, (* O4' *)
{ x = 37.3999; y = 11.1488; z = 43.5973 }
, (* C1' *)
{ x = 36.5061; y = 11.1221; z = 44.2206 }
, (* H1' *)
{ x = 37.0364; y = 10.7838; z = 42.1836 }
, (* C2' *)
{ x = 37.8636; y = 11.0489; z = 41.5252 }
, (* H2'' *)
{ x = 35.8275; y = 11.3133; z = 41.7379 }
, (* O2' *)
{ x = 35.6214; y = 12.1896; z = 42.0714 }
, (* H2' *)
{ x = 36.9316; y = 9.2556; z = 42.2837 }
, (* C3' *)
{ x = 37.1778; y = 8.8260; z = 41.3127 }
, (* H3' *)
{ x = 35.6285; y = 8.9334; z = 42.7926 }
, (* O3' *)
{ x = 38.1482; y = 15.2833; z = 46.4641 }
, (* N1 *)
{ x = 37.3641; y = 13.0968; z = 45.9007 }
, (* N3 *)
{ x = 37.5032; y = 14.1288; z = 46.7300 }
, (* C2 *)
{ x = 37.9570; y = 13.3377; z = 44.7113 }
, (* C4 *)
{ x = 38.6397; y = 14.4660; z = 44.3267 }
, (* C5 *)
{ x = 38.7473; y = 15.5229; z = 45.2609 }
, (* C6 *)
A
( { x = 39.3720; y = 16.6649; z = 45.0297 }
, (* N6 *)
{ x = 39.1079; y = 14.3351; z = 43.0223 }
, (* N7 *)
{ x = 38.0132; y = 12.4868; z = 43.6280 }
, (* N9 *)
{ x = 38.7058; y = 13.1402; z = 42.6620 }
, (* C8 *)
{ x = 37.0731; y = 14.0857; z = 47.7306 }
, (* H2 *)
{ x = 39.8113; y = 16.8281; z = 44.1350 }
, (* H61 *)
{ x = 39.4100; y = 17.3741; z = 45.7478 }
, (* H62 *)
{ x = 39.0412; y = 12.9660; z = 41.6397 } ) )
(* H8 *)
let rA10 =
N
( { a = 0.7063
; b = 0.6317
; c = -0.3196
; (* dgf_base_tfo *)
d = -0.0403
; e = -0.4149
; f = -0.9090
; g = -0.7068
; h = 0.6549
; i = -0.2676
; tx = 6.4402
; ty = -52.1496
; tz = 30.8246
}
, { a = 0.7529
; b = 0.1548
; c = 0.6397
; (* P_O3'_275_tfo *)
d = 0.2952
; e = -0.9481
; f = -0.1180
; g = 0.5882
; h = 0.2777
; i = -0.7595
; tx = -58.8919
; ty = -11.3095
; tz = 6.0866
}
, { a = -0.0239
; b = 0.9667
; c = -0.2546
; (* P_O3'_180_tfo *)
d = 0.9731
; e = -0.0359
; f = -0.2275
; g = -0.2290
; h = -0.2532
; i = -0.9399
; tx = 3.5401
; ty = -29.7913
; tz = 52.2796
}
, { a = -0.8912
; b = -0.4531
; c = 0.0242
; (* P_O3'_60_tfo *)
d = -0.1183
; e = 0.1805
; f = -0.9764
; g = 0.4380
; h = -0.8730
; i = -0.2145
; tx = 19.9023
; ty = 54.8054
; tz = 15.2799
}
, { x = 41.8210; y = 8.3880; z = 43.5890 }
, (* P *)
{ x = 42.5400; y = 8.0450; z = 44.8330 }
, (* O1P *)
{ x = 42.2470; y = 9.6920; z = 42.9910 }
, (* O2P *)
{ x = 40.2550; y = 8.2030; z = 43.7340 }
, (* O5' *)
{ x = 39.4850; y = 8.9301; z = 44.6977 }
, (* C5' *)
{ x = 39.0638; y = 9.8199; z = 44.2296 }
, (* H5' *)
{ x = 40.0757; y = 9.0713; z = 45.6029 }
, (* H5'' *)
{ x = 38.3102; y = 8.0414; z = 45.0789 }
, (* C4' *)
{ x = 37.7099; y = 7.8166; z = 44.1973 }
, (* H4' *)
{ x = 38.8012; y = 6.8321; z = 45.6380 }
, (* O4' *)
{ x = 38.2431; y = 6.6413; z = 46.9529 }
, (* C1' *)
{ x = 37.3505; y = 6.0262; z = 46.8385 }
, (* H1' *)
{ x = 37.8484; y = 8.0156; z = 47.4214 }
, (* C2' *)
{ x = 38.7381; y = 8.5406; z = 47.7690 }
, (* H2'' *)
{ x = 36.8286; y = 8.0368; z = 48.3701 }
, (* O2' *)
{ x = 36.8392; y = 7.3063; z = 48.9929 }
, (* H2' *)
{ x = 37.3576; y = 8.6512; z = 46.1132 }
, (* C3' *)
{ x = 37.5207; y = 9.7275; z = 46.1671 }
, (* H3' *)
{ x = 35.9985; y = 8.2392; z = 45.9032 }
, (* O3' *)
{ x = 39.9117; y = 2.2278; z = 48.8527 }
, (* N1 *)
{ x = 38.6207; y = 3.6941; z = 47.4757 }
, (* N3 *)
{ x = 38.9872; y = 2.4888; z = 47.9057 }
, (* C2 *)
{ x = 39.2961; y = 4.6720; z = 48.1174 }
, (* C4 *)
{ x = 40.2546; y = 4.5307; z = 49.0912 }
, (* C5 *)
{ x = 40.5932; y = 3.2189; z = 49.4985 }
, (* C6 *)
A
( { x = 41.4938; y = 2.9317; z = 50.4229 }
, (* N6 *)
{ x = 40.7195; y = 5.7755; z = 49.5060 }
, (* N7 *)
{ x = 39.1730; y = 6.0305; z = 47.9170 }
, (* N9 *)
{ x = 40.0413; y = 6.6250; z = 48.7728 }
, (* C8 *)
{ x = 38.5257; y = 1.5960; z = 47.4838 }
, (* H2 *)
{ x = 41.9907; y = 3.6753; z = 50.8921 }
, (* H61 *)
{ x = 41.6848; y = 1.9687; z = 50.6599 }
, (* H62 *)
{ x = 40.3571; y = 7.6321; z = 49.0452 } ) )
(* H8 *)
let rAs = [ rA01; rA02; rA03; rA04; rA05; rA06; rA07; rA08; rA09; rA10 ]
let rC =
N
( { a = -0.0359
; b = -0.8071
; c = 0.5894
; (* dgf_base_tfo *)
d = -0.2669
; e = 0.5761
; f = 0.7726
; g = -0.9631
; h = -0.1296
; i = -0.2361
; tx = 0.1584
; ty = 8.3434
; tz = 0.5434
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 5.2430; y = -8.2420; z = 2.8260 }
, (* C5' *)
{ x = 5.1974; y = -8.8497; z = 1.9223 }
, (* H5' *)
{ x = 5.5548; y = -8.7348; z = 3.7469 }
, (* H5'' *)
{ x = 6.3140; y = -7.2060; z = 2.5510 }
, (* C4' *)
{ x = 7.2954; y = -7.6762; z = 2.4898 }
, (* H4' *)
{ x = 6.0140; y = -6.5420; z = 1.2890 }
, (* O4' *)
{ x = 6.4190; y = -5.1840; z = 1.3620 }
, (* C1' *)
{ x = 7.1608; y = -5.0495; z = 0.5747 }
, (* H1' *)
{ x = 7.0760; y = -4.9560; z = 2.7270 }
, (* C2' *)
{ x = 6.7770; y = -3.9803; z = 3.1099 }
, (* H2'' *)
{ x = 8.4500; y = -5.1930; z = 2.5810 }
, (* O2' *)
{ x = 8.8309; y = -4.8755; z = 1.7590 }
, (* H2' *)
{ x = 6.4060; y = -6.0590; z = 3.5580 }
, (* C3' *)
{ x = 5.4021; y = -5.7313; z = 3.8281 }
, (* H3' *)
{ x = 7.1570; y = -6.4240; z = 4.7070 }
, (* O3' *)
{ x = 5.2170; y = -4.3260; z = 1.1690 }
, (* N1 *)
{ x = 4.2960; y = -2.2560; z = 0.6290 }
, (* N3 *)
{ x = 5.4330; y = -3.0200; z = 0.7990 }
, (* C2 *)
{ x = 2.9930; y = -2.6780; z = 0.7940 }
, (* C4 *)
{ x = 2.8670; y = -4.0630; z = 1.1830 }
, (* C5 *)
{ x = 3.9570; y = -4.8300; z = 1.3550 }
, (* C6 *)
C
( { x = 2.0187; y = -1.8047; z = 0.5874 }
, (* N4 *)
{ x = 6.5470; y = -2.5560; z = 0.6290 }
, (* O2 *)
{ x = 1.0684; y = -2.1236; z = 0.7109 }
, (* H41 *)
{ x = 2.2344; y = -0.8560; z = 0.3162 }
, (* H42 *)
{ x = 1.8797; y = -4.4972; z = 1.3404 }
, (* H5 *)
{ x = 3.8479; y = -5.8742; z = 1.6480 } ) )
(* H6 *)
let rC01 =
N
( { a = -0.0137
; b = -0.8012
; c = 0.5983
; (* dgf_base_tfo *)
d = -0.2523
; e = 0.5817
; f = 0.7733
; g = -0.9675
; h = -0.1404
; i = -0.2101
; tx = 0.2031
; ty = 8.3874
; tz = 0.4228
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 5.2416; y = -8.2422; z = 2.8181 }
, (* C5' *)
{ x = 5.2050; y = -8.8128; z = 1.8901 }
, (* H5' *)
{ x = 5.5368; y = -8.7738; z = 3.7227 }
, (* H5'' *)
{ x = 6.3232; y = -7.2037; z = 2.6002 }
, (* C4' *)
{ x = 7.3048; y = -7.6757; z = 2.5577 }
, (* H4' *)
{ x = 6.0635; y = -6.5092; z = 1.3456 }
, (* O4' *)
{ x = 6.4697; y = -5.1547; z = 1.4629 }
, (* C1' *)
{ x = 7.2354; y = -5.0043; z = 0.7018 }
, (* H1' *)
{ x = 7.0856; y = -4.9610; z = 2.8521 }
, (* C2' *)
{ x = 6.7777; y = -3.9935; z = 3.2487 }
, (* H2'' *)
{ x = 8.4627; y = -5.1992; z = 2.7423 }
, (* O2' *)
{ x = 8.8693; y = -4.8638; z = 1.9399 }
, (* H2' *)
{ x = 6.3877; y = -6.0809; z = 3.6362 }
, (* C3' *)
{ x = 5.3770; y = -5.7562; z = 3.8834 }
, (* H3' *)
{ x = 7.1024; y = -6.4754; z = 4.7985 }
, (* O3' *)
{ x = 5.2764; y = -4.2883; z = 1.2538 }
, (* N1 *)
{ x = 4.3777; y = -2.2062; z = 0.7229 }
, (* N3 *)
{ x = 5.5069; y = -2.9779; z = 0.9088 }
, (* C2 *)
{ x = 3.0693; y = -2.6246; z = 0.8500 }
, (* C4 *)
{ x = 2.9279; y = -4.0146; z = 1.2149 }
, (* C5 *)
{ x = 4.0101; y = -4.7892; z = 1.4017 }
, (* C6 *)
C
( { x = 2.1040; y = -1.7437; z = 0.6331 }
, (* N4 *)
{ x = 6.6267; y = -2.5166; z = 0.7728 }
, (* O2 *)
{ x = 1.1496; y = -2.0600; z = 0.7287 }
, (* H41 *)
{ x = 2.3303; y = -0.7921; z = 0.3815 }
, (* H42 *)
{ x = 1.9353; y = -4.4465; z = 1.3419 }
, (* H5 *)
{ x = 3.8895; y = -5.8371; z = 1.6762 } ) )
(* H6 *)
let rC02 =
N
( { a = 0.5141
; b = 0.0246
; c = 0.8574
; (* dgf_base_tfo *)
d = -0.5547
; e = -0.7529
; f = 0.3542
; g = 0.6542
; h = -0.6577
; i = -0.3734
; tx = -9.1111
; ty = -3.4598
; tz = -3.2939
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 4.3825; y = -6.6585; z = 4.0489 }
, (* C5' *)
{ x = 4.6841; y = -7.2019; z = 4.9443 }
, (* H5' *)
{ x = 3.6189; y = -5.8889; z = 4.1625 }
, (* H5'' *)
{ x = 5.6255; y = -5.9175; z = 3.5998 }
, (* C4' *)
{ x = 5.8732; y = -5.1228; z = 4.3034 }
, (* H4' *)
{ x = 6.7337; y = -6.8605; z = 3.5222 }
, (* O4' *)
{ x = 7.5932; y = -6.4923; z = 2.4548 }
, (* C1' *)
{ x = 8.5661; y = -6.2983; z = 2.9064 }
, (* H1' *)
{ x = 7.0527; y = -5.2012; z = 1.8322 }
, (* C2' *)
{ x = 7.1627; y = -5.2525; z = 0.7490 }
, (* H2'' *)
{ x = 7.6666; y = -4.1249; z = 2.4880 }
, (* O2' *)
{ x = 8.5944; y = -4.2543; z = 2.6981 }
, (* H2' *)
{ x = 5.5661; y = -5.3029; z = 2.2009 }
, (* C3' *)
{ x = 5.0841; y = -6.0018; z = 1.5172 }
, (* H3' *)
{ x = 4.9062; y = -4.0452; z = 2.2042 }
, (* O3' *)
{ x = 7.6298; y = -7.6136; z = 1.4752 }
, (* N1 *)
{ x = 8.6945; y = -8.7046; z = -0.2857 }
, (* N3 *)
{ x = 8.6943; y = -7.6514; z = 0.6066 }
, (* C2 *)
{ x = 7.7426; y = -9.6987; z = -0.3801 }
, (* C4 *)
{ x = 6.6642; y = -9.5742; z = 0.5722 }
, (* C5 *)
{ x = 6.6391; y = -8.5592; z = 1.4526 }
, (* C6 *)
C
( { x = 7.9033; y = -10.6371; z = -1.3010 }
, (* N4 *)
{ x = 9.5840; y = -6.8186; z = 0.6136 }
, (* O2 *)
{ x = 7.2009; y = -11.3604; z = -1.3619 }
, (* H41 *)
{ x = 8.7058; y = -10.6168; z = -1.9140 }
, (* H42 *)
{ x = 5.8585; y = -10.3083; z = 0.5822 }
, (* H5 *)
{ x = 5.8197; y = -8.4773; z = 2.1667 } ) )
(* H6 *)
let rC03 =
N
( { a = -0.4993
; b = 0.0476
; c = 0.8651
; (* dgf_base_tfo *)
d = 0.8078
; e = -0.3353
; f = 0.4847
; g = 0.3132
; h = 0.9409
; i = 0.1290
; tx = 6.2989
; ty = -5.2303
; tz = -3.8577
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 3.9938; y = -6.7042; z = 1.9023 }
, (* C5' *)
{ x = 3.2332; y = -5.9343; z = 2.0319 }
, (* H5' *)
{ x = 3.9666; y = -7.2863; z = 0.9812 }
, (* H5'' *)
{ x = 5.3098; y = -5.9546; z = 1.8564 }
, (* C4' *)
{ x = 5.3863; y = -5.3702; z = 0.9395 }
, (* H4' *)
{ x = 5.3851; y = -5.0642; z = 3.0076 }
, (* O4' *)
{ x = 6.7315; y = -4.9724; z = 3.4462 }
, (* C1' *)
{ x = 7.0033; y = -3.9202; z = 3.3619 }
, (* H1' *)
{ x = 7.5997; y = -5.8018; z = 2.4948 }
, (* C2' *)
{ x = 8.3627; y = -6.3254; z = 3.0707 }
, (* H2'' *)
{ x = 8.0410; y = -4.9501; z = 1.4724 }
, (* O2' *)
{ x = 8.2781; y = -4.0644; z = 1.7570 }
, (* H2' *)
{ x = 6.5701; y = -6.8129; z = 1.9714 }
, (* C3' *)
{ x = 6.4186; y = -7.5809; z = 2.7299 }
, (* H3' *)
{ x = 6.9357; y = -7.3841; z = 0.7235 }
, (* O3' *)
{ x = 6.8024; y = -5.4718; z = 4.8475 }
, (* N1 *)
{ x = 7.9218; y = -5.5700; z = 6.8877 }
, (* N3 *)
{ x = 7.8908; y = -5.0886; z = 5.5944 }
, (* C2 *)
{ x = 6.9789; y = -6.3827; z = 7.4823 }
, (* C4 *)
{ x = 5.8742; y = -6.7319; z = 6.6202 }
, (* C5 *)
{ x = 5.8182; y = -6.2769; z = 5.3570 }
, (* C6 *)
C
( { x = 7.1702; y = -6.7511; z = 8.7402 }
, (* N4 *)
{ x = 8.7747; y = -4.3728; z = 5.1568 }
, (* O2 *)
{ x = 6.4741; y = -7.3461; z = 9.1662 }
, (* H41 *)
{ x = 7.9889; y = -6.4396; z = 9.2429 }
, (* H42 *)
{ x = 5.0736; y = -7.3713; z = 6.9922 }
, (* H5 *)
{ x = 4.9784; y = -6.5473; z = 4.7170 } ) )
(* H6 *)
let rC04 =
N
( { a = -0.5669
; b = -0.8012
; c = 0.1918
; (* dgf_base_tfo *)
d = -0.8129
; e = 0.5817
; f = 0.0273
; g = -0.1334
; h = -0.1404
; i = -0.9811
; tx = -0.3279
; ty = 8.3874
; tz = 0.3355
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 5.2416; y = -8.2422; z = 2.8181 }
, (* C5' *)
{ x = 5.2050; y = -8.8128; z = 1.8901 }
, (* H5' *)
{ x = 5.5368; y = -8.7738; z = 3.7227 }
, (* H5'' *)
{ x = 6.3232; y = -7.2037; z = 2.6002 }
, (* C4' *)
{ x = 7.3048; y = -7.6757; z = 2.5577 }
, (* H4' *)
{ x = 6.0635; y = -6.5092; z = 1.3456 }
, (* O4' *)
{ x = 6.4697; y = -5.1547; z = 1.4629 }
, (* C1' *)
{ x = 7.2354; y = -5.0043; z = 0.7018 }
, (* H1' *)
{ x = 7.0856; y = -4.9610; z = 2.8521 }
, (* C2' *)
{ x = 6.7777; y = -3.9935; z = 3.2487 }
, (* H2'' *)
{ x = 8.4627; y = -5.1992; z = 2.7423 }
, (* O2' *)
{ x = 8.8693; y = -4.8638; z = 1.9399 }
, (* H2' *)
{ x = 6.3877; y = -6.0809; z = 3.6362 }
, (* C3' *)
{ x = 5.3770; y = -5.7562; z = 3.8834 }
, (* H3' *)
{ x = 7.1024; y = -6.4754; z = 4.7985 }
, (* O3' *)
{ x = 5.2764; y = -4.2883; z = 1.2538 }
, (* N1 *)
{ x = 3.8961; y = -3.0896; z = -0.1893 }
, (* N3 *)
{ x = 5.0095; y = -3.8907; z = -0.0346 }
, (* C2 *)
{ x = 3.0480; y = -2.6632; z = 0.8116 }
, (* C4 *)
{ x = 3.4093; y = -3.1310; z = 2.1292 }
, (* C5 *)
{ x = 4.4878; y = -3.9124; z = 2.3088 }
, (* C6 *)
C
( { x = 2.0216; y = -1.8941; z = 0.4804 }
, (* N4 *)
{ x = 5.7005; y = -4.2164; z = -0.9842 }
, (* O2 *)
{ x = 1.4067; y = -1.5873; z = 1.2205 }
, (* H41 *)
{ x = 1.8721; y = -1.6319; z = -0.4835 }
, (* H42 *)
{ x = 2.8048; y = -2.8507; z = 2.9918 }
, (* H5 *)
{ x = 4.7491; y = -4.2593; z = 3.3085 } ) )
(* H6 *)
let rC05 =
N
( { a = -0.6298
; b = 0.0246
; c = 0.7763
; (* dgf_base_tfo *)
d = -0.5226
; e = -0.7529
; f = -0.4001
; g = 0.5746
; h = -0.6577
; i = 0.4870
; tx = -0.0208
; ty = -3.4598
; tz = -9.6882
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 4.3825; y = -6.6585; z = 4.0489 }
, (* C5' *)
{ x = 4.6841; y = -7.2019; z = 4.9443 }
, (* H5' *)
{ x = 3.6189; y = -5.8889; z = 4.1625 }
, (* H5'' *)
{ x = 5.6255; y = -5.9175; z = 3.5998 }
, (* C4' *)
{ x = 5.8732; y = -5.1228; z = 4.3034 }
, (* H4' *)
{ x = 6.7337; y = -6.8605; z = 3.5222 }
, (* O4' *)
{ x = 7.5932; y = -6.4923; z = 2.4548 }
, (* C1' *)
{ x = 8.5661; y = -6.2983; z = 2.9064 }
, (* H1' *)
{ x = 7.0527; y = -5.2012; z = 1.8322 }
, (* C2' *)
{ x = 7.1627; y = -5.2525; z = 0.7490 }
, (* H2'' *)
{ x = 7.6666; y = -4.1249; z = 2.4880 }
, (* O2' *)
{ x = 8.5944; y = -4.2543; z = 2.6981 }
, (* H2' *)
{ x = 5.5661; y = -5.3029; z = 2.2009 }
, (* C3' *)
{ x = 5.0841; y = -6.0018; z = 1.5172 }
, (* H3' *)
{ x = 4.9062; y = -4.0452; z = 2.2042 }
, (* O3' *)
{ x = 7.6298; y = -7.6136; z = 1.4752 }
, (* N1 *)
{ x = 8.5977; y = -9.5977; z = 0.7329 }
, (* N3 *)
{ x = 8.5951; y = -8.5745; z = 1.6594 }
, (* C2 *)
{ x = 7.7372; y = -9.7371; z = -0.3364 }
, (* C4 *)
{ x = 6.7596; y = -8.6801; z = -0.4476 }
, (* C5 *)
{ x = 6.7338; y = -7.6721; z = 0.4408 }
, (* C6 *)
C
( { x = 7.8849; y = -10.7881; z = -1.1289 }
, (* N4 *)
{ x = 9.3993; y = -8.5377; z = 2.5743 }
, (* O2 *)
{ x = 7.2499; y = -10.8809; z = -1.9088 }
, (* H41 *)
{ x = 8.6122; y = -11.4649; z = -0.9468 }
, (* H42 *)
{ x = 6.0317; y = -8.6941; z = -1.2588 }
, (* H5 *)
{ x = 5.9901; y = -6.8809; z = 0.3459 } ) )
(* H6 *)
let rC06 =
N
( { a = -0.9837
; b = 0.0476
; c = -0.1733
; (* dgf_base_tfo *)
d = -0.1792
; e = -0.3353
; f = 0.9249
; g = -0.0141
; h = 0.9409
; i = 0.3384
; tx = 5.7793
; ty = -5.2303
; tz = 4.5997
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 3.9938; y = -6.7042; z = 1.9023 }
, (* C5' *)
{ x = 3.2332; y = -5.9343; z = 2.0319 }
, (* H5' *)
{ x = 3.9666; y = -7.2863; z = 0.9812 }
, (* H5'' *)
{ x = 5.3098; y = -5.9546; z = 1.8564 }
, (* C4' *)
{ x = 5.3863; y = -5.3702; z = 0.9395 }
, (* H4' *)
{ x = 5.3851; y = -5.0642; z = 3.0076 }
, (* O4' *)
{ x = 6.7315; y = -4.9724; z = 3.4462 }
, (* C1' *)
{ x = 7.0033; y = -3.9202; z = 3.3619 }
, (* H1' *)
{ x = 7.5997; y = -5.8018; z = 2.4948 }
, (* C2' *)
{ x = 8.3627; y = -6.3254; z = 3.0707 }
, (* H2'' *)
{ x = 8.0410; y = -4.9501; z = 1.4724 }
, (* O2' *)
{ x = 8.2781; y = -4.0644; z = 1.7570 }
, (* H2' *)
{ x = 6.5701; y = -6.8129; z = 1.9714 }
, (* C3' *)
{ x = 6.4186; y = -7.5809; z = 2.7299 }
, (* H3' *)
{ x = 6.9357; y = -7.3841; z = 0.7235 }
, (* O3' *)
{ x = 6.8024; y = -5.4718; z = 4.8475 }
, (* N1 *)
{ x = 6.6920; y = -5.0495; z = 7.1354 }
, (* N3 *)
{ x = 6.6201; y = -4.5500; z = 5.8506 }
, (* C2 *)
{ x = 6.9254; y = -6.3614; z = 7.4926 }
, (* C4 *)
{ x = 7.1046; y = -7.2543; z = 6.3718 }
, (* C5 *)
{ x = 7.0391; y = -6.7951; z = 5.1106 }
, (* C6 *)
C
( { x = 6.9614; y = -6.6648; z = 8.7815 }
, (* N4 *)
{ x = 6.4083; y = -3.3696; z = 5.6340 }
, (* O2 *)
{ x = 7.1329; y = -7.6280; z = 9.0324 }
, (* H41 *)
{ x = 6.8204; y = -5.9469; z = 9.4777 }
, (* H42 *)
{ x = 7.2954; y = -8.3135; z = 6.5440 }
, (* H5 *)
{ x = 7.1753; y = -7.4798; z = 4.2735 } ) )
(* H6 *)
let rC07 =
N
( { a = 0.0033
; b = 0.2720
; c = -0.9623
; (* dgf_base_tfo *)
d = 0.3013
; e = -0.9179
; f = -0.2584
; g = -0.9535
; h = -0.2891
; i = -0.0850
; tx = 43.0403
; ty = 13.7233
; tz = 34.5710
}
, { a = 0.9187
; b = 0.2887
; c = 0.2694
; (* P_O3'_275_tfo *)
d = 0.0302
; e = -0.7316
; f = 0.6811
; g = 0.3938
; h = -0.6176
; i = -0.6808
; tx = -48.4330
; ty = 26.3254
; tz = 13.6383
}
, { a = -0.1504
; b = 0.7744
; c = -0.6145
; (* P_O3'_180_tfo *)
d = 0.7581
; e = 0.4893
; f = 0.4311
; g = 0.6345
; h = -0.4010
; i = -0.6607
; tx = -31.9784
; ty = -13.4285
; tz = 44.9650
}
, { a = -0.6236
; b = -0.7810
; c = -0.0337
; (* P_O3'_60_tfo *)
d = -0.6890
; e = 0.5694
; f = -0.4484
; g = 0.3694
; h = -0.2564
; i = -0.8932
; tx = 12.1105
; ty = 30.8774
; tz = 46.0946
}
, { x = 33.3400; y = 11.0980; z = 46.1750 }
, (* P *)
{ x = 34.5130; y = 10.2320; z = 46.4660 }
, (* O1P *)
{ x = 33.4130; y = 12.3960; z = 46.9340 }
, (* O2P *)
{ x = 31.9810; y = 10.3390; z = 46.4820 }
, (* O5' *)
{ x = 30.8152; y = 11.1619; z = 46.2003 }
, (* C5' *)
{ x = 30.4519; y = 10.9454; z = 45.1957 }
, (* H5' *)
{ x = 31.0379; y = 12.2016; z = 46.4400 }
, (* H5'' *)
{ x = 29.7081; y = 10.7448; z = 47.1428 }
, (* C4' *)
{ x = 28.8710; y = 11.4416; z = 47.0982 }
, (* H4' *)
{ x = 29.2550; y = 9.4394; z = 46.8162 }
, (* O4' *)
{ x = 29.3907; y = 8.5625; z = 47.9460 }
, (* C1' *)
{ x = 28.4416; y = 8.5669; z = 48.4819 }
, (* H1' *)
{ x = 30.4468; y = 9.2031; z = 48.7952 }
, (* C2' *)
{ x = 31.4222; y = 8.9651; z = 48.3709 }
, (* H2'' *)
{ x = 30.3701; y = 8.9157; z = 50.1624 }
, (* O2' *)
{ x = 30.0652; y = 8.0304; z = 50.3740 }
, (* H2' *)
{ x = 30.1622; y = 10.6879; z = 48.6120 }
, (* C3' *)
{ x = 31.0952; y = 11.2399; z = 48.7254 }
, (* H3' *)
{ x = 29.1076; y = 11.1535; z = 49.4702 }
, (* O3' *)
{ x = 29.7883; y = 7.2209; z = 47.5235 }
, (* N1 *)
{ x = 29.1825; y = 5.0438; z = 46.8275 }
, (* N3 *)
{ x = 28.8008; y = 6.2912; z = 47.2263 }
, (* C2 *)
{ x = 30.4888; y = 4.6890; z = 46.7186 }
, (* C4 *)
{ x = 31.5034; y = 5.6405; z = 47.0249 }
, (* C5 *)
{ x = 31.1091; y = 6.8691; z = 47.4156 }
, (* C6 *)
C
( { x = 30.8109; y = 3.4584; z = 46.3336 }
, (* N4 *)
{ x = 27.6171; y = 6.5989; z = 47.3189 }
, (* O2 *)
{ x = 31.7923; y = 3.2301; z = 46.2638 }
, (* H41 *)
{ x = 30.0880; y = 2.7857; z = 46.1215 }
, (* H42 *)
{ x = 32.5542; y = 5.3634; z = 46.9395 }
, (* H5 *)
{ x = 31.8523; y = 7.6279; z = 47.6603 } ) )
(* H6 *)
let rC08 =
N
( { a = 0.0797
; b = -0.6026
; c = -0.7941
; (* dgf_base_tfo *)
d = 0.7939
; e = 0.5201
; f = -0.3150
; g = 0.6028
; h = -0.6054
; i = 0.5198
; tx = -36.8341
; ty = 41.5293
; tz = 1.6628
}
, { a = 0.9187
; b = 0.2887
; c = 0.2694
; (* P_O3'_275_tfo *)
d = 0.0302
; e = -0.7316
; f = 0.6811
; g = 0.3938
; h = -0.6176
; i = -0.6808
; tx = -48.4330
; ty = 26.3254
; tz = 13.6383
}
, { a = -0.1504
; b = 0.7744
; c = -0.6145
; (* P_O3'_180_tfo *)
d = 0.7581
; e = 0.4893
; f = 0.4311
; g = 0.6345
; h = -0.4010
; i = -0.6607
; tx = -31.9784
; ty = -13.4285
; tz = 44.9650
}
, { a = -0.6236
; b = -0.7810
; c = -0.0337
; (* P_O3'_60_tfo *)
d = -0.6890
; e = 0.5694
; f = -0.4484
; g = 0.3694
; h = -0.2564
; i = -0.8932
; tx = 12.1105
; ty = 30.8774
; tz = 46.0946
}
, { x = 33.3400; y = 11.0980; z = 46.1750 }
, (* P *)
{ x = 34.5130; y = 10.2320; z = 46.4660 }
, (* O1P *)
{ x = 33.4130; y = 12.3960; z = 46.9340 }
, (* O2P *)
{ x = 31.9810; y = 10.3390; z = 46.4820 }
, (* O5' *)
{ x = 31.8779; y = 9.9369; z = 47.8760 }
, (* C5' *)
{ x = 31.3239; y = 10.6931; z = 48.4322 }
, (* H5' *)
{ x = 32.8647; y = 9.6624; z = 48.2489 }
, (* H5'' *)
{ x = 31.0429; y = 8.6773; z = 47.9401 }
, (* C4' *)
{ x = 31.0779; y = 8.2331; z = 48.9349 }
, (* H4' *)
{ x = 29.6956; y = 8.9669; z = 47.5983 }
, (* O4' *)
{ x = 29.2784; y = 8.1700; z = 46.4782 }
, (* C1' *)
{ x = 28.8006; y = 7.2731; z = 46.8722 }
, (* H1' *)
{ x = 30.5544; y = 7.7940; z = 45.7875 }
, (* C2' *)
{ x = 30.8837; y = 8.6410; z = 45.1856 }
, (* H2'' *)
{ x = 30.5100; y = 6.6007; z = 45.0582 }
, (* O2' *)
{ x = 29.6694; y = 6.4168; z = 44.6326 }
, (* H2' *)
{ x = 31.5146; y = 7.5954; z = 46.9527 }
, (* C3' *)
{ x = 32.5255; y = 7.8261; z = 46.6166 }
, (* H3' *)
{ x = 31.3876; y = 6.2951; z = 47.5516 }
, (* O3' *)
{ x = 28.3976; y = 8.9302; z = 45.5933 }
, (* N1 *)
{ x = 26.2155; y = 9.6135; z = 44.9910 }
, (* N3 *)
{ x = 27.0281; y = 8.8961; z = 45.8192 }
, (* C2 *)
{ x = 26.7044; y = 10.3489; z = 43.9595 }
, (* C4 *)
{ x = 28.1088; y = 10.3837; z = 43.7247 }
, (* C5 *)
{ x = 28.8978; y = 9.6708; z = 44.5535 }
, (* C6 *)
C
( { x = 25.8715; y = 11.0249; z = 43.1749 }
, (* N4 *)
{ x = 26.5733; y = 8.2371; z = 46.7484 }
, (* O2 *)
{ x = 26.2707; y = 11.5609; z = 42.4177 }
, (* H41 *)
{ x = 24.8760; y = 10.9939; z = 43.3427 }
, (* H42 *)
{ x = 28.5089; y = 10.9722; z = 42.8990 }
, (* H5 *)
{ x = 29.9782; y = 9.6687; z = 44.4097 } ) )
(* H6 *)
let rC09 =
N
( { a = 0.8727
; b = 0.4760
; c = -0.1091
; (* dgf_base_tfo *)
d = -0.4188
; e = 0.6148
; f = -0.6682
; g = -0.2510
; h = 0.6289
; i = 0.7359
; tx = -8.1687
; ty = -52.0761
; tz = -25.0726
}
, { a = 0.9187
; b = 0.2887
; c = 0.2694
; (* P_O3'_275_tfo *)
d = 0.0302
; e = -0.7316
; f = 0.6811
; g = 0.3938
; h = -0.6176
; i = -0.6808
; tx = -48.4330
; ty = 26.3254
; tz = 13.6383
}
, { a = -0.1504
; b = 0.7744
; c = -0.6145
; (* P_O3'_180_tfo *)
d = 0.7581
; e = 0.4893
; f = 0.4311
; g = 0.6345
; h = -0.4010
; i = -0.6607
; tx = -31.9784
; ty = -13.4285
; tz = 44.9650
}
, { a = -0.6236
; b = -0.7810
; c = -0.0337
; (* P_O3'_60_tfo *)
d = -0.6890
; e = 0.5694
; f = -0.4484
; g = 0.3694
; h = -0.2564
; i = -0.8932
; tx = 12.1105
; ty = 30.8774
; tz = 46.0946
}
, { x = 33.3400; y = 11.0980; z = 46.1750 }
, (* P *)
{ x = 34.5130; y = 10.2320; z = 46.4660 }
, (* O1P *)
{ x = 33.4130; y = 12.3960; z = 46.9340 }
, (* O2P *)
{ x = 31.9810; y = 10.3390; z = 46.4820 }
, (* O5' *)
{ x = 30.8152; y = 11.1619; z = 46.2003 }
, (* C5' *)
{ x = 30.4519; y = 10.9454; z = 45.1957 }
, (* H5' *)
{ x = 31.0379; y = 12.2016; z = 46.4400 }
, (* H5'' *)
{ x = 29.7081; y = 10.7448; z = 47.1428 }
, (* C4' *)
{ x = 29.4506; y = 9.6945; z = 47.0059 }
, (* H4' *)
{ x = 30.1045; y = 10.9634; z = 48.4885 }
, (* O4' *)
{ x = 29.1794; y = 11.8418; z = 49.1490 }
, (* C1' *)
{ x = 28.4388; y = 11.2210; z = 49.6533 }
, (* H1' *)
{ x = 28.5211; y = 12.6008; z = 48.0367 }
, (* C2' *)
{ x = 29.1947; y = 13.3949; z = 47.7147 }
, (* H2'' *)
{ x = 27.2316; y = 13.0683; z = 48.3134 }
, (* O2' *)
{ x = 27.0851; y = 13.3391; z = 49.2227 }
, (* H2' *)
{ x = 28.4131; y = 11.5507; z = 46.9391 }
, (* C3' *)
{ x = 28.4451; y = 12.0512; z = 45.9713 }
, (* H3' *)
{ x = 27.2707; y = 10.6955; z = 47.1097 }
, (* O3' *)
{ x = 29.8751; y = 12.7405; z = 50.0682 }
, (* N1 *)
{ x = 30.7172; y = 13.1841; z = 52.2328 }
, (* N3 *)
{ x = 30.0617; y = 12.3404; z = 51.3847 }
, (* C2 *)
{ x = 31.1834; y = 14.3941; z = 51.8297 }
, (* C4 *)
{ x = 30.9913; y = 14.8074; z = 50.4803 }
, (* C5 *)
{ x = 30.3434; y = 13.9610; z = 49.6548 }
, (* C6 *)
C
( { x = 31.8090; y = 15.1847; z = 52.6957 }
, (* N4 *)
{ x = 29.6470; y = 11.2494; z = 51.7616 }
, (* O2 *)
{ x = 32.1422; y = 16.0774; z = 52.3606 }
, (* H41 *)
{ x = 31.9392; y = 14.8893; z = 53.6527 }
, (* H42 *)
{ x = 31.3632; y = 15.7771; z = 50.1491 }
, (* H5 *)
{ x = 30.1742; y = 14.2374; z = 48.6141 } ) )
(* H6 *)
let rC10 =
N
( { a = 0.1549
; b = 0.8710
; c = -0.4663
; (* dgf_base_tfo *)
d = 0.6768
; e = -0.4374
; f = -0.5921
; g = -0.7197
; h = -0.2239
; i = -0.6572
; tx = 25.2447
; ty = -14.1920
; tz = 50.3201
}
, { a = 0.9187
; b = 0.2887
; c = 0.2694
; (* P_O3'_275_tfo *)
d = 0.0302
; e = -0.7316
; f = 0.6811
; g = 0.3938
; h = -0.6176
; i = -0.6808
; tx = -48.4330
; ty = 26.3254
; tz = 13.6383
}
, { a = -0.1504
; b = 0.7744
; c = -0.6145
; (* P_O3'_180_tfo *)
d = 0.7581
; e = 0.4893
; f = 0.4311
; g = 0.6345
; h = -0.4010
; i = -0.6607
; tx = -31.9784
; ty = -13.4285
; tz = 44.9650
}
, { a = -0.6236
; b = -0.7810
; c = -0.0337
; (* P_O3'_60_tfo *)
d = -0.6890
; e = 0.5694
; f = -0.4484
; g = 0.3694
; h = -0.2564
; i = -0.8932
; tx = 12.1105
; ty = 30.8774
; tz = 46.0946
}
, { x = 33.3400; y = 11.0980; z = 46.1750 }
, (* P *)
{ x = 34.5130; y = 10.2320; z = 46.4660 }
, (* O1P *)
{ x = 33.4130; y = 12.3960; z = 46.9340 }
, (* O2P *)
{ x = 31.9810; y = 10.3390; z = 46.4820 }
, (* O5' *)
{ x = 31.8779; y = 9.9369; z = 47.8760 }
, (* C5' *)
{ x = 31.3239; y = 10.6931; z = 48.4322 }
, (* H5' *)
{ x = 32.8647; y = 9.6624; z = 48.2489 }
, (* H5'' *)
{ x = 31.0429; y = 8.6773; z = 47.9401 }
, (* C4' *)
{ x = 30.0440; y = 8.8473; z = 47.5383 }
, (* H4' *)
{ x = 31.6749; y = 7.6351; z = 47.2119 }
, (* O4' *)
{ x = 31.9159; y = 6.5022; z = 48.0616 }
, (* C1' *)
{ x = 31.0691; y = 5.8243; z = 47.9544 }
, (* H1' *)
{ x = 31.9300; y = 7.0685; z = 49.4493 }
, (* C2' *)
{ x = 32.9024; y = 7.5288; z = 49.6245 }
, (* H2'' *)
{ x = 31.5672; y = 6.1750; z = 50.4632 }
, (* O2' *)
{ x = 31.8416; y = 5.2663; z = 50.3200 }
, (* H2' *)
{ x = 30.8618; y = 8.1514; z = 49.3749 }
, (* C3' *)
{ x = 31.1122; y = 8.9396; z = 50.0850 }
, (* H3' *)
{ x = 29.5351; y = 7.6245; z = 49.5409 }
, (* O3' *)
{ x = 33.1890; y = 5.8629; z = 47.7343 }
, (* N1 *)
{ x = 34.4004; y = 4.2636; z = 46.4828 }
, (* N3 *)
{ x = 33.2062; y = 4.8497; z = 46.7851 }
, (* C2 *)
{ x = 35.5600; y = 4.6374; z = 47.0822 }
, (* C4 *)
{ x = 35.5444; y = 5.6751; z = 48.0577 }
, (* C5 *)
{ x = 34.3565; y = 6.2450; z = 48.3432 }
, (* C6 *)
C
( { x = 36.6977; y = 4.0305; z = 46.7598 }
, (* N4 *)
{ x = 32.1661; y = 4.5034; z = 46.2348 }
, (* O2 *)
{ x = 37.5405; y = 4.3347; z = 47.2259 }
, (* H41 *)
{ x = 36.7033; y = 3.2923; z = 46.0706 }
, (* H42 *)
{ x = 36.4713; y = 5.9811; z = 48.5428 }
, (* H5 *)
{ x = 34.2986; y = 7.0426; z = 49.0839 } ) )
(* H6 *)
let rCs = [ rC01; rC02; rC03; rC04; rC05; rC06; rC07; rC08; rC09; rC10 ]
let rG =
N
( { a = -0.0018
; b = -0.8207
; c = 0.5714
; (* dgf_base_tfo *)
d = 0.2679
; e = -0.5509
; f = -0.7904
; g = 0.9634
; h = 0.1517
; i = 0.2209
; tx = 0.0073
; ty = 8.4030
; tz = 0.6232
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 5.4550; y = 8.2120; z = -2.8810 }
, (* C5' *)
{ x = 5.4546; y = 8.8508; z = -1.9978 }
, (* H5' *)
{ x = 5.7588; y = 8.6625; z = -3.8259 }
, (* H5'' *)
{ x = 6.4970; y = 7.1480; z = -2.5980 }
, (* C4' *)
{ x = 7.4896; y = 7.5919; z = -2.5214 }
, (* H4' *)
{ x = 6.1630; y = 6.4860; z = -1.3440 }
, (* O4' *)
{ x = 6.5400; y = 5.1200; z = -1.4190 }
, (* C1' *)
{ x = 7.2763; y = 4.9681; z = -0.6297 }
, (* H1' *)
{ x = 7.1940; y = 4.8830; z = -2.7770 }
, (* C2' *)
{ x = 6.8667; y = 3.9183; z = -3.1647 }
, (* H2'' *)
{ x = 8.5860; y = 5.0910; z = -2.6140 }
, (* O2' *)
{ x = 8.9510; y = 4.7626; z = -1.7890 }
, (* H2' *)
{ x = 6.5720; y = 6.0040; z = -3.6090 }
, (* C3' *)
{ x = 5.5636; y = 5.7066; z = -3.8966 }
, (* H3' *)
{ x = 7.3801; y = 6.3562; z = -4.7350 }
, (* O3' *)
{ x = 4.7150; y = 0.4910; z = -0.1360 }
, (* N1 *)
{ x = 6.3490; y = 2.1730; z = -0.6020 }
, (* N3 *)
{ x = 5.9530; y = 0.9650; z = -0.2670 }
, (* C2 *)
{ x = 5.2900; y = 2.9790; z = -0.8260 }
, (* C4 *)
{ x = 3.9720; y = 2.6390; z = -0.7330 }
, (* C5 *)
{ x = 3.6770; y = 1.3160; z = -0.3660 }
, (* C6 *)
G
( { x = 6.8426; y = 0.0056; z = -0.0019 }
, (* N2 *)
{ x = 3.1660; y = 3.7290; z = -1.0360 }
, (* N7 *)
{ x = 5.3170; y = 4.2990; z = -1.1930 }
, (* N9 *)
{ x = 4.0100; y = 4.6780; z = -1.2990 }
, (* C8 *)
{ x = 2.4280; y = 0.8450; z = -0.2360 }
, (* O6 *)
{ x = 4.6151; y = -0.4677; z = 0.1305 }
, (* H1 *)
{ x = 6.6463; y = -0.9463; z = 0.2729 }
, (* H21 *)
{ x = 7.8170; y = 0.2642; z = -0.0640 }
, (* H22 *)
{ x = 3.4421; y = 5.5744; z = -1.5482 } ) )
(* H8 *)
let rG01 =
N
( { a = -0.0043
; b = -0.8175
; c = 0.5759
; (* dgf_base_tfo *)
d = 0.2617
; e = -0.5567
; f = -0.7884
; g = 0.9651
; h = 0.1473
; i = 0.2164
; tx = 0.0359
; ty = 8.3929
; tz = 0.5532
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 5.4352; y = 8.2183; z = -2.7757 }
, (* C5' *)
{ x = 5.3830; y = 8.7883; z = -1.8481 }
, (* H5' *)
{ x = 5.7729; y = 8.7436; z = -3.6691 }
, (* H5'' *)
{ x = 6.4830; y = 7.1518; z = -2.5252 }
, (* C4' *)
{ x = 7.4749; y = 7.5972; z = -2.4482 }
, (* H4' *)
{ x = 6.1626; y = 6.4620; z = -1.2827 }
, (* O4' *)
{ x = 6.5431; y = 5.0992; z = -1.3905 }
, (* C1' *)
{ x = 7.2871; y = 4.9328; z = -0.6114 }
, (* H1' *)
{ x = 7.1852; y = 4.8935; z = -2.7592 }
, (* C2' *)
{ x = 6.8573; y = 3.9363; z = -3.1645 }
, (* H2'' *)
{ x = 8.5780; y = 5.1025; z = -2.6046 }
, (* O2' *)
{ x = 8.9516; y = 4.7577; z = -1.7902 }
, (* H2' *)
{ x = 6.5522; y = 6.0300; z = -3.5612 }
, (* C3' *)
{ x = 5.5420; y = 5.7356; z = -3.8459 }
, (* H3' *)
{ x = 7.3487; y = 6.4089; z = -4.6867 }
, (* O3' *)
{ x = 4.7442; y = 0.4514; z = -0.1390 }
, (* N1 *)
{ x = 6.3687; y = 2.1459; z = -0.5926 }
, (* N3 *)
{ x = 5.9795; y = 0.9335; z = -0.2657 }
, (* C2 *)
{ x = 5.3052; y = 2.9471; z = -0.8125 }
, (* C4 *)
{ x = 3.9891; y = 2.5987; z = -0.7230 }
, (* C5 *)
{ x = 3.7016; y = 1.2717; z = -0.3647 }
, (* C6 *)
G
( { x = 6.8745; y = -0.0224; z = -0.0058 }
, (* N2 *)
{ x = 3.1770; y = 3.6859; z = -1.0198 }
, (* N7 *)
{ x = 5.3247; y = 4.2695; z = -1.1710 }
, (* N9 *)
{ x = 4.0156; y = 4.6415; z = -1.2759 }
, (* C8 *)
{ x = 2.4553; y = 0.7925; z = -0.2390 }
, (* O6 *)
{ x = 4.6497; y = -0.5095; z = 0.1212 }
, (* H1 *)
{ x = 6.6836; y = -0.9771; z = 0.2627 }
, (* H21 *)
{ x = 7.8474; y = 0.2424; z = -0.0653 }
, (* H22 *)
{ x = 3.4426; y = 5.5361; z = -1.5199 } ) )
(* H8 *)
let rG02 =
N
( { a = 0.5566
; b = 0.0449
; c = 0.8296
; (* dgf_base_tfo *)
d = 0.5125
; e = 0.7673
; f = -0.3854
; g = -0.6538
; h = 0.6397
; i = 0.4041
; tx = -9.1161
; ty = -3.7679
; tz = -2.9968
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.5778; y = 6.6594; z = -4.0364 }
, (* C5' *)
{ x = 4.9220; y = 7.1963; z = -4.9204 }
, (* H5' *)
{ x = 3.7996; y = 5.9091; z = -4.1764 }
, (* H5'' *)
{ x = 5.7873; y = 5.8869; z = -3.5482 }
, (* C4' *)
{ x = 6.0405; y = 5.0875; z = -4.2446 }
, (* H4' *)
{ x = 6.9135; y = 6.8036; z = -3.4310 }
, (* O4' *)
{ x = 7.7293; y = 6.4084; z = -2.3392 }
, (* C1' *)
{ x = 8.7078; y = 6.1815; z = -2.7624 }
, (* H1' *)
{ x = 7.1305; y = 5.1418; z = -1.7347 }
, (* C2' *)
{ x = 7.2040; y = 5.1982; z = -0.6486 }
, (* H2'' *)
{ x = 7.7417; y = 4.0392; z = -2.3813 }
, (* O2' *)
{ x = 8.6785; y = 4.1443; z = -2.5630 }
, (* H2' *)
{ x = 5.6666; y = 5.2728; z = -2.1536 }
, (* C3' *)
{ x = 5.1747; y = 5.9805; z = -1.4863 }
, (* H3' *)
{ x = 4.9997; y = 4.0086; z = -2.1973 }
, (* O3' *)
{ x = 10.3245; y = 8.5459; z = 1.5467 }
, (* N1 *)
{ x = 9.8051; y = 6.9432; z = -0.1497 }
, (* N3 *)
{ x = 10.5175; y = 7.4328; z = 0.8408 }
, (* C2 *)
{ x = 8.7523; y = 7.7422; z = -0.4228 }
, (* C4 *)
{ x = 8.4257; y = 8.9060; z = 0.2099 }
, (* C5 *)
{ x = 9.2665; y = 9.3242; z = 1.2540 }
, (* C6 *)
G
( { x = 11.6077; y = 6.7966; z = 1.2752 }
, (* N2 *)
{ x = 7.2750; y = 9.4537; z = -0.3428 }
, (* N7 *)
{ x = 7.7962; y = 7.5519; z = -1.3859 }
, (* N9 *)
{ x = 6.9479; y = 8.6157; z = -1.2771 }
, (* C8 *)
{ x = 9.0664; y = 10.4462; z = 1.9610 }
, (* O6 *)
{ x = 10.9838; y = 8.7524; z = 2.2697 }
, (* H1 *)
{ x = 12.2274; y = 7.0896; z = 2.0170 }
, (* H21 *)
{ x = 11.8502; y = 5.9398; z = 0.7984 }
, (* H22 *)
{ x = 6.0430; y = 8.9853; z = -1.7594 } ) )
(* H8 *)
let rG03 =
N
( { a = -0.5021
; b = 0.0731
; c = 0.8617
; (* dgf_base_tfo *)
d = -0.8112
; e = 0.3054
; f = -0.4986
; g = -0.2996
; h = -0.9494
; i = -0.0940
; tx = 6.4273
; ty = -5.1944
; tz = -3.7807
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.1214; y = 6.7116; z = -1.9049 }
, (* C5' *)
{ x = 3.3465; y = 5.9610; z = -2.0607 }
, (* H5' *)
{ x = 4.0789; y = 7.2928; z = -0.9837 }
, (* H5'' *)
{ x = 5.4170; y = 5.9293; z = -1.8186 }
, (* C4' *)
{ x = 5.4506; y = 5.3400; z = -0.9023 }
, (* H4' *)
{ x = 5.5067; y = 5.0417; z = -2.9703 }
, (* O4' *)
{ x = 6.8650; y = 4.9152; z = -3.3612 }
, (* C1' *)
{ x = 7.1090; y = 3.8577; z = -3.2603 }
, (* H1' *)
{ x = 7.7152; y = 5.7282; z = -2.3894 }
, (* C2' *)
{ x = 8.5029; y = 6.2356; z = -2.9463 }
, (* H2'' *)
{ x = 8.1036; y = 4.8568; z = -1.3419 }
, (* O2' *)
{ x = 8.3270; y = 3.9651; z = -1.6184 }
, (* H2' *)
{ x = 6.7003; y = 6.7565; z = -1.8911 }
, (* C3' *)
{ x = 6.5898; y = 7.5329; z = -2.6482 }
, (* H3' *)
{ x = 7.0505; y = 7.2878; z = -0.6105 }
, (* O3' *)
{ x = 9.6740; y = 4.7656; z = -7.6614 }
, (* N1 *)
{ x = 9.0739; y = 4.3013; z = -5.3941 }
, (* N3 *)
{ x = 9.8416; y = 4.2192; z = -6.4581 }
, (* C2 *)
{ x = 7.9885; y = 5.0632; z = -5.6446 }
, (* C4 *)
{ x = 7.6822; y = 5.6856; z = -6.8194 }
, (* C5 *)
{ x = 8.5831; y = 5.5215; z = -7.8840 }
, (* C6 *)
G
( { x = 10.9733; y = 3.5117; z = -6.4286 }
, (* N2 *)
{ x = 6.4857; y = 6.3816; z = -6.7035 }
, (* N7 *)
{ x = 6.9740; y = 5.3703; z = -4.7760 }
, (* N9 *)
{ x = 6.1133; y = 6.1613; z = -5.4808 }
, (* C8 *)
{ x = 8.4084; y = 6.0747; z = -9.0933 }
, (* O6 *)
{ x = 10.3759; y = 4.5855; z = -8.3504 }
, (* H1 *)
{ x = 11.6254; y = 3.3761; z = -7.1879 }
, (* H21 *)
{ x = 11.1917; y = 3.0460; z = -5.5593 }
, (* H22 *)
{ x = 5.1705; y = 6.6830; z = -5.3167 } ) )
(* H8 *)
let rG04 =
N
( { a = -0.5426
; b = -0.8175
; c = 0.1929
; (* dgf_base_tfo *)
d = 0.8304
; e = -0.5567
; f = -0.0237
; g = 0.1267
; h = 0.1473
; i = 0.9809
; tx = -0.5075
; ty = 8.3929
; tz = 0.2229
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 5.4352; y = 8.2183; z = -2.7757 }
, (* C5' *)
{ x = 5.3830; y = 8.7883; z = -1.8481 }
, (* H5' *)
{ x = 5.7729; y = 8.7436; z = -3.6691 }
, (* H5'' *)
{ x = 6.4830; y = 7.1518; z = -2.5252 }
, (* C4' *)
{ x = 7.4749; y = 7.5972; z = -2.4482 }
, (* H4' *)
{ x = 6.1626; y = 6.4620; z = -1.2827 }
, (* O4' *)
{ x = 6.5431; y = 5.0992; z = -1.3905 }
, (* C1' *)
{ x = 7.2871; y = 4.9328; z = -0.6114 }
, (* H1' *)
{ x = 7.1852; y = 4.8935; z = -2.7592 }
, (* C2' *)
{ x = 6.8573; y = 3.9363; z = -3.1645 }
, (* H2'' *)
{ x = 8.5780; y = 5.1025; z = -2.6046 }
, (* O2' *)
{ x = 8.9516; y = 4.7577; z = -1.7902 }
, (* H2' *)
{ x = 6.5522; y = 6.0300; z = -3.5612 }
, (* C3' *)
{ x = 5.5420; y = 5.7356; z = -3.8459 }
, (* H3' *)
{ x = 7.3487; y = 6.4089; z = -4.6867 }
, (* O3' *)
{ x = 3.6343; y = 2.6680; z = 2.0783 }
, (* N1 *)
{ x = 5.4505; y = 3.9805; z = 1.2446 }
, (* N3 *)
{ x = 4.7540; y = 3.3816; z = 2.1851 }
, (* C2 *)
{ x = 4.8805; y = 3.7951; z = 0.0354 }
, (* C4 *)
{ x = 3.7416; y = 3.0925; z = -0.2305 }
, (* C5 *)
{ x = 3.0873; y = 2.4980; z = 0.8606 }
, (* C6 *)
G
( { x = 5.1433; y = 3.4373; z = 3.4609 }
, (* N2 *)
{ x = 3.4605; y = 3.1184; z = -1.5906 }
, (* N7 *)
{ x = 5.3247; y = 4.2695; z = -1.1710 }
, (* N9 *)
{ x = 4.4244; y = 3.8244; z = -2.0953 }
, (* C8 *)
{ x = 1.9600; y = 1.7805; z = 0.7462 }
, (* O6 *)
{ x = 3.2489; y = 2.2879; z = 2.9191 }
, (* H1 *)
{ x = 4.6785; y = 3.0243; z = 4.2568 }
, (* H21 *)
{ x = 5.9823; y = 3.9654; z = 3.6539 }
, (* H22 *)
{ x = 4.2675; y = 3.8876; z = -3.1721 } ) )
(* H8 *)
let rG05 =
N
( { a = -0.5891
; b = 0.0449
; c = 0.8068
; (* dgf_base_tfo *)
d = 0.5375
; e = 0.7673
; f = 0.3498
; g = -0.6034
; h = 0.6397
; i = -0.4762
; tx = -0.3019
; ty = -3.7679
; tz = -9.5913
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.5778; y = 6.6594; z = -4.0364 }
, (* C5' *)
{ x = 4.9220; y = 7.1963; z = -4.9204 }
, (* H5' *)
{ x = 3.7996; y = 5.9091; z = -4.1764 }
, (* H5'' *)
{ x = 5.7873; y = 5.8869; z = -3.5482 }
, (* C4' *)
{ x = 6.0405; y = 5.0875; z = -4.2446 }
, (* H4' *)
{ x = 6.9135; y = 6.8036; z = -3.4310 }
, (* O4' *)
{ x = 7.7293; y = 6.4084; z = -2.3392 }
, (* C1' *)
{ x = 8.7078; y = 6.1815; z = -2.7624 }
, (* H1' *)
{ x = 7.1305; y = 5.1418; z = -1.7347 }
, (* C2' *)
{ x = 7.2040; y = 5.1982; z = -0.6486 }
, (* H2'' *)
{ x = 7.7417; y = 4.0392; z = -2.3813 }
, (* O2' *)
{ x = 8.6785; y = 4.1443; z = -2.5630 }
, (* H2' *)
{ x = 5.6666; y = 5.2728; z = -2.1536 }
, (* C3' *)
{ x = 5.1747; y = 5.9805; z = -1.4863 }
, (* H3' *)
{ x = 4.9997; y = 4.0086; z = -2.1973 }
, (* O3' *)
{ x = 10.2594; y = 10.6774; z = -1.0056 }
, (* N1 *)
{ x = 9.7528; y = 8.7080; z = -2.2631 }
, (* N3 *)
{ x = 10.4471; y = 9.7876; z = -1.9791 }
, (* C2 *)
{ x = 8.7271; y = 8.5575; z = -1.3991 }
, (* C4 *)
{ x = 8.4100; y = 9.3803; z = -0.3580 }
, (* C5 *)
{ x = 9.2294; y = 10.5030; z = -0.1574 }
, (* C6 *)
G
( { x = 11.5110; y = 10.1256; z = -2.7114 }
, (* N2 *)
{ x = 7.2891; y = 8.9068; z = 0.3121 }
, (* N7 *)
{ x = 7.7962; y = 7.5519; z = -1.3859 }
, (* N9 *)
{ x = 6.9702; y = 7.8292; z = -0.3353 }
, (* C8 *)
{ x = 9.0349; y = 11.3951; z = 0.8250 }
, (* O6 *)
{ x = 10.9013; y = 11.4422; z = -0.9512 }
, (* H1 *)
{ x = 12.1031; y = 10.9341; z = -2.5861 }
, (* H21 *)
{ x = 11.7369; y = 9.5180; z = -3.4859 }
, (* H22 *)
{ x = 6.0888; y = 7.3990; z = 0.1403 } ) )
(* H8 *)
let rG06 =
N
( { a = -0.9815
; b = 0.0731
; c = -0.1772
; (* dgf_base_tfo *)
d = 0.1912
; e = 0.3054
; f = -0.9328
; g = -0.0141
; h = -0.9494
; i = -0.3137
; tx = 5.7506
; ty = -5.1944
; tz = 4.7470
}
, { a = -0.8143
; b = -0.5091
; c = -0.2788
; (* P_O3'_275_tfo *)
d = -0.0433
; e = -0.4257
; f = 0.9038
; g = -0.5788
; h = 0.7480
; i = 0.3246
; tx = 1.5227
; ty = 6.9114
; tz = -7.0765
}
, { a = 0.3822
; b = -0.7477
; c = 0.5430
; (* P_O3'_180_tfo *)
d = 0.4552
; e = 0.6637
; f = 0.5935
; g = -0.8042
; h = 0.0203
; i = 0.5941
; tx = -6.9472
; ty = -4.1186
; tz = -5.9108
}
, { a = 0.5640
; b = 0.8007
; c = -0.2022
; (* P_O3'_60_tfo *)
d = -0.8247
; e = 0.5587
; f = -0.0878
; g = 0.0426
; h = 0.2162
; i = 0.9754
; tx = 6.2694
; ty = -7.0540
; tz = 3.3316
}
, { x = 2.8930; y = 8.5380; z = -3.3280 }
, (* P *)
{ x = 1.6980; y = 7.6960; z = -3.5570 }
, (* O1P *)
{ x = 3.2260; y = 9.5010; z = -4.4020 }
, (* O2P *)
{ x = 4.1590; y = 7.6040; z = -3.0340 }
, (* O5' *)
{ x = 4.1214; y = 6.7116; z = -1.9049 }
, (* C5' *)
{ x = 3.3465; y = 5.9610; z = -2.0607 }
, (* H5' *)
{ x = 4.0789; y = 7.2928; z = -0.9837 }
, (* H5'' *)
{ x = 5.4170; y = 5.9293; z = -1.8186 }
, (* C4' *)
{ x = 5.4506; y = 5.3400; z = -0.9023 }
, (* H4' *)
{ x = 5.5067; y = 5.0417; z = -2.9703 }
, (* O4' *)
{ x = 6.8650; y = 4.9152; z = -3.3612 }
, (* C1' *)
{ x = 7.1090; y = 3.8577; z = -3.2603 }
, (* H1' *)
{ x = 7.7152; y = 5.7282; z = -2.3894 }
, (* C2' *)
{ x = 8.5029; y = 6.2356; z = -2.9463 }
, (* H2'' *)
{ x = 8.1036; y = 4.8568; z = -1.3419 }
, (* O2' *)
{ x = 8.3270; y = 3.9651; z = -1.6184 }
, (* H2' *)
{ x = 6.7003; y = 6.7565; z = -1.8911 }
, (* C3' *)
{ x = 6.5898; y = 7.5329; z = -2.6482 }
, (* H3' *)
{ x = 7.0505; y = 7.2878; z = -0.6105 }
, (* O3' *)
{ x = 6.6624; y = 3.5061; z = -8.2986 }
, (* N1 *)
{ x = 6.5810; y = 3.2570; z = -5.9221 }
, (* N3 *)
{ x = 6.5151; y = 2.8263; z = -7.1625 }
, (* C2 *)
{ x = 6.8364; y = 4.5817; z = -5.8882 }
, (* C4 *)
{ x = 7.0116; y = 5.4064; z = -6.9609 }
, (* C5 *)
{ x = 6.9173; y = 4.8260; z = -8.2361 }
, (* C6 *)
G
( { x = 6.2717; y = 1.5402; z = -7.4250 }
, (* N2 *)
{ x = 7.2573; y = 6.7070; z = -6.5394 }
, (* N7 *)
{ x = 6.9740; y = 5.3703; z = -4.7760 }
, (* N9 *)
{ x = 7.2238; y = 6.6275; z = -5.2453 }
, (* C8 *)
{ x = 7.0668; y = 5.5163; z = -9.3763 }
, (* O6 *)
{ x = 6.5754; y = 2.9964; z = -9.1545 }
, (* H1 *)
{ x = 6.1908; y = 1.1105; z = -8.3354 }
, (* H21 *)
{ x = 6.1346; y = 0.9352; z = -6.6280 }
, (* H22 *)
{ x = 7.4108; y = 7.6227; z = -4.8418 } ) )
(* H8 *)
let rG07 =
N
( { a = 0.0894
; b = -0.6059
; c = 0.7905
; (* dgf_base_tfo *)
d = -0.6810
; e = 0.5420
; f = 0.4924
; g = -0.7268
; h = -0.5824
; i = -0.3642
; tx = 34.1424
; ty = 45.9610
; tz = -11.8600
}
, { a = -0.8644
; b = -0.4956
; c = -0.0851
; (* P_O3'_275_tfo *)
d = -0.0427
; e = 0.2409
; f = -0.9696
; g = 0.5010
; h = -0.8345
; i = -0.2294
; tx = 4.0167
; ty = 54.5377
; tz = 12.4779
}
, { a = 0.3706
; b = -0.6167
; c = 0.6945
; (* P_O3'_180_tfo *)
d = -0.2867
; e = -0.7872
; f = -0.5460
; g = 0.8834
; h = 0.0032
; i = -0.4686
; tx = -52.9020
; ty = 18.6313
; tz = -0.6709
}
, { a = 0.4155
; b = 0.9025
; c = -0.1137
; (* P_O3'_60_tfo *)
d = 0.9040
; e = -0.4236
; f = -0.0582
; g = -0.1007
; h = -0.0786
; i = -0.9918
; tx = -7.6624
; ty = -25.2080
; tz = 49.5181
}
, { x = 31.3810; y = 0.1400; z = 47.5810 }
, (* P *)
{ x = 29.9860; y = 0.6630; z = 47.6290 }
, (* O1P *)
{ x = 31.7210; y = -0.6460; z = 48.8090 }
, (* O2P *)
{ x = 32.4940; y = 1.2540; z = 47.2740 }
, (* O5' *)
{ x = 33.8709; y = 0.7918; z = 47.2113 }
, (* C5' *)
{ x = 34.1386; y = 0.5870; z = 46.1747 }
, (* H5' *)
{ x = 34.0186; y = -0.0095; z = 47.9353 }
, (* H5'' *)
{ x = 34.7297; y = 1.9687; z = 47.6685 }
, (* C4' *)
{ x = 35.7723; y = 1.6845; z = 47.8113 }
, (* H4' *)
{ x = 34.6455; y = 2.9768; z = 46.6660 }
, (* O4' *)
{ x = 34.1690; y = 4.1829; z = 47.2627 }
, (* C1' *)
{ x = 35.0437; y = 4.7633; z = 47.5560 }
, (* H1' *)
{ x = 33.4145; y = 3.7532; z = 48.4954 }
, (* C2' *)
{ x = 32.4340; y = 3.3797; z = 48.2001 }
, (* H2'' *)
{ x = 33.3209; y = 4.6953; z = 49.5217 }
, (* O2' *)
{ x = 33.2374; y = 5.6059; z = 49.2295 }
, (* H2' *)
{ x = 34.2724; y = 2.5970; z = 48.9773 }
, (* C3' *)
{ x = 33.6373; y = 1.8935; z = 49.5157 }
, (* H3' *)
{ x = 35.3453; y = 3.1884; z = 49.7285 }
, (* O3' *)
{ x = 34.0511; y = 7.8930; z = 43.7791 }
, (* N1 *)
{ x = 34.9937; y = 6.3369; z = 45.3199 }
, (* N3 *)
{ x = 35.0882; y = 7.3126; z = 44.4200 }
, (* C2 *)
{ x = 33.7190; y = 5.9650; z = 45.5374 }
, (* C4 *)
{ x = 32.5845; y = 6.4770; z = 44.9458 }
, (* C5 *)
{ x = 32.7430; y = 7.5179; z = 43.9914 }
, (* C6 *)
G
( { x = 36.3030; y = 7.7827; z = 44.1036 }
, (* N2 *)
{ x = 31.4499; y = 5.8335; z = 45.4368 }
, (* N7 *)
{ x = 33.2760; y = 4.9817; z = 46.4043 }
, (* N9 *)
{ x = 31.9235; y = 4.9639; z = 46.2934 }
, (* C8 *)
{ x = 31.8602; y = 8.1000; z = 43.3695 }
, (* O6 *)
{ x = 34.2623; y = 8.6223; z = 43.1283 }
, (* H1 *)
{ x = 36.5188; y = 8.5081; z = 43.4347 }
, (* H21 *)
{ x = 37.0888; y = 7.3524; z = 44.5699 }
, (* H22 *)
{ x = 31.0815; y = 4.4201; z = 46.7218 } ) )
(* H8 *)
let rG08 =
N
( { a = 0.2224
; b = 0.6335
; c = 0.7411
; (* dgf_base_tfo *)
d = -0.3644
; e = -0.6510
; f = 0.6659
; g = 0.9043
; h = -0.4181
; i = 0.0861
; tx = -47.6824
; ty = -0.5823
; tz = -31.7554
}
, { a = -0.8644
; b = -0.4956
; c = -0.0851
; (* P_O3'_275_tfo *)
d = -0.0427
; e = 0.2409
; f = -0.9696
; g = 0.5010
; h = -0.8345
; i = -0.2294
; tx = 4.0167
; ty = 54.5377
; tz = 12.4779
}
, { a = 0.3706
; b = -0.6167
; c = 0.6945
; (* P_O3'_180_tfo *)
d = -0.2867
; e = -0.7872
; f = -0.5460
; g = 0.8834
; h = 0.0032
; i = -0.4686
; tx = -52.9020
; ty = 18.6313
; tz = -0.6709
}
, { a = 0.4155
; b = 0.9025
; c = -0.1137
; (* P_O3'_60_tfo *)
d = 0.9040
; e = -0.4236
; f = -0.0582
; g = -0.1007
; h = -0.0786
; i = -0.9918
; tx = -7.6624
; ty = -25.2080
; tz = 49.5181
}
, { x = 31.3810; y = 0.1400; z = 47.5810 }
, (* P *)
{ x = 29.9860; y = 0.6630; z = 47.6290 }
, (* O1P *)
{ x = 31.7210; y = -0.6460; z = 48.8090 }
, (* O2P *)
{ x = 32.4940; y = 1.2540; z = 47.2740 }
, (* O5' *)
{ x = 32.5924; y = 2.3488; z = 48.2255 }
, (* C5' *)
{ x = 33.3674; y = 2.1246; z = 48.9584 }
, (* H5' *)
{ x = 31.5994; y = 2.5917; z = 48.6037 }
, (* H5'' *)
{ x = 33.0722; y = 3.5577; z = 47.4258 }
, (* C4' *)
{ x = 33.0310; y = 4.4778; z = 48.0089 }
, (* H4' *)
{ x = 34.4173; y = 3.3055; z = 47.0316 }
, (* O4' *)
{ x = 34.5056; y = 3.3910; z = 45.6094 }
, (* C1' *)
{ x = 34.7881; y = 4.4152; z = 45.3663 }
, (* H1' *)
{ x = 33.1122; y = 3.1198; z = 45.1010 }
, (* C2' *)
{ x = 32.9230; y = 2.0469; z = 45.1369 }
, (* H2'' *)
{ x = 32.7946; y = 3.6590; z = 43.8529 }
, (* O2' *)
{ x = 33.5170; y = 3.6707; z = 43.2207 }
, (* H2' *)
{ x = 32.2730; y = 3.8173; z = 46.1566 }
, (* C3' *)
{ x = 31.3094; y = 3.3123; z = 46.2244 }
, (* H3' *)
{ x = 32.2391; y = 5.2039; z = 45.7807 }
, (* O3' *)
{ x = 39.3337; y = 2.7157; z = 44.1441 }
, (* N1 *)
{ x = 37.4430; y = 3.8242; z = 45.0824 }
, (* N3 *)
{ x = 38.7276; y = 3.7646; z = 44.7403 }
, (* C2 *)
{ x = 36.7791; y = 2.6963; z = 44.7704 }
, (* C4 *)
{ x = 37.2860; y = 1.5653; z = 44.1678 }
, (* C5 *)
{ x = 38.6647; y = 1.5552; z = 43.8235 }
, (* C6 *)
G
( { x = 39.5123; y = 4.8216; z = 44.9936 }
, (* N2 *)
{ x = 36.2829; y = 0.6110; z = 44.0078 }
, (* N7 *)
{ x = 35.4394; y = 2.4314; z = 44.9931 }
, (* N9 *)
{ x = 35.2180; y = 1.1815; z = 44.5128 }
, (* C8 *)
{ x = 39.2907; y = 0.6514; z = 43.2796 }
, (* O6 *)
{ x = 40.3076; y = 2.8048; z = 43.9352 }
, (* H1 *)
{ x = 40.4994; y = 4.9066; z = 44.7977 }
, (* H21 *)
{ x = 39.0738; y = 5.6108; z = 45.4464 }
, (* H22 *)
{ x = 34.3856; y = 0.4842; z = 44.4185 } ) )
(* H8 *)
let rG09 =
N
( { a = -0.9699
; b = -0.1688
; c = -0.1753
; (* dgf_base_tfo *)
d = -0.1050
; e = -0.3598
; f = 0.9271
; g = -0.2196
; h = 0.9176
; i = 0.3312
; tx = 45.6217
; ty = -38.9484
; tz = -12.3208
}
, { a = -0.8644
; b = -0.4956
; c = -0.0851
; (* P_O3'_275_tfo *)
d = -0.0427
; e = 0.2409
; f = -0.9696
; g = 0.5010
; h = -0.8345
; i = -0.2294
; tx = 4.0167
; ty = 54.5377
; tz = 12.4779
}
, { a = 0.3706
; b = -0.6167
; c = 0.6945
; (* P_O3'_180_tfo *)
d = -0.2867
; e = -0.7872
; f = -0.5460
; g = 0.8834
; h = 0.0032
; i = -0.4686
; tx = -52.9020
; ty = 18.6313
; tz = -0.6709
}
, { a = 0.4155
; b = 0.9025
; c = -0.1137
; (* P_O3'_60_tfo *)
d = 0.9040
; e = -0.4236
; f = -0.0582
; g = -0.1007
; h = -0.0786
; i = -0.9918
; tx = -7.6624
; ty = -25.2080
; tz = 49.5181
}
, { x = 31.3810; y = 0.1400; z = 47.5810 }
, (* P *)
{ x = 29.9860; y = 0.6630; z = 47.6290 }
, (* O1P *)
{ x = 31.7210; y = -0.6460; z = 48.8090 }
, (* O2P *)
{ x = 32.4940; y = 1.2540; z = 47.2740 }
, (* O5' *)
{ x = 33.8709; y = 0.7918; z = 47.2113 }
, (* C5' *)
{ x = 34.1386; y = 0.5870; z = 46.1747 }
, (* H5' *)
{ x = 34.0186; y = -0.0095; z = 47.9353 }
, (* H5'' *)
{ x = 34.7297; y = 1.9687; z = 47.6685 }
, (* C4' *)
{ x = 34.5880; y = 2.8482; z = 47.0404 }
, (* H4' *)
{ x = 34.3575; y = 2.2770; z = 49.0081 }
, (* O4' *)
{ x = 35.5157; y = 2.1993; z = 49.8389 }
, (* C1' *)
{ x = 35.9424; y = 3.2010; z = 49.8893 }
, (* H1' *)
{ x = 36.4701; y = 1.2820; z = 49.1169 }
, (* C2' *)
{ x = 36.1545; y = 0.2498; z = 49.2683 }
, (* H2'' *)
{ x = 37.8262; y = 1.4547; z = 49.4008 }
, (* O2' *)
{ x = 38.0227; y = 1.6945; z = 50.3094 }
, (* H2' *)
{ x = 36.2242; y = 1.6797; z = 47.6725 }
, (* C3' *)
{ x = 36.4297; y = 0.8197; z = 47.0351 }
, (* H3' *)
{ x = 37.0289; y = 2.8480; z = 47.4426 }
, (* O3' *)
{ x = 34.3005; y = 3.5042; z = 54.6070 }
, (* N1 *)
{ x = 34.7693; y = 3.7936; z = 52.2874 }
, (* N3 *)
{ x = 34.4484; y = 4.2541; z = 53.4939 }
, (* C2 *)
{ x = 34.9354; y = 2.4584; z = 52.2785 }
, (* C4 *)
{ x = 34.8092; y = 1.5915; z = 53.3422 }
, (* C5 *)
{ x = 34.4646; y = 2.1367; z = 54.6085 }
, (* C6 *)
G
( { x = 34.2514; y = 5.5708; z = 53.6503 }
, (* N2 *)
{ x = 35.0641; y = 0.2835; z = 52.9337 }
, (* N7 *)
{ x = 35.2669; y = 1.6690; z = 51.1915 }
, (* N9 *)
{ x = 35.3288; y = 0.3954; z = 51.6563 }
, (* C8 *)
{ x = 34.3151; y = 1.5317; z = 55.6650 }
, (* O6 *)
{ x = 34.0623; y = 3.9797; z = 55.4539 }
, (* H1 *)
{ x = 33.9950; y = 6.0502; z = 54.5016 }
, (* H21 *)
{ x = 34.3512; y = 6.1432; z = 52.8242 }
, (* H22 *)
{ x = 35.5414; y = -0.6006; z = 51.2679 } ) )
(* H8 *)
let rG10 =
N
( { a = -0.0980
; b = -0.9723
; c = 0.2122
; (* dgf_base_tfo *)
d = -0.9731
; e = 0.1383
; f = 0.1841
; g = -0.2083
; h = -0.1885
; i = -0.9597
; tx = 17.8469
; ty = 38.8265
; tz = 37.0475
}
, { a = -0.8644
; b = -0.4956
; c = -0.0851
; (* P_O3'_275_tfo *)
d = -0.0427
; e = 0.2409
; f = -0.9696
; g = 0.5010
; h = -0.8345
; i = -0.2294
; tx = 4.0167
; ty = 54.5377
; tz = 12.4779
}
, { a = 0.3706
; b = -0.6167
; c = 0.6945
; (* P_O3'_180_tfo *)
d = -0.2867
; e = -0.7872
; f = -0.5460
; g = 0.8834
; h = 0.0032
; i = -0.4686
; tx = -52.9020
; ty = 18.6313
; tz = -0.6709
}
, { a = 0.4155
; b = 0.9025
; c = -0.1137
; (* P_O3'_60_tfo *)
d = 0.9040
; e = -0.4236
; f = -0.0582
; g = -0.1007
; h = -0.0786
; i = -0.9918
; tx = -7.6624
; ty = -25.2080
; tz = 49.5181
}
, { x = 31.3810; y = 0.1400; z = 47.5810 }
, (* P *)
{ x = 29.9860; y = 0.6630; z = 47.6290 }
, (* O1P *)
{ x = 31.7210; y = -0.6460; z = 48.8090 }
, (* O2P *)
{ x = 32.4940; y = 1.2540; z = 47.2740 }
, (* O5' *)
{ x = 32.5924; y = 2.3488; z = 48.2255 }
, (* C5' *)
{ x = 33.3674; y = 2.1246; z = 48.9584 }
, (* H5' *)
{ x = 31.5994; y = 2.5917; z = 48.6037 }
, (* H5'' *)
{ x = 33.0722; y = 3.5577; z = 47.4258 }
, (* C4' *)
{ x = 34.0333; y = 3.3761; z = 46.9447 }
, (* H4' *)
{ x = 32.0890; y = 3.8338; z = 46.4332 }
, (* O4' *)
{ x = 31.6377; y = 5.1787; z = 46.5914 }
, (* C1' *)
{ x = 32.2499; y = 5.8016; z = 45.9392 }
, (* H1' *)
{ x = 31.9167; y = 5.5319; z = 48.0305 }
, (* C2' *)
{ x = 31.1507; y = 5.0820; z = 48.6621 }
, (* H2'' *)
{ x = 32.0865; y = 6.8890; z = 48.3114 }
, (* O2' *)
{ x = 31.5363; y = 7.4819; z = 47.7942 }
, (* H2' *)
{ x = 33.2398; y = 4.8224; z = 48.2563 }
, (* C3' *)
{ x = 33.3166; y = 4.5570; z = 49.3108 }
, (* H3' *)
{ x = 34.2528; y = 5.7056; z = 47.7476 }
, (* O3' *)
{ x = 28.2782; y = 6.3049; z = 42.9364 }
, (* N1 *)
{ x = 30.4001; y = 5.8547; z = 43.9258 }
, (* N3 *)
{ x = 29.6195; y = 6.1568; z = 42.8913 }
, (* C2 *)
{ x = 29.7005; y = 5.7006; z = 45.0649 }
, (* C4 *)
{ x = 28.3383; y = 5.8221; z = 45.2343 }
, (* C5 *)
{ x = 27.5519; y = 6.1461; z = 44.0958 }
, (* C6 *)
G
( { x = 30.1838; y = 6.3385; z = 41.6890 }
, (* N2 *)
{ x = 27.9936; y = 5.5926; z = 46.5651 }
, (* N7 *)
{ x = 30.2046; y = 5.3825; z = 46.3136 }
, (* N9 *)
{ x = 29.1371; y = 5.3398; z = 47.1506 }
, (* C8 *)
{ x = 26.3361; y = 6.3024; z = 44.0495 }
, (* O6 *)
{ x = 27.8122; y = 6.5394; z = 42.0833 }
, (* H1 *)
{ x = 29.7125; y = 6.5595; z = 40.8235 }
, (* H21 *)
{ x = 31.1859; y = 6.2231; z = 41.6389 }
, (* H22 *)
{ x = 28.9406; y = 5.1504; z = 48.2059 } ) )
(* H8 *)
let rGs = [ rG01; rG02; rG03; rG04; rG05; rG06; rG07; rG08; rG09; rG10 ]
let rU =
N
( { a = -0.0359
; b = -0.8071
; c = 0.5894
; (* dgf_base_tfo *)
d = -0.2669
; e = 0.5761
; f = 0.7726
; g = -0.9631
; h = -0.1296
; i = -0.2361
; tx = 0.1584
; ty = 8.3434
; tz = 0.5434
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 5.2430; y = -8.2420; z = 2.8260 }
, (* C5' *)
{ x = 5.1974; y = -8.8497; z = 1.9223 }
, (* H5' *)
{ x = 5.5548; y = -8.7348; z = 3.7469 }
, (* H5'' *)
{ x = 6.3140; y = -7.2060; z = 2.5510 }
, (* C4' *)
{ x = 7.2954; y = -7.6762; z = 2.4898 }
, (* H4' *)
{ x = 6.0140; y = -6.5420; z = 1.2890 }
, (* O4' *)
{ x = 6.4190; y = -5.1840; z = 1.3620 }
, (* C1' *)
{ x = 7.1608; y = -5.0495; z = 0.5747 }
, (* H1' *)
{ x = 7.0760; y = -4.9560; z = 2.7270 }
, (* C2' *)
{ x = 6.7770; y = -3.9803; z = 3.1099 }
, (* H2'' *)
{ x = 8.4500; y = -5.1930; z = 2.5810 }
, (* O2' *)
{ x = 8.8309; y = -4.8755; z = 1.7590 }
, (* H2' *)
{ x = 6.4060; y = -6.0590; z = 3.5580 }
, (* C3' *)
{ x = 5.4021; y = -5.7313; z = 3.8281 }
, (* H3' *)
{ x = 7.1570; y = -6.4240; z = 4.7070 }
, (* O3' *)
{ x = 5.2170; y = -4.3260; z = 1.1690 }
, (* N1 *)
{ x = 4.2960; y = -2.2560; z = 0.6290 }
, (* N3 *)
{ x = 5.4330; y = -3.0200; z = 0.7990 }
, (* C2 *)
{ x = 2.9930; y = -2.6780; z = 0.7940 }
, (* C4 *)
{ x = 2.8670; y = -4.0630; z = 1.1830 }
, (* C5 *)
{ x = 3.9570; y = -4.8300; z = 1.3550 }
, (* C6 *)
U
( { x = 6.5470; y = -2.5560; z = 0.6290 }
, (* O2 *)
{ x = 2.0540; y = -1.9000; z = 0.6130 }
, (* O4 *)
{ x = 4.4300; y = -1.3020; z = 0.3600 }
, (* H3 *)
{ x = 1.9590; y = -4.4570; z = 1.3250 }
, (* H5 *)
{ x = 3.8460; y = -5.7860; z = 1.6240 } ) )
(* H6 *)
let rU01 =
N
( { a = -0.0137
; b = -0.8012
; c = 0.5983
; (* dgf_base_tfo *)
d = -0.2523
; e = 0.5817
; f = 0.7733
; g = -0.9675
; h = -0.1404
; i = -0.2101
; tx = 0.2031
; ty = 8.3874
; tz = 0.4228
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 5.2416; y = -8.2422; z = 2.8181 }
, (* C5' *)
{ x = 5.2050; y = -8.8128; z = 1.8901 }
, (* H5' *)
{ x = 5.5368; y = -8.7738; z = 3.7227 }
, (* H5'' *)
{ x = 6.3232; y = -7.2037; z = 2.6002 }
, (* C4' *)
{ x = 7.3048; y = -7.6757; z = 2.5577 }
, (* H4' *)
{ x = 6.0635; y = -6.5092; z = 1.3456 }
, (* O4' *)
{ x = 6.4697; y = -5.1547; z = 1.4629 }
, (* C1' *)
{ x = 7.2354; y = -5.0043; z = 0.7018 }
, (* H1' *)
{ x = 7.0856; y = -4.9610; z = 2.8521 }
, (* C2' *)
{ x = 6.7777; y = -3.9935; z = 3.2487 }
, (* H2'' *)
{ x = 8.4627; y = -5.1992; z = 2.7423 }
, (* O2' *)
{ x = 8.8693; y = -4.8638; z = 1.9399 }
, (* H2' *)
{ x = 6.3877; y = -6.0809; z = 3.6362 }
, (* C3' *)
{ x = 5.3770; y = -5.7562; z = 3.8834 }
, (* H3' *)
{ x = 7.1024; y = -6.4754; z = 4.7985 }
, (* O3' *)
{ x = 5.2764; y = -4.2883; z = 1.2538 }
, (* N1 *)
{ x = 4.3777; y = -2.2062; z = 0.7229 }
, (* N3 *)
{ x = 5.5069; y = -2.9779; z = 0.9088 }
, (* C2 *)
{ x = 3.0693; y = -2.6246; z = 0.8500 }
, (* C4 *)
{ x = 2.9279; y = -4.0146; z = 1.2149 }
, (* C5 *)
{ x = 4.0101; y = -4.7892; z = 1.4017 }
, (* C6 *)
U
( { x = 6.6267; y = -2.5166; z = 0.7728 }
, (* O2 *)
{ x = 2.1383; y = -1.8396; z = 0.6581 }
, (* O4 *)
{ x = 4.5223; y = -1.2489; z = 0.4716 }
, (* H3 *)
{ x = 2.0151; y = -4.4065; z = 1.3290 }
, (* H5 *)
{ x = 3.8886; y = -5.7486; z = 1.6535 } ) )
(* H6 *)
let rU02 =
N
( { a = 0.5141
; b = 0.0246
; c = 0.8574
; (* dgf_base_tfo *)
d = -0.5547
; e = -0.7529
; f = 0.3542
; g = 0.6542
; h = -0.6577
; i = -0.3734
; tx = -9.1111
; ty = -3.4598
; tz = -3.2939
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 4.3825; y = -6.6585; z = 4.0489 }
, (* C5' *)
{ x = 4.6841; y = -7.2019; z = 4.9443 }
, (* H5' *)
{ x = 3.6189; y = -5.8889; z = 4.1625 }
, (* H5'' *)
{ x = 5.6255; y = -5.9175; z = 3.5998 }
, (* C4' *)
{ x = 5.8732; y = -5.1228; z = 4.3034 }
, (* H4' *)
{ x = 6.7337; y = -6.8605; z = 3.5222 }
, (* O4' *)
{ x = 7.5932; y = -6.4923; z = 2.4548 }
, (* C1' *)
{ x = 8.5661; y = -6.2983; z = 2.9064 }
, (* H1' *)
{ x = 7.0527; y = -5.2012; z = 1.8322 }
, (* C2' *)
{ x = 7.1627; y = -5.2525; z = 0.7490 }
, (* H2'' *)
{ x = 7.6666; y = -4.1249; z = 2.4880 }
, (* O2' *)
{ x = 8.5944; y = -4.2543; z = 2.6981 }
, (* H2' *)
{ x = 5.5661; y = -5.3029; z = 2.2009 }
, (* C3' *)
{ x = 5.0841; y = -6.0018; z = 1.5172 }
, (* H3' *)
{ x = 4.9062; y = -4.0452; z = 2.2042 }
, (* O3' *)
{ x = 7.6298; y = -7.6136; z = 1.4752 }
, (* N1 *)
{ x = 8.6945; y = -8.7046; z = -0.2857 }
, (* N3 *)
{ x = 8.6943; y = -7.6514; z = 0.6066 }
, (* C2 *)
{ x = 7.7426; y = -9.6987; z = -0.3801 }
, (* C4 *)
{ x = 6.6642; y = -9.5742; z = 0.5722 }
, (* C5 *)
{ x = 6.6391; y = -8.5592; z = 1.4526 }
, (* C6 *)
U
( { x = 9.5840; y = -6.8186; z = 0.6136 }
, (* O2 *)
{ x = 7.8505; y = -10.5925; z = -1.2223 }
, (* O4 *)
{ x = 9.4601; y = -8.7514; z = -0.9277 }
, (* H3 *)
{ x = 5.9281; y = -10.2509; z = 0.5782 }
, (* H5 *)
{ x = 5.8831; y = -8.4931; z = 2.1028 } ) )
(* H6 *)
let rU03 =
N
( { a = -0.4993
; b = 0.0476
; c = 0.8651
; (* dgf_base_tfo *)
d = 0.8078
; e = -0.3353
; f = 0.4847
; g = 0.3132
; h = 0.9409
; i = 0.1290
; tx = 6.2989
; ty = -5.2303
; tz = -3.8577
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 3.9938; y = -6.7042; z = 1.9023 }
, (* C5' *)
{ x = 3.2332; y = -5.9343; z = 2.0319 }
, (* H5' *)
{ x = 3.9666; y = -7.2863; z = 0.9812 }
, (* H5'' *)
{ x = 5.3098; y = -5.9546; z = 1.8564 }
, (* C4' *)
{ x = 5.3863; y = -5.3702; z = 0.9395 }
, (* H4' *)
{ x = 5.3851; y = -5.0642; z = 3.0076 }
, (* O4' *)
{ x = 6.7315; y = -4.9724; z = 3.4462 }
, (* C1' *)
{ x = 7.0033; y = -3.9202; z = 3.3619 }
, (* H1' *)
{ x = 7.5997; y = -5.8018; z = 2.4948 }
, (* C2' *)
{ x = 8.3627; y = -6.3254; z = 3.0707 }
, (* H2'' *)
{ x = 8.0410; y = -4.9501; z = 1.4724 }
, (* O2' *)
{ x = 8.2781; y = -4.0644; z = 1.7570 }
, (* H2' *)
{ x = 6.5701; y = -6.8129; z = 1.9714 }
, (* C3' *)
{ x = 6.4186; y = -7.5809; z = 2.7299 }
, (* H3' *)
{ x = 6.9357; y = -7.3841; z = 0.7235 }
, (* O3' *)
{ x = 6.8024; y = -5.4718; z = 4.8475 }
, (* N1 *)
{ x = 7.9218; y = -5.5700; z = 6.8877 }
, (* N3 *)
{ x = 7.8908; y = -5.0886; z = 5.5944 }
, (* C2 *)
{ x = 6.9789; y = -6.3827; z = 7.4823 }
, (* C4 *)
{ x = 5.8742; y = -6.7319; z = 6.6202 }
, (* C5 *)
{ x = 5.8182; y = -6.2769; z = 5.3570 }
, (* C6 *)
U
( { x = 8.7747; y = -4.3728; z = 5.1568 }
, (* O2 *)
{ x = 7.1154; y = -6.7509; z = 8.6509 }
, (* O4 *)
{ x = 8.7055; y = -5.3037; z = 7.4491 }
, (* H3 *)
{ x = 5.1416; y = -7.3178; z = 6.9665 }
, (* H5 *)
{ x = 5.0441; y = -6.5310; z = 4.7784 } ) )
(* H6 *)
let rU04 =
N
( { a = -0.5669
; b = -0.8012
; c = 0.1918
; (* dgf_base_tfo *)
d = -0.8129
; e = 0.5817
; f = 0.0273
; g = -0.1334
; h = -0.1404
; i = -0.9811
; tx = -0.3279
; ty = 8.3874
; tz = 0.3355
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 5.2416; y = -8.2422; z = 2.8181 }
, (* C5' *)
{ x = 5.2050; y = -8.8128; z = 1.8901 }
, (* H5' *)
{ x = 5.5368; y = -8.7738; z = 3.7227 }
, (* H5'' *)
{ x = 6.3232; y = -7.2037; z = 2.6002 }
, (* C4' *)
{ x = 7.3048; y = -7.6757; z = 2.5577 }
, (* H4' *)
{ x = 6.0635; y = -6.5092; z = 1.3456 }
, (* O4' *)
{ x = 6.4697; y = -5.1547; z = 1.4629 }
, (* C1' *)
{ x = 7.2354; y = -5.0043; z = 0.7018 }
, (* H1' *)
{ x = 7.0856; y = -4.9610; z = 2.8521 }
, (* C2' *)
{ x = 6.7777; y = -3.9935; z = 3.2487 }
, (* H2'' *)
{ x = 8.4627; y = -5.1992; z = 2.7423 }
, (* O2' *)
{ x = 8.8693; y = -4.8638; z = 1.9399 }
, (* H2' *)
{ x = 6.3877; y = -6.0809; z = 3.6362 }
, (* C3' *)
{ x = 5.3770; y = -5.7562; z = 3.8834 }
, (* H3' *)
{ x = 7.1024; y = -6.4754; z = 4.7985 }
, (* O3' *)
{ x = 5.2764; y = -4.2883; z = 1.2538 }
, (* N1 *)
{ x = 3.8961; y = -3.0896; z = -0.1893 }
, (* N3 *)
{ x = 5.0095; y = -3.8907; z = -0.0346 }
, (* C2 *)
{ x = 3.0480; y = -2.6632; z = 0.8116 }
, (* C4 *)
{ x = 3.4093; y = -3.1310; z = 2.1292 }
, (* C5 *)
{ x = 4.4878; y = -3.9124; z = 2.3088 }
, (* C6 *)
U
( { x = 5.7005; y = -4.2164; z = -0.9842 }
, (* O2 *)
{ x = 2.0800; y = -1.9458; z = 0.5503 }
, (* O4 *)
{ x = 3.6834; y = -2.7882; z = -1.1190 }
, (* H3 *)
{ x = 2.8508; y = -2.8721; z = 2.9172 }
, (* H5 *)
{ x = 4.7188; y = -4.2247; z = 3.2295 } ) )
(* H6 *)
let rU05 =
N
( { a = -0.6298
; b = 0.0246
; c = 0.7763
; (* dgf_base_tfo *)
d = -0.5226
; e = -0.7529
; f = -0.4001
; g = 0.5746
; h = -0.6577
; i = 0.4870
; tx = -0.0208
; ty = -3.4598
; tz = -9.6882
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 4.3825; y = -6.6585; z = 4.0489 }
, (* C5' *)
{ x = 4.6841; y = -7.2019; z = 4.9443 }
, (* H5' *)
{ x = 3.6189; y = -5.8889; z = 4.1625 }
, (* H5'' *)
{ x = 5.6255; y = -5.9175; z = 3.5998 }
, (* C4' *)
{ x = 5.8732; y = -5.1228; z = 4.3034 }
, (* H4' *)
{ x = 6.7337; y = -6.8605; z = 3.5222 }
, (* O4' *)
{ x = 7.5932; y = -6.4923; z = 2.4548 }
, (* C1' *)
{ x = 8.5661; y = -6.2983; z = 2.9064 }
, (* H1' *)
{ x = 7.0527; y = -5.2012; z = 1.8322 }
, (* C2' *)
{ x = 7.1627; y = -5.2525; z = 0.7490 }
, (* H2'' *)
{ x = 7.6666; y = -4.1249; z = 2.4880 }
, (* O2' *)
{ x = 8.5944; y = -4.2543; z = 2.6981 }
, (* H2' *)
{ x = 5.5661; y = -5.3029; z = 2.2009 }
, (* C3' *)
{ x = 5.0841; y = -6.0018; z = 1.5172 }
, (* H3' *)
{ x = 4.9062; y = -4.0452; z = 2.2042 }
, (* O3' *)
{ x = 7.6298; y = -7.6136; z = 1.4752 }
, (* N1 *)
{ x = 8.5977; y = -9.5977; z = 0.7329 }
, (* N3 *)
{ x = 8.5951; y = -8.5745; z = 1.6594 }
, (* C2 *)
{ x = 7.7372; y = -9.7371; z = -0.3364 }
, (* C4 *)
{ x = 6.7596; y = -8.6801; z = -0.4476 }
, (* C5 *)
{ x = 6.7338; y = -7.6721; z = 0.4408 }
, (* C6 *)
U
( { x = 9.3993; y = -8.5377; z = 2.5743 }
, (* O2 *)
{ x = 7.8374; y = -10.6990; z = -1.1008 }
, (* O4 *)
{ x = 9.2924; y = -10.3081; z = 0.8477 }
, (* H3 *)
{ x = 6.0932; y = -8.6982; z = -1.1929 }
, (* H5 *)
{ x = 6.0481; y = -6.9515; z = 0.3446 } ) )
(* H6 *)
let rU06 =
N
( { a = -0.9837
; b = 0.0476
; c = -0.1733
; (* dgf_base_tfo *)
d = -0.1792
; e = -0.3353
; f = 0.9249
; g = -0.0141
; h = 0.9409
; i = 0.3384
; tx = 5.7793
; ty = -5.2303
; tz = 4.5997
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 3.9938; y = -6.7042; z = 1.9023 }
, (* C5' *)
{ x = 3.2332; y = -5.9343; z = 2.0319 }
, (* H5' *)
{ x = 3.9666; y = -7.2863; z = 0.9812 }
, (* H5'' *)
{ x = 5.3098; y = -5.9546; z = 1.8564 }
, (* C4' *)
{ x = 5.3863; y = -5.3702; z = 0.9395 }
, (* H4' *)
{ x = 5.3851; y = -5.0642; z = 3.0076 }
, (* O4' *)
{ x = 6.7315; y = -4.9724; z = 3.4462 }
, (* C1' *)
{ x = 7.0033; y = -3.9202; z = 3.3619 }
, (* H1' *)
{ x = 7.5997; y = -5.8018; z = 2.4948 }
, (* C2' *)
{ x = 8.3627; y = -6.3254; z = 3.0707 }
, (* H2'' *)
{ x = 8.0410; y = -4.9501; z = 1.4724 }
, (* O2' *)
{ x = 8.2781; y = -4.0644; z = 1.7570 }
, (* H2' *)
{ x = 6.5701; y = -6.8129; z = 1.9714 }
, (* C3' *)
{ x = 6.4186; y = -7.5809; z = 2.7299 }
, (* H3' *)
{ x = 6.9357; y = -7.3841; z = 0.7235 }
, (* O3' *)
{ x = 6.8024; y = -5.4718; z = 4.8475 }
, (* N1 *)
{ x = 6.6920; y = -5.0495; z = 7.1354 }
, (* N3 *)
{ x = 6.6201; y = -4.5500; z = 5.8506 }
, (* C2 *)
{ x = 6.9254; y = -6.3614; z = 7.4926 }
, (* C4 *)
{ x = 7.1046; y = -7.2543; z = 6.3718 }
, (* C5 *)
{ x = 7.0391; y = -6.7951; z = 5.1106 }
, (* C6 *)
U
( { x = 6.4083; y = -3.3696; z = 5.6340 }
, (* O2 *)
{ x = 6.9679; y = -6.6901; z = 8.6800 }
, (* O4 *)
{ x = 6.5626; y = -4.3957; z = 7.8812 }
, (* H3 *)
{ x = 7.2781; y = -8.2254; z = 6.5350 }
, (* H5 *)
{ x = 7.1657; y = -7.4312; z = 4.3503 } ) )
(* H6 *)
let rU07 =
N
( { a = -0.9434
; b = 0.3172
; c = 0.0971
; (* dgf_base_tfo *)
d = 0.2294
; e = 0.4125
; f = 0.8816
; g = 0.2396
; h = 0.8539
; i = -0.4619
; tx = 8.3625
; ty = -52.7147
; tz = 1.3745
}
, { a = 0.2765
; b = -0.1121
; c = -0.9545
; (* P_O3'_275_tfo *)
d = -0.8297
; e = 0.4733
; f = -0.2959
; g = 0.4850
; h = 0.8737
; i = 0.0379
; tx = -14.7774
; ty = -45.2464
; tz = 21.9088
}
, { a = 0.1063
; b = -0.6334
; c = -0.7665
; (* P_O3'_180_tfo *)
d = -0.5932
; e = -0.6591
; f = 0.4624
; g = -0.7980
; h = 0.4055
; i = -0.4458
; tx = 43.7634
; ty = 4.3296
; tz = 28.4890
}
, { a = 0.7136
; b = -0.5032
; c = -0.4873
; (* P_O3'_60_tfo *)
d = 0.6803
; e = 0.3317
; f = 0.6536
; g = -0.1673
; h = -0.7979
; i = 0.5791
; tx = -17.1858
; ty = 41.4390
; tz = -27.0751
}
, { x = 21.3880; y = 15.0780; z = 45.5770 }
, (* P *)
{ x = 21.9980; y = 14.5500; z = 46.8210 }
, (* O1P *)
{ x = 21.1450; y = 14.0270; z = 44.5420 }
, (* O2P *)
{ x = 22.1250; y = 16.3600; z = 44.9460 }
, (* O5' *)
{ x = 21.5037; y = 16.8594; z = 43.7323 }
, (* C5' *)
{ x = 20.8147; y = 17.6663; z = 43.9823 }
, (* H5' *)
{ x = 21.1086; y = 16.0230; z = 43.1557 }
, (* H5'' *)
{ x = 22.5654; y = 17.4874; z = 42.8616 }
, (* C4' *)
{ x = 22.1584; y = 17.7243; z = 41.8785 }
, (* H4' *)
{ x = 23.0557; y = 18.6826; z = 43.4751 }
, (* O4' *)
{ x = 24.4788; y = 18.6151; z = 43.6455 }
, (* C1' *)
{ x = 24.9355; y = 19.0840; z = 42.7739 }
, (* H1' *)
{ x = 24.7958; y = 17.1427; z = 43.6474 }
, (* C2' *)
{ x = 24.5652; y = 16.7400; z = 44.6336 }
, (* H2'' *)
{ x = 26.1041; y = 16.8773; z = 43.2455 }
, (* O2' *)
{ x = 26.7516; y = 17.5328; z = 43.5149 }
, (* H2' *)
{ x = 23.8109; y = 16.5979; z = 42.6377 }
, (* C3' *)
{ x = 23.5756; y = 15.5686; z = 42.9084 }
, (* H3' *)
{ x = 24.2890; y = 16.7447; z = 41.2729 }
, (* O3' *)
{ x = 24.9420; y = 19.2174; z = 44.8923 }
, (* N1 *)
{ x = 25.2655; y = 20.5636; z = 44.8883 }
, (* N3 *)
{ x = 25.1663; y = 21.2219; z = 43.8561 }
, (* C2 *)
{ x = 25.6911; y = 21.1219; z = 46.0494 }
, (* C4 *)
{ x = 25.8051; y = 20.4068; z = 47.2048 }
, (* C5 *)
{ x = 26.2093; y = 20.9962; z = 48.2534 }
, (* C6 *)
U
( { x = 25.4692; y = 19.0221; z = 47.2053 }
, (* O2 *)
{ x = 25.0502; y = 18.4827; z = 46.0370 }
, (* O4 *)
{ x = 25.9599; y = 22.1772; z = 46.0966 }
, (* H3 *)
{ x = 25.5545; y = 18.4409; z = 48.1234 }
, (* H5 *)
{ x = 24.7854; y = 17.4265; z = 45.9883 } ) )
(* H6 *)
let rU08 =
N
( { a = -0.0080
; b = -0.7928
; c = 0.6094
; (* dgf_base_tfo *)
d = -0.7512
; e = 0.4071
; f = 0.5197
; g = -0.6601
; h = -0.4536
; i = -0.5988
; tx = 44.1482
; ty = 30.7036
; tz = 2.1088
}
, { a = 0.2765
; b = -0.1121
; c = -0.9545
; (* P_O3'_275_tfo *)
d = -0.8297
; e = 0.4733
; f = -0.2959
; g = 0.4850
; h = 0.8737
; i = 0.0379
; tx = -14.7774
; ty = -45.2464
; tz = 21.9088
}
, { a = 0.1063
; b = -0.6334
; c = -0.7665
; (* P_O3'_180_tfo *)
d = -0.5932
; e = -0.6591
; f = 0.4624
; g = -0.7980
; h = 0.4055
; i = -0.4458
; tx = 43.7634
; ty = 4.3296
; tz = 28.4890
}
, { a = 0.7136
; b = -0.5032
; c = -0.4873
; (* P_O3'_60_tfo *)
d = 0.6803
; e = 0.3317
; f = 0.6536
; g = -0.1673
; h = -0.7979
; i = 0.5791
; tx = -17.1858
; ty = 41.4390
; tz = -27.0751
}
, { x = 21.3880; y = 15.0780; z = 45.5770 }
, (* P *)
{ x = 21.9980; y = 14.5500; z = 46.8210 }
, (* O1P *)
{ x = 21.1450; y = 14.0270; z = 44.5420 }
, (* O2P *)
{ x = 22.1250; y = 16.3600; z = 44.9460 }
, (* O5' *)
{ x = 23.5096; y = 16.1227; z = 44.5783 }
, (* C5' *)
{ x = 23.5649; y = 15.8588; z = 43.5222 }
, (* H5' *)
{ x = 23.9621; y = 15.4341; z = 45.2919 }
, (* H5'' *)
{ x = 24.2805; y = 17.4138; z = 44.7151 }
, (* C4' *)
{ x = 25.3492; y = 17.2309; z = 44.6030 }
, (* H4' *)
{ x = 23.8497; y = 18.3471; z = 43.7208 }
, (* O4' *)
{ x = 23.4090; y = 19.5681; z = 44.3321 }
, (* C1' *)
{ x = 24.2595; y = 20.2496; z = 44.3524 }
, (* H1' *)
{ x = 23.0418; y = 19.1813; z = 45.7407 }
, (* C2' *)
{ x = 22.0532; y = 18.7224; z = 45.7273 }
, (* H2'' *)
{ x = 23.1307; y = 20.2521; z = 46.6291 }
, (* O2' *)
{ x = 22.8888; y = 21.1051; z = 46.2611 }
, (* H2' *)
{ x = 24.0799; y = 18.1326; z = 46.0700 }
, (* C3' *)
{ x = 23.6490; y = 17.4370; z = 46.7900 }
, (* H3' *)
{ x = 25.3329; y = 18.7227; z = 46.5109 }
, (* O3' *)
{ x = 22.2515; y = 20.1624; z = 43.6698 }
, (* N1 *)
{ x = 22.4760; y = 21.0609; z = 42.6406 }
, (* N3 *)
{ x = 23.6229; y = 21.3462; z = 42.3061 }
, (* C2 *)
{ x = 21.3986; y = 21.6081; z = 42.0236 }
, (* C4 *)
{ x = 20.1189; y = 21.3012; z = 42.3804 }
, (* C5 *)
{ x = 19.1599; y = 21.8516; z = 41.7578 }
, (* C6 *)
U
( { x = 19.8919; y = 20.3745; z = 43.4387 }
, (* O2 *)
{ x = 20.9790; y = 19.8423; z = 44.0440 }
, (* O4 *)
{ x = 21.5235; y = 22.3222; z = 41.2097 }
, (* H3 *)
{ x = 18.8732; y = 20.1200; z = 43.7312 }
, (* H5 *)
{ x = 20.8545; y = 19.1313; z = 44.8608 } ) )
(* H6 *)
let rU09 =
N
( { a = -0.0317
; b = 0.1374
; c = 0.9900
; (* dgf_base_tfo *)
d = -0.3422
; e = -0.9321
; f = 0.1184
; g = 0.9391
; h = -0.3351
; i = 0.0765
; tx = -32.1929
; ty = 25.8198
; tz = -28.5088
}
, { a = 0.2765
; b = -0.1121
; c = -0.9545
; (* P_O3'_275_tfo *)
d = -0.8297
; e = 0.4733
; f = -0.2959
; g = 0.4850
; h = 0.8737
; i = 0.0379
; tx = -14.7774
; ty = -45.2464
; tz = 21.9088
}
, { a = 0.1063
; b = -0.6334
; c = -0.7665
; (* P_O3'_180_tfo *)
d = -0.5932
; e = -0.6591
; f = 0.4624
; g = -0.7980
; h = 0.4055
; i = -0.4458
; tx = 43.7634
; ty = 4.3296
; tz = 28.4890
}
, { a = 0.7136
; b = -0.5032
; c = -0.4873
; (* P_O3'_60_tfo *)
d = 0.6803
; e = 0.3317
; f = 0.6536
; g = -0.1673
; h = -0.7979
; i = 0.5791
; tx = -17.1858
; ty = 41.4390
; tz = -27.0751
}
, { x = 21.3880; y = 15.0780; z = 45.5770 }
, (* P *)
{ x = 21.9980; y = 14.5500; z = 46.8210 }
, (* O1P *)
{ x = 21.1450; y = 14.0270; z = 44.5420 }
, (* O2P *)
{ x = 22.1250; y = 16.3600; z = 44.9460 }
, (* O5' *)
{ x = 21.5037; y = 16.8594; z = 43.7323 }
, (* C5' *)
{ x = 20.8147; y = 17.6663; z = 43.9823 }
, (* H5' *)
{ x = 21.1086; y = 16.0230; z = 43.1557 }
, (* H5'' *)
{ x = 22.5654; y = 17.4874; z = 42.8616 }
, (* C4' *)
{ x = 23.0565; y = 18.3036; z = 43.3915 }
, (* H4' *)
{ x = 23.5375; y = 16.5054; z = 42.4925 }
, (* O4' *)
{ x = 23.6574; y = 16.4257; z = 41.0649 }
, (* C1' *)
{ x = 24.4701; y = 17.0882; z = 40.7671 }
, (* H1' *)
{ x = 22.3525; y = 16.9643; z = 40.5396 }
, (* C2' *)
{ x = 21.5993; y = 16.1799; z = 40.6133 }
, (* H2'' *)
{ x = 22.4693; y = 17.4849; z = 39.2515 }
, (* O2' *)
{ x = 23.0899; y = 17.0235; z = 38.6827 }
, (* H2' *)
{ x = 22.0341; y = 18.0633; z = 41.5279 }
, (* C3' *)
{ x = 20.9509; y = 18.1709; z = 41.5846 }
, (* H3' *)
{ x = 22.7249; y = 19.3020; z = 41.2100 }
, (* O3' *)
{ x = 23.8580; y = 15.0648; z = 40.5757 }
, (* N1 *)
{ x = 25.1556; y = 14.5982; z = 40.4523 }
, (* N3 *)
{ x = 26.1047; y = 15.3210; z = 40.7448 }
, (* C2 *)
{ x = 25.3391; y = 13.3315; z = 40.0020 }
, (* C4 *)
{ x = 24.2974; y = 12.5148; z = 39.6749 }
, (* C5 *)
{ x = 24.5450; y = 11.3410; z = 39.2610 }
, (* C6 *)
U
( { x = 22.9633; y = 12.9979; z = 39.8053 }
, (* O2 *)
{ x = 22.8009; y = 14.2648; z = 40.2524 }
, (* O4 *)
{ x = 26.3414; y = 12.9194; z = 39.8855 }
, (* H3 *)
{ x = 22.1227; y = 12.3533; z = 39.5486 }
, (* H5 *)
{ x = 21.7989; y = 14.6788; z = 40.3650 } ) )
(* H6 *)
let rU10 =
N
( { a = -0.9674
; b = 0.1021
; c = -0.2318
; (* dgf_base_tfo *)
d = -0.2514
; e = -0.2766
; f = 0.9275
; g = 0.0306
; h = 0.9555
; i = 0.2933
; tx = 27.8571
; ty = -42.1305
; tz = -24.4563
}
, { a = 0.2765
; b = -0.1121
; c = -0.9545
; (* P_O3'_275_tfo *)
d = -0.8297
; e = 0.4733
; f = -0.2959
; g = 0.4850
; h = 0.8737
; i = 0.0379
; tx = -14.7774
; ty = -45.2464
; tz = 21.9088
}
, { a = 0.1063
; b = -0.6334
; c = -0.7665
; (* P_O3'_180_tfo *)
d = -0.5932
; e = -0.6591
; f = 0.4624
; g = -0.7980
; h = 0.4055
; i = -0.4458
; tx = 43.7634
; ty = 4.3296
; tz = 28.4890
}
, { a = 0.7136
; b = -0.5032
; c = -0.4873
; (* P_O3'_60_tfo *)
d = 0.6803
; e = 0.3317
; f = 0.6536
; g = -0.1673
; h = -0.7979
; i = 0.5791
; tx = -17.1858
; ty = 41.4390
; tz = -27.0751
}
, { x = 21.3880; y = 15.0780; z = 45.5770 }
, (* P *)
{ x = 21.9980; y = 14.5500; z = 46.8210 }
, (* O1P *)
{ x = 21.1450; y = 14.0270; z = 44.5420 }
, (* O2P *)
{ x = 22.1250; y = 16.3600; z = 44.9460 }
, (* O5' *)
{ x = 23.5096; y = 16.1227; z = 44.5783 }
, (* C5' *)
{ x = 23.5649; y = 15.8588; z = 43.5222 }
, (* H5' *)
{ x = 23.9621; y = 15.4341; z = 45.2919 }
, (* H5'' *)
{ x = 24.2805; y = 17.4138; z = 44.7151 }
, (* C4' *)
{ x = 23.8509; y = 18.1819; z = 44.0720 }
, (* H4' *)
{ x = 24.2506; y = 17.8583; z = 46.0741 }
, (* O4' *)
{ x = 25.5830; y = 18.0320; z = 46.5775 }
, (* C1' *)
{ x = 25.8569; y = 19.0761; z = 46.4256 }
, (* H1' *)
{ x = 26.4410; y = 17.1555; z = 45.7033 }
, (* C2' *)
{ x = 26.3459; y = 16.1253; z = 46.0462 }
, (* H2'' *)
{ x = 27.7649; y = 17.5888; z = 45.6478 }
, (* O2' *)
{ x = 28.1004; y = 17.9719; z = 46.4616 }
, (* H2' *)
{ x = 25.7796; y = 17.2997; z = 44.3513 }
, (* C3' *)
{ x = 25.9478; y = 16.3824; z = 43.7871 }
, (* H3' *)
{ x = 26.2154; y = 18.4984; z = 43.6541 }
, (* O3' *)
{ x = 25.7321; y = 17.6281; z = 47.9726 }
, (* N1 *)
{ x = 25.5136; y = 18.5779; z = 48.9560 }
, (* N3 *)
{ x = 25.2079; y = 19.7276; z = 48.6503 }
, (* C2 *)
{ x = 25.6482; y = 18.1987; z = 50.2518 }
, (* C4 *)
{ x = 25.9847; y = 16.9266; z = 50.6092 }
, (* C5 *)
{ x = 26.0918; y = 16.6439; z = 51.8416 }
, (* C6 *)
U
( { x = 26.2067; y = 15.9515; z = 49.5943 }
, (* O2 *)
{ x = 26.0713; y = 16.3497; z = 48.3080 }
, (* O4 *)
{ x = 25.4890; y = 18.9105; z = 51.0618 }
, (* H3 *)
{ x = 26.4742; y = 14.9310; z = 49.8682 }
, (* H5 *)
{ x = 26.2346; y = 15.6394; z = 47.4975 } ) )
(* H6 *)
let rUs = [ rU01; rU02; rU03; rU04; rU05; rU06; rU07; rU08; rU09; rU10 ]
let rG' =
N
( { a = -0.2067
; b = -0.0264
; c = 0.9780
; (* dgf_base_tfo *)
d = 0.9770
; e = -0.0586
; f = 0.2049
; g = 0.0519
; h = 0.9979
; i = 0.0379
; tx = 1.0331
; ty = -46.8078
; tz = -36.4742
}
, { a = -0.8644
; b = -0.4956
; c = -0.0851
; (* P_O3'_275_tfo *)
d = -0.0427
; e = 0.2409
; f = -0.9696
; g = 0.5010
; h = -0.8345
; i = -0.2294
; tx = 4.0167
; ty = 54.5377
; tz = 12.4779
}
, { a = 0.3706
; b = -0.6167
; c = 0.6945
; (* P_O3'_180_tfo *)
d = -0.2867
; e = -0.7872
; f = -0.5460
; g = 0.8834
; h = 0.0032
; i = -0.4686
; tx = -52.9020
; ty = 18.6313
; tz = -0.6709
}
, { a = 0.4155
; b = 0.9025
; c = -0.1137
; (* P_O3'_60_tfo *)
d = 0.9040
; e = -0.4236
; f = -0.0582
; g = -0.1007
; h = -0.0786
; i = -0.9918
; tx = -7.6624
; ty = -25.2080
; tz = 49.5181
}
, { x = 31.3810; y = 0.1400; z = 47.5810 }
, (* P *)
{ x = 29.9860; y = 0.6630; z = 47.6290 }
, (* O1P *)
{ x = 31.7210; y = -0.6460; z = 48.8090 }
, (* O2P *)
{ x = 32.4940; y = 1.2540; z = 47.2740 }
, (* O5' *)
{ x = 32.1610; y = 2.2370; z = 46.2560 }
, (* C5' *)
{ x = 31.2986; y = 2.8190; z = 46.5812 }
, (* H5' *)
{ x = 32.0980; y = 1.7468; z = 45.2845 }
, (* H5'' *)
{ x = 33.3476; y = 3.1959; z = 46.1947 }
, (* C4' *)
{ x = 33.2668; y = 3.8958; z = 45.3630 }
, (* H4' *)
{ x = 33.3799; y = 3.9183; z = 47.4216 }
, (* O4' *)
{ x = 34.6515; y = 3.7222; z = 48.0398 }
, (* C1' *)
{ x = 35.2947; y = 4.5412; z = 47.7180 }
, (* H1' *)
{ x = 35.1756; y = 2.4228; z = 47.4827 }
, (* C2' *)
{ x = 34.6778; y = 1.5937; z = 47.9856 }
, (* H2'' *)
{ x = 36.5631; y = 2.2672; z = 47.4798 }
, (* O2' *)
{ x = 37.0163; y = 2.6579; z = 48.2305 }
, (* H2' *)
{ x = 34.6953; y = 2.5043; z = 46.0448 }
, (* C3' *)
{ x = 34.5444; y = 1.4917; z = 45.6706 }
, (* H3' *)
{ x = 35.6679; y = 3.3009; z = 45.3487 }
, (* O3' *)
{ x = 37.4804; y = 4.0914; z = 52.2559 }
, (* N1 *)
{ x = 36.9670; y = 4.1312; z = 49.9281 }
, (* N3 *)
{ x = 37.8045; y = 4.2519; z = 50.9550 }
, (* C2 *)
{ x = 35.7171; y = 3.8264; z = 50.3222 }
, (* C4 *)
{ x = 35.2668; y = 3.6420; z = 51.6115 }
, (* C5 *)
{ x = 36.2037; y = 3.7829; z = 52.6706 }
, (* C6 *)
G
( { x = 39.0869; y = 4.5552; z = 50.7092 }
, (* N2 *)
{ x = 33.9075; y = 3.3338; z = 51.6102 }
, (* N7 *)
{ x = 34.6126; y = 3.6358; z = 49.5108 }
, (* N9 *)
{ x = 33.5805; y = 3.3442; z = 50.3425 }
, (* C8 *)
{ x = 35.9958; y = 3.6512; z = 53.8724 }
, (* O6 *)
{ x = 38.2106; y = 4.2053; z = 52.9295 }
, (* H1 *)
{ x = 39.8218; y = 4.6863; z = 51.3896 }
, (* H21 *)
{ x = 39.3420; y = 4.6857; z = 49.7407 }
, (* H22 *)
{ x = 32.5194; y = 3.1070; z = 50.2664 } ) )
(* H8 *)
let rU' =
N
( { a = -0.0109
; b = 0.5907
; c = 0.8068
; (* dgf_base_tfo *)
d = 0.2217
; e = -0.7853
; f = 0.5780
; g = 0.9751
; h = 0.1852
; i = -0.1224
; tx = -1.4225
; ty = -11.0956
; tz = -2.5217
}
, { a = -0.8313
; b = -0.4738
; c = -0.2906
; (* P_O3'_275_tfo *)
d = 0.0649
; e = 0.4366
; f = -0.8973
; g = 0.5521
; h = -0.7648
; i = -0.3322
; tx = 1.6833
; ty = 6.8060
; tz = -7.0011
}
, { a = 0.3445
; b = -0.7630
; c = 0.5470
; (* P_O3'_180_tfo *)
d = -0.4628
; e = -0.6450
; f = -0.6082
; g = 0.8168
; h = -0.0436
; i = -0.5753
; tx = -6.8179
; ty = -3.9778
; tz = -5.9887
}
, { a = 0.5855
; b = 0.7931
; c = -0.1682
; (* P_O3'_60_tfo *)
d = 0.8103
; e = -0.5790
; f = 0.0906
; g = -0.0255
; h = -0.1894
; i = -0.9816
; tx = 6.1203
; ty = -7.1051
; tz = 3.1984
}
, { x = 2.6760; y = -8.4960; z = 3.2880 }
, (* P *)
{ x = 1.4950; y = -7.6230; z = 3.4770 }
, (* O1P *)
{ x = 2.9490; y = -9.4640; z = 4.3740 }
, (* O2P *)
{ x = 3.9730; y = -7.5950; z = 3.0340 }
, (* O5' *)
{ x = 5.2430; y = -8.2420; z = 2.8260 }
, (* C5' *)
{ x = 5.1974; y = -8.8497; z = 1.9223 }
, (* H5' *)
{ x = 5.5548; y = -8.7348; z = 3.7469 }
, (* H5'' *)
{ x = 6.3140; y = -7.2060; z = 2.5510 }
, (* C4' *)
{ x = 5.8744; y = -6.2116; z = 2.4731 }
, (* H4' *)
{ x = 7.2798; y = -7.2260; z = 3.6420 }
, (* O4' *)
{ x = 8.5733; y = -6.9410; z = 3.1329 }
, (* C1' *)
{ x = 8.9047; y = -6.0374; z = 3.6446 }
, (* H1' *)
{ x = 8.4429; y = -6.6596; z = 1.6327 }
, (* C2' *)
{ x = 9.2880; y = -7.1071; z = 1.1096 }
, (* H2'' *)
{ x = 8.2502; y = -5.2799; z = 1.4754 }
, (* O2' *)
{ x = 8.7676; y = -4.7284; z = 2.0667 }
, (* H2' *)
{ x = 7.1642; y = -7.4416; z = 1.3021 }
, (* C3' *)
{ x = 7.4125; y = -8.5002; z = 1.2260 }
, (* H3' *)
{ x = 6.5160; y = -6.9772; z = 0.1267 }
, (* O3' *)
{ x = 9.4531; y = -8.1107; z = 3.4087 }
, (* N1 *)
{ x = 11.5931; y = -9.0015; z = 3.6357 }
, (* N3 *)
{ x = 10.8101; y = -7.8950; z = 3.3748 }
, (* C2 *)
{ x = 11.1439; y = -10.2744; z = 3.9206 }
, (* C4 *)
{ x = 9.7056; y = -10.4026; z = 3.9332 }
, (* C5 *)
{ x = 8.9192; y = -9.3419; z = 3.6833 }
, (* C6 *)
U
( { x = 11.3013; y = -6.8063; z = 3.1326 }
, (* O2 *)
{ x = 11.9431; y = -11.1876; z = 4.1375 }
, (* O4 *)
{ x = 12.5840; y = -8.8673; z = 3.6158 }
, (* H3 *)
{ x = 9.2891; y = -11.2898; z = 4.1313 }
, (* H5 *)
{ x = 7.9263; y = -9.4537; z = 3.6977 } ) )
(* H6 *)
(* -- PARTIAL INSTANTIATIONS ------------------------------------------------*)
type variable =
{ id : int
; t : tfo
; n : nuc
}
let mk_var i t n = { id = i; t; n }
let absolute_pos v p = tfo_apply v.t p
let atom_pos atom v = absolute_pos v (atom v.n)
let rec get_var id = function
| v :: lst -> if id = v.id then v else get_var id lst
| _ -> assert false
(* -- SEARCH ----------------------------------------------------------------*)
(* Sequential backtracking algorithm *)
let rec search (partial_inst : variable list) l constr =
match l with
| [] -> [ partial_inst ]
| h :: t ->
let rec try_assignments = function
| [] -> []
| v :: vs ->
if constr v partial_inst
then search (v :: partial_inst) t constr @ try_assignments vs
else try_assignments vs
in
try_assignments (h partial_inst)
(* -- DOMAINS ---------------------------------------------------------------*)
(* Primary structure: strand A CUGCCACGUCUG, strand B CAGACGUGGCAG
Secondary structure: strand A CUGCCACGUCUG
||||||||||||
GACGGUGCAGAC strand B
Tertiary structure:
5' end of strand A C1----G12 3' end of strand B
U2-------A11
G3-------C10
C4-----G9
C5---G8
A6
G6-C7
C5----G8
A4-------U9
G3--------C10
A2-------U11
5' end of strand B C1----G12 3' end of strand A
"helix", "stacked" and "connected" describe the spatial relationship
between two consecutive nucleotides. E.g. the nucleotides C1 and U2
from the strand A.
"wc" (stands for Watson-Crick and is a type of base-pairing),
and "wc-dumas" describe the spatial relationship between
nucleotides from two chains that are growing in opposite directions.
E.g. the nucleotides C1 from strand A and G12 from strand B.
*)
(* Dynamic Domains *)
(* Given,
"refnuc" a nucleotide which is already positioned,
"nucl" the nucleotide to be placed,
and "tfo" a transformation matrix which expresses the desired
relationship between "refnuc" and "nucl",
the function "dgf-base" computes the transformation matrix that
places the nucleotide "nucl" in the given relationship to "refnuc".
*)
let dgf_base tfo v nucl =
let x =
if is_A v.n
then tfo_align (atom_pos nuc_C1' v) (atom_pos rA_N9 v) (atom_pos nuc_C4 v)
else if is_C v.n
then tfo_align (atom_pos nuc_C1' v) (atom_pos nuc_N1 v) (atom_pos nuc_C2 v)
else if is_G v.n
then tfo_align (atom_pos nuc_C1' v) (atom_pos rG_N9 v) (atom_pos nuc_C4 v)
else tfo_align (atom_pos nuc_C1' v) (atom_pos nuc_N1 v) (atom_pos nuc_C2 v)
in
tfo_combine (nuc_dgf_base_tfo nucl) (tfo_combine tfo (tfo_inv_ortho x))
(* Placement of first nucleotide. *)
let reference n i partial_inst = [ mk_var i tfo_id n ]
(* The transformation matrix for wc is from:
Chandrasekaran R. et al (1989) A Re-Examination of the Crystal
Structure of A-DNA Using Fiber Diffraction Data. J. Biomol.
Struct. & Dynamics 6(6):1189-1202.
*)
let wc_tfo =
{ a = -1.0000
; b = 0.0028
; c = -0.0019
; d = 0.0028
; e = 0.3468
; f = -0.9379
; g = -0.0019
; h = -0.9379
; i = -0.3468
; tx = -0.0080
; ty = 6.0730
; tz = 8.7208
}
let wc nucl i j partial_inst =
[ mk_var i (dgf_base wc_tfo (get_var j partial_inst) nucl) nucl ]
let wc_dumas_tfo =
{ a = -0.9737
; b = -0.1834
; c = 0.1352
; d = -0.1779
; e = 0.2417
; f = -0.9539
; g = 0.1422
; h = -0.9529
; i = -0.2679
; tx = 0.4837
; ty = 6.2649
; tz = 8.0285
}
let wc_dumas nucl i j partial_inst =
[ mk_var i (dgf_base wc_dumas_tfo (get_var j partial_inst) nucl) nucl ]
let helix5'_tfo =
{ a = 0.9886
; b = -0.0961
; c = 0.1156
; d = 0.1424
; e = 0.8452
; f = -0.5152
; g = -0.0482
; h = 0.5258
; i = 0.8492
; tx = -3.8737
; ty = 0.5480
; tz = 3.8024
}
let helix5' nucl i j partial_inst =
[ mk_var i (dgf_base helix5'_tfo (get_var j partial_inst) nucl) nucl ]
let helix3'_tfo =
{ a = 0.9886
; b = 0.1424
; c = -0.0482
; d = -0.0961
; e = 0.8452
; f = 0.5258
; g = 0.1156
; h = -0.5152
; i = 0.8492
; tx = 3.4426
; ty = 2.0474
; tz = -3.7042
}
let helix3' nucl i j partial_inst =
[ mk_var i (dgf_base helix3'_tfo (get_var j partial_inst) nucl) nucl ]
let g37_a38_tfo =
{ a = 0.9991
; b = 0.0164
; c = -0.0387
; d = -0.0375
; e = 0.7616
; f = -0.6470
; g = 0.0189
; h = 0.6478
; i = 0.7615
; tx = -3.3018
; ty = 0.9975
; tz = 2.5585
}
let g37_a38 nucl i j partial_inst =
mk_var i (dgf_base g37_a38_tfo (get_var j partial_inst) nucl) nucl
let stacked5' nucl i j partial_inst =
g37_a38 nucl i j partial_inst :: helix5' nucl i j partial_inst
let a38_g37_tfo =
{ a = 0.9991
; b = -0.0375
; c = 0.0189
; d = 0.0164
; e = 0.7616
; f = 0.6478
; g = -0.0387
; h = -0.6470
; i = 0.7615
; tx = 3.3819
; ty = 0.7718
; tz = -2.5321
}
let a38_g37 nucl i j partial_inst =
mk_var i (dgf_base a38_g37_tfo (get_var j partial_inst) nucl) nucl
let stacked3' nucl i j partial_inst =
a38_g37 nucl i j partial_inst :: helix3' nucl i j partial_inst
let p_o3' nucls i j partial_inst =
let refnuc = get_var j partial_inst in
let align =
tfo_inv_ortho
(tfo_align
(atom_pos nuc_O3' refnuc)
(atom_pos nuc_C3' refnuc)
(atom_pos nuc_C4' refnuc))
in
let rec generate domains = function
| [] -> domains
| n :: ns ->
generate
(mk_var i (tfo_combine (nuc_p_o3'_60_tfo n) align) n
:: mk_var i (tfo_combine (nuc_p_o3'_180_tfo n) align) n
:: mk_var i (tfo_combine (nuc_p_o3'_275_tfo n) align) n
:: domains)
ns
in
generate [] nucls
(* -- PROBLEM STATEMENT -----------------------------------------------------*)
(* Define anticodon problem -- Science 253:1255 Figure 3a, 3b and 3c *)
let anticodon_domains =
[ reference rC 27
; helix5' rC 28 27
; helix5' rA 29 28
; helix5' rG 30 29
; helix5' rA 31 30
; wc rU 39 31
; helix5' rC 40 39
; helix5' rU 41 40
; helix5' rG 42 41
; helix5' rG 43 42
; stacked3' rA 38 39
; stacked3' rG 37 38
; stacked3' rA 36 37
; stacked3' rA 35 36
; stacked3' rG 34 35 (* <-. Distance *)
; p_o3' rCs 32 31 (* | Constraint *)
; p_o3' rUs 33 32 (* <-' 3.0 Angstroms *)
]
[@@ocamlformat "disable"]
(* Anticodon constraint *)
let anticodon_constraint v partial_inst =
let dist j =
let p = atom_pos nuc_P (get_var j partial_inst) in
let o3' = atom_pos nuc_O3' v in
pt_dist p o3'
in
if v.id = 33 then dist 34 <= 3.0 else true
let anticodon () = search [] anticodon_domains anticodon_constraint
(* Define pseudoknot problem -- Science 253:1255 Figure 4a and 4b *)
let pseudoknot_domains =
[ reference rA 23
; wc_dumas rU 8 23
; helix3' rG 22 23
; wc_dumas rC 9 22
; helix3' rG 21 22
; wc_dumas rC 10 21
; helix3' rC 20 21
; wc_dumas rG 11 20
; helix3' rU' 19 20 (* <-. *)
; wc_dumas rA 12 19 (* | Distance *)
(* | Constraint *)
(* Helix 1 | 4.0 Angstroms *)
; helix3' rC 3 19 (* | *)
; wc_dumas rG 13 3 (* | *)
; helix3' rC 2 3 (* | *)
; wc_dumas rG 14 2 (* | *)
; helix3' rC 1 2 (* | *)
; wc_dumas rG' 15 1 (* | *)
(* | *)
(* L2 LOOP | *)
; p_o3' rUs 16 15 (* | *)
; p_o3' rCs 17 16 (* | *)
; p_o3' rAs 18 17 (* <-' *)
(* *)
(* L1 LOOP *)
; helix3' rU 7 8 (* <-. *)
; p_o3' rCs 4 3 (* | Constraint *)
; stacked5' rU 5 4 (* | 4.5 Angstroms *)
; stacked5' rC 6 5 (* <-' *)
]
[@@ocamlformat "disable"]
(* Pseudoknot constraint *)
let pseudoknot_constraint v partial_inst =
let dist j =
let p = atom_pos nuc_P (get_var j partial_inst) in
let o3' = atom_pos nuc_O3' v in
pt_dist p o3'
in
if v.id = 18 then dist 19 <= 4.0 else if v.id = 6 then dist 7 <= 4.5 else true
let pseudoknot () = search [] pseudoknot_domains pseudoknot_constraint
(* -- TESTING ---------------------------------------------------------------*)
let list_of_atoms = function
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, A (n6, n7, n9, c8, h2, h61, h62, h8) ) ->
[| p
; o1p
; o2p
; o5'
; c5'
; h5'
; h5''
; c4'
; h4'
; o4'
; c1'
; h1'
; c2'
; h2''
; o2'
; h2'
; c3'
; h3'
; o3'
; n1
; n3
; c2
; c4
; c5
; c6
; n6
; n7
; n9
; c8
; h2
; h61
; h62
; h8
|]
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, C (n4, o2, h41, h42, h5, h6) ) ->
[| p
; o1p
; o2p
; o5'
; c5'
; h5'
; h5''
; c4'
; h4'
; o4'
; c1'
; h1'
; c2'
; h2''
; o2'
; h2'
; c3'
; h3'
; o3'
; n1
; n3
; c2
; c4
; c5
; c6
; n4
; o2
; h41
; h42
; h5
; h6
|]
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, G (n2, n7, n9, c8, o6, h1, h21, h22, h8) ) ->
[| p
; o1p
; o2p
; o5'
; c5'
; h5'
; h5''
; c4'
; h4'
; o4'
; c1'
; h1'
; c2'
; h2''
; o2'
; h2'
; c3'
; h3'
; o3'
; n1
; n3
; c2
; c4
; c5
; c6
; n2
; n7
; n9
; c8
; o6
; h1
; h21
; h22
; h8
|]
| N
( dgf_base_tfo
, p_o3'_275_tfo
, p_o3'_180_tfo
, p_o3'_60_tfo
, p
, o1p
, o2p
, o5'
, c5'
, h5'
, h5''
, c4'
, h4'
, o4'
, c1'
, h1'
, c2'
, h2''
, o2'
, h2'
, c3'
, h3'
, o3'
, n1
, n3
, c2
, c4
, c5
, c6
, U (o2, o4, h3, h5, h6) ) ->
[| p
; o1p
; o2p
; o5'
; c5'
; h5'
; h5''
; c4'
; h4'
; o4'
; c1'
; h1'
; c2'
; h2''
; o2'
; h2'
; c3'
; h3'
; o3'
; n1
; n3
; c2
; c4
; c5
; c6
; o2
; o4
; h3
; h5
; h6
|]
let maximum = function
| x :: xs ->
let rec iter m = function
| [] -> m
| a :: b -> iter (if a > m then a else m) b
in
iter x xs
| _ -> assert false
let var_most_distant_atom v =
let atoms = list_of_atoms v.n in
let max_dist = ref 0.0 in
for i = 0 to pred (Array.length atoms) do
let p = atoms.(i) in
let distance =
let pos = absolute_pos v p in
sqrt ((pos.x * pos.x) + (pos.y * pos.y) + (pos.z * pos.z))
in
if distance > !max_dist then max_dist := distance
done;
!max_dist
let sol_most_distant_atom s = maximum (List.map var_most_distant_atom s)
let most_distant_atom sols = maximum (List.map sol_most_distant_atom sols)
let check () = List.length (pseudoknot ())
let run () = most_distant_atom (pseudoknot ())
let main () =
for _ = 1 to 50 do
ignore (run ())
done;
assert (abs_float (run () -. 33.7976) < 0.0002)
(*
Printf.printf "%.4f" (run ()); print_newline()
*)
let _ = main ()
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/quicksort.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: quicksort.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
(* Good test for loops. Best compiled with -unsafe. *)
let rec qsort lo hi (a : int array) =
if lo < hi
then (
let i = ref lo in
let j = ref hi in
let pivot = a.(hi) in
while !i < !j do
while !i < hi && a.(!i) <= pivot do
incr i
done;
while !j > lo && a.(!j) >= pivot do
decr j
done;
if !i < !j
then (
let temp = a.(!i) in
a.(!i) <- a.(!j);
a.(!j) <- temp)
done;
let temp = a.(!i) in
a.(!i) <- a.(hi);
a.(hi) <- temp;
qsort lo (!i - 1) a;
qsort (!i + 1) hi a)
(* Same but abstract over the comparison to force spilling *)
let cmp i j = i - j
let rec qsort2 lo hi (a : int array) =
if lo < hi
then (
let i = ref lo in
let j = ref hi in
let pivot = a.(hi) in
while !i < !j do
while !i < hi && cmp a.(!i) pivot <= 0 do
incr i
done;
while !j > lo && cmp a.(!j) pivot >= 0 do
decr j
done;
if !i < !j
then (
let temp = a.(!i) in
a.(!i) <- a.(!j);
a.(!j) <- temp)
done;
let temp = a.(!i) in
a.(!i) <- a.(hi);
a.(hi) <- temp;
qsort2 lo (!i - 1) a;
qsort2 (!i + 1) hi a)
(* Test *)
let seed = ref 0
let random () =
seed := (!seed * 25173) + 17431;
!seed land 0xFFF
exception Failed
let test_sort sort_fun size =
let a = Array.make size 0 in
let check = Array.make 4096 0 in
for i = 0 to size - 1 do
let n = random () in
a.(i) <- n;
check.(n) <- check.(n) + 1
done;
sort_fun 0 (size - 1) a;
try
check.(a.(0)) <- check.(a.(0)) - 1;
for i = 1 to size - 1 do
if a.(i - 1) > a.(i) then raise Failed;
check.(a.(i)) <- check.(a.(i)) - 1
done;
for i = 0 to 4095 do
if check.(i) <> 0 then raise Failed
done
(*print_string "OK"; print_newline()*)
with Failed -> assert false
(*print_string "failed"; print_newline()*)
let main () =
test_sort qsort 2_000_000;
test_sort qsort2 2_000_000
let _ = main ()
(*exit 0*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/raytrace.ml
|
module Color = struct
type t =
{ red : float
; green : float
; blue : float
}
let make r g b = { red = r; green = g; blue = b }
(*
let print ch c =
let r = truncate (c.red *. 255.) in
let g = truncate (c.green *. 255.) in
let b = truncate (c.blue *. 255.) in
Format.fprintf ch "rgb(%d,%d,%d)" r g b
*)
let limit c =
{ red =
(let red = c.red in
if red <= 0. then 0. else if red > 1.0 then 1.0 else red)
; green =
(let green = c.green in
if green <= 0. then 0. else if green > 1.0 then 1.0 else green)
; blue =
(let blue = c.blue in
if blue <= 0. then 0. else if blue > 1.0 then 1.0 else blue)
}
let add c1 c2 =
{ red = c1.red +. c2.red; green = c1.green +. c2.green; blue = c1.blue +. c2.blue }
let add_scalar c1 s =
limit { red = c1.red +. s; green = c1.green +. s; blue = c1.blue +. s }
let subtract c1 c2 =
{ red = c1.red -. c2.red; green = c1.green -. c2.green; blue = c1.blue -. c2.blue }
let multiply c1 c2 =
{ red = c1.red *. c2.red; green = c1.green *. c2.green; blue = c1.blue *. c2.blue }
let multiply_scalar c1 s =
{ red = c1.red *. s; green = c1.green *. s; blue = c1.blue *. s }
let divide_factor c1 f =
{ red = c1.red /. f; green = c1.green /. f; blue = c1.blue /. f }
let distance c1 c2 =
abs_float (c1.red -. c2.red)
+. abs_float (c1.green -. c2.green)
+. abs_float (c1.blue -. c2.blue)
let blend c1 c2 w = add (multiply_scalar c1 (1. -. w)) (multiply_scalar c2 w)
let brightness c =
let r = truncate (c.red *. 255.) in
let g = truncate (c.green *. 255.) in
let b = truncate (c.blue *. 255.) in
((r * 77) + (g * 150) + (b * 29)) lsr 8
end
module Vector = struct
type t =
{ x : float
; mutable y : float
; z : float
}
let make x y z = { x; y; z }
(*
let print ch v = Format.fprintf ch "%f %f %f" v.x v.y v.z
*)
let magnitude v = sqrt ((v.x *. v.x) +. (v.y *. v.y) +. (v.z *. v.z))
let normalize v =
let m = magnitude v in
{ x = v.x /. m; y = v.y /. m; z = v.z /. m }
let cross v w =
{ x = (v.y *. w.z) -. (v.z *. w.y)
; y = (v.z *. w.x) -. (v.x *. w.z)
; z = (v.x *. w.y) -. (v.y *. w.x)
}
let dot v w = (v.x *. w.x) +. (v.y *. w.y) +. (v.z *. w.z)
let add v w = { x = v.x +. w.x; y = v.y +. w.y; z = v.z +. w.z }
let subtract v w = { x = v.x -. w.x; y = v.y -. w.y; z = v.z -. w.z }
let multiply_vector v w = { x = v.x *. w.x; y = v.y *. w.y; z = v.z *. w.z }
let multiply_scalar v w = { x = v.x *. w; y = v.y *. w; z = v.z *. w }
end
module Light = struct
type t =
{ position : Vector.t
; color : Color.t
; intensity : float
}
let make p c i = { position = p; color = c; intensity = i }
end
module Ray = struct
type t =
{ position : Vector.t
; direction : Vector.t
}
let make p d = { position = p; direction = d }
end
module Intersection_info = struct
type 'a t =
{ shape : 'a
; distance : float
; position : Vector.t
; normal : Vector.t
; color : Color.t
}
end
module Camera = struct
type t =
{ position : Vector.t
; look_at : Vector.t
; equator : Vector.t
; up : Vector.t
; screen : Vector.t
}
let make pos look_at up =
{ position = pos
; look_at
; up
; equator = Vector.cross (Vector.normalize look_at) up
; screen = Vector.add pos look_at
}
let get_ray c vx vy =
let pos =
Vector.subtract
c.screen
(Vector.subtract
(Vector.multiply_scalar c.equator vx)
(Vector.multiply_scalar c.up vy))
in
pos.Vector.y <- pos.Vector.y *. -1.;
let dir = Vector.subtract pos c.position in
Ray.make pos (Vector.normalize dir)
end
module Background = struct
type t =
{ color : Color.t
; ambience : float
}
let make c a = { color = c; ambience = a }
end
module Material = struct
type t =
{ reflection : float
; transparency : float
; gloss : float
; has_texture : bool
; get_color : float -> float -> Color.t
}
let wrap_up t =
let t = mod_float t 2.0 in
if t < -1. then t +. 2.0 else if t >= 1. then t -. 2.0 else t
let solid color reflection transparency gloss =
{ reflection
; transparency
; gloss
; has_texture = false
; get_color = (fun _ _ -> color)
}
let chessboard color_even color_odd reflection transparency gloss density =
{ reflection
; transparency
; gloss
; has_texture = true
; get_color =
(fun u v ->
let t = wrap_up (u *. density) *. wrap_up (v *. density) in
if t < 0. then color_even else color_odd)
}
end
module Shape = struct
type shape =
| Sphere of Vector.t * float
| Plane of Vector.t * float
type t =
{ shape : shape
; material : Material.t
}
let make shape material = { shape; material }
let dummy =
make
(Sphere (Vector.make 0. 0. 0., 0.))
(Material.solid (Color.make 0. 0. 0.) 0. 0. 0.)
let position s =
match s.shape with
| Sphere (p, _) -> p
| Plane (p, _) -> p
let intersect s ray =
match s.shape with
| Sphere (position, radius) ->
let dst = Vector.subtract ray.Ray.position position in
let b = Vector.dot dst ray.Ray.direction in
let c = Vector.dot dst dst -. (radius *. radius) in
let d = (b *. b) -. c in
if d > 0.
then
let dist = -.b -. sqrt d in
let pos =
Vector.add ray.Ray.position (Vector.multiply_scalar ray.Ray.direction dist)
in
Some
{ Intersection_info.shape = s
; distance = dist
; position = pos
; normal = Vector.normalize (Vector.subtract pos position)
; color = s.material.Material.get_color 0. 0.
}
else None
| Plane (position, d) ->
let vd = Vector.dot position ray.Ray.direction in
if vd = 0.
then None
else
let t = -.(Vector.dot position ray.Ray.position +. d) /. vd in
if t <= 0.
then None
else
let pos =
Vector.add ray.Ray.position (Vector.multiply_scalar ray.Ray.direction t)
in
Some
{ Intersection_info.shape = s
; distance = t
; position = pos
; normal = position
; color =
(if s.material.Material.has_texture
then
let vu =
Vector.make
position.Vector.y
position.Vector.z
(-.position.Vector.x)
in
let vv = Vector.cross vu position in
let u = Vector.dot pos vu in
let v = Vector.dot pos vv in
s.material.Material.get_color u v
else s.material.Material.get_color 0. 0.)
}
end
module Scene = struct
type t =
{ camera : Camera.t
; shapes : Shape.t array
; lights : Light.t array
; background : Background.t
}
let make c s l b = { camera = c; shapes = s; lights = l; background = b }
end
module Engine = struct
type t =
{ pixel_width : int
; pixel_height : int
; canvas_width : int
; canvas_height : int
; render_diffuse : bool
; render_shadows : bool
; render_highlights : bool
; render_reflections : bool
; ray_depth : int
}
let check_number = ref 0
let get_reflection_ray p n v =
let c1 = -.Vector.dot n v in
let r1 = Vector.add (Vector.multiply_scalar n (2. *. c1)) v in
Ray.make p r1
let rec ray_trace options info ray scene depth =
let old_color =
Color.multiply_scalar
info.Intersection_info.color
scene.Scene.background.Background.ambience
in
let color = ref old_color in
let shininess =
10. ** (info.Intersection_info.shape.Shape.material.Material.gloss +. 1.)
in
let lights = scene.Scene.lights in
for i = 0 to Array.length lights - 1 do
let light = lights.(i) in
let v =
Vector.normalize
(Vector.subtract light.Light.position info.Intersection_info.position)
in
(if options.render_diffuse
then
let l = Vector.dot v info.Intersection_info.normal in
if l > 0.
then
color :=
Color.add
!color
(Color.multiply
info.Intersection_info.color
(Color.multiply_scalar light.Light.color l)));
(if depth <= options.ray_depth
then
if
options.render_reflections
&& info.Intersection_info.shape.Shape.material.Material.reflection > 0.
then
let reflection_ray =
get_reflection_ray
info.Intersection_info.position
info.Intersection_info.normal
ray.Ray.direction
in
let col =
match
test_intersection reflection_ray scene info.Intersection_info.shape
with
| Some ({ Intersection_info.distance = d; _ } as info) when d > 0. ->
ray_trace options info reflection_ray scene (depth + 1)
| _ -> scene.Scene.background.Background.color
in
color :=
Color.blend
!color
col
info.Intersection_info.shape.Shape.material.Material.reflection);
let shadow_info = ref None in
if options.render_shadows
then (
let shadow_ray = Ray.make info.Intersection_info.position v in
shadow_info := test_intersection shadow_ray scene info.Intersection_info.shape;
match !shadow_info with
| Some info ->
(*XXX This looks wrong! *)
let va = Color.multiply_scalar !color 0.5 in
let db =
0.5
*. (info.Intersection_info.shape.Shape.material.Material.transparency ** 0.5)
in
color := Color.add_scalar va db
| None -> ());
if
options.render_highlights
&& !shadow_info <> None
&& info.Intersection_info.shape.Shape.material.Material.gloss > 0.
then
(*XXX This looks wrong! *)
let shape_position = Shape.position info.Intersection_info.shape in
let lv = Vector.normalize (Vector.subtract shape_position light.Light.position) in
let e =
Vector.normalize
(Vector.subtract scene.Scene.camera.Camera.position shape_position)
in
let h = Vector.normalize (Vector.subtract e lv) in
let gloss_weight =
max (Vector.dot info.Intersection_info.normal h) 0. ** shininess
in
color := Color.add (Color.multiply_scalar light.Light.color gloss_weight) !color
done;
Color.limit !color
and test_intersection ray scene exclude =
let best = ref None in
let dist = ref 2000. in
let shapes = scene.Scene.shapes in
for i = 0 to Array.length shapes - 1 do
let shape = shapes.(i) in
if shape != exclude
then
match Shape.intersect shape ray with
| Some { Intersection_info.distance = d; _ } as v when d >= 0. && d < !dist ->
best := v;
dist := d
| _ -> ()
done;
!best
let get_pixel_color options ray scene =
match test_intersection ray scene Shape.dummy with
| Some info -> ray_trace options info ray scene 0
| None -> scene.Scene.background.Background.color
let set_pixel _options x y color =
if x == y then check_number := !check_number + Color.brightness color;
( (*
let pxw = options.pixel_width in
let pxh = options.pixel_height in
Format.eprintf "%d %d %d %d %d %a@." (x * pxw) (y * pxh) pxw pxh !check_number Color.print color;
*) )
let render_scene options scene _canvas =
check_number := 0;
(*XXX canvas *)
let canvas_height = options.canvas_height in
let canvas_width = options.canvas_width in
for y = 0 to canvas_height - 1 do
for x = 0 to canvas_width - 1 do
let yp = (float y /. float canvas_height *. 2.) -. 1. in
let xp = (float x /. float canvas_width *. 2.) -. 1. in
let ray = Camera.get_ray scene.Scene.camera xp yp in
let color = get_pixel_color options ray scene in
set_pixel options x y color
done
done;
assert (!check_number = 2321)
let make
canvas_width
canvas_height
pixel_width
pixel_height
render_diffuse
render_shadows
render_highlights
render_reflections
ray_depth =
{ canvas_width = canvas_width / pixel_width
; canvas_height = canvas_height / pixel_height
; pixel_width
; pixel_height
; render_diffuse
; render_shadows
; render_highlights
; render_reflections
; ray_depth
}
end
let render_scene () =
let camera =
Camera.make
(Vector.make 0. 0. (-15.))
(Vector.make (-0.2) 0. 5.)
(Vector.make 0. 1. 0.)
in
let background = Background.make (Color.make 0.5 0.5 0.5) 0.4 in
let sphere =
Shape.make
(Shape.Sphere (Vector.make (-1.5) 1.5 2., 1.5))
(Material.solid (Color.make 0. 0.5 0.5) 0.3 0. 2.)
in
let sphere1 =
Shape.make
(Shape.Sphere (Vector.make 1. 0.25 1., 0.5))
(Material.solid (Color.make 0.9 0.9 0.9) 0.1 0. 1.5)
in
let plane =
Shape.make
(Shape.Plane (Vector.normalize (Vector.make 0.1 0.9 (-0.5)), 1.2))
(Material.chessboard (Color.make 1. 1. 1.) (Color.make 0. 0. 0.) 0.2 0. 1.0 0.7)
in
let light = Light.make (Vector.make 5. 10. (-1.)) (Color.make 0.8 0.8 0.8) 10. in
let light1 = Light.make (Vector.make (-3.) 5. (-15.)) (Color.make 0.8 0.8 0.8) 100. in
let scene =
Scene.make camera [| plane; sphere; sphere1 |] [| light; light1 |] background
in
let image_width = 100 in
let image_height = 100 in
let pixel_size = 5, 5 in
let render_diffuse = true in
let render_shadows = true in
let render_highlights = true in
let render_reflections = true in
let ray_depth = 2 in
let engine =
Engine.make
image_width
image_height
(fst pixel_size)
(snd pixel_size)
render_diffuse
render_shadows
render_highlights
render_reflections
ray_depth
in
Engine.render_scene engine scene None
let _ =
for _ = 1 to 2000 do
render_scene ()
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/soli.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: soli.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
type peg =
| Out
| Empty
| Peg
let print_peg = function
| Out -> print_string "."
| Empty -> print_string " "
| Peg -> print_string "$"
let print_board board =
for i = 0 to 8 do
for j = 0 to 8 do
print_peg board.(i).(j)
done;
print_newline ()
done
type direction =
{ dx : int
; dy : int
}
let dir =
[| { dx = 0; dy = 1 }; { dx = 1; dy = 0 }; { dx = 0; dy = -1 }; { dx = -1; dy = 0 } |]
type move =
{ x1 : int
; y1 : int
; x2 : int
; y2 : int
}
exception Found
let rec solve board moves counter m =
counter := !counter + 1;
if m = 31
then
match board.(4).(4) with
| Peg -> true
| _ -> false
else
try
for i = 1 to 7 do
for j = 1 to 7 do
match board.(i).(j) with
| Peg ->
for k = 0 to 3 do
let d1 = dir.(k).dx in
let d2 = dir.(k).dy in
let i1 = i + d1 in
let i2 = i1 + d1 in
let j1 = j + d2 in
let j2 = j1 + d2 in
match board.(i1).(j1) with
| Peg -> (
match board.(i2).(j2) with
| Empty ->
board.(i).(j) <- Empty;
board.(i1).(j1) <- Empty;
board.(i2).(j2) <- Peg;
if solve board moves counter (m + 1)
then (
moves.(m) <- { x1 = i; y1 = j; x2 = i2; y2 = j2 };
raise Found);
board.(i).(j) <- Peg;
board.(i1).(j1) <- Peg;
board.(i2).(j2) <- Empty
| _ -> ())
| _ -> ()
done
| _ -> ()
done
done;
false
with Found -> true
let solve () =
let board =
[| [| Out; Out; Out; Out; Out; Out; Out; Out; Out |]
; [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out |]
; [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out |]
; [| Out; Peg; Peg; Peg; Peg; Peg; Peg; Peg; Out |]
; [| Out; Peg; Peg; Peg; Empty; Peg; Peg; Peg; Out |]
; [| Out; Peg; Peg; Peg; Peg; Peg; Peg; Peg; Out |]
; [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out |]
; [| Out; Out; Out; Peg; Peg; Peg; Out; Out; Out |]
; [| Out; Out; Out; Out; Out; Out; Out; Out; Out |]
|]
in
let moves = Array.make 31 { x1 = 0; y1 = 0; x2 = 0; y2 = 0 } in
let counter = ref 0 in
solve board moves counter 0, board
let _ =
for _ = 0 to 200 do
let solved, board = solve () in
if solved
then ()
else (
print_string "Failed:\n";
print_board board)
done
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/splay.ml
|
(*
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This benchmark is based on a JavaScript log processing module used
// by the V8 profiler to generate execution time profiles for runs of
// JavaScript applications, and it effectively measures how fast the
// JavaScript engine is at allocating nodes and reclaiming the memory
// used for old nodes. Because of the way splay trees work, the engine
// also has to deal with a lot of changes to the large tree object
// graph.
*)
(* Translation in ocaml by VB:
This program is probably not the best splay tree implementation in OCaml,
because it tries to follow exactly the steps of the Google v8 benchmark.
*)
let kSplayTreeSize = 8000
let kSplayTreeModifications = 80
let kSplayTreePayloadDepth = 5
type content_leaf =
{ array : int array
; string : string
}
type content =
| CLeaf of content_leaf
| CNode of content * content
type tree =
| Empty
| Node of (tree * float * content * tree)
(**
* Perform the splay operation for the given key. Moves the node with
* the given key to the top of the tree. If no node has the given
* key, the last node on the search path is moved to the top of the
* tree. This is the simplified top-down splaying algorithm from:
* "Self-adjusting Binary Search Trees" by Sleator and Tarjan
*)
let rec splay_ ((left, key, value, right) as a) k =
if k = key
then a
else if k < key
then
match left with
| Empty -> a (* not found *)
| Node (lleft, lk, lv, lright) -> (
if k = lk
then lleft, lk, lv, Node (lright, key, value, right) (* zig *)
else if k < lk
then
match lleft with
| Empty -> Empty, lk, lv, Node (lright, key, value, right)
(* not found *)
| Node n ->
(* zig-zig *)
let llleft, llk, llv, llright = splay_ n k in
llleft, llk, llv, Node (llright, lk, lv, Node (lright, key, value, right))
else
match lright with
| Empty -> lleft, lk, lv, Node (Empty, key, value, right)
| Node n ->
(* zig-zag *)
let lrleft, lrk, lrv, lrright = splay_ n k in
Node (lleft, lk, lv, lrleft), lrk, lrv, Node (lrright, key, value, right))
else
match right with
| Empty -> a
| Node (rleft, rk, rv, rright) -> (
if k = rk
then Node (left, key, value, rleft), rk, rv, rright (* zag *)
else if k > rk
then
match rright with
| Empty -> Node (left, key, value, rleft), rk, rv, rright (* not found *)
| Node n ->
(* zag-zag *)
let rrleft, rrk, rrv, rrright = splay_ n k in
Node (Node (left, key, value, rleft), rk, rv, rrleft), rrk, rrv, rrright
else
match rleft with
| Empty -> Node (left, key, value, rleft), rk, rv, rright (* not found *)
| Node n ->
(* zag-zig *)
let rlleft, rlk, rlv, rlright = splay_ n k in
Node (left, key, value, rlleft), rlk, rlv, Node (rlright, rk, rv, rright))
let splay t key =
match t with
| Empty -> t
| Node n -> Node (splay_ n key)
let insert key value t =
(* Splay on the key to move the last node on the search path for
the key to the root of the tree. *)
let t = splay t key in
match t with
| Empty -> Node (Empty, key, value, Empty)
| Node (left, rk, rv, right) ->
if rk = key
then t
else if key > rk
then Node (Node (left, rk, rv, Empty), key, value, right)
else Node (left, key, value, Node (Empty, rk, rv, right))
let remove key t =
let t = splay t key in
match t with
| Empty -> t
| Node (_, rk, _, _) when rk <> key -> raise Not_found
| Node (Empty, _, _, right) -> right
| Node (left, _, _, right) -> (
match splay left key with
| Node (lleft, lk, lv, Empty) -> Node (lleft, lk, lv, right)
| _ -> failwith "remove")
let find key t =
let t = splay t key in
match t with
| Node (_, k, v, _) when k = key -> Some v, t
| _ -> None, t
let rec findMax = function
(* here we do not splay (but that's what the original program does) *)
| Empty -> raise Not_found
| Node (_, k, _, Empty) -> k
| Node (_, _, _, right) -> findMax right
let findGreatestLessThan key t =
(* Splay on the key to move the node with the given key or the last
node on the search path to the top of the tree.
Now the result is either the root node or the greatest node in
the left subtree. *)
let t = splay t key in
match t with
| Empty -> None, t
| Node (_, k, _, _) when k < key -> Some k, t
| Node (Empty, _, _, _) -> None, t
| Node (left, _, _, _) -> Some (findMax left), t
let exportKeys t =
let rec aux l length = function
| Empty -> l, length
| Node (left, k, _, right) ->
let l, length = aux l length right in
aux (k :: l) (length + 1) left
in
aux [] 0 t
let rec generatePayloadTree depth tag =
if depth = 0
then
CLeaf
{ array = [| 0; 1; 2; 3; 4; 5; 6; 7; 8; 9 |]
; string = "String for key " ^ tag ^ " in leaf node"
}
else CNode (generatePayloadTree (depth - 1) tag, generatePayloadTree (depth - 1) tag)
let random =
let seed = ref 49734321 in
let mask_32bit =
match Sys.int_size with
| 31 | 32 -> -1
| _ -> int_of_string "0xffffffff"
in
let l_0xc761c23c = Int64.of_string "0xc761c23c" |> Int64.to_int in
let l_0xd3a2646c = Int64.of_string "0xd3a2646c" |> Int64.to_int in
let l_0xfd7046c5 = Int64.of_string "0xfd7046c5" |> Int64.to_int in
let l_0xb55a4f09 = Int64.of_string "0xb55a4f09" |> Int64.to_int in
fun () ->
(* // Robert Jenkins' 32 bit integer hash function. *)
let s = !seed in
let s = (s + 0x7ed55d16 + (s lsl 12)) land mask_32bit in
let s = s lxor l_0xc761c23c lxor (s lsr 19) in
let s = s + 0x165667b1 + (s lsl 5) in
let s = (s + l_0xd3a2646c) lxor (s lsl 9) in
let s = (s + l_0xfd7046c5 + (s lsl 3)) land mask_32bit in
let s = s lxor l_0xb55a4f09 lxor (s lsr 16) in
seed := s;
float (s land 0xfffffff) /. float 0x10000000
let generateKey = random
let insertNewNode t =
let rec aux t =
let key = generateKey () in
let vo, t = find key t in
match vo with
| None -> key, t
| _ -> aux t
in
let key, t = aux t in
let payload = generatePayloadTree kSplayTreePayloadDepth (string_of_float key) in
key, insert key payload t
let splaySetup () =
let rec aux i t =
if i < kSplayTreeSize then aux (i + 1) (snd (insertNewNode t)) else t
in
aux 0 Empty
let splayTearDown t =
let keys, length = exportKeys t in
(* // Verify that the splay tree has the right size. *)
if length <> kSplayTreeSize then failwith "Splay tree has wrong size";
(* // Verify that the splay tree has sorted, unique keys. *)
match keys with
| [] -> ()
| a :: l ->
ignore
(List.fold_left
(fun b e -> if b >= e then failwith "Splay tree not sorted" else e)
a
l)
let splayRun t =
(* // Replace a few nodes in the splay tree. *)
let rec aux i t =
if i < kSplayTreeModifications
then
let key, t = insertNewNode t in
aux
(i + 1)
(match findGreatestLessThan key t with
| None, t -> remove key t
| Some k, t -> remove k t)
else t
in
aux 0 t
let ( ++ ) a b = b a
let () = splaySetup () ++ splayRun ++ splayTearDown
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/takc.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: takc.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
let rec tak x y z =
if x > y then tak (tak (x - 1) y z) (tak (y - 1) z x) (tak (z - 1) x y) else z
let rec repeat n accu = if n <= 0 then accu else repeat (n - 1) (tak 18 12 6 + accu)
let _ = assert (repeat 2000 0 = 14000)
(*
print_int (repeat 2000); print_newline(); exit 0
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/sources/ml/taku.ml
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: taku.ml 7017 2005-08-12 09:22:04Z xleroy $ *)
let rec tak (x, y, z) =
if x > y then tak (tak (x - 1, y, z), tak (y - 1, z, x), tak (z - 1, x, y)) else z
let rec repeat n accu = if n <= 0 then accu else repeat (n - 1) (tak (18, 12, 6) + accu)
let _ = assert (repeat 2000 0 = 14000)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/stripdebug.ml
|
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Gallium, INRIA Paris *)
(* *)
(* Copyright 2015 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(* Copy a bytecode executable, removing debugging information
and #! header from the copy.
Usage: stripdebug <source file> <dest file>
*)
open Printf
open Misc
module Bytesections : sig
module Name : sig
type raw_name = private string
type t =
| CODE (** bytecode *)
| CRCS (** crcs for modules *)
| DATA (** global data (constant) *)
| DBUG (** debug info *)
| DLLS (** dll names *)
| DLPT (** dll paths *)
| PRIM (** primitives names *)
| RNTM (** The path to the bytecode interpreter (use_runtime mode) *)
| SYMB (** global identifiers *)
| Other of raw_name
end
(** Recording sections written to a bytecode executable file *)
type toc_writer
val init_record : out_channel -> toc_writer
(** Start recording sections from the current position in out_channel *)
val record : toc_writer -> Name.t -> unit
(** Record the current position in the out_channel as the end of
the section with the given name. *)
val write_toc_and_trailer : toc_writer -> unit
(** Write the table of contents and the standard trailer for bytecode
executable files *)
(** Reading sections from a bytecode executable file *)
type section_entry =
{ name : Name.t (** name of the section. *)
; pos : int (** byte offset at which the section starts. *)
; len : int (** length of the section. *)
}
type section_table
exception Bad_magic_number
val read_toc : in_channel -> section_table
(** Read the table of sections from a bytecode executable.
Raise [Bad_magic_number] if magic number doesn't match *)
val all : section_table -> section_entry list
(** Returns all [section_entry] from a [section_table] in increasing
position order. *)
val pos_first_section : section_table -> int
(** Return the position of the beginning of the first section *)
end = struct
module Name = struct
type raw_name = string
type t =
| CODE (** bytecode *)
| CRCS (** crcs for modules *)
| DATA (** global data (constant) *)
| DBUG (** debug info *)
| DLLS (** dll names *)
| DLPT (** dll paths *)
| PRIM (** primitives names *)
| RNTM (** The path to the bytecode interpreter (use_runtime mode) *)
| SYMB (** global identifiers *)
| Other of raw_name
let of_string name =
match name with
| "CODE" -> CODE
| "DLPT" -> DLPT
| "DLLS" -> DLLS
| "DATA" -> DATA
| "PRIM" -> PRIM
| "SYMB" -> SYMB
| "DBUG" -> DBUG
| "CRCS" -> CRCS
| "RNTM" -> RNTM
| name ->
if String.length name <> 4
then invalid_arg "Bytesections.Name.of_string: must be of size 4";
Other name
let to_string = function
| CODE -> "CODE"
| DLPT -> "DLPT"
| DLLS -> "DLLS"
| DATA -> "DATA"
| PRIM -> "PRIM"
| SYMB -> "SYMB"
| DBUG -> "DBUG"
| CRCS -> "CRCS"
| RNTM -> "RNTM"
| Other n -> n
end
type section_entry =
{ name : Name.t
; pos : int
; len : int
}
type section_table =
{ sections : section_entry list
; first_pos : int
}
(* Recording sections *)
type toc_writer =
{ (* List of all sections, in reverse order *)
mutable section_table_rev : section_entry list
; mutable section_prev : int
; outchan : out_channel
}
let init_record outchan : toc_writer =
let pos = pos_out outchan in
{ section_prev = pos; section_table_rev = []; outchan }
let record t name =
let pos = pos_out t.outchan in
if pos < t.section_prev
then invalid_arg "Bytesections.record: out_channel offset moved backward";
let entry = { name; pos = t.section_prev; len = pos - t.section_prev } in
t.section_table_rev <- entry :: t.section_table_rev;
t.section_prev <- pos
let write_toc_and_trailer t =
let section_table = List.rev t.section_table_rev in
List.iter
(fun { name; pos = _; len } ->
let name = Name.to_string name in
assert (String.length name = 4);
output_string t.outchan name;
output_binary_int t.outchan len)
section_table;
output_binary_int t.outchan (List.length section_table);
output_string t.outchan Config.exec_magic_number
(* Read the table of sections from a bytecode executable *)
exception Bad_magic_number
let read_toc ic =
let pos_trailer = in_channel_length ic - 16 in
seek_in ic pos_trailer;
let num_sections = input_binary_int ic in
let header = really_input_string ic (String.length Config.exec_magic_number) in
if header <> Config.exec_magic_number then raise Bad_magic_number;
let toc_pos = pos_trailer - (8 * num_sections) in
seek_in ic toc_pos;
let section_table_rev = ref [] in
for _i = 1 to num_sections do
let name = Name.of_string (really_input_string ic 4) in
let len = input_binary_int ic in
section_table_rev := (name, len) :: !section_table_rev
done;
let first_pos, sections =
List.fold_left
(fun (pos, l) (name, len) ->
let section = { name; pos = pos - len; len } in
pos - len, section :: l)
(toc_pos, [])
!section_table_rev
in
{ sections; first_pos }
let all t = t.sections
let pos_first_section t = t.first_pos
end
let stripdebug infile outfile =
let ic = open_in_bin infile in
let toc = Bytesections.read_toc ic in
let pos_first_section = Bytesections.pos_first_section toc in
let oc =
open_out_gen [ Open_wronly; Open_creat; Open_trunc; Open_binary ] 0o777 outfile
in
(* Skip the #! header, going straight to the first section. *)
seek_in ic pos_first_section;
(* Copy each section except DBUG *)
let writer = Bytesections.init_record oc in
List.iter
(fun { Bytesections.name; pos; len } ->
match name with
| Bytesections.Name.DBUG -> ()
| name ->
seek_in ic pos;
copy_file_chunk ic oc len;
Bytesections.record writer name)
(Bytesections.all toc);
(* Rewrite the toc and trailer *)
Bytesections.write_toc_and_trailer writer;
(* Done *)
close_in ic;
close_out oc
let _ =
if Array.length Sys.argv = 3
then stripdebug Sys.argv.(1) Sys.argv.(2)
else (
eprintf "Usage: stripdebug <source file> <destination file>\n";
exit 2)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/benchmarks/utils/compilation_metrics.ml
|
let compiler = Sys.argv.(1)
let benchmark_name = Sys.argv.(2)
let output = Sys.argv.(3)
let time_re = Str.regexp "^ \\([^ ].*\\): \\([0-9.]+\\)$"
let () =
let times = Hashtbl.create 16 in
let last_line = ref "" in
(try
while true do
let l = read_line () in
(if Str.string_match time_re l 0
then
let nm = Str.matched_group 1 l in
let t = float_of_string (Str.matched_group 2 l) in
Hashtbl.replace times nm (t +. try Hashtbl.find times nm with Not_found -> 0.));
last_line := l
done
with End_of_file -> ());
let file_size =
let file =
match compiler with
| "js_of_ocaml" -> output
| "wasm_of_ocaml" ->
let dir = Filename.chop_suffix output ".js" ^ ".assets" in
let contents = Sys.readdir dir in
let code =
Array.find_opt (fun nm -> Filename.check_suffix nm ".wasm") contents
in
Filename.concat dir (Option.get code)
| _ -> assert false
in
In_channel.(with_open_bin file length)
in
let l = Hashtbl.fold (fun nm v rem -> (nm, v) :: rem) times [] in
let l = List.filter (fun (_, v) -> v > 0.2) l in
let l = List.map (fun (nm, v) -> "Compilation phases/" ^ nm, "s", v) l in
let l' =
Scanf.sscanf !last_line "%f:%f %f" (fun m s mem ->
[ "Compilation time", "s", (m *. 60.) +. s
; "Compilation memory usage", "KiB", mem
; "Code size", "KiB", float (Int64.to_int file_size / 1024)
])
in
Format.printf
{|{ "name": "%s",
"results":
[ { "name": "%s",
"metrics":@.|}
(String.capitalize_ascii compiler)
benchmark_name;
Format.printf " [ @[";
List.iteri
(fun i (nm, u, v) ->
if i > 0 then Format.printf ",@ ";
Format.printf {|{ "name": "%s", "units": "%s", "value": %f }|} nm u v)
(l' @ l);
Format.printf "@] ] } ] }@."
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/build_fs.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Cmdliner
type options =
{ files : string list
; output_file : string
; include_dirs : string list
}
let options =
let files =
let doc = "Embed [$(docv)] in the js_of_ocaml pseudo filesystem." in
Arg.(value & pos_all string [] & info [] ~docv:"FILES" ~doc)
in
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(required & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let include_dirs =
let doc = "Add [$(docv)] to the list of include directories." in
Arg.(value & opt_all string [] & info [ "I" ] ~docv:"DIR" ~doc)
in
Term.(
const (fun files output_file include_dirs -> { files; output_file; include_dirs })
$ files
$ output_file
$ include_dirs)
let f { files; output_file; include_dirs } =
let code =
{|
//Provides: jsoo_create_file_extern
function jsoo_create_file_extern(name,content){
if(globalThis.jsoo_create_file)
globalThis.jsoo_create_file(name,content);
else {
if(!globalThis.jsoo_fs_tmp) globalThis.jsoo_fs_tmp = [];
globalThis.jsoo_fs_tmp.push({name:name,content:content});
}
return 0;
}
|}
in
Config.set_target `JavaScript;
Config.set_effects_backend `Disabled;
let fragments = Linker.Fragment.parse_string code in
Linker.load_fragments ~target_env:Isomorphic ~filename:"<dummy>" fragments;
Linker.check_deps ();
let include_dirs =
List.filter_map (include_dirs @ [ "+stdlib/" ]) ~f:(fun d -> Findlib.find [] d)
in
let instr =
Pseudo_fs.f ~prim:`create_file_extern ~cmis:StringSet.empty ~files ~paths:include_dirs
in
let code = Code.prepend Code.empty instr in
Filename.gen_file output_file (fun chan ->
let pfs_fmt = Pretty_print.to_out_channel chan in
let (_ : Source_map.info * Shape.t StringMap.t) =
Driver.f
~standalone:true
~wrap_with_fun:`Iife
~link:`Needed
~formatter:pfs_fmt
~source_map:false
code
in
())
let info =
Info.make
~name:"build-fs"
~doc:"Js_of_ocaml pseudo filesystem utility"
~description:
"jsoo_fs is a tool for embeding files in a Js_of_ocaml pseudo filesystem."
let command =
let t = Cmdliner.Term.(const f $ options) in
Cmdliner.Cmd.v info t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/build_fs.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val command : unit Cmdliner.Cmd.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/build_runtime.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
let info =
Info.make
~name:"build-runtime"
~doc:"Build standalone runtime. Used for separate compilation."
~description:
"Js_of_ocaml is a compiler from OCaml bytecode to Javascript. It makes it possible \
to run pure OCaml programs in JavaScript environments like web browsers and \
Node.js."
let command =
let t = Cmdliner.Term.(const Compile.run $ Cmd_arg.options_runtime_only) in
Cmdliner.Cmd.v info t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/build_runtime.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val command : unit Cmdliner.Cmd.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/check_runtime.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2021 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
let group_by_snd l =
l
|> List.sort_uniq ~cmp:(fun (n1, l1) (n2, l2) ->
match List.compare ~cmp:String.compare l1 l2 with
| 0 -> String.compare n1 n2
| c -> c)
|> List.group ~f:(fun (_, g1) (_, g2) -> List.equal ~eq:String.equal g1 g2)
let print_groups output l =
List.iter l ~f:(fun group ->
match group with
| [] -> assert false
| (_, loc) :: _ ->
(match loc with
| [] -> ()
| loc ->
output_string
output
(Printf.sprintf "\nFrom %s:\n" (String.concat ~sep:"," loc)));
List.iter group ~f:(fun (name, _) ->
output_string output (Printf.sprintf "%s\n" name)))
let f (runtime_files, bytecode, target_env) =
Config.set_target `JavaScript;
Config.set_effects_backend `Disabled;
Linker.reset ();
let runtime_files, builtin =
List.partition_map runtime_files ~f:(fun name ->
match Builtins.find name with
| Some t -> Right t
| None -> Left name)
in
let builtin =
if false then builtin else Js_of_ocaml_compiler_runtime_files.runtime @ builtin
in
List.iter builtin ~f:(fun t ->
let filename = Builtins.File.name t in
let runtimes = Linker.Fragment.parse_builtin t in
Linker.load_fragments ~target_env ~filename runtimes);
Linker.load_files ~target_env runtime_files;
Linker.check_deps ();
let all_prims =
List.concat_map bytecode ~f:(fun f ->
let ic = open_in_bin f in
let prims =
match Parse_bytecode.from_channel ic with
| `Cmo x -> x.Cmo_format.cu_primitives
| `Cma x ->
List.concat_map
~f:(fun x -> x.Cmo_format.cu_primitives)
x.Cmo_format.lib_units
| `Exe ->
let toc = Parse_bytecode.Toc.read ic in
Parse_bytecode.read_primitives toc ic
in
close_in ic;
List.map ~f:(fun p -> p, f) prims)
in
let _percent_prim, needed =
List.partition all_prims ~f:(fun (x, _) -> Char.equal (String.get x 0) '%')
in
let origin =
List.fold_left
~f:(fun acc (x, y) ->
let l = try StringMap.find x acc with Not_found -> [] in
StringMap.add x (y :: l) acc)
~init:StringMap.empty
needed
in
let needed = StringSet.of_list (List.map ~f:fst needed) in
let needed =
List.fold_left
~f:(fun acc x -> StringSet.remove x acc)
~init:needed
[ (* this list was copied from parse_bytecode *)
"caml_ensure_stack_capacity"
; "caml_process_pending_actions_with_root"
; "caml_make_array"
; "caml_array_of_uniform_array"
]
in
let needed =
(* internal primitives *)
List.fold_left
~f:(fun acc x -> StringSet.add x acc)
~init:needed
[ "caml_register_global"
; "caml_js_set"
; "caml_js_get"
; "caml_get_global_data"
; "caml_oo_cache_id"
; "caml_get_public_method"
; "caml_get_cached_method"
]
in
let from_runtime1 = Linker.list_all () in
let from_runtime2 = Primitive.get_external () in
(* [from_runtime2] is a superset of [from_runtime1].
Extra primitives are registered on the ocaml side (e.g. generate.ml) *)
assert (StringSet.is_empty (StringSet.diff from_runtime1 from_runtime2));
let missing' = StringSet.diff needed from_runtime1 in
let all_used, missing =
let state = Linker.init () in
let state, missing = Linker.resolve_deps state needed in
StringSet.of_list (Linker.all state), missing
in
assert (StringSet.equal missing missing');
let extra = StringSet.diff from_runtime1 all_used |> StringSet.elements in
let extra =
extra
|> List.map ~f:(fun name ->
( (name ^ if Linker.deprecated ~name then " (deprecated)" else "")
, match Linker.origin ~name with
| None -> []
| Some x -> [ x ] ))
|> group_by_snd
in
let missing_for_real =
StringSet.diff missing from_runtime2
|> StringSet.elements
|> List.map ~f:(fun x -> x, StringMap.find x origin)
|> group_by_snd
in
let output = stdout in
set_binary_mode_out output true;
output_string output "Missing\n";
output_string output "-------\n";
print_groups output missing_for_real;
output_string output "\n";
output_string output "Unused\n";
output_string output "-------\n";
print_groups output extra;
output_string output "\n";
()
let options =
let open Cmdliner in
(* TODO: add flags to only display missing or extra primitives *)
let files =
let doc = "Bytecode and JavaScript files [$(docv)]. " in
Arg.(value & pos_all string [] & info [] ~docv:"FILES" ~doc)
in
let build_t files target_env =
let runtime_files, bc_files =
List.partition files ~f:(fun file -> Filename.check_suffix file ".js")
in
`Ok (runtime_files, bc_files, target_env)
in
let target_env =
let doc = "Runtime compile target." in
let options = List.map ~f:(fun env -> Target_env.to_string env, env) Target_env.all in
let docv = Printf.sprintf "{%s}" (String.concat ~sep:"," (List.map ~f:fst options)) in
Arg.(
value & opt (enum options) Target_env.Isomorphic & info [ "target-env" ] ~docv ~doc)
in
let t = Term.(const build_t $ files $ target_env) in
Term.ret t
let info =
Info.make
~name:"check-runtime"
~doc:"Check runtime"
~description:"js_of_ocaml-check-runtime checks the runtime."
let command =
let t = Cmdliner.Term.(const f $ options) in
Cmdliner.Cmd.v info t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/cmd_arg.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2014 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Cmdliner
let is_dir_sep = function
| '/' -> true
| '\\' when String.equal Filename.dir_sep "\\" -> true
| _ -> false
let trim_trailing_dir_sep s =
if String.equal s ""
then s
else
let len = String.length s in
let j = ref (len - 1) in
while !j >= 0 && is_dir_sep (String.unsafe_get s !j) do
decr j
done;
if !j >= 0 then String.sub s ~pos:0 ~len:(!j + 1) else String.sub s ~pos:0 ~len:1
let normalize_include_dirs dirs = List.map dirs ~f:trim_trailing_dir_sep
let normalize_effects (effects : [ `Disabled | `Cps | `Double_translation ] option) common
: Config.effects_backend =
match effects with
| None ->
(* For backward compatibility, consider that [--enable effects] alone means
[--effects cps] *)
if List.mem ~eq:String.equal "effects" common.Jsoo_cmdline.Arg.optim.enable
then `Cps
else `Disabled
| Some ((`Disabled | `Cps | `Double_translation) as e) -> e
type t =
{ common : Jsoo_cmdline.Arg.t
; (* compile option *)
profile : Profile.t option
; source_map : Source_map.Encoding_spec.t option
; runtime_files : string list
; no_runtime : bool
; include_runtime : bool
; output_file : [ `Name of string | `Stdout ] * bool
; bytecode : [ `File of string | `Stdin | `None ]
; params : (string * string) list
; static_env : (string * string) list
; wrap_with_fun : [ `Iife | `Named of string | `Anonymous ]
; target_env : Target_env.t
; shape_files : string list
; (* toplevel *)
dynlink : bool
; linkall : bool
; toplevel : bool
; export_file : string option
; no_cmis : bool
; (* filesystem *)
include_dirs : string list
; fs_files : string list
; fs_output : string option
; fs_external : bool
; keep_unit_names : bool
; effects : Config.effects_backend
}
let set_param =
let doc = "Set compiler options." in
let all = List.map (Config.Param.all ()) ~f:(fun (x, _, _) -> x, x) in
let pair = Arg.(pair ~sep:'=' (enum all) string) in
let parser s =
match Arg.conv_parser pair s with
| Ok (k, v) -> (
match
List.find ~f:(fun (k', _, _) -> String.equal k k') (Config.Param.all ())
with
| _, _, valid -> (
match valid v with
| Ok () -> Ok (k, v)
| Error msg -> Error (`Msg ("Unexpected VALUE after [=], " ^ msg))))
| Error _ as e -> e
in
let printer = Arg.conv_printer pair in
let c = Arg.conv (parser, printer) in
Arg.(value & opt_all (list c) [] & info [ "set" ] ~docv:"PARAM=VALUE" ~doc)
let wrap_with_fun_conv =
let conv s =
if String.equal s ""
then Ok `Anonymous
else if Javascript.is_ident s
then Ok (`Named s)
else Error (`Msg "must be empty or a valid JavaScript identifier")
in
let printer fmt o =
Format.fprintf
fmt
"%s"
(match o with
| `Anonymous -> ""
| `Named s -> s
| `Iife -> "<Immediately Invoked Function Expression>")
in
Arg.conv (conv, printer)
let toplevel_section = "OPTIONS (TOPLEVEL)"
let options =
let filesystem_section = "OPTIONS (FILESYSTEM)" in
let js_files =
let doc =
"Link JavaScript files [$(docv)]. "
^ "One can refer to path relative to Findlib packages with "
^ "the syntax '+pkg_name/file.js'"
in
Arg.(value & pos_left ~rev:true 0 string [] & info [] ~docv:"JS_FILES" ~doc)
in
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(value & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let shape_files =
let doc = "load shape file [$(docv)]." in
Arg.(value & opt_all string [] & info [ "load-shape" ] ~docv:"FILE" ~doc)
in
let input_file =
let doc =
"Compile the bytecode program [$(docv)]. "
^ "Use '-' to read from the standard input instead."
in
Arg.(required & pos ~rev:true 0 (some string) None & info [] ~docv:"PROGRAM" ~doc)
in
let keep_unit_names =
let doc = "Keep unit name" in
Arg.(value & flag & info [ "keep-unit-names" ] ~doc)
in
let profile =
let doc = "Set optimization profile : [$(docv)]." in
let profile =
List.map Profile.all ~f:(fun p -> string_of_int (Profile.to_int p), p)
in
Arg.(value & opt (some (enum profile)) None & info [ "opt" ] ~docv:"NUM" ~doc)
in
let noruntime =
let doc = "Do not include the standard runtime." in
Arg.(value & flag & info [ "noruntime"; "no-runtime" ] ~doc)
in
let include_runtime =
let doc =
"Include (partial) runtime when compiling cmo and cma files to JavaScript."
in
Arg.(value & flag & info [ "include-runtime" ] ~doc)
in
let no_sourcemap =
let doc =
"Don't generate source map. All other source map related flags will be ignored."
in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
let sourcemap =
let doc = "Generate source map." in
Arg.(value & flag & info [ "sourcemap"; "source-map" ] ~doc)
in
let sourcemap_inline_in_js =
let doc = "Inline sourcemap in the generated JavaScript." in
Arg.(value & flag & info [ "source-map-inline" ] ~doc)
in
let sourcemap_don't_inline_content =
let doc = "Do not inline sources in source map." in
Arg.(value & flag & info [ "source-map-no-source" ] ~doc)
in
let sourcemap_empty =
let doc = "Always generate empty source maps." in
Arg.(value & flag & info [ "empty-sourcemap"; "empty-source-map" ] ~doc)
in
let sourcemap_root =
let doc = "root dir for source map." in
Arg.(value & opt (some string) None & info [ "source-map-root" ] ~doc)
in
let wrap_with_function =
let doc =
"Wrap the generated JavaScript code inside a function that needs to be applied \
with the global object."
in
Arg.(value & opt wrap_with_fun_conv `Iife & info [ "wrap-with-fun" ] ~doc)
in
let set_env =
let doc = "Set environment variable statically." in
Arg.(
value
& opt_all (list (pair ~sep:'=' string string)) []
& info [ "setenv" ] ~docv:"PARAM=VALUE" ~doc)
in
let target_env =
let doc = "Runtime compile target." in
let options = List.map ~f:(fun env -> Target_env.to_string env, env) Target_env.all in
let docv = Printf.sprintf "{%s}" (String.concat ~sep:"," (List.map ~f:fst options)) in
Arg.(
value & opt (enum options) Target_env.Isomorphic & info [ "target-env" ] ~docv ~doc)
in
let toplevel =
let doc =
"Compile a toplevel and embed necessary cmis (unless '--no-cmis' is provided). \
Exported compilation units can be configured with '--export'. Note you you'll \
also need to link against js_of_ocaml-toplevel."
in
Arg.(value & flag & info [ "toplevel" ] ~docs:toplevel_section ~doc)
in
let export_file =
let doc =
"File containing the list of unit to export in a toplevel, with Dynlink or with \
--linkall. If absent, all units will be exported."
in
Arg.(value & opt (some string) None & info [ "export" ] ~docs:toplevel_section ~doc)
in
let dynlink =
let doc =
"Enable dynlink of bytecode files. Use this if you want to be able to use the \
Dynlink module. Note that you'll also need to link with \
'js_of_ocaml-compiler.dynlink'."
in
Arg.(value & flag & info [ "dynlink" ] ~doc)
in
let linkall =
let doc =
"Link all primitives and compilation units. Exported compilation units can be \
configured with '--export'."
in
Arg.(value & flag & info [ "linkall" ] ~doc)
in
let no_cmis =
let doc = "Do not include cmis when compiling toplevel." in
Arg.(value & flag & info [ "nocmis"; "no-cmis" ] ~docs:toplevel_section ~doc)
in
let include_dirs =
let doc = "Add [$(docv)] to the list of include directories." in
Arg.(
value & opt_all string [] & info [ "I" ] ~docs:filesystem_section ~docv:"DIR" ~doc)
in
let fs_files =
let doc = "Register [$(docv)] to the pseudo filesystem." in
Arg.(
value
& opt_all string []
& info [ "file" ] ~docs:filesystem_section ~docv:"FILE" ~doc)
in
let fs_external =
Arg.(
value
& vflag
true
[ ( true
, info
[ "extern-fs" ]
~docs:filesystem_section
~doc:
"Configure pseudo-filesystem to allow registering files from outside. \
(default)" )
; ( false
, info
[ "no-extern-fs" ]
~docs:filesystem_section
~doc:
"Configure pseudo-filesystem to NOT allow registering files from \
outside." )
])
in
let fs_output =
let doc = "Output the filesystem to [$(docv)]." in
Arg.(
value
& opt (some string) None
& info [ "ofs" ] ~docs:filesystem_section ~docv:"FILE" ~doc)
in
let effects =
let doc =
"Select an implementation of effect handlers. [$(docv)] should be one of $(b,cps), \
$(b,double-translation) or $(b,disabled) (the default). Effects won't be \
supported if unspecified."
in
Arg.(
value
& opt
(some
(enum
[ "cps", `Cps
; "double-translation", `Double_translation
; "disabled", `Disabled
]))
None
& info [ "effects" ] ~docv:"KIND" ~doc)
in
let build_t
common
set_param
set_env
dynlink
linkall
toplevel
export_file
wrap_with_fun
include_dirs
fs_files
fs_output
fs_external
no_cmis
profile
no_runtime
include_runtime
no_sourcemap
sourcemap
sourcemap_inline_in_js
sourcemap_don't_inline_content
sourcemap_empty
sourcemap_root
target_env
output_file
input_file
js_files
keep_unit_names
effects
shape_files =
let inline_source_content = not sourcemap_don't_inline_content in
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
let runtime_files = js_files in
let fs_external = fs_external || (toplevel && no_cmis) in
let bytecode =
match input_file with
| "-" -> `Stdin
| x -> `File x
in
let output_file =
match output_file with
| Some "-" -> `Stdout, true
| Some s -> `Name s, true
| None -> (
match bytecode with
| `File s -> `Name (chop_extension s ^ ".js"), false
| `Stdin -> `Stdout, false)
in
let source_map =
if (not no_sourcemap) && (sourcemap || sourcemap_inline_in_js)
then
let file, sm_output_file =
match output_file with
| `Name file, _ when sourcemap_inline_in_js -> Some file, None
| `Name file, _ -> Some file, Some (chop_extension file ^ ".map")
| `Stdout, _ -> None, None
in
let source_map =
{ (Source_map.Standard.empty ~inline_source_content) with
file
; sourceroot = sourcemap_root
}
in
let spec =
{ Source_map.Encoding_spec.output_file = sm_output_file
; source_map
; keep_empty = sourcemap_empty
}
in
Some spec
else None
in
let params : (string * string) list = List.flatten set_param in
let static_env : (string * string) list = List.flatten set_env in
let include_dirs = normalize_include_dirs include_dirs in
let effects = normalize_effects effects common in
`Ok
{ common
; params
; profile
; static_env
; wrap_with_fun
; dynlink
; linkall
; target_env
; toplevel
; export_file
; include_dirs
; runtime_files
; no_runtime
; include_runtime
; fs_files
; fs_output
; fs_external
; no_cmis
; output_file
; bytecode
; source_map
; keep_unit_names
; effects
; shape_files
}
in
let t =
Term.(
const build_t
$ Lazy.force Jsoo_cmdline.Arg.t
$ set_param
$ set_env
$ dynlink
$ linkall
$ toplevel
$ export_file
$ wrap_with_function
$ include_dirs
$ fs_files
$ fs_output
$ fs_external
$ no_cmis
$ profile
$ noruntime
$ include_runtime
$ no_sourcemap
$ sourcemap
$ sourcemap_inline_in_js
$ sourcemap_don't_inline_content
$ sourcemap_empty
$ sourcemap_root
$ target_env
$ output_file
$ input_file
$ js_files
$ keep_unit_names
$ effects
$ shape_files)
in
Term.ret t
let options_runtime_only =
let filesystem_section = "OPTIONS (FILESYSTEM)" in
let js_files =
let doc =
"Link JavaScript files [$(docv)]. "
^ "One can refer to path relative to Findlib packages with "
^ "the syntax '+pkg_name/file.js'"
in
Arg.(value & pos_all string [] & info [] ~docv:"JS_FILES" ~doc)
in
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(required & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let noruntime =
let doc = "Do not include the standard runtime." in
Arg.(value & flag & info [ "noruntime"; "no-runtime" ] ~doc)
in
let no_sourcemap =
let doc =
"Don't generate source map. All other source map related flags will be ignored."
in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
let sourcemap =
let doc = "Generate source map." in
Arg.(value & flag & info [ "sourcemap"; "source-map" ] ~doc)
in
let sourcemap_inline_in_js =
let doc = "Inline sourcemap in the generated JavaScript." in
Arg.(value & flag & info [ "source-map-inline" ] ~doc)
in
let sourcemap_don't_inline_content =
let doc = "Do not inline sources in source map." in
Arg.(value & flag & info [ "source-map-no-source" ] ~doc)
in
let sourcemap_empty =
let doc = "Always generate empty source maps." in
Arg.(value & flag & info [ "empty-sourcemap"; "empty-source-map" ] ~doc)
in
let sourcemap_root =
let doc = "root dir for source map." in
Arg.(value & opt (some string) None & info [ "source-map-root" ] ~doc)
in
let toplevel =
let doc =
"Compile a toplevel and embed necessary cmis (unless '--no-cmis' is provided). \
Exported compilation units can be configured with '--export'. Note you you'll \
also need to link against js_of_ocaml-toplevel."
in
Arg.(value & flag & info [ "toplevel" ] ~docs:toplevel_section ~doc)
in
let no_cmis =
let doc = "Do not include cmis when compiling toplevel." in
Arg.(value & flag & info [ "nocmis"; "no-cmis" ] ~docs:toplevel_section ~doc)
in
let target_env =
let doc = "Runtime compile target." in
let options = List.map ~f:(fun env -> Target_env.to_string env, env) Target_env.all in
let docv = Printf.sprintf "{%s}" (String.concat ~sep:"," (List.map ~f:fst options)) in
Arg.(
value & opt (enum options) Target_env.Isomorphic & info [ "target-env" ] ~docv ~doc)
in
let wrap_with_function =
let doc =
"Wrap the generated JavaScript code inside a function that needs to be applied \
with the global object."
in
Arg.(value & opt wrap_with_fun_conv `Iife & info [ "wrap-with-fun" ] ~doc)
in
let set_env =
let doc = "Set environment variable statically." in
Arg.(
value
& opt_all (list (pair ~sep:'=' string string)) []
& info [ "setenv" ] ~docv:"PARAM=VALUE" ~doc)
in
let include_dirs =
let doc = "Add [$(docv)] to the list of include directories." in
Arg.(
value & opt_all string [] & info [ "I" ] ~docs:filesystem_section ~docv:"DIR" ~doc)
in
let fs_files =
let doc = "Register [$(docv)] to the pseudo filesystem." in
Arg.(
value
& opt_all string []
& info [ "file" ] ~docs:filesystem_section ~docv:"FILE" ~doc)
in
let fs_external =
Arg.(
value
& vflag
true
[ ( true
, info
[ "extern-fs" ]
~docs:filesystem_section
~doc:
"Configure pseudo-filesystem to allow registering files from outside. \
(default)" )
; ( false
, info
[ "no-extern-fs" ]
~docs:filesystem_section
~doc:
"Configure pseudo-filesystem to NOT allow registering files from \
outside." )
])
in
let fs_output =
let doc = "Output the filesystem to [$(docv)]." in
Arg.(
value
& opt (some string) None
& info [ "ofs" ] ~docs:filesystem_section ~docv:"FILE" ~doc)
in
let effects =
let doc =
"Select an implementation of effect handlers. [$(docv)] should be one of $(b,cps), \
$(b,double-translation), or $(b,disabled) (the default). Effects won't be \
supported if unspecified."
in
Arg.(
value
& opt
(some
(enum
[ "cps", `Cps
; "double-translation", `Double_translation
; "disabled", `Disabled
]))
None
& info [ "effects" ] ~docv:"KIND" ~doc)
in
let build_t
common
toplevel
no_cmis
set_param
set_env
wrap_with_fun
fs_files
fs_output
fs_external
include_dirs
no_runtime
no_sourcemap
sourcemap
sourcemap_inline_in_js
sourcemap_don't_inline_content
sourcemap_empty
sourcemap_root
target_env
output_file
js_files
effects =
let inline_source_content = not sourcemap_don't_inline_content in
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
let runtime_files = js_files in
let output_file =
match output_file with
| "-" -> `Stdout, true
| s -> `Name s, true
in
let source_map =
if (not no_sourcemap) && (sourcemap || sourcemap_inline_in_js)
then
let file, sm_output_file =
match output_file with
| `Name file, _ when sourcemap_inline_in_js -> Some file, None
| `Name file, _ -> Some file, Some (chop_extension file ^ ".map")
| `Stdout, _ -> None, None
in
let source_map =
{ (Source_map.Standard.empty ~inline_source_content) with
file
; sourceroot = sourcemap_root
}
in
let spec =
{ Source_map.Encoding_spec.output_file = sm_output_file
; source_map
; keep_empty = sourcemap_empty
}
in
Some spec
else None
in
let params : (string * string) list = List.flatten set_param in
let static_env : (string * string) list = List.flatten set_env in
let include_dirs = normalize_include_dirs include_dirs in
let effects = normalize_effects effects common in
`Ok
{ common
; params
; profile = None
; static_env
; wrap_with_fun
; dynlink = false
; linkall = false
; target_env
; toplevel
; export_file = None
; include_dirs
; runtime_files
; no_runtime
; include_runtime = false
; fs_files
; fs_output
; fs_external
; no_cmis
; output_file
; bytecode = `None
; source_map
; keep_unit_names = false
; effects
; shape_files = []
}
in
let t =
Term.(
const build_t
$ Lazy.force Jsoo_cmdline.Arg.t
$ toplevel
$ no_cmis
$ set_param
$ set_env
$ wrap_with_function
$ fs_files
$ fs_output
$ fs_external
$ include_dirs
$ noruntime
$ no_sourcemap
$ sourcemap
$ sourcemap_inline_in_js
$ sourcemap_don't_inline_content
$ sourcemap_empty
$ sourcemap_root
$ target_env
$ output_file
$ js_files
$ effects)
in
Term.ret t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/cmd_arg.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2014 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Js_of_ocaml_compiler
type t =
{ common : Jsoo_cmdline.Arg.t
; (* compile option *)
profile : Profile.t option
; source_map : Source_map.Encoding_spec.t option
; runtime_files : string list
; no_runtime : bool
; include_runtime : bool
; output_file : [ `Name of string | `Stdout ] * bool
; bytecode : [ `File of string | `Stdin | `None ]
; params : (string * string) list
; static_env : (string * string) list
; wrap_with_fun :
[ `Iife (* IIFE stands for Immediately Invoked Function Expression *)
| `Named of string
| `Anonymous
]
; target_env : Target_env.t
; shape_files : string list
; (* toplevel *)
dynlink : bool
; linkall : bool
; toplevel : bool
; export_file : string option
; no_cmis : bool
; (* filesystem *)
include_dirs : string list
; fs_files : string list
; fs_output : string option
; fs_external : bool
; keep_unit_names : bool
; effects : Config.effects_backend
}
val options : t Cmdliner.Term.t
val options_runtime_only : t Cmdliner.Term.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/compile.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
let times = Debug.find "times"
let debug_mem = Debug.find "mem"
let () = Sys.catch_break true
let gen_unit_filename dir u =
Filename.concat dir (Printf.sprintf "%s.js" (Ocaml_compiler.Cmo_format.name u))
let header formatter ~custom_header =
match custom_header with
| None -> ()
| Some c -> Pretty_print.string formatter (c ^ "\n")
let jsoo_header formatter build_info =
Pretty_print.string formatter (Printf.sprintf "%s\n" Global_constant.header);
Pretty_print.string formatter (Build_info.to_string build_info)
let source_map_enabled : Source_map.Encoding_spec.t option -> bool = function
| None -> false
| Some _ -> true
let output_gen
~write_shape
~standalone
~custom_header
~build_info
~(source_map : Source_map.Encoding_spec.t option)
output_file
f =
let f chan k =
let fmt = Pretty_print.to_out_channel chan in
Driver.configure fmt;
if standalone then header ~custom_header fmt;
if Config.Flag.header () then jsoo_header fmt build_info;
let sm = f ~standalone ~shapes:write_shape ~source_map (k, fmt) in
match source_map, sm with
| None, _ | _, None -> ()
| Some { output_file = output; source_map; keep_empty }, Some sm ->
let sm = if keep_empty then Source_map.Standard source_map else sm in
if Debug.find "invariant" () then Source_map.invariant sm;
let urlData =
match output with
| None ->
let data = Source_map.to_string sm in
"data:application/json;base64," ^ Base64.encode_exn data
| Some output_file ->
Source_map.to_file sm output_file;
Filename.basename output_file
in
Pretty_print.newline fmt;
Pretty_print.string fmt (Printf.sprintf "//# sourceMappingURL=%s\n" urlData)
in
match output_file with
| `Stdout -> f stdout `Stdout
| `Name name -> Filename.gen_file name (fun chan -> f chan `File)
let find_source file =
match Builtins.find file with
| Some f -> Some (Source_map.Source_content.create (Builtins.File.content f))
| None ->
if String.equal file Js_output.blackbox_filename
then Some (Source_map.Source_content.create "(* generated code *)")
else if Sys.file_exists file && not (Sys.is_directory file)
then
let content = Fs.read_file file in
Some (Source_map.Source_content.create content)
else None
let sourcemap_section_of_info
~(base : Source_map.Standard.t)
{ Source_map.sources; names; mappings } =
let sources_content =
match base.sources_content with
| None -> None
| Some _ -> Some (List.map ~f:find_source sources)
in
let sources =
List.map sources ~f:(fun filename ->
match Builtins.find filename with
| None -> filename
| Some _ -> Filename.concat "/builtin" filename)
in
let ignore_list =
List.filter sources ~f:(fun filename ->
String.starts_with ~prefix:"/builtin/" filename)
in
let offset, mappings = Source_map.Mappings.encode_with_offset mappings in
let map =
{ (base : Source_map.Standard.t) with
sources
; sources_content
; names
; mappings
; ignore_list
}
in
{ Source_map.Index.offset; map }
let sourcemap_of_infos ~base l =
match base with
| None -> None
| Some (base : Source_map.Standard.t) ->
let sections = List.map l ~f:(sourcemap_section_of_info ~base) in
Some
(Source_map.Index
{ Source_map.Index.version = base.Source_map.Standard.version
; file = base.file
; sections
})
let sourcemap_of_info ~base info = sourcemap_of_infos ~base [ info ]
let run
{ Cmd_arg.common
; profile
; source_map
; runtime_files = runtime_files_from_cmdline
; no_runtime
; bytecode
; output_file
; params
; static_env
; wrap_with_fun
; dynlink
; linkall
; target_env
; toplevel
; no_cmis
; include_dirs
; fs_files
; fs_output
; fs_external
; export_file
; keep_unit_names
; include_runtime
; effects
; shape_files
} =
let source_map_base =
Option.map ~f:(fun spec -> spec.Source_map.Encoding_spec.source_map) source_map
in
let include_cmis = toplevel && not no_cmis in
let custom_header = common.Jsoo_cmdline.Arg.custom_header in
Config.set_target `JavaScript;
Jsoo_cmdline.Arg.eval common;
Config.set_effects_backend effects;
Linker.reset ();
(match output_file with
| `Stdout, _ -> ()
| `Name name, _ when debug_mem () -> Debug.start_profiling name
| `Name _, _ -> ());
List.iter params ~f:(fun (s, v) -> Config.Param.set s v);
List.iter static_env ~f:(fun (s, v) -> Eval.set_static_env s v);
List.iter shape_files ~f:(fun fn -> Shape.Store.load' fn);
let t = Timer.make () in
let include_dirs =
List.filter_map (include_dirs @ [ "+stdlib/" ]) ~f:(fun d -> Findlib.find [] d)
in
let exported_unit =
match export_file with
| None -> None
| Some file ->
if not (Sys.file_exists file)
then failwith (Printf.sprintf "export file %S does not exist" file);
let ic = open_in_text file in
let t = String.Hashtbl.create 17 in
(try
while true do
String.Hashtbl.add t (String.trim (In_channel.input_line_exn ic)) ()
done;
assert false
with End_of_file -> ());
close_in ic;
Some (String.Hashtbl.fold (fun cmi () acc -> cmi :: acc) t [])
in
let runtime_files =
if (not no_runtime) && (toplevel || dynlink)
then
let add_if_absent x l = if List.mem ~eq:String.equal x l then l else x :: l in
runtime_files_from_cmdline
|> add_if_absent "+toplevel.js"
|> add_if_absent "+dynlink.js"
else runtime_files_from_cmdline
in
let runtime_files, builtin =
List.partition_map runtime_files ~f:(fun name ->
match Builtins.find name with
| Some t -> Right t
| None -> Left name)
in
let t1 = Timer.make () in
let builtin =
if no_runtime then builtin else Js_of_ocaml_compiler_runtime_files.runtime @ builtin
in
List.iter builtin ~f:(fun t ->
let filename = Builtins.File.name t in
let runtimes = Linker.Fragment.parse_builtin t in
Linker.load_fragments ~target_env ~filename runtimes);
Linker.load_files ~target_env runtime_files;
Linker.check_deps ();
if times () then Format.eprintf " parsing js: %a@." Timer.print t1;
if times () then Format.eprintf "Start parsing...@.";
let need_debug = Option.is_some source_map || Config.Flag.debuginfo () in
let check_debug (one : Parse_bytecode.one) =
if Option.is_some source_map && Parse_bytecode.Debug.is_empty one.debug
then
Warning.warn
`Missing_debug_event
"'--source-map' is enabled but the bytecode program was compiled with no \
debugging information.\n\
Consider passing '-g' option to ocamlc.\n\
%!"
in
let pseudo_fs_instr prim debug cmis =
let paths =
include_dirs @ StringSet.elements (Parse_bytecode.Debug.paths debug ~units:cmis)
in
Pseudo_fs.f ~prim ~cmis ~files:fs_files ~paths
in
let env_instr () =
List.concat_map static_env ~f:(fun (k, v) ->
Primitive.add_external "caml_set_static_env";
let var_k = Code.Var.fresh () in
let var_v = Code.Var.fresh () in
Code.
[ Let (var_k, Prim (Extern "caml_jsstring_of_string", [ Pc (String k) ]))
; Let (var_v, Prim (Extern "caml_jsstring_of_string", [ Pc (String v) ]))
; Let (Var.fresh (), Prim (Extern "caml_set_static_env", [ Pv var_k; Pv var_v ]))
])
in
let output
(one : Parse_bytecode.one)
~check_sourcemap
~standalone
~shapes
~(source_map : Source_map.Encoding_spec.t option)
~link
output_file =
if check_sourcemap then check_debug one;
let init_pseudo_fs = fs_external && standalone in
let sm, shapes =
match output_file with
| `Stdout, formatter ->
let instr =
List.concat
[ pseudo_fs_instr `create_file one.debug one.cmis
; (if init_pseudo_fs then [ Pseudo_fs.init () ] else [])
; env_instr ()
]
in
let code = Code.prepend one.code instr in
Driver.f
~standalone
~shapes
?profile
~link
~wrap_with_fun
~source_map:(source_map_enabled source_map)
~formatter
code
| `File, formatter ->
let fs_instr1, fs_instr2 =
match fs_output with
| None -> pseudo_fs_instr `create_file one.debug one.cmis, []
| Some _ -> [], pseudo_fs_instr `create_file_extern one.debug one.cmis
in
let instr =
List.concat
[ fs_instr1
; (if init_pseudo_fs then [ Pseudo_fs.init () ] else [])
; env_instr ()
]
in
let code = Code.prepend one.code instr in
let res =
Driver.f
~standalone
~shapes
?profile
~link
~wrap_with_fun
~source_map:(source_map_enabled source_map)
~formatter
code
in
Option.iter fs_output ~f:(fun file ->
Filename.gen_file file (fun chan ->
let instr = fs_instr2 in
let code = Code.prepend Code.empty instr in
let pfs_fmt = Pretty_print.to_out_channel chan in
Driver.f' ~standalone ~link:`Needed ?profile ~wrap_with_fun pfs_fmt code));
res
in
StringMap.iter (fun name shape -> Shape.Store.set ~name shape) shapes;
if times () then Format.eprintf "compilation: %a@." Timer.print t;
sm
in
let output_partial
(cmo : Cmo_format.compilation_unit)
~standalone
~shapes
~source_map
code
((_, fmt) as output_file) =
assert (not standalone);
let uinfo = Unit_info.of_cmo cmo in
Pretty_print.string fmt "\n";
Pretty_print.string fmt (Unit_info.to_string uinfo);
output
code
~check_sourcemap:true
~source_map
~standalone
~shapes
~link:`No
output_file
in
let output_partial_runtime ~standalone ~source_map ((_, fmt) as output_file) =
assert (not standalone);
let primitives, aliases =
let all = Linker.list_all_with_aliases ~from:runtime_files_from_cmdline () in
StringMap.fold
(fun n a (primitives, aliases) ->
let primitives = StringSet.add n primitives in
let aliases = List.map (StringSet.elements a) ~f:(fun a -> a, n) @ aliases in
primitives, aliases)
all
(StringSet.empty, [])
in
let uinfo = Unit_info.of_primitives ~aliases (StringSet.elements primitives) in
Pretty_print.string fmt "\n";
Pretty_print.string fmt (Unit_info.to_string uinfo);
let code =
{ Parse_bytecode.code = Code.empty
; cmis = StringSet.empty
; debug = Parse_bytecode.Debug.default_summary
}
in
output
code
~check_sourcemap:false
~source_map
~standalone
~link:(`All_from runtime_files_from_cmdline)
output_file
in
(match bytecode with
| `None ->
let primitives, aliases =
let all = Linker.list_all_with_aliases () in
StringMap.fold
(fun n a (primitives, aliases) ->
let primitives = StringSet.add n primitives in
let aliases = List.map (StringSet.elements a) ~f:(fun a -> a, n) @ aliases in
primitives, aliases)
all
(StringSet.empty, [])
in
let primitives = StringSet.elements primitives in
assert (List.length primitives > 0);
let code, uinfo = Parse_bytecode.predefined_exceptions () in
let uinfo = Unit_info.union uinfo (Unit_info.of_primitives ~aliases primitives) in
let code : Parse_bytecode.one =
{ code; cmis = StringSet.empty; debug = Parse_bytecode.Debug.default_summary }
in
output_gen
~write_shape:false
~standalone:true
~custom_header
~build_info:(Build_info.create `Runtime)
~source_map
(fst output_file)
(fun ~standalone ~shapes ~source_map ((_, fmt) as output_file) ->
Pretty_print.string fmt "\n";
Pretty_print.string fmt (Unit_info.to_string uinfo);
output
code
~check_sourcemap:false
~source_map
~standalone
~shapes
~link:`All
output_file
|> sourcemap_of_info ~base:source_map_base)
| (`Stdin | `File _) as bytecode ->
let kind, ic, close_ic, include_dirs =
match bytecode with
| `Stdin -> Parse_bytecode.from_channel stdin, stdin, (fun () -> ()), include_dirs
| `File fn ->
let ch = open_in_bin fn in
let res = Parse_bytecode.from_channel ch in
let include_dirs = Filename.dirname fn :: include_dirs in
res, ch, (fun () -> close_in ch), include_dirs
in
(match kind with
| `Exe ->
let t1 = Timer.make () in
(* The OCaml compiler can generate code using the
"caml_string_greaterthan" primitive but does not use it
itself. This is (was at some point at least) the only primitive
in this case. Ideally, Js_of_ocaml should parse the .mli files
for primitives as well as marking this primitive as potentially
used. But the -linkall option is probably good enough. *)
let linkall = linkall || toplevel || dynlink in
let code =
Parse_bytecode.from_exe
~includes:include_dirs
~include_cmis
~link_info:(toplevel || dynlink)
~linkall
?exported_unit
~debug:need_debug
ic
in
if times () then Format.eprintf " parsing: %a@." Timer.print t1;
output_gen
~write_shape:false
~standalone:true
~custom_header
~build_info:(Build_info.create `Exe)
~source_map
(fst output_file)
(fun ~standalone ~shapes ~source_map output_file ->
output
code
~check_sourcemap:true
~standalone
~shapes
~source_map
~link:(if linkall then `All else `Needed)
output_file
|> sourcemap_of_info ~base:source_map_base)
| `Cmo cmo ->
let output_file =
match output_file, keep_unit_names with
| (`Stdout, false), true -> `Name (gen_unit_filename "./" cmo)
| (`Name x, false), true -> `Name (gen_unit_filename (Filename.dirname x) cmo)
| (`Stdout, _), false -> `Stdout
| (`Name x, _), false -> `Name x
| (`Name x, true), true
when String.length x > 0 && Char.equal x.[String.length x - 1] '/' ->
`Name (gen_unit_filename x cmo)
| (`Name _, true), true | (`Stdout, true), true ->
failwith "use [-o dirname/] or remove [--keep-unit-names]"
in
let t1 = Timer.make () in
let code =
Parse_bytecode.from_cmo
~includes:include_dirs
~include_cmis
~debug:need_debug
cmo
ic
in
if times () then Format.eprintf " parsing: %a@." Timer.print t1;
output_gen
~write_shape:true
~standalone:false
~custom_header
~build_info:(Build_info.create `Cmo)
~source_map
output_file
(fun ~standalone ~shapes ~source_map output ->
match include_runtime with
| true ->
let sm1 =
output_partial_runtime ~standalone ~shapes ~source_map output
in
let sm2 =
output_partial cmo code ~standalone ~shapes ~source_map output
in
sourcemap_of_infos ~base:source_map_base [ sm1; sm2 ]
| false ->
output_partial cmo code ~standalone ~shapes ~source_map output
|> sourcemap_of_info ~base:source_map_base)
| `Cma cma when keep_unit_names ->
(if include_runtime
then
let output_file =
let gen dir = Filename.concat dir "runtime.js" in
match output_file with
| `Stdout, false -> gen "./"
| `Name x, false -> gen (Filename.dirname x)
| `Name x, true
when String.length x > 0 && Char.equal x.[String.length x - 1] '/' ->
gen x
| `Stdout, true | `Name _, true ->
failwith "use [-o dirname/] or remove [--keep-unit-names]"
in
output_gen
~write_shape:false
~standalone:false
~custom_header
~build_info:(Build_info.create `Runtime)
~source_map
(`Name output_file)
(fun ~standalone ~shapes ~source_map output ->
output_partial_runtime ~standalone ~shapes ~source_map output
|> sourcemap_of_info ~base:source_map_base));
List.iter cma.lib_units ~f:(fun cmo ->
let output_file =
match output_file with
| `Stdout, false -> gen_unit_filename "./" cmo
| `Name x, false -> gen_unit_filename (Filename.dirname x) cmo
| `Name x, true
when String.length x > 0 && Char.equal x.[String.length x - 1] '/' ->
gen_unit_filename x cmo
| `Stdout, true | `Name _, true ->
failwith "use [-o dirname/] or remove [--keep-unit-names]"
in
let t1 = Timer.make () in
let code =
Parse_bytecode.from_cmo
~includes:include_dirs
~include_cmis
~debug:need_debug
cmo
ic
in
if times ()
then
Format.eprintf
" parsing: %a (%s)@."
Timer.print
t1
(Ocaml_compiler.Cmo_format.name cmo);
output_gen
~write_shape:true
~standalone:false
~custom_header
~build_info:(Build_info.create `Cma)
~source_map
(`Name output_file)
(fun ~standalone ~shapes ~source_map output ->
output_partial ~standalone ~shapes ~source_map cmo code output
|> sourcemap_of_info ~base:source_map_base))
| `Cma cma ->
let f ~standalone ~shapes ~source_map output =
(* Always compute shapes because it can be used by other units of the cma *)
let shapes = shapes || true in
let runtime =
if not include_runtime
then None
else Some (output_partial_runtime ~standalone ~shapes ~source_map output)
in
let units =
List.map cma.lib_units ~f:(fun cmo ->
let t1 = Timer.make () in
let code =
Parse_bytecode.from_cmo
~includes:include_dirs
~include_cmis
~debug:need_debug
cmo
ic
in
if times ()
then
Format.eprintf
" parsing: %a (%s)@."
Timer.print
t1
(Ocaml_compiler.Cmo_format.name cmo);
output_partial ~standalone ~shapes ~source_map cmo code output)
in
let sm =
match runtime with
| None -> units
| Some x -> x :: units
in
sourcemap_of_infos ~base:source_map_base sm
in
output_gen
~write_shape:true
~standalone:false
~custom_header
~build_info:(Build_info.create `Cma)
~source_map
(fst output_file)
f);
close_ic ());
Debug.stop_profiling ()
let info name =
Info.make
~name
~doc:"Js_of_ocaml compiler"
~description:
"Js_of_ocaml is a compiler from OCaml bytecode to Javascript. It makes it possible \
to run pure OCaml programs in JavaScript environments like web browsers and \
Node.js."
let term = Cmdliner.Term.(const run $ Cmd_arg.options)
let command =
let t = Cmdliner.Term.(const run $ Cmd_arg.options) in
Cmdliner.Cmd.v (info "compile") t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/compile.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val run : Cmd_arg.t -> unit
val command : unit Cmdliner.Cmd.t
val term : unit Cmdliner.Term.t
val info : string -> Cmdliner.Cmd.info
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/dune
|
(executable
(name js_of_ocaml)
(public_name js_of_ocaml)
(package js_of_ocaml-compiler)
(libraries
jsoo_cmdline
js_of_ocaml-compiler
cmdliner
compiler-libs.common
js_of_ocaml-compiler.runtime-files
(select
findlib_support.ml
from
;; Only link js_of_ocaml-compiler.findlib-support if it exists
(js_of_ocaml-compiler.findlib-support -> findlib_support.empty.ml)
(-> findlib_support.empty.ml)))
(modes
byte
(best exe))
(flags
(:standard -safe-string)))
(rule
(targets js_of_ocaml.1)
(action
(with-stdout-to
%{targets}
(run %{bin:js_of_ocaml} --help=groff))))
(rule
(targets js_of_ocaml-link.1)
(action
(with-stdout-to
%{targets}
(run %{bin:js_of_ocaml} link --help=groff))))
(rule
(targets js_of_ocaml-build-fs.1)
(action
(with-stdout-to
%{targets}
(run %{bin:js_of_ocaml} build-fs --help=groff))))
(rule
(targets js_of_ocaml-build-runtime.1)
(action
(with-stdout-to
%{targets}
(run %{bin:js_of_ocaml} build-runtime --help=groff))))
(install
(section man)
(package js_of_ocaml-compiler)
(files
js_of_ocaml.1
js_of_ocaml-link.1
js_of_ocaml-build-fs.1
js_of_ocaml-build-runtime.1))
;; Generate and install runtime.js for compatibility reasons
(rule
(target runtime.js)
(action
(with-stdout-to
%{target}
(run %{bin:js_of_ocaml} print-standard-runtime))))
(install
(section lib)
(package js_of_ocaml-compiler)
(files runtime.js))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/findlib_support.empty.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/info.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Js_of_ocaml_compiler
open Cmdliner
let make ~name ~doc ~description =
let man =
[ `S "DESCRIPTION"
; `P description
; `S "BUGS"
; `P
"Bugs are tracked on github at \
$(i,https://github.com/ocsigen/js_of_ocaml/issues)."
; `S "SEE ALSO"
; `P "ocaml(1)"
; `S "AUTHORS"
; `P "Jerome Vouillon, Hugo Heuzard."
; `S "LICENSE"
; `P "Copyright (C) 2010-2020."
; `P
"js_of_ocaml is free software, you can redistribute it and/or modify it under \
the terms of the GNU Lesser General Public License as published by the Free \
Software Foundation, with linking exception; either version 2.1 of the License, \
or (at your option) any later version."
]
in
let version =
match Compiler_version.git_version with
| "" -> Compiler_version.s
| v -> Printf.sprintf "%s+%s" Compiler_version.s v
in
Cmd.info name ~version ~doc ~man
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/info.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val make : name:string -> doc:string -> description:string -> Cmdliner.Cmd.info
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/js_of_ocaml.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2010 Jérôme Vouillon
* Laboratoire PPS - CNRS Université Paris Diderot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
let () =
Sys.catch_break true;
let argv = Sys.argv in
let argv =
let like_arg x = String.length x > 0 && Char.equal x.[0] '-' in
let like_command x =
String.length x > 0
&& (not (Char.equal x.[0] '-'))
&& String.for_all x ~f:(function
| 'a' .. 'z' | 'A' .. 'Z' | '-' -> true
| _ -> false)
in
match Array.to_list argv with
| exe :: maybe_command :: rest ->
if like_command maybe_command || like_arg maybe_command
then argv
else
(* Keep compatibility with js_of_ocaml < 3.6.0 *)
Array.of_list (exe :: Cmdliner.Cmd.name Compile.command :: maybe_command :: rest)
| _ -> argv
in
try
match
Cmdliner.Cmd.eval_value
~catch:false
~argv
(Cmdliner.Cmd.group
~default:Compile.term
(Compile.info "js_of_ocaml")
[ Link.command
; Build_fs.command
; Build_runtime.command
; Print_runtime.command
; Check_runtime.command
; Compile.command
])
with
| Ok (`Ok () | `Help | `Version) ->
Warning.process_warnings ();
exit 0
| Error `Term -> exit 1
| Error `Parse -> exit Cmdliner.Cmd.Exit.cli_error
| Error `Exn -> ()
(* should not happen *)
with
| (Match_failure _ | Assert_failure _ | Not_found) as exc ->
let backtrace = Printexc.get_backtrace () in
Format.eprintf
"%s: You found a bug. Please report it at \
https://github.com/ocsigen/js_of_ocaml/issues :@."
Sys.argv.(0);
Format.eprintf "Error: %s@." (Printexc.to_string exc);
prerr_string backtrace;
exit Cmdliner.Cmd.Exit.internal_error
| Magic_number.Bad_magic_number s ->
Format.eprintf "%s: Error: Not an ocaml bytecode file@." Sys.argv.(0);
Format.eprintf "%s: Error: Invalid magic number %S@." Sys.argv.(0) s;
exit 1
| Magic_number.Bad_magic_version h ->
Format.eprintf "%s: Error: Bytecode version mismatch.@." Sys.argv.(0);
let k =
match Magic_number.kind h with
| (`Cmo | `Cma | `Exe) as x -> x
| `Other _ -> assert false
in
let comp =
if Magic_number.compare h (Magic_number.current k) < 0
then "an older"
else "a newer"
in
Format.eprintf
"%s: Error: Your ocaml bytecode and the js_of_ocaml compiler have to be compiled \
with the same version of ocaml.@."
Sys.argv.(0);
Format.eprintf
"%s: Error: The Js_of_ocaml compiler has been compiled with ocaml version %s.@."
Sys.argv.(0)
Sys.ocaml_version;
Format.eprintf
"%s: Error: Its seems that your ocaml bytecode has been compiled with %s version \
of ocaml.@."
Sys.argv.(0)
comp;
exit 1
| Failure s ->
let backtrace = Printexc.get_backtrace () in
Format.eprintf "%s: Error: %s@." Sys.argv.(0) s;
prerr_string backtrace;
exit 1
| exc ->
let backtrace = Printexc.get_backtrace () in
Format.eprintf "%s: Error: %s@." Sys.argv.(0) (Printexc.to_string exc);
prerr_string backtrace;
exit 1
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/js_of_ocaml.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/link.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Cmdliner
type t =
{ common : Jsoo_cmdline.Arg.t
; source_map : Source_map.Encoding_spec.t option
; js_files : string list
; output_file : string option
; resolve_sourcemap_url : bool
; linkall : bool
; mklib : bool
; toplevel : bool
}
let options =
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(value & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let no_sourcemap =
let doc =
"Don't generate source map. All other source map related flags will be ignored."
in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
let sourcemap =
let doc = "Generate source map." in
Arg.(value & flag & info [ "sourcemap"; "source-map" ] ~doc)
in
let sourcemap_inline_in_js =
let doc = "Inline sourcemap in the generated JavaScript." in
Arg.(value & flag & info [ "source-map-inline" ] ~doc)
in
let sourcemap_empty =
let doc = "Always generate empty source maps." in
Arg.(value & flag & info [ "empty-sourcemap"; "empty-source-map" ] ~doc)
in
let sourcemap_root =
let doc = "root dir for source map." in
Arg.(value & opt (some string) None & info [ "source-map-root" ] ~doc)
in
let resolve_sourcemap_url =
let doc = "Resolve source map url." in
Arg.(value & opt bool false & info [ "resolve-sourcemap-url" ] ~doc)
in
let js_files =
let doc = "Link JavaScript files [$(docv)]." in
Arg.(value & pos_all string [] & info [] ~docv:"JS_FILES" ~doc)
in
let linkall =
let doc = "Link all compilation units." in
Arg.(value & flag & info [ "linkall" ] ~doc)
in
let mklib =
let doc =
"Build a library (.cma.js file) with the js files (.cmo.js files) given on the \
command line. Similar to ocamlc -a."
in
Arg.(value & flag & info [ "a" ] ~doc)
in
let toplevel =
let doc = "Compile a toplevel." in
Arg.(value & flag & info [ "toplevel" ] ~doc)
in
let build_t
common
no_sourcemap
sourcemap
sourcemap_inline_in_js
sourcemap_empty
sourcemap_root
output_file
resolve_sourcemap_url
js_files
linkall
mklib
toplevel =
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
let source_map =
if (not no_sourcemap) && (sourcemap || sourcemap_inline_in_js)
then
let file, sm_output_file =
match output_file with
| Some file when sourcemap_inline_in_js -> Some file, None
| Some file -> Some file, Some (chop_extension file ^ ".map")
| None -> None, None
in
let source_map =
{ (Source_map.Standard.empty ~inline_source_content:true) with
file
; sourceroot = sourcemap_root
}
in
let spec =
{ Source_map.Encoding_spec.output_file = sm_output_file
; source_map
; keep_empty = sourcemap_empty
}
in
Some spec
else None
in
`Ok
{ common
; output_file
; js_files
; source_map
; resolve_sourcemap_url
; linkall
; mklib
; toplevel
}
in
let t =
Term.(
const build_t
$ Lazy.force Jsoo_cmdline.Arg.t
$ no_sourcemap
$ sourcemap
$ sourcemap_inline_in_js
$ sourcemap_empty
$ sourcemap_root
$ output_file
$ resolve_sourcemap_url
$ js_files
$ linkall
$ mklib
$ toplevel)
in
Term.ret t
let f
{ common
; output_file
; source_map
; resolve_sourcemap_url
; js_files
; linkall
; mklib
; toplevel
} =
Config.set_target `JavaScript;
Jsoo_cmdline.Arg.eval common;
Linker.reset ();
let with_output f =
match output_file with
| None -> f stdout
| Some file -> Filename.gen_file file f
in
with_output (fun output ->
Link_js.link
~output
~linkall
~mklib
~toplevel
~files:js_files
~source_map
~resolve_sourcemap_url)
let info =
Info.make
~name:"link"
~doc:"Js_of_ocaml linker"
~description:
"js_of_ocaml-link is a JavaScript linker. It can concatenate multiple JavaScript \
files keeping sourcemap information."
let command =
let t = Cmdliner.Term.(const f $ options) in
Cmdliner.Cmd.v info t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/link.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val command : unit Cmdliner.Cmd.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/print_runtime.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
let f () =
let output = stdout in
let new_line () = output_string output "\n" in
List.iter Js_of_ocaml_compiler_runtime_files.runtime ~f:(fun x ->
output_string output (Printf.sprintf "//# 1 %S" (Builtins.File.name x));
new_line ();
output_string output (Builtins.File.content x);
new_line ())
let info =
Info.make
~name:"print-standard-runtime"
~doc:"Print standard runtime to stdout"
~description:"js_of_ocaml-print-standard-runtime dump the standard runtime to stdout."
let command =
let t = Cmdliner.Term.(const f $ const ()) in
Cmdliner.Cmd.v info t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-js_of_ocaml/print_runtime.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val command : unit Cmdliner.Cmd.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-jsoo_minify/cmd_arg.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2014 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Cmdliner
type t =
{ common : Jsoo_cmdline.Arg.t
; (* minify option *)
use_stdin : bool
; output_file : string option
; files : string list
}
let options =
let files = Arg.(value & pos_all file [] & info [] ~docv:"JS_FILES") in
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(value & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let use_stdin =
let doc = "Read from standard input." in
Arg.(value & flag & info [ "stdin" ] ~doc)
in
let build_t common files output_file use_stdin =
`Ok { common; use_stdin; output_file; files }
in
let t =
Term.(const build_t $ Lazy.force Jsoo_cmdline.Arg.t $ files $ output_file $ use_stdin)
in
Term.ret t
let info =
let doc = "JavaScript minifier" in
let man =
[ `S "DESCRIPTION"
; `P "jsoo_minify is a JavaScript minifier."
; `S "BUGS"
; `P
"Bugs are tracked on github at \
$(i,https://github.com/ocsigen/js_of_ocaml/issues)."
; `S "SEE ALSO"
; `P "js_of_ocaml(1)"
; `S "AUTHORS"
; `P "Jerome Vouillon, Hugo Heuzard."
; `S "LICENSE"
; `P "Copyright (C) 2010-2019."
; `P
"jsoo_minify is free software, you can redistribute it and/or modify it under \
the terms of the GNU Lesser General Public License as published by the Free \
Software Foundation, with linking exception; either version 2.1 of the License, \
or (at your option) any later version."
]
in
let version =
match Compiler_version.git_version with
| "" -> Compiler_version.s
| v -> Printf.sprintf "%s+%s" Compiler_version.s v
in
Cmd.info "jsoo_minify" ~version ~doc ~man
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-jsoo_minify/cmd_arg.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2014 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
type t =
{ common : Jsoo_cmdline.Arg.t
; (* minify option *)
use_stdin : bool
; output_file : string option
; files : string list
}
val options : t Cmdliner.Term.t
val info : Cmdliner.Cmd.info
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/compiler/bin-jsoo_minify/dune
|
(executable
(name jsoo_minify)
(public_name jsoo_minify)
(package js_of_ocaml-compiler)
(libraries jsoo_cmdline js_of_ocaml-compiler cmdliner compiler-libs.common)
(flags
(:standard -safe-string)))
(rule
(targets jsoo_minify.1)
(action
(with-stdout-to
%{targets}
(run %{bin:jsoo_minify} --help=groff))))
(install
(section man)
(package js_of_ocaml-compiler)
(files jsoo_minify.1))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-jsoo_minify/jsoo_minify.ml
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2013 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
let error k = Format.ksprintf (fun s -> failwith s) k
let () = Sys.catch_break true
let f { Cmd_arg.common; output_file; use_stdin; files } =
Jsoo_cmdline.Arg.eval common;
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
let with_output f =
match output_file with
| Some "-" -> f stdout
| None when use_stdin -> f stdout
| None | Some _ ->
let file =
match output_file with
| Some f -> f
| None ->
if List.length files = 1
then chop_extension (List.hd files) ^ ".min.js"
else "a.min.js"
in
Filename.gen_file file f
in
let gen pp =
let pretty = Config.Flag.pretty () in
Pretty_print.set_compact pp (not pretty);
let error_of_pi pi =
match pi with
| { Parse_info.name = Some src; line; col; _ }
| { Parse_info.src = Some src; line; col; _ } ->
error "error at file:%S l:%d col:%d" src line col
| { Parse_info.src = None; name = None; line; col; _ } ->
error "error at l:%d col:%d" line col
in
let p =
List.flatten
(List.map files ~f:(fun file ->
let lex = Parse_js.Lexer.of_file file in
try Parse_js.parse lex with Parse_js.Parsing_error pi -> error_of_pi pi))
in
let p =
if use_stdin
then
let lex = Parse_js.Lexer.of_channel stdin in
try p @ Parse_js.parse lex with Parse_js.Parsing_error pi -> error_of_pi pi
else p
in
let true_ () = true in
let open Config in
let passes : ((unit -> bool) * (unit -> Js_traverse.mapper)) list =
[ ( Flag.shortvar
, fun () -> (new Js_traverse.rename_variable ~esm:false :> Js_traverse.mapper) )
; (true_, fun () -> new Js_traverse.simpl)
; (true_, fun () -> new Js_traverse.clean)
]
in
let p =
List.fold_left passes ~init:p ~f:(fun p (t, m) ->
if t () then (m ())#program p else p)
in
let p = Js_assign.program p in
let (_ : Source_map.info) = Js_output.program pp p in
()
in
with_output (fun out_channel ->
let pp = Pretty_print.to_out_channel out_channel in
gen pp)
let main =
let t = Cmdliner.Term.(const f $ Cmd_arg.options) in
Cmdliner.Cmd.v Cmd_arg.info t
let (_ : int) =
try Cmdliner.Cmd.eval ~catch:false ~argv:Sys.argv main with
| (Match_failure _ | Assert_failure _ | Not_found) as exc ->
let backtrace = Printexc.get_backtrace () in
Format.eprintf
"%s: You found a bug. Please report it at \
https://github.com/ocsigen/js_of_ocaml/issues :@."
Sys.argv.(0);
Format.eprintf "Error: %s@." (Printexc.to_string exc);
prerr_string backtrace;
exit 1
| Failure s ->
Format.eprintf "%s: Error: %s@." Sys.argv.(0) s;
exit 1
| exc ->
Format.eprintf "%s: Error: %s@." Sys.argv.(0) (Printexc.to_string exc);
exit 1
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-jsoo_minify/jsoo_minify.mli
|
(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2020 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/build_runtime.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
let info =
Info.make
~name:"build-runtime"
~doc:"Build standalone runtime. Used for separate compilation."
~description:"Wasm_of_ocaml is a compiler from OCaml bytecode to WebAssembly."
let command =
let t = Cmdliner.Term.(const Compile.run $ Cmd_arg.options_runtime_only ()) in
Cmdliner.Cmd.v info t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/build_runtime.mli
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val command : unit Cmdliner.Cmd.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/cmd_arg.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Cmdliner
let is_dir_sep = function
| '/' -> true
| '\\' when String.equal Filename.dir_sep "\\" -> true
| _ -> false
let trim_trailing_dir_sep s =
if String.equal s ""
then s
else
let len = String.length s in
let j = ref (len - 1) in
while !j >= 0 && is_dir_sep (String.unsafe_get s !j) do
decr j
done;
if !j >= 0 then String.sub s ~pos:0 ~len:(!j + 1) else String.sub s ~pos:0 ~len:1
let normalize_include_dirs dirs = List.map dirs ~f:trim_trailing_dir_sep
let normalize_effects (effects : [ `Disabled | `Cps | `Jspi ] option) common :
Config.effects_backend =
match effects with
| None ->
(* For backward compatibility, consider that [--enable effects] alone means
[--effects cps] *)
if List.mem ~eq:String.equal "effects" common.Jsoo_cmdline.Arg.optim.enable
then `Cps
else `Jspi
| Some ((`Disabled | `Cps | `Jspi) as e) -> e
type t =
{ common : Jsoo_cmdline.Arg.t
; (* compile option *)
profile : Profile.t option
; runtime_files : string list
; runtime_only : bool
; output_file : string * bool
; input_file : string option
; enable_source_maps : bool
; sourcemap_root : string option
; sourcemap_don't_inline_content : bool
; params : (string * string) list
; include_dirs : string list
; effects : Config.effects_backend
; shape_files : string list
}
let set_param =
let doc = "Set compiler options." in
let all = List.map (Config.Param.all ()) ~f:(fun (x, _, _) -> x, x) in
let pair = Arg.(pair ~sep:'=' (enum all) string) in
let parser s =
match Arg.conv_parser pair s with
| Ok (k, v) -> (
match
List.find ~f:(fun (k', _, _) -> String.equal k k') (Config.Param.all ())
with
| _, _, valid -> (
match valid v with
| Ok () -> Ok (k, v)
| Error msg -> Error (`Msg ("Unexpected VALUE after [=], " ^ msg))))
| Error _ as e -> e
in
let printer = Arg.conv_printer pair in
let c = Arg.conv (parser, printer) in
Arg.(value & opt_all (list c) [] & info [ "set" ] ~docv:"PARAM=VALUE" ~doc)
let options () =
let runtime_files =
let doc = "Link JavaScript and WebAssembly files [$(docv)]. " in
Arg.(value & pos_left ~rev:true 0 string [] & info [] ~docv:"RUNTIME_FILES" ~doc)
in
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(value & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let input_file =
let doc = "Compile the bytecode program [$(docv)]. " in
Arg.(required & pos ~rev:true 0 (some string) None & info [] ~docv:"PROGRAM" ~doc)
in
let shape_files =
let doc = "load shape file [$(docv)]." in
Arg.(value & opt_all string [] & info [ "load-shape" ] ~docv:"FILE" ~doc)
in
let profile =
let doc = "Set optimization profile : [$(docv)]." in
let profile =
List.map Profile.all ~f:(fun p -> string_of_int (Profile.to_int p), p)
in
Arg.(value & opt (some (enum profile)) None & info [ "opt" ] ~docv:"NUM" ~doc)
in
let linkall =
let doc = "Currently ignored (for compatibility with Js_of_ocaml)." in
Arg.(value & flag & info [ "linkall" ] ~doc)
in
let no_sourcemap =
let doc = "Disable sourcemap output." in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
let sourcemap =
let doc = "Output source locations." in
Arg.(value & flag & info [ "sourcemap"; "source-map"; "source-map-inline" ] ~doc)
in
let sourcemap_don't_inline_content =
let doc = "Do not inline sources in source map." in
Arg.(value & flag & info [ "source-map-no-source" ] ~doc)
in
let sourcemap_root =
let doc = "root dir for source map." in
Arg.(value & opt (some string) None & info [ "source-map-root" ] ~doc)
in
let include_dirs =
let doc = "Add [$(docv)] to the list of include directories." in
Arg.(value & opt_all string [] & info [ "I" ] ~docv:"DIR" ~doc)
in
let effects =
let doc =
"Select an implementation of effect handlers. [$(docv)] should be one of $(b,jspi) \
(the default), $(b,cps), or $(b,disabled)."
in
Arg.(
value
& opt (some (enum [ "jspi", `Jspi; "cps", `Cps; "disabled", `Disabled ])) None
& info [ "effects" ] ~docv:"KIND" ~doc)
in
let build_t
common
set_param
include_dirs
profile
_
sourcemap
no_sourcemap
sourcemap_don't_inline_content
sourcemap_root
output_file
input_file
runtime_files
effects
shape_files =
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
let output_file =
let ext =
try
snd
(List.find
~f:(fun (ext, _) -> Filename.check_suffix input_file ext)
[ ".cmo", ".wasmo"; ".cma", ".wasma" ])
with Not_found -> ".js"
in
match output_file with
| Some s -> s, true
| None -> chop_extension input_file ^ ext, false
in
let params : (string * string) list = List.flatten set_param in
let enable_source_maps = (not no_sourcemap) && sourcemap in
let include_dirs = normalize_include_dirs include_dirs in
let effects = normalize_effects effects common in
`Ok
{ common
; params
; include_dirs
; profile
; output_file
; input_file = Some input_file
; runtime_files
; runtime_only = false
; enable_source_maps
; sourcemap_root
; sourcemap_don't_inline_content
; effects
; shape_files
}
in
let t =
Term.(
const build_t
$ Lazy.force Jsoo_cmdline.Arg.t
$ set_param
$ include_dirs
$ profile
$ linkall
$ sourcemap
$ no_sourcemap
$ sourcemap_don't_inline_content
$ sourcemap_root
$ output_file
$ input_file
$ runtime_files
$ effects
$ shape_files)
in
Term.ret t
let options_runtime_only () =
let runtime_files =
let doc = "Link JavaScript and WebAssembly files [$(docv)]. " in
Arg.(value & pos_all string [] & info [] ~docv:"RUNTIME_FILES" ~doc)
in
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(required & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let no_sourcemap =
let doc =
"Don't generate source map. All other source map related flags will be ignored."
in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
let sourcemap =
let doc = "Generate source map." in
Arg.(value & flag & info [ "sourcemap"; "source-map"; "source-map-inline" ] ~doc)
in
let sourcemap_don't_inline_content =
let doc = "Do not inline sources in source map." in
Arg.(value & flag & info [ "source-map-no-source" ] ~doc)
in
let sourcemap_root =
let doc = "root dir for source map." in
Arg.(value & opt (some string) None & info [ "source-map-root" ] ~doc)
in
let include_dirs =
let doc = "Add [$(docv)] to the list of include directories." in
Arg.(value & opt_all string [] & info [ "I" ] ~docv:"DIR" ~doc)
in
let effects =
let doc =
"Select an implementation of effect handlers. [$(docv)] should be one of $(b,jspi) \
(the default), $(b,cps), or $(b,disabled)."
in
Arg.(
value
& opt (some (enum [ "jspi", `Jspi; "cps", `Cps; "disabled", `Disabled ])) None
& info [ "effects" ] ~docv:"KIND" ~doc)
in
let build_t
common
set_param
include_dirs
sourcemap
no_sourcemap
sourcemap_don't_inline_content
sourcemap_root
output_file
runtime_files
effects =
let params : (string * string) list = List.flatten set_param in
let enable_source_maps = (not no_sourcemap) && sourcemap in
let include_dirs = normalize_include_dirs include_dirs in
let effects = normalize_effects effects common in
`Ok
{ common
; params
; include_dirs
; profile = None
; output_file = output_file, true
; input_file = None
; runtime_files
; runtime_only = true
; enable_source_maps
; sourcemap_root
; sourcemap_don't_inline_content
; effects
; shape_files = []
}
in
let t =
Term.(
const build_t
$ Lazy.force Jsoo_cmdline.Arg.t
$ set_param
$ include_dirs
$ sourcemap
$ no_sourcemap
$ sourcemap_don't_inline_content
$ sourcemap_root
$ output_file
$ runtime_files
$ effects)
in
Term.ret t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/cmd_arg.mli
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Js_of_ocaml_compiler
type t =
{ common : Jsoo_cmdline.Arg.t
; (* compile option *)
profile : Profile.t option
; runtime_files : string list
; runtime_only : bool
; output_file : string * bool
; input_file : string option
; enable_source_maps : bool
; sourcemap_root : string option
; sourcemap_don't_inline_content : bool
; params : (string * string) list
; include_dirs : string list
; effects : Config.effects_backend
; shape_files : string list
}
val options : unit -> t Cmdliner.Term.t
val options_runtime_only : unit -> t Cmdliner.Term.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/compile.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Wasm_of_ocaml_compiler
let times = Debug.find "times"
let binaryen_times = Debug.find "binaryen-times"
let debug_mem = Debug.find "mem"
let debug_wat = Debug.find "wat"
let () = Sys.catch_break true
let update_sourcemap ~sourcemap_root ~sourcemap_don't_inline_content sourcemap_file =
if Option.is_some sourcemap_root || not sourcemap_don't_inline_content
then (
let open Source_map in
let source_map =
match Source_map.of_file sourcemap_file with
| Index _ -> assert false
| Standard sm -> sm
in
assert (List.is_empty (Option.value source_map.sources_content ~default:[]));
(* Add source file contents to source map *)
let sources_content =
if sourcemap_don't_inline_content
then None
else
Some
(List.map source_map.sources ~f:(fun file ->
if String.equal file Wasm_source_map.blackbox_filename
then
Some (Source_map.Source_content.create Wasm_source_map.blackbox_contents)
else if Sys.file_exists file && not (Sys.is_directory file)
then Some (Source_map.Source_content.create (Fs.read_file file))
else None))
in
let source_map =
{ source_map with
sources_content
; sourceroot =
(if Option.is_some sourcemap_root then sourcemap_root else source_map.sourceroot)
; ignore_list =
(if
List.mem
~eq:String.equal
Wasm_source_map.blackbox_filename
source_map.sources
then [ Wasm_source_map.blackbox_filename ]
else [])
}
in
Source_map.to_file (Standard source_map) sourcemap_file)
let opt_with action x f =
match x with
| None -> f None
| Some x -> action x (fun y -> f (Some y))
let preprocessor_variables () =
(* Keep this variables in sync with gen/gen.ml *)
[ ( "effects"
, Wat_preprocess.String
(match Config.effects () with
| `Disabled | `Jspi -> "jspi"
| `Cps -> "cps"
| `Double_translation -> assert false) )
]
let with_runtime_files ~runtime_wasm_files f =
let inputs =
List.map
~f:(fun file -> { Wat_preprocess.module_name = "env"; file; source = File })
runtime_wasm_files
in
Wat_preprocess.with_preprocessed_files ~variables:(preprocessor_variables ()) ~inputs f
let build_runtime ~runtime_file =
let variables = preprocessor_variables () in
match
List.find_opt Runtime_files.precompiled_runtimes ~f:(fun (flags, _) ->
assert (List.length flags = List.length variables);
List.equal
~eq:(fun (k1, v1) (k2, v2) ->
assert (String.equal k1 k2);
Wat_preprocess.value_equal v1 v2)
flags
variables)
with
| Some (_, contents) -> Fs.write_file ~name:runtime_file ~contents
| None ->
let inputs =
List.map
~f:(fun (module_name, contents) ->
{ Wat_preprocess.module_name
; file = module_name ^ ".wat"
; source = Contents contents
})
Runtime_files.wat_files
in
Runtime.build
~link_options:[ "-g" ]
~opt_options:[ "-g"; "-O2" ]
~variables
~allowed_imports:
(Some
[ "bindings"
; "Math"
; "js"
; "wasm:js-string"
; "wasm:text-encoder"
; "wasm:text-decoder"
])
~inputs
~output_file:runtime_file
let link_and_optimize
~profile
~sourcemap_root
~sourcemap_don't_inline_content
~opt_sourcemap
runtime_wasm_files
wat_files
output_file =
let opt_sourcemap_file =
(* Check that Binaryen supports the necessary sourcemaps options (requires
version >= 118) *)
match opt_sourcemap with
| Some _ when Sys.command "wasm-merge -osm foo 2> /dev/null" <> 0 -> None
| Some _ | None -> opt_sourcemap
in
let enable_source_maps = Option.is_some opt_sourcemap_file in
Fs.with_intermediate_file (Filename.temp_file "runtime" ".wasm")
@@ fun runtime_file ->
build_runtime ~runtime_file;
Fs.with_intermediate_file (Filename.temp_file "wasm-merged" ".wasm")
@@ fun temp_file ->
opt_with
Fs.with_intermediate_file
(if enable_source_maps
then Some (Filename.temp_file "wasm-merged" ".wasm.map")
else None)
@@ fun opt_temp_sourcemap ->
(with_runtime_files ~runtime_wasm_files
@@ fun runtime_inputs ->
let t = Timer.make ~get_time:Unix.time () in
Binaryen.link
~inputs:
({ Binaryen.module_name = "env"; file = runtime_file; source_map_file = None }
:: runtime_inputs
@ List.map
~f:(fun (file, source_map_file) ->
{ Binaryen.module_name = "OCaml"; file; source_map_file })
wat_files)
~opt_output_sourcemap:opt_temp_sourcemap
~output_file:temp_file
();
if binaryen_times () then Format.eprintf " binaryen link: %a@." Timer.print t);
Fs.with_intermediate_file (Filename.temp_file "wasm-dce" ".wasm")
@@ fun temp_file' ->
opt_with
Fs.with_intermediate_file
(if enable_source_maps then Some (Filename.temp_file "wasm-dce" ".wasm.map") else None)
@@ fun opt_temp_sourcemap' ->
let t = Timer.make ~get_time:Unix.time () in
let primitives =
Binaryen.dead_code_elimination
~dependencies:Runtime_files.dependencies
~opt_input_sourcemap:opt_temp_sourcemap
~opt_output_sourcemap:opt_temp_sourcemap'
~input_file:temp_file
~output_file:temp_file'
in
if binaryen_times () then Format.eprintf " binaryen dce: %a@." Timer.print t;
let t = Timer.make ~get_time:Unix.time () in
Binaryen.optimize
~profile
~opt_input_sourcemap:opt_temp_sourcemap'
~opt_output_sourcemap:opt_sourcemap
~input_file:temp_file'
~output_file
();
if binaryen_times () then Format.eprintf " binaryen opt: %a@." Timer.print t;
Option.iter
~f:(update_sourcemap ~sourcemap_root ~sourcemap_don't_inline_content)
opt_sourcemap_file;
primitives
let link_runtime ~profile runtime_wasm_files output_file =
if List.is_empty runtime_wasm_files
then build_runtime ~runtime_file:output_file
else
Fs.with_intermediate_file (Filename.temp_file "extra_runtime" ".wasm")
@@ fun extra_runtime ->
Fs.with_intermediate_file (Filename.temp_file "merged_runtime" ".wasm")
@@ fun temp_file ->
(with_runtime_files ~runtime_wasm_files
@@ fun runtime_inputs ->
Binaryen.link
~opt_output_sourcemap:None
~inputs:runtime_inputs
~output_file:temp_file
());
Binaryen.optimize
~profile
~opt_input_sourcemap:None
~opt_output_sourcemap:None
~input_file:temp_file
~output_file:extra_runtime
();
Fs.with_intermediate_file (Filename.temp_file "runtime" ".wasm")
@@ fun runtime_file ->
build_runtime ~runtime_file;
Binaryen.link
~opt_output_sourcemap:None
~inputs:
(List.map
~f:(fun file -> { Binaryen.module_name = "env"; file; source_map_file = None })
[ runtime_file; extra_runtime ])
~output_file
()
let generate_prelude ~out_file =
Filename.gen_file out_file
@@ fun ch ->
let code, uinfo = Parse_bytecode.predefined_exceptions () in
let profile = Profile.O1 in
let ( Driver.
{ program
; variable_uses
; in_cps
; deadcode_sentinal
; shapes = _
; trampolined_calls = _
}
, global_flow_data ) =
Driver.optimize_for_wasm ~profile ~shapes:false code
in
let context = Generate.start () in
let _ =
Generate.f
~context
~unit_name:(Some "prelude")
~live_vars:variable_uses
~in_cps
~deadcode_sentinal
~global_flow_data
program
in
Generate.wasm_output ch ~opt_source_map_file:None ~context;
uinfo.provides
let build_prelude z =
Fs.with_intermediate_file (Filename.temp_file "prelude" ".wasm")
@@ fun prelude_file ->
let predefined_exceptions = generate_prelude ~out_file:prelude_file in
Zip.add_file z ~name:"prelude.wasm" ~file:prelude_file;
predefined_exceptions
let build_js_runtime ~primitives ?runtime_arguments () =
let always_required_js, primitives =
let l =
StringSet.fold
(fun nm l ->
let id = Utf8_string.of_string_exn nm in
Javascript.Property (PNI id, EVar (S { name = id; var = None; loc = N })) :: l)
primitives
[]
in
match
List.split_last
@@ Driver.link_and_pack
~link:`Needed
[ Javascript.Return_statement (Some (EObj l), N), N ]
with
| Some x -> x
| None -> assert false
in
let primitives =
match primitives with
| Javascript.Expression_statement e, N -> e
| _ -> assert false
in
let init_fun =
match Parse_js.parse (Parse_js.Lexer.of_string Runtime_files.js_runtime) with
| [ (Expression_statement f, _) ] -> f
| _ -> assert false
in
let launcher =
let js = Javascript.call init_fun [ primitives ] N in
let js =
match runtime_arguments with
| None -> js
| Some runtime_arguments -> Javascript.call js [ runtime_arguments ] N
in
[ Javascript.Expression_statement js, Javascript.N ]
in
Link.output_js (always_required_js @ launcher)
let add_source_map sourcemap_don't_inline_content z opt_source_map =
let sm =
match opt_source_map with
| `File opt_file -> Option.map ~f:Source_map.of_file opt_file
| `Source_map sm -> Some sm
in
Option.iter sm ~f:(fun sm ->
Zip.add_entry z ~name:"source_map.map" ~contents:(Source_map.to_string sm);
if not sourcemap_don't_inline_content
then
Wasm_source_map.iter_sources sm (fun i j file ->
if Sys.file_exists file && not (Sys.is_directory file)
then
let sm = Fs.read_file file in
Zip.add_entry
z
~name:(Link.source_name i j file)
~contents:(Yojson.Basic.to_string (`String sm))))
let merge_shape a b =
StringMap.union (fun _name s1 s2 -> if Shape.equal s1 s2 then Some s1 else None) a b
let sexp_of_shapes s =
StringMap.bindings s
|> List.map ~f:(fun (name, shape) ->
Sexp.List [ Atom name; Atom (Shape.to_string shape) ])
let string_of_shapes s = Sexp.List (sexp_of_shapes s) |> Sexp.to_string
let run
{ Cmd_arg.common
; profile
; runtime_only
; runtime_files
; input_file
; output_file
; enable_source_maps
; params
; include_dirs
; sourcemap_root
; sourcemap_don't_inline_content
; effects
; shape_files
} =
Config.set_target `Wasm;
Jsoo_cmdline.Arg.eval common;
Config.set_effects_backend effects;
Generate.init ();
List.iter shape_files ~f:(fun s ->
let z = Zip.open_in s in
if Zip.has_entry z ~name:"shapes.sexp"
then
let s = Zip.read_entry z ~name:"shapes.sexp" in
match Sexp.from_string s with
| List l ->
List.iter l ~f:(function
| Sexp.List [ Atom name; Atom shape ] ->
Shape.Store.set ~name (Shape.of_string shape)
| _ -> ())
| _ -> ());
let output_file = fst output_file in
if debug_mem () then Debug.start_profiling output_file;
List.iter params ~f:(fun (s, v) -> Config.Param.set s v);
let t = Timer.make () in
let include_dirs =
List.filter_map (include_dirs @ [ "+stdlib/" ]) ~f:(fun d -> Findlib.find [] d)
in
let runtime_wasm_files, runtime_js_files =
List.partition runtime_files ~f:(fun name ->
List.exists
~f:(fun s -> Filename.check_suffix name s)
[ ".wasm"; ".wat"; ".wast" ])
in
let runtime_js_files, builtin =
List.partition_map runtime_js_files ~f:(fun name ->
match Builtins.find name with
| Some t -> Right t
| None -> Left name)
in
let t1 = Timer.make () in
let builtin = Js_of_ocaml_compiler_runtime_files.runtime @ builtin in
List.iter builtin ~f:(fun t ->
let filename = Builtins.File.name t in
let runtimes = Linker.Fragment.parse_builtin t in
Linker.load_fragments ~target_env:Target_env.Isomorphic ~filename runtimes);
Linker.load_files ~target_env:Target_env.Isomorphic runtime_js_files;
Linker.check_deps ();
if times () then Format.eprintf " parsing js: %a@." Timer.print t1;
if times () then Format.eprintf "Start parsing...@.";
let need_debug = enable_source_maps || Config.Flag.debuginfo () in
let check_debug (one : Parse_bytecode.one) =
if
(not runtime_only)
&& enable_source_maps
&& Parse_bytecode.Debug.is_empty one.debug
&& not (Code.is_empty one.code)
then
Warning.warn
`Missing_debug_event
"'--source-map' is enabled but the bytecode program was compiled with no \
debugging information.\n\
Warning: Consider passing '-g' option to ocamlc.\n\
%!"
in
let profile =
match profile with
| Some p -> p
| None -> Profile.O1
in
let output (one : Parse_bytecode.one) ~unit_name ~wat_file ~file ~opt_source_map_file =
check_debug one;
let code = one.code in
let standalone = Option.is_none unit_name in
let ( Driver.
{ program
; variable_uses
; in_cps
; deadcode_sentinal
; shapes
; trampolined_calls = _
}
, global_flow_data ) =
Driver.optimize_for_wasm ~profile ~shapes:true code
in
StringMap.iter (fun name shape -> Shape.Store.set ~name shape) shapes;
let context = Generate.start () in
let toplevel_name, generated_js =
Generate.f
~context
~unit_name
~live_vars:variable_uses
~in_cps
~deadcode_sentinal
~global_flow_data
program
in
if standalone then Generate.add_start_function ~context toplevel_name;
let ch = open_out_bin file in
Generate.wasm_output ch ~opt_source_map_file ~context;
close_out ch;
if debug_wat ()
then (
let ch = open_out_bin wat_file in
Generate.output ch ~context;
close_out ch);
if times () then Format.eprintf "compilation: %a@." Timer.print t;
generated_js, shapes
in
(if runtime_only
then (
Fs.gen_file output_file
@@ fun tmp_output_file ->
Fs.with_intermediate_file (Filename.temp_file "wasm" ".wasm")
@@ fun tmp_wasm_file ->
link_runtime ~profile runtime_wasm_files tmp_wasm_file;
let primitives =
tmp_wasm_file
|> (fun file -> Link.Wasm_binary.read_imports ~file)
|> List.filter_map ~f:(fun { Link.Wasm_binary.module_; name; _ } ->
if String.equal module_ "js" then Some name else None)
|> StringSet.of_list
in
let js_runtime = build_js_runtime ~primitives () in
let z = Zip.open_out tmp_output_file in
Zip.add_file z ~name:"runtime.wasm" ~file:tmp_wasm_file;
Zip.add_entry z ~name:"runtime.js" ~contents:js_runtime;
let predefined_exceptions = build_prelude z in
Link.add_info
z
~predefined_exceptions
~build_info:(Build_info.create `Runtime)
~unit_data:[]
();
Zip.close_out z)
else
let kind, ic, close_ic, include_dirs =
let input_file =
match input_file with
| None -> assert false
| Some f -> f
in
let ch = open_in_bin input_file in
let res = Parse_bytecode.from_channel ch in
let include_dirs = Filename.dirname input_file :: include_dirs in
res, ch, (fun () -> close_in ch), include_dirs
in
let compile_cmo cmo cont =
let t1 = Timer.make () in
let code =
Parse_bytecode.from_cmo ~includes:include_dirs ~debug:need_debug cmo ic
in
let unit_info = Unit_info.of_cmo cmo in
let unit_name = Ocaml_compiler.Cmo_format.name cmo in
if times () then Format.eprintf " parsing: %a (%s)@." Timer.print t1 unit_name;
Fs.with_intermediate_file (Filename.temp_file unit_name ".wasm")
@@ fun tmp_wasm_file ->
opt_with
Fs.with_intermediate_file
(if enable_source_maps
then Some (Filename.temp_file unit_name ".wasm.map")
else None)
@@ fun opt_tmp_map_file ->
let unit_data, shapes =
Fs.with_intermediate_file (Filename.temp_file unit_name ".wasm")
@@ fun input_file ->
opt_with
Fs.with_intermediate_file
(if enable_source_maps
then Some (Filename.temp_file unit_name ".wasm.map")
else None)
@@ fun opt_input_sourcemap ->
let fragments, shapes =
output
code
~wat_file:
(Filename.concat (Filename.dirname output_file) (unit_name ^ ".wat"))
~unit_name:(Some unit_name)
~file:input_file
~opt_source_map_file:opt_input_sourcemap
in
Binaryen.optimize
~profile
~opt_input_sourcemap
~opt_output_sourcemap:opt_tmp_map_file
~input_file
~output_file:tmp_wasm_file
();
{ Link.unit_name; unit_info; fragments }, shapes
in
cont unit_data unit_name tmp_wasm_file opt_tmp_map_file shapes
in
(match kind with
| `Exe ->
let t1 = Timer.make () in
let code =
Parse_bytecode.from_exe
~includes:include_dirs
~include_cmis:false
~link_info:false
~linkall:false
~debug:need_debug
ic
in
if times () then Format.eprintf " parsing: %a@." Timer.print t1;
Fs.with_intermediate_file (Filename.temp_file "code" ".wasm")
@@ fun input_wasm_file ->
let dir = Filename.chop_extension output_file ^ ".assets" in
Link.gen_dir dir
@@ fun tmp_dir ->
Sys.mkdir tmp_dir 0o777;
let opt_sourcemap =
if enable_source_maps
then Some (Filename.concat tmp_dir "code.wasm.map")
else None
in
let opt_source_map_file =
if enable_source_maps
then Some (Filename.temp_file "code" ".wasm.map")
else None
in
let generated_js, _shapes =
output
code
~unit_name:None
~wat_file:(Filename.chop_extension output_file ^ ".wat")
~file:input_wasm_file
~opt_source_map_file
in
let tmp_wasm_file = Filename.concat tmp_dir "code.wasm" in
let t2 = Timer.make ~get_time:Unix.time () in
let primitives =
link_and_optimize
~profile
~sourcemap_root
~sourcemap_don't_inline_content
~opt_sourcemap
runtime_wasm_files
[ input_wasm_file, opt_source_map_file ]
tmp_wasm_file
in
if binaryen_times ()
then Format.eprintf " link_and_optimize: %a@." Timer.print t2;
let wasm_name =
Printf.sprintf
"code-%s"
(String.sub (Digest.to_hex (Digest.file tmp_wasm_file)) ~pos:0 ~len:20)
in
let tmp_wasm_file' = Filename.concat tmp_dir (wasm_name ^ ".wasm") in
Sys.rename tmp_wasm_file tmp_wasm_file';
if enable_source_maps
then (
Sys.rename (Filename.concat tmp_dir "code.wasm.map") (tmp_wasm_file' ^ ".map");
Link.Wasm_binary.append_source_map_section
~file:tmp_wasm_file'
~url:(wasm_name ^ ".wasm.map"));
if times () then Format.eprintf "Start building js runtime@.";
let js_runtime =
let missing_primitives =
let l = Link.Wasm_binary.read_imports ~file:tmp_wasm_file' in
List.filter_map
~f:(fun { Link.Wasm_binary.module_; name; _ } ->
if String.equal module_ "env" then Some name else None)
l
in
build_js_runtime
~primitives
~runtime_arguments:
(Link.build_runtime_arguments
~missing_primitives
~wasm_dir:dir
~link_spec:[ wasm_name, None ]
~separate_compilation:false
~generated_js:[ None, generated_js ]
())
()
in
Fs.gen_file output_file
@@ fun tmp_output_file ->
Fs.write_file ~name:tmp_output_file ~contents:js_runtime
| `Cmo cmo ->
Fs.gen_file output_file
@@ fun tmp_output_file ->
let z = Zip.open_out tmp_output_file in
let compile_cmo' z cmo =
compile_cmo cmo (fun unit_data _ tmp_wasm_file opt_tmp_map_file shapes ->
Zip.add_file z ~name:"code.wasm" ~file:tmp_wasm_file;
Zip.add_entry z ~name:"shapes.sexp" ~contents:(string_of_shapes shapes);
add_source_map sourcemap_don't_inline_content z (`File opt_tmp_map_file);
unit_data)
in
let unit_data = [ compile_cmo' z cmo ] in
Link.add_info z ~build_info:(Build_info.create `Cmo) ~unit_data ();
Zip.close_out z
| `Cma cma ->
Fs.gen_file output_file
@@ fun tmp_output_file ->
let z = Zip.open_out tmp_output_file in
let unit_data =
let tmp_buf = Buffer.create 10000 in
List.fold_right
~f:(fun cmo cont l ->
compile_cmo cmo
@@ fun unit_data unit_name tmp_wasm_file opt_tmp_map_file shapes ->
cont ((unit_data, unit_name, tmp_wasm_file, opt_tmp_map_file, shapes) :: l))
cma.lib_units
~init:(fun l ->
Fs.with_intermediate_file (Filename.temp_file "wasm" ".wasm")
@@ fun tmp_wasm_file ->
let l = List.rev l in
let source_map =
Wasm_link.f
(List.map
~f:(fun (_, _, file, opt_source_map, _) ->
{ Wasm_link.module_name = "OCaml"
; file
; code = None
; opt_source_map =
Option.map
~f:(fun f -> Source_map.Standard.of_file ~tmp_buf f)
opt_source_map
})
l)
~output_file:tmp_wasm_file
in
Zip.add_file z ~name:"code.wasm" ~file:tmp_wasm_file;
let shapes =
List.fold_left
~init:StringMap.empty
~f:(fun acc (_, _, _, _, shapes) -> merge_shape acc shapes)
l
in
Zip.add_entry z ~name:"shapes.sexp" ~contents:(string_of_shapes shapes);
if enable_source_maps
then
add_source_map sourcemap_don't_inline_content z (`Source_map source_map);
List.map ~f:(fun (unit_data, _, _, _, _) -> unit_data) l)
[]
in
Link.add_info z ~build_info:(Build_info.create `Cma) ~unit_data ();
Zip.close_out z);
close_ic ());
Debug.stop_profiling ()
let info name =
Info.make
~name
~doc:"Wasm_of_ocaml compiler"
~description:"Wasm_of_ocaml is a compiler from OCaml bytecode to WebAssembly."
let options = Cmd_arg.options ()
let term = Cmdliner.Term.(const run $ options)
let command =
let t = Cmdliner.Term.(const run $ options) in
Cmdliner.Cmd.v (info "compile") t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/compile.mli
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val run : Cmd_arg.t -> unit
val command : unit Cmdliner.Cmd.t
val term : unit Cmdliner.Term.t
val info : string -> Cmdliner.Cmd.info
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/dune
|
(executables
(names wasm_of_ocaml wasmoo_link_wasm)
(public_names wasm_of_ocaml -)
(package wasm_of_ocaml-compiler)
(libraries
jsoo_cmdline
wasm_of_ocaml-compiler
cmdliner
compiler-libs.common
js_of_ocaml-compiler.runtime-files
yojson
unix
(select
findlib_support.ml
from
;; Only link wasm_of_ocaml-compiler.findlib-support if it exists
(js_of_ocaml-compiler.findlib-support -> findlib_support.empty.ml)
(-> findlib_support.empty.ml)))
(modes
byte
(best exe))
(flags
(:standard -safe-string)))
(rule
(target runtime_files.ml)
(deps
gen/gen.exe
../../runtime/wasm/runtime.js
../../runtime/wasm/deps.json
(glob_files ../../runtime/wasm/*.wat)
(glob_files ../../runtime/wasm/runtime-*.wasm))
(action
(with-stdout-to
%{target}
(run %{deps}))))
(rule
(targets wasm_of_ocaml.1)
(action
(with-stdout-to
%{targets}
(run %{bin:wasm_of_ocaml} --help=groff))))
(install
(section man)
(package wasm_of_ocaml-compiler)
(files wasm_of_ocaml.1))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/findlib_support.empty.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
dune
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/gen/dune
|
(executable
(name gen)
(libraries js_of_ocaml-compiler))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/gen/gen.ml
|
open Js_of_ocaml_compiler
open Js_of_ocaml_compiler.Stdlib
class check_and_warn =
object
inherit Js_traverse.free as super
method! merge_info from =
let def = from#get_def in
let use = from#get_use in
let diff = Javascript.IdentSet.diff def use in
let diff =
Javascript.IdentSet.fold
(fun x acc ->
match x with
| S { name = Utf8_string.Utf8 s; _ } ->
if String.starts_with s ~prefix:"_" then acc else s :: acc
| V _ -> acc)
diff
[]
in
(match diff with
| [] -> ()
| l ->
Warning.warn
`Unused_js_variable
"unused variable:@. %s@."
(String.concat ~sep:", " l));
super#merge_info from
end
let free_variable code =
if Warning.enabled `Unused_js_variable
then
let o = new check_and_warn in
let _code = o#program code in
Javascript.IdentSet.fold
(fun x acc ->
match x with
| S { name = Utf8 x; _ } -> StringSet.add x acc
| V _ -> acc)
o#get_free
StringSet.empty
else
let free = ref StringSet.empty in
let o = new Js_traverse.fast_freevar (fun s -> free := StringSet.add s !free) in
o#program code;
!free
let check_js_file fname =
Warning.werror := true;
Warning.enable `Unused_js_variable;
let c = Fs.read_file fname in
let p =
try Parse_js.parse (Parse_js.Lexer.of_string ~filename:fname c)
with Parse_js.Parsing_error pi ->
failwith (Printf.sprintf "cannot parse file %S (l:%d, c:%d)@." fname pi.line pi.col)
in
let freenames = free_variable p in
let freenames = StringSet.diff freenames Reserved.keyword in
let freenames = StringSet.diff freenames Reserved.provided in
if not (StringSet.is_empty freenames)
then
Warning.warn
`Free_variables_in_primitive
"free variables in %[email protected]: %a@."
fname
(Format.pp_print_list
~pp_sep:(fun fmt () -> Format.pp_print_string fmt ", ")
Format.pp_print_string)
(StringSet.elements freenames);
Warning.process_warnings ();
()
(* Keep the two variables below in sync with function build_runtime in
../compile.ml *)
let default_flags = []
let interesting_runtimes = [ [ "effects", `S "jspi" ]; [ "effects", `S "cps" ] ]
let name_runtime standard l =
let flags =
List.filter_map l ~f:(fun (k, v) ->
match v with
| `S s -> Some s
| `B b -> if b then Some k else None)
in
String.concat ~sep:"-" ("runtime" :: (if standard then [ "standard" ] else flags))
^ ".wasm"
let print_flags f flags =
Format.fprintf
f
"@[<2>[ %a ]@]"
(Format.pp_print_list
~pp_sep:(fun f () -> Format.fprintf f ";@ ")
(fun f (k, v) ->
Format.fprintf
f
"@[\"%s\",@ %a@]"
k
(fun f v ->
match v with
| `S s -> Format.fprintf f "Wat_preprocess.String \"%s\"" s
| `B b ->
Format.fprintf f "Wat_preprocess.Bool %s" (if b then "true" else "false"))
v))
flags
let () =
let () = set_binary_mode_out stdout true in
let js_runtime, deps, wat_files, runtimes =
match Array.to_list Sys.argv with
| _ :: js_runtime :: deps :: rest ->
assert (Filename.check_suffix js_runtime ".js");
assert (Filename.check_suffix deps ".json");
let wat_files, rest =
List.partition rest ~f:(fun f -> Filename.check_suffix f ".wat")
in
let wasm_files, rest =
List.partition rest ~f:(fun f -> Filename.check_suffix f ".wasm")
in
assert (List.is_empty rest);
js_runtime, deps, wat_files, wasm_files
| _ -> assert false
in
check_js_file js_runtime;
Format.printf "open Wasm_of_ocaml_compiler@.";
Format.printf "let js_runtime = {|\n%s\n|}@." (Fs.read_file js_runtime);
Format.printf "let dependencies = {|\n%s\n|}@." (Fs.read_file deps);
Format.printf
"let wat_files = [%a]@."
(Format.pp_print_list (fun f file ->
Format.fprintf
f
"{|%s|},@;{|%s|};@;"
Filename.(chop_suffix (basename file) ".wat")
(Fs.read_file file)))
wat_files;
Format.printf
"let precompiled_runtimes = [%a]@."
(Format.pp_print_list (fun f (standard, flags) ->
let flags = flags @ default_flags in
let name = name_runtime standard flags in
match
List.find_opt runtimes ~f:(fun file ->
String.equal (Filename.basename file) name)
with
| None -> failwith ("Missing runtime " ^ name)
| Some file ->
Format.fprintf f "%a,@;%S;@;" print_flags flags (Fs.read_file file)))
(List.mapi interesting_runtimes ~f:(fun i flags -> i = 0, flags))
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/info.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Js_of_ocaml_compiler
open Cmdliner
let make ~name ~doc ~description =
let man =
[ `S "DESCRIPTION"
; `P description
; `S "BUGS"
; `P
"Bugs are tracked on github at \
$(i,https://github.com/ocsigen/js_of_ocaml/issues)."
; `S "SEE ALSO"
; `P "ocaml(1)"
; `S "AUTHORS"
; `P "Jerome Vouillon, Hugo Heuzard."
; `S "LICENSE"
; `P "Copyright (C) 2010-2025."
; `P
"wasm_of_ocaml is free software, you can redistribute it and/or modify it under \
the terms of the GNU Lesser General Public License as published by the Free \
Software Foundation, with linking exception; either version 2.1 of the License, \
or (at your option) any later version."
]
in
let version =
match Compiler_version.git_version with
| "" -> Compiler_version.s
| v -> Printf.sprintf "%s+git-%s" Compiler_version.s v
in
Cmd.info name ~version ~doc ~man
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/info.mli
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val make : name:string -> doc:string -> description:string -> Cmdliner.Cmd.info
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/link.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Js_of_ocaml_compiler.Stdlib
open Wasm_of_ocaml_compiler
open Cmdliner
type t =
{ common : Jsoo_cmdline.Arg.t
; files : string list
; output_file : string
; linkall : bool
; mklib : bool
; enable_source_maps : bool
}
let options () =
let output_file =
let doc = "Set output file name to [$(docv)]." in
Arg.(required & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
in
let no_sourcemap =
let doc = "Disable sourcemap output." in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
let sourcemap =
let doc = "Output source locations." in
Arg.(value & flag & info [ "sourcemap"; "source-map"; "source-map-inline" ] ~doc)
in
let files =
let doc =
"Link the archive files [$(docv)]. Unless the $(b,-a) option is used, the first \
archive must be a runtime produced by $(b,wasm_of_ocaml build-runtime). The other \
archives can be produced by compiling .cma or .cmo files."
in
Arg.(non_empty & pos_all string [] & info [] ~docv:"FILES" ~doc)
in
let linkall =
let doc = "Link all compilation units." in
Arg.(value & flag & info [ "linkall" ] ~doc)
in
let mklib =
let doc =
"Build a library (.wasma file) with the .wasmo files given on the command line. \
Similar to ocamlc -a."
in
Arg.(value & flag & info [ "a" ] ~doc)
in
let build_t common no_sourcemap sourcemap output_file files linkall mklib =
let enable_source_maps = (not no_sourcemap) && sourcemap in
`Ok { common; output_file; files; linkall; mklib; enable_source_maps }
in
let t =
Term.(
const build_t
$ Lazy.force Jsoo_cmdline.Arg.t
$ no_sourcemap
$ sourcemap
$ output_file
$ files
$ linkall
$ mklib)
in
Term.ret t
let f { common; output_file; files; linkall; enable_source_maps; mklib } =
Js_of_ocaml_compiler.Config.set_target `Wasm;
Jsoo_cmdline.Arg.eval common;
Link.link ~output_file ~linkall ~mklib ~enable_source_maps ~files
let info =
Info.make
~name:"link"
~doc:"Wasm_of_ocaml linker"
~description:
"wasm_of_ocaml-link links together several wasm_of_ocaml intermediate files to \
produce either a library or some executable code."
let command () =
let t = Cmdliner.Term.(const f $ options ()) in
Cmdliner.Cmd.v info t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/link.mli
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val command : unit -> unit Cmdliner.Cmd.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/link_wasm.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Cmdliner
open Js_of_ocaml_compiler.Stdlib
open Wasm_of_ocaml_compiler
type binaryen_options =
{ common : string list
; opt : string list
; merge : string list
}
type options =
{ input_modules : (string * string) list
; output_file : string
; variables : Preprocess.variables
; allowed_imports : string list option
; binaryen_options : binaryen_options
}
let options =
let input_modules =
let doc =
"Specify an input module with name $(i,NAME) in Wasm text file $(i,FILE)."
in
Arg.(
value
& pos_right 0 (pair ~sep:':' string string) []
& info [] ~docv:"NAME:FILE" ~doc)
in
let output_file =
let doc = "Specify the Wasm binary output file $(docv)." in
Arg.(required & pos 0 (some string) None & info [] ~docv:"WASM_FILE" ~doc)
in
let allowed_imports =
let doc = "List of modules we expect to import from." in
Arg.(
value
& opt_all (list ~sep:',' string) []
& info [ "allowed-imports" ] ~docv:"IMPORT" ~doc)
in
let binaryen_options =
let doc = "Pass option $(docv) to binaryen tools" in
Arg.(value & opt_all string [] & info [ "binaryen" ] ~docv:"OPT" ~doc)
in
let opt_options =
let doc = "Pass option $(docv) to $(b,wasm-opt)" in
Arg.(value & opt_all string [] & info [ "binaryen-opt" ] ~docv:"OPT" ~doc)
in
let merge_options =
let doc = "Pass option $(docv) to $(b,wasm-merge)" in
Arg.(value & opt_all string [] & info [ "binaryen-merge" ] ~docv:"OPT" ~doc)
in
let build_t input_modules output_file variables allowed_imports common opt merge =
let allowed_imports =
if List.is_empty allowed_imports then None else Some (List.concat allowed_imports)
in
`Ok
{ input_modules
; output_file
; variables
; allowed_imports
; binaryen_options = { common; opt; merge }
}
in
let t =
Term.(
const build_t
$ input_modules
$ output_file
$ Preprocess.variable_options
$ allowed_imports
$ binaryen_options
$ opt_options
$ merge_options)
in
Term.ret t
let link
{ input_modules
; output_file
; variables
; allowed_imports
; binaryen_options = { common; merge; opt }
} =
let inputs =
List.map
~f:(fun (module_name, file) -> { Wat_preprocess.module_name; file; source = File })
input_modules
in
Runtime.build
~allowed_imports
~link_options:(common @ merge)
~opt_options:(common @ opt)
~variables:(Preprocess.set_variables variables)
~inputs
~output_file
let info =
Info.make
~name:"link-wasm"
~doc:"Wasm linker"
~description:
"$(b,wasmoo_link_wasm) is a Wasm linker. It takes as input a list of Wasm text \
files, preprocesses them, links them together, and outputs a single Wasm binary \
module"
let term = Cmdliner.Term.(const link $ options)
let command = Cmdliner.Cmd.v info term
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/link_wasm.mli
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
val command : unit Cmdliner.Cmd.t
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
ml
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/preprocess.ml
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Cmdliner
open Js_of_ocaml_compiler.Stdlib
open Wasm_of_ocaml_compiler
let () = Sys.catch_break true
type variables =
{ enable : string list
; disable : string list
; set : (string * string) list
}
type options =
{ input_file : string option
; output_file : string option
; variables : variables
}
let variable_options =
let enable =
let doc = "Set preprocessor variable $(docv) to true." in
let arg =
Arg.(value & opt_all (list string) [] & info [ "enable" ] ~docv:"VAR" ~doc)
in
Term.(const List.flatten $ arg)
in
let disable =
let doc = "Set preprocessor variable $(docv) to false." in
let arg =
Arg.(value & opt_all (list string) [] & info [ "disable" ] ~docv:"VAR" ~doc)
in
Term.(const List.flatten $ arg)
in
let set =
let doc = "Set preprocessor variable $(i,VAR) to value $(i,VALUE)." in
let arg =
Arg.(
value
& opt_all (list (pair ~sep:'=' string string)) []
& info [ "set" ] ~docv:"VAR=VALUE" ~doc)
in
Term.(const List.flatten $ arg)
in
let build_t enable disable set = { enable; disable; set } in
Term.(const build_t $ enable $ disable $ set)
let options =
let input_file =
let doc =
"Use the Wasm text file $(docv) as input (default to the standard input)."
in
Arg.(value & pos 0 (some string) None & info [] ~docv:"INPUT_FILE" ~doc)
in
let output_file =
let doc = "Specify the output file $(docv) (default to the standard output)." in
Arg.(value & opt (some string) None & info [ "o" ] ~docv:"OUTPUT_FILE" ~doc)
in
let build_t input_file output_file variables =
`Ok { input_file; output_file; variables }
in
let t = Term.(const build_t $ input_file $ output_file $ variable_options) in
Term.ret t
let set_variables { enable; disable; set } =
List.map ~f:(fun nm -> nm, Wat_preprocess.Bool true) enable
@ List.map ~f:(fun nm -> nm, Wat_preprocess.Bool false) disable
@ List.map ~f:(fun (nm, v) -> nm, Wat_preprocess.String v) set
let preprocess { input_file; output_file; variables } =
let with_input f =
match input_file with
| None -> f stdin
| Some file ->
let ch = open_in_text file in
let res = f ch in
close_in ch;
res
in
let with_output f =
match output_file with
| Some "-" | None -> f stdout
| Some file -> Filename.gen_file file f
in
let contents = with_input In_channel.input_all in
let res =
Wat_preprocess.f
~filename:(Option.value ~default:"-" input_file)
~contents
~variables:(set_variables variables)
in
with_output (fun ch -> output_string ch res)
let term = Cmdliner.Term.(const preprocess $ options)
let info =
Info.make
~name:"preprocess"
~doc:"Wasm text file preprocessor"
~description:"$(b,wasmoo_util pp) is a Wasm text file preprocessor."
let command = Cmdliner.Cmd.v info term
(* Adapted from
https://github.com/ocaml/opam/blob/fbbe93c3f67034da62d28c8666ec6b05e0a9b17c/s
rc/client/opamArg.ml#L759 *)
let alias_command ?orig_name cmd term name =
let orig =
match orig_name with
| Some s -> s
| None -> Cmd.name cmd
in
let doc = Printf.sprintf "An alias for $(b,%s)." orig in
let man =
[ `S "DESCRIPTION"
; `P (Printf.sprintf "$(mname)$(b, %s) is an alias for $(mname)$(b, %s)." name orig)
; `P (Printf.sprintf "See $(mname)$(b, %s --help) for details." orig)
]
in
Cmd.v (Cmd.info name ~docs:"COMMAND ALIASES" ~doc ~man) term
let command_alias = alias_command ~orig_name:"preprocess" command term "pp"
|
js_of_ocaml-lwt
|
6.2.0
|
[
|
https://ocsigen.org/js_of_ocaml/latest/manual/overview
|
git+https://github.com/ocsigen/js_of_ocaml.git
|
mli
|
js_of_ocaml-6.2.0/compiler/bin-wasm_of_ocaml/preprocess.mli
|
(* Wasm_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
type variables =
{ enable : string list
; disable : string list
; set : (string * string) list
}
val variable_options : variables Cmdliner.Term.t
val set_variables :
variables -> (string * Wasm_of_ocaml_compiler.Wat_preprocess.value) list
val command : unit Cmdliner.Cmd.t
val command_alias : unit Cmdliner.Cmd.t
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.