mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-09 07:33:40 +01:00
72 lines
1.8 KiB
OCaml
72 lines
1.8 KiB
OCaml
(* 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. *)
|
|
|
|
val to_vector_array : ?threshold:float -> t -> Vector.t array
|
|
(** 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
|