10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-23 21:03:56 +01:00
quantum_package/ocaml/Multiplicity.ml

37 lines
745 B
OCaml
Raw Normal View History

2014-10-23 14:42:14 +02:00
open Core.Std;;
2014-08-24 20:00:26 +02:00
open Qptypes ;;
2014-10-25 21:24:21 +02:00
type t = Strictly_positive_int.t with sexp
2014-08-24 20:00:26 +02:00
let of_int = Strictly_positive_int.of_int ;;
let to_int = Strictly_positive_int.to_int ;;
let to_string m =
match (to_int m) with
| 1 -> "Singlet"
| 2 -> "Doublet"
| 3 -> "Triplet"
| 4 -> "Quartet"
| 5 -> "Quintet"
| 6 -> "Sextet"
| 7 -> "Septet"
| 8 -> "Octet"
| 9 -> "Nonet"
| i -> Printf.sprintf "%d-et" i
;;
let of_alpha_beta a b =
2014-10-23 14:42:14 +02:00
let a = Elec_alpha_number.to_int a
and b = Elec_beta_number.to_int b
2014-08-24 20:00:26 +02:00
in
assert (a >= b);
of_int (1 + a - b)
;;
let to_alpha_beta ne m =
2014-10-23 14:42:14 +02:00
let ne = Elec_number.to_int ne in
2014-08-24 20:00:26 +02:00
let nb = (ne-(to_int m)+1)/2 in
let na = ne - nb in
2014-10-23 14:42:14 +02:00
(Elec_alpha_number.of_int na, Elec_beta_number.of_int nb)
2014-08-24 20:00:26 +02:00
;;