10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-23 04:43:32 +01:00
QCaml/common/lib/powers.mli

59 lines
1.2 KiB
OCaml
Raw Normal View History

2024-01-17 13:59:05 +01:00
(** Powers *)
(* Contains powers of $x$, $y$ and $z$ describing the polynomials in
* atomic basis sets.
*)
(** Type *)
2020-12-28 01:08:55 +01:00
2018-02-25 00:53:09 +01:00
type t = private {
2020-12-28 01:08:55 +01:00
x : int ;
y : int ;
z : int ;
2024-01-17 13:59:05 +01:00
tot : int ; (* ~tot~ always contains ~x+y+z~. *)
2020-12-28 01:08:55 +01:00
}
2018-02-25 00:53:09 +01:00
2024-01-17 13:59:05 +01:00
(** Conversions *)
2018-02-25 00:53:09 +01:00
2020-12-28 01:08:55 +01:00
val of_int_tuple : int * int * int -> t
2024-01-17 13:59:05 +01:00
(** Powers.of_int_tuple (2,3,1);;
* - : Powers.t = x^2 + y^3 + z^1
*)
2020-12-28 01:08:55 +01:00
val to_int_tuple : t -> int * int * int
2018-02-25 00:53:09 +01:00
2024-01-17 13:59:05 +01:00
(** Powers.(to_int_tuple (of_int_tuple (2,3,1)));;
* - : int * int * int = (2, 3, 1)
*)
2018-02-25 00:53:09 +01:00
2024-01-17 13:59:05 +01:00
(** Operations *)
2018-02-19 11:24:15 +01:00
val get : Coordinate.axis -> t -> int
2024-01-17 13:59:05 +01:00
(** Returns the value of the power for $x$, $y$ or $z$.
*
* Powers.get Coordinate.Y (Powers.of_int_tuple (2,3,1));;
* - : int = 3
*
*)
2021-01-28 00:34:26 +01:00
val incr : Coordinate.axis -> t -> t
2024-01-17 13:59:05 +01:00
(** Returns a new ~Powers.t~ with the power on the given axis incremented.
*
* Powers.incr Coordinate.Y (Powers.of_int_tuple (2,3,1));;
* - : Powers.t = x^2 + y^4 + z^1
*)
2018-02-19 11:24:15 +01:00
val decr : Coordinate.axis -> t -> t
2024-01-17 13:59:05 +01:00
(** Returns a new ~Powers.t~ with the power on the given axis decremented.
* As opposed to ~of_int_tuple~, the values may become negative.
*
* Powers.decr Coordinate.Y (Powers.of_int_tuple (2,3,1));;
* - : Powers.t = x^2 + y^2 + z^1
*)
2018-02-25 00:53:09 +01:00
2024-01-17 13:59:05 +01:00
(** Printers *)
2018-02-19 11:24:15 +01:00
2020-12-28 01:08:55 +01:00
val pp : Format.formatter -> t -> unit