10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-03 20:54:00 +01:00
quantum_package/ocaml/Long_basis.ml

30 lines
607 B
OCaml
Raw Normal View History

2014-09-17 14:57:12 +02:00
open Core.Std;;
2014-09-17 23:47:13 +02:00
open Qptypes;;
2014-09-17 14:57:12 +02:00
2014-09-17 23:47:13 +02:00
type t = (Symmetry.Xyz.t * Gto.t * Atom_number.t ) list;;
2014-09-17 14:57:12 +02:00
let of_basis b =
let rec do_work accu = function
| [] -> accu
2014-09-17 23:47:13 +02:00
| (g,n)::tail ->
2014-09-17 14:57:12 +02:00
begin
let new_accu =
Symmetry.Xyz.of_symmetry g.Gto.sym
2014-09-17 23:47:13 +02:00
|> List.map ~f:(fun x-> (x,g,n))
2014-09-17 14:57:12 +02:00
in
do_work (new_accu@accu) tail
end
in
do_work [] b
|> List.rev
;;
let to_string b =
2014-09-17 23:47:13 +02:00
List.map ~f:(fun (x,y,z) ->
(Int.to_string (Atom_number.to_int z))^":"^
2014-09-17 14:57:12 +02:00
(Symmetry.Xyz.to_string x)^" "^(Gto.to_string y)
) b
|> String.concat ~sep:"\n"
;;