package slap
Module Slap_size
Slap.Size contains operations on sizes (the dimensions of vectors and matrices).
A singleton type on sizes (i.e., dimensions of vectors and matrices).
Evaluation of a term with singleton type 'n size always results in the natural number corresponding to phantom type parameter 'n. 'n is instantiated to a generative phantom type or a (phantom) type that represents an arithmetic operation defined in this module. In either case, only the equality of sizes is verified statically.
Constants
Arithmetic operations
Storage sizes for BLAS and LAPACK
unpacked n computes the inverse of the packed storage size, i.e., unpacked (packed n) = n for all n.
('m, 'n, 'kl, 'ku) geband represents band storage size: A 'm-by-'n band matrix with 'kl subdiagonals and 'ku superdiagonals is stored in a ('kl+'ku+1)-by-'n matrix where 'kl, 'ku << min('m, 'n). ('m, 'n, 'kl, 'ku) geband corresponds to the number of columns of a band-storage-format matrix for such a band matrix.
geband_dyn m n kl ku computs the band storage size of m-by-n band matrices with kl subdiagonals and ku superdiagonals.
('n, 'kd) syband represents symmetric or Hermitian band storage size: A n-by-n symmetric or Hermitian band matrix with kd superdiagonals or subdiagonals is stored in a (kd+1)-by-n matrix where kd << n. ('n, 'kd) syband corresponds to the number of columns of a band-storage-format matrix for such a symmetric band matrix.
syband_dyn n kd computs the band storage size of symmetric or Hermitian band matrices with kd superdiagonals or subdiagonals.
('m, 'n, 'kl, 'ku) luband represents band storage size for LU factorization: A 'm-by-'n band matrix with 'kl subdiagonals and 'ku superdiagonals for LU factorization is stored in band storage format with 'kl+'ku superdiagonals.
luband_dyn m n kl ku computs the band storage size for LU factorization of m-by-n band matrices with kl subdiagonals and ku superdiagonals.
Conversion between a size and an integer
module type SIZE = sig ... endThe signature of modules as packages of types like exists n. n Size.t.
val to_int : 'n t -> intReturn the integer correponding to the given size.
val of_int_dyn : int -> (module SIZE)module N = (val of_int_dyn n : SIZE)
val unsafe_of_int : int -> (module SIZE)Like of_int_dyn, but dynamic size checking is not performed.
module Of_int_dyn (N : sig ... end) : SIZEA functor version of of_int_dyn.
The type of packages of existential quantified sized type: dyn = exists n. n Size.t.
val of_int_c_dyn : int -> dynlet SIZE n = of_int_c_dyn i
Iterators on sizes
The following functions are iterators over [1; 2; ...; n] where n is a size.
fold_left f init n is f (... (f (f init 1) 2) ...) n.
fold_right f n init is f 1 (f 2 (... (f n init) ...)).
Iterators on integers
The following functions are iterators over [1; 2; ...; to_int n] where n is a size.
val fold_lefti : ('accum -> int -> 'accum) -> 'accum -> 'n t -> 'accumfold_lefti f init n is f (... (f (f init 1) 2) ...) (to_int n).
val fold_righti : (int -> 'accum -> 'accum) -> 'n t -> 'accum -> 'accumfold_righti f n init is f 1 (f 2 (... (f (to_int n) init) ...)).
val iteri : (int -> unit) -> 'n t -> unititeri f n is f 1; f 2; ...; f (to_int n).
val riteri : (int -> unit) -> 'n t -> unitriteri f n is f (to_int n); ...; f 2; f 1.
Checking
val iszero : 'n t -> booliszero n returns true if size n is zero.
val nonzero : 'n t -> boolnonzero n returns true if size n is not zero.