10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-07 22:53:41 +01:00
QCaml/Utils/Matrix.mli

72 lines
1.8 KiB
OCaml
Raw Normal View History

2019-02-28 12:08:28 +01:00
(* Sparse or dense matrices *)
open Lacaml.D
type t
(** {1 Accessors} *)
val is_sparse : t -> bool
(** True is the matrix is sparse. *)
val is_dense : t -> bool
(** True is the matrix is dense. *)
val dim1 : t -> int
(** First dimension of the matrix *)
val dim2 : t -> int
(** Secons dimension of the matrix *)
val get : t -> int -> int -> float
(** [get m i j] returns {% $\mathbf{m}_{ij}$ %}. *)
(** {1 Converters } *)
val to_mat : t -> Mat.t
(** Convert into a Lacaml Mat. *)
2019-02-28 12:30:20 +01:00
val to_vector_array : ?threshold:float -> t -> Vector.t array
2019-02-28 12:08:28 +01:00
(** Convert the matrix into an array of column vectors. *)
val sparse_of_dense : ?threshold:float -> t -> t
(** Creates a sparse matrix from a dense matrix. Default threshold is {!Constants.epsilon}. *)
val dense_of_sparse : t -> t
(** Creates a dense matrix from a sparse matrix. *)
val dense_of_mat : Mat.t -> t
(** Create a dense matrix from a Lacaml Mat *)
val sparse_of_mat : ?threshold:float -> Lacaml.D.Mat.t -> t
(** Create a sparse matrix from a Lacaml Mat. Default threshold is {!Constants.epsilon}. *)
val sparse_of_vector_array : Vector.t array -> t
(** Create a sparse matrix from an array of column vectors. *)
val transpose : t -> t
(** Returns the transposed matrix. *)
(** {1 Operations} *)
val outer_product : ?threshold:float -> Vector.t -> Vector.t -> t
(** Creates the matrix formed by the outer product of two vectors. *)
val mm : ?transa:trans3 -> ?transb:trans3 -> ?threshold:float -> t -> t -> t
(** Matrix multiplication *)
val mv : ?sparse:bool -> ?trans:trans3 -> ?threshold:float -> t -> Vector.t -> Vector.t
(** Matrix Vector product *)
(** {1 Printers } *)
val pp_matrix : Format.formatter -> t -> unit
(** {1 Unit testing} *)
val test_case : unit -> (string * [> `Quick ] * (unit -> unit)) list