package phylogenetics

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t = mat
val dim : t -> int * int
Matrix and vector creation
val init : int -> f:(int -> int -> float) -> t

Initialises a square matrix from a int->int->float function.

val init_sym : int -> f:(int -> int -> float) -> t

init_sym n ~f creates a symetric square matrix by calling f only for elements s.t. i <= j

val diagm : vec -> t

Initializes a square diagonal matrix from the vector of its diagonal elements.

val mul : t -> t -> t

Matrix element-wise multiplication

val add : t -> t -> t

Matrix addition.

val scal_mul : float -> t -> t

Multiplication of a matrix by a scalar.

val inplace_scal_mul : float -> t -> unit

Inplace multiplication of a matrix by a scalar.

val dot : ?transa:[ `N | `T ] -> ?transb:[ `N | `T ] -> t -> t -> t

Matrix multiplication

val apply : ?trans:[ `N | `T ] -> t -> vec -> vec

Matrix-vector product

val pow : t -> int -> t

Matrix exponentiation

val expm : t -> t

Matrix exponential

val log : t -> t

Element-wise logarithm of matrix

val robust_equal : tol:float -> t -> t -> bool

Compares two matrices and tolerates a certain relative difference. Let f be the float parameter, it returns true iff the elements of the second matrix are between 1-f and 1+f times the corresponding elements of the first

val get : t -> int -> int -> float

Access a specific element of a matrix.

val set : t -> int -> int -> float -> unit

Set a specific element of a matrix.

val row : t -> int -> vec

Copy row from a matrix

val diagonalize : t -> vec * t

Diagonalizes a matrix M so that M = PxDxP^T; returns (v,P) where v is the diagonal vector of D.

val transpose : t -> t
val inverse : t -> t

Computes the inverse of a matrix.

val zero_eigen_vector : t -> vec

zero_eigen_vector m is a vector v such that Vec.sum v = 1 and mat_vec_mul m v = zero

val of_arrays : float array array -> t option
val of_arrays_exn : float array array -> t
val pp : Stdlib.Format.formatter -> t -> unit

Prints a matrix to the standard output (display may be messy).

OCaml

Innovation. Community. Security.