mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-09-02 01:33:40 +02:00
Added phantom types to Vectors
This commit is contained in:
parent
99a78616fd
commit
13b791e321
@ -1,7 +1,7 @@
|
||||
type t =
|
||||
type 'a t =
|
||||
{
|
||||
p : Vector.t list;
|
||||
e : Vector.t list;
|
||||
p : 'a Vector.t list;
|
||||
e : 'a Vector.t list;
|
||||
m : int;
|
||||
mmax : int;
|
||||
}
|
||||
|
@ -48,15 +48,15 @@ $$ %}
|
||||
|
||||
*)
|
||||
|
||||
type t
|
||||
type 'a t
|
||||
|
||||
val make : ?mmax:int -> unit -> t
|
||||
val make : ?mmax:int -> unit -> 'a t
|
||||
(** Initialize DIIS with a maximum size.*)
|
||||
|
||||
val append : p:Vector.t -> e:Vector.t -> t -> t
|
||||
val append : p:'a Vector.t -> e:'a Vector.t -> 'a t -> 'a t
|
||||
(** Append a parameter vector [p] and the corresponding error vector [e]. *)
|
||||
|
||||
val next : t -> Vector.t
|
||||
val next : 'a t -> 'a Vector.t
|
||||
(** Returns a new parameter vector. *)
|
||||
|
||||
|
||||
|
@ -47,10 +47,10 @@ val increment_chem : t -> int -> int -> int -> int -> float -> unit
|
||||
val increment_phys : t -> int -> int -> int -> int -> float -> unit
|
||||
(** Increments an integral using the Physicist's convention {% $\langle ij|kl \rangle$ %}. *)
|
||||
|
||||
val get_chem_all_i : t -> j:int -> k:int -> l:int -> Vector.t
|
||||
val get_chem_all_i : t -> j:int -> k:int -> l:int -> 'a Vector.t
|
||||
(** Get all integrals in an array [a.{i} =] {% $(\cdot j|kl)$ %} . *)
|
||||
|
||||
val get_phys_all_i : t -> j:int -> k:int -> l:int -> Vector.t
|
||||
val get_phys_all_i : t -> j:int -> k:int -> l:int -> 'a Vector.t
|
||||
(** Get all integrals in an array [a.{i} =] {% $\langle \cdot j|kl \rangle$ %} . *)
|
||||
|
||||
val get_chem_all_ij : t -> k:int -> l:int -> Matrix.t
|
||||
|
@ -73,16 +73,16 @@ val to_bigarray_inplace :
|
||||
t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t
|
||||
(** Converts the matrix into a Bigarray in Fortran layout in place*)
|
||||
|
||||
val to_col_vecs : t -> Vector.t array
|
||||
val to_col_vecs : t -> 'a Vector.t array
|
||||
(** Converts the matrix into an array of vectors *)
|
||||
|
||||
val to_col_vecs_list : t -> Vector.t list
|
||||
val to_col_vecs_list : t -> 'a Vector.t list
|
||||
(** Converts the matrix into a list of vectors *)
|
||||
|
||||
val of_col_vecs : Vector.t array -> t
|
||||
val of_col_vecs : 'a Vector.t array -> t
|
||||
(** Converts an array of vectors into a matrix *)
|
||||
|
||||
val of_col_vecs_list : Vector.t list -> t
|
||||
val of_col_vecs_list : 'a Vector.t list -> t
|
||||
(** Converts a list of vectors into a matrix *)
|
||||
|
||||
val of_bigarray : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t -> t
|
||||
@ -98,7 +98,7 @@ val copy: ?m:int -> ?n:int -> ?br:int -> ?bc:int -> ?ar:int -> ?ac:int -> t -> t
|
||||
val copy_inplace: ?m:int -> ?n:int -> ?br:int -> ?bc:int -> b:t -> ?ar:int -> ?ac:int -> t -> unit
|
||||
(** Copies all or part of a two-dimensional matrix A to an existing matrix B *)
|
||||
|
||||
val col: t -> int -> Vector.t
|
||||
val col: t -> int -> 'a Vector.t
|
||||
(** Returns a column of the matrix as a vector *)
|
||||
|
||||
val detri: t -> t
|
||||
@ -109,10 +109,10 @@ val detri_inplace: t -> unit
|
||||
(** Takes an upper-triangular matrix, and makes it a symmetric matrix
|
||||
by mirroring the defined triangle along the diagonal. *)
|
||||
|
||||
val as_vec_inplace: t -> Vector.t
|
||||
val as_vec_inplace: t -> 'a Vector.t
|
||||
(** Interpret the matrix as a vector (reshape). *)
|
||||
|
||||
val as_vec: t -> Vector.t
|
||||
val as_vec: t -> 'a Vector.t
|
||||
(** Return a copy of the reshaped matrix into a vector *)
|
||||
|
||||
val random: ?rnd_state:Random.State.t -> ?from:float -> ?range:float -> int -> int -> t
|
||||
@ -131,19 +131,19 @@ val scale: float -> t -> t
|
||||
val scale_inplace: float -> t -> unit
|
||||
(** Multiplies the matrix by a constant *)
|
||||
|
||||
val scale_cols: t -> Vector.t -> t
|
||||
val scale_cols: t -> 'a Vector.t -> t
|
||||
(** Multiplies the matrix by a constant *)
|
||||
|
||||
val scale_cols_inplace: t -> Vector.t -> unit
|
||||
val scale_cols_inplace: t -> 'a Vector.t -> unit
|
||||
(** Multiplies the matrix by a constant *)
|
||||
|
||||
val sycon: t -> float
|
||||
(** Returns the condition number of a matrix *)
|
||||
|
||||
val outer_product : ?alpha:float -> Vector.t -> Vector.t -> t
|
||||
val outer_product : ?alpha:float -> 'a Vector.t -> 'b Vector.t -> t
|
||||
(** Computes M = %{ $\alpha u.v^t$ %} *)
|
||||
|
||||
val outer_product_inplace : t -> ?alpha:float -> Vector.t -> Vector.t -> unit
|
||||
val outer_product_inplace : t -> ?alpha:float -> 'a Vector.t -> 'b Vector.t -> unit
|
||||
(** Computes M = %{ $\alpha u.v^t$ %} *)
|
||||
|
||||
val gemm_inplace : ?m:int -> ?n:int -> ?k:int -> ?beta:float -> c:t -> ?transa:[`N | `T] -> ?alpha:float ->
|
||||
@ -163,7 +163,7 @@ val gemm_trace: ?transa:[`N | `T] -> t -> ?transb:[`N | `T] -> t -> float
|
||||
[transa=`N] [transb=`N]
|
||||
[gemm_trace a b]: %{ $C = Tr(A B)$ *)
|
||||
|
||||
val svd: t -> t * Vector.t * t
|
||||
val svd: t -> t * 'b Vector.t * t
|
||||
(** Singular value decomposition. *)
|
||||
|
||||
val qr: t -> t * t
|
||||
@ -175,7 +175,7 @@ val normalize_mat : t -> t
|
||||
val normalize_mat_inplace : t -> unit
|
||||
(** Returns the matrix with all the column vectors normalized *)
|
||||
|
||||
val diagonalize_symm : t -> t * Vector.t
|
||||
val diagonalize_symm : t -> t * 'a Vector.t
|
||||
(** Diagonalize a symmetric matrix. Returns the eigenvectors and the eigenvalues. *)
|
||||
|
||||
val xt_o_x : o:t -> x:t -> t
|
||||
|
@ -1,6 +1,6 @@
|
||||
open Lacaml.D
|
||||
|
||||
type t = Vec.t
|
||||
type 'a t = Vec.t
|
||||
|
||||
let copy ?n ?ofsy ?incy ?y ?ofsx ?incx t = copy ?n ?ofsy ?incy ?y ?ofsx ?incx t
|
||||
let norm t = nrm2 t
|
||||
|
@ -6,123 +6,124 @@ in the future, or to easily implement distributed vectors.
|
||||
The indexing of vectors is 1-based.
|
||||
*)
|
||||
|
||||
open Lacaml.D
|
||||
open Lacaml.D
|
||||
|
||||
type t = Vec.t
|
||||
type 'a t = Vec.t
|
||||
(* Parameter ['a] defines the basis on which the vector is expanded. *)
|
||||
|
||||
val dim : t -> int
|
||||
val dim : 'a t -> int
|
||||
(** Returns the dimension of the vector *)
|
||||
|
||||
val add : t -> t -> t
|
||||
val add : 'a t -> 'a t -> 'a t
|
||||
(** [c = add a b] : %{ $c = a + b$ %} *)
|
||||
|
||||
val sub : t -> t -> t
|
||||
val sub : 'a t -> 'a t -> 'a t
|
||||
(** [c = sub a b] : %{ $c = a - b$ %} *)
|
||||
|
||||
val mul : t -> t -> t
|
||||
val mul : 'a t -> 'a t -> 'a t
|
||||
(** [c = mul a b] : %{ $c_i = a_i \times b_i$ %} *)
|
||||
|
||||
val div : t -> t -> t
|
||||
val div : 'a t -> 'a t -> 'a t
|
||||
(** [c = div a b] : %{ $c_i = a_i / b_i$ %} *)
|
||||
|
||||
val dot : t -> t -> float
|
||||
val dot : 'a t -> 'a t -> float
|
||||
(** [dot v1 v2] : Dot product between v1 and v2 *)
|
||||
|
||||
val norm : t -> float
|
||||
val norm : 'a t -> float
|
||||
(** Norm of the vector : %{ ||v|| = $\sqrt{v.v}$ %} *)
|
||||
|
||||
val sqr : t -> t
|
||||
val sqr : 'a t -> 'a t
|
||||
(** [sqr t = map (fun x -> x *. x) t] *)
|
||||
|
||||
val sqrt : t -> t
|
||||
val sqrt : 'a t -> 'a t
|
||||
(** [sqrt t = map sqrt t] *)
|
||||
|
||||
val neg : t -> t
|
||||
val neg : 'a t -> 'a t
|
||||
(** [neg t = map (f x -> -. x) t *)
|
||||
|
||||
val reci : t -> t
|
||||
val reci : 'a t -> 'a t
|
||||
(** [reci t = map (f x -> 1./x) t *)
|
||||
|
||||
val abs : t -> t
|
||||
val abs : 'a t -> 'a t
|
||||
(** [abs t = map (f x -> abs_float x) t *)
|
||||
|
||||
val cos : t -> t
|
||||
val cos : 'a t -> 'a t
|
||||
(** [cos t = map (f x -> cos x) t *)
|
||||
|
||||
val sin : t -> t
|
||||
val sin : 'a t -> 'a t
|
||||
(** [sin t = map (f x -> sin x) t *)
|
||||
|
||||
val tan : t -> t
|
||||
val tan : 'a t -> 'a t
|
||||
(** [tan t = map (f x -> tan x) t *)
|
||||
|
||||
val acos : t -> t
|
||||
val acos : 'a t -> 'a t
|
||||
(** [acos t = map (f x -> acos x) t *)
|
||||
|
||||
val asin : t -> t
|
||||
val asin : 'a t -> 'a t
|
||||
(** [asin t = map (f x -> asin x) t *)
|
||||
|
||||
val atan : t -> t
|
||||
val atan : 'a t -> 'a t
|
||||
(** [atan t = map (f x -> atan x) t *)
|
||||
|
||||
val normalize : t -> t
|
||||
val normalize : 'a t -> 'a t
|
||||
(** Returns the vector normalized *)
|
||||
|
||||
val init : int -> (int -> float) -> t
|
||||
(** Initialized the vector with a function taking the index as parameter.*)
|
||||
val init : int -> (int -> float) -> 'a t
|
||||
(** Initialize the vector with a function taking the index as parameter.*)
|
||||
|
||||
val sum : t -> float
|
||||
val sum : 'a t -> float
|
||||
(** Returns the sum of the elements of the vector *)
|
||||
|
||||
val copy : ?n:int -> ?ofsy:int -> ?incy:int -> ?y:vec -> ?ofsx:int -> ?incx:int -> t -> t
|
||||
val copy : ?n:int -> ?ofsy:int -> ?incy:int -> ?y:vec -> ?ofsx:int -> ?incx:int -> 'a t -> 'a t
|
||||
(** Returns a copy of the vector X into Y. [ofs] controls the offset and [inc]
|
||||
the increment. *)
|
||||
|
||||
val map : (float -> float) -> t -> t
|
||||
val map : (float -> float) -> 'a t -> 'a t
|
||||
(** Equivalent to [Array.map] *)
|
||||
|
||||
val iter : (float -> unit) -> t -> unit
|
||||
val iter : (float -> unit) -> 'a t -> unit
|
||||
(** Equivalent to [Array.iter] *)
|
||||
|
||||
val iteri : (int -> float -> unit) -> t -> unit
|
||||
val iteri : (int -> float -> unit) -> 'a t -> unit
|
||||
(** Equivalent to [Array.iteri] *)
|
||||
|
||||
val of_array : float array -> t
|
||||
val of_array : float array -> 'a t
|
||||
(** Converts an array of floats into a vector *)
|
||||
|
||||
val of_list : float list -> t
|
||||
val of_list : float list -> 'a t
|
||||
(** Converts a list of floats into a vector *)
|
||||
|
||||
val to_array : t -> float array
|
||||
val to_array : 'a t -> float array
|
||||
(** Converts to an array of floats *)
|
||||
|
||||
val to_list : t -> float list
|
||||
val to_list : 'a t -> float list
|
||||
(** Converts to a list of floats *)
|
||||
|
||||
val create : int -> t
|
||||
val create : int -> 'a t
|
||||
(** Creates an uninitialized vector *)
|
||||
|
||||
val make : int -> float -> t
|
||||
val make : int -> float -> 'a t
|
||||
(** Creates a vector initialized with the given [float].*)
|
||||
|
||||
val make0 : int -> t
|
||||
val make0 : int -> 'a t
|
||||
(** Creates a zero-initialized vector.*)
|
||||
|
||||
val fold : ('a -> float -> 'a) -> 'a -> t -> 'a
|
||||
val fold : ('a -> float -> 'a) -> 'a -> 'a t -> 'a
|
||||
(** Equivalent to [Array.fold] *)
|
||||
|
||||
val random : ?rnd_state:Random.State.t -> ?from:float -> ?range:float -> int -> t
|
||||
val random : ?rnd_state:Random.State.t -> ?from:float -> ?range:float -> int -> 'a t
|
||||
(** Returns a vector of uniform random numbers %{ $ f \le u \le f+r $
|
||||
%} where [f] is [from] and [r] is [range].
|
||||
Default values: [from:-1.0] [range:2.0] *)
|
||||
|
||||
val of_bigarray : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> t
|
||||
val of_bigarray : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> 'a t
|
||||
(** Builds by converting from a Fortran bigarray *)
|
||||
|
||||
val to_bigarray : t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t
|
||||
val to_bigarray : 'a t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t
|
||||
(** Converts the vector into a Fortran bigarray *)
|
||||
|
||||
val of_bigarray_inplace : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> t
|
||||
val of_bigarray_inplace : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> 'a t
|
||||
(** Builds by converting from a Fortran bigarray *)
|
||||
|
||||
val to_bigarray_inplace : t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t
|
||||
val to_bigarray_inplace : 'a t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t
|
||||
(** Converts the vector into a Fortran bigarray *)
|
||||
|
Loading…
Reference in New Issue
Block a user