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

102 lines
2.7 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. *)
2019-04-03 18:09:13 +02:00
val of_fun : int -> int -> (int -> int -> float) -> t
(** [of_fun m n f] creates a computed matrix of dimension m times n, where the function
[f i j] is called to evaluate element [i j] *)
2019-02-28 12:08:28 +01:00
val sparse_of_dense : ?threshold:float -> t -> t
(** Creates a sparse matrix from a dense matrix. Default threshold is {!Constants.epsilon}. *)
2019-04-03 18:09:13 +02:00
val sparse_of_computed : ?threshold:float -> t -> t
(** Creates a sparse matrix from a computed matrix. *)
val dense_of_computed : t -> t
(** Creates a dense matrix from a computed matrix. *)
2019-02-28 12:08:28 +01:00
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. *)
2019-04-02 13:54:16 +02:00
val split_cols : int -> t -> t list
(** [split_cols n m_M] Split the matrix [m_M] by packs of [n] columns *)
val join_cols : t list -> t
(** [join_cols l] Joins the list of matrices into a single matrix (along columns). *)
2019-02-28 12:08:28 +01:00
(** {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 *)
2019-03-21 11:02:58 +01:00
val ax_eq_b : ?trans:trans3 -> t -> t -> t
(** Solves A.X = B or A'.X = B *)
2019-03-21 21:48:21 +01:00
val add : t -> t -> t
(** Add two matrices *)
val sub : t -> t -> t
(** Subtract two matrices *)
2019-02-28 12:08:28 +01:00
2019-04-02 13:54:16 +02:00
(** {1 Parallel routines } *)
val parallel_mm : ?transa:trans3 -> ?transb:trans3 -> ?threshold:float -> t -> t -> t
(** Matrix multiplication, parallelized by splitting b along the columns. *)
2019-02-28 12:08:28 +01:00
(** {1 Printers } *)
2019-12-02 14:58:48 +01:00
val pp : Format.formatter -> t -> unit
2019-02-28 12:08:28 +01:00
(** {1 Unit testing} *)
val test_case : unit -> (string * [> `Quick ] * (unit -> unit)) list