mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 20:33:36 +01:00
32 lines
490 B
OCaml
32 lines
490 B
OCaml
type t =
|
|
| Pos
|
|
| Neg
|
|
|
|
let of_nperm nperm =
|
|
if (nperm land 1) = 1 then Neg
|
|
else Pos
|
|
|
|
let to_nperm = function
|
|
| Pos -> 0
|
|
| Neg -> 1
|
|
|
|
let multiply t t' =
|
|
match t, t' with
|
|
| Pos, Pos
|
|
| Neg, Neg -> Pos
|
|
| Pos, Neg
|
|
| Neg, Pos -> Neg
|
|
|
|
let neg = function
|
|
| Pos -> Neg
|
|
| Neg -> Pos
|
|
|
|
let add_nperm phase = function
|
|
| 0 -> phase
|
|
| nperm -> multiply phase (of_nperm nperm)
|
|
|
|
let pp ppf = function
|
|
| Pos -> Format.fprintf ppf "@[<h>+1@]"
|
|
| Neg -> Format.fprintf ppf "@[<h>-1@]"
|
|
|