package slap
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=e3bdbaad3574e8d7c4521821bf9f0a8f09284af31f16f69184dac65b6657d182
md5=6f237f6812b3f732b311d482528a39a7
doc/slap/Slap_mat/index.html
Module Slap_mat
Slap.Mat provides operations on sized matrices.
('m, 'n, 'num, 'prec) mat is the type of 'm-by-'n matrix whose elements have OCaml type 'num, representation kind 'prec and memory contiguity 'cnt_or_dsc. The internal implementation is fortran-style two-dimensional big array.
val cnt :
('m, 'n, 'num, 'prec, Slap_misc.cnt) t ->
('m, 'n, 'num, 'prec, 'cnt) tRecover polymorphism of the fifth type parameter.
Creation of matrices
val create :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
('m, 'n, 'num, 'prec, 'cnt) tcreate kind m n
val make :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
'num ->
('m, 'n, 'num, 'prec, 'cnt) tmake kind m n x
val init :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
(int -> int -> 'num) ->
('m, 'n, 'num, 'prec, 'cnt) tAn alias of init_cols.
val init_cols :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
(int -> int -> 'num) ->
('m, 'n, 'num, 'prec, 'cnt) tinit_cols kind m n f returns a fresh m-by-n matrix whose the (i,j) element is initialized by the result of calling f i j. The elements are passed column-wise.
val init_rows :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
(int -> int -> 'num) ->
('m, 'n, 'num, 'prec, 'cnt) tinit_rows kind m n f returns a fresh m-by-n matrix whose the (i,j) element is initialized by the result of calling f i j. The elements are passed row-wise.
Accessors
val kind : ('m, 'n, 'num, 'prec, 'cd) t -> ('num, 'prec) Bigarray.kindval dim : ('m, 'n, 'num, 'prec, 'cd) t -> 'm Slap_size.t * 'n Slap_size.tdim a is (dim1 a, dim2 a).
val dim1 : ('m, 'n, 'num, 'prec, 'cd) t -> 'm Slap_size.tdim1 a
val dim2 : ('m, 'n, 'num, 'prec, 'cd) t -> 'n Slap_size.tdim1 a
val get_dyn : ('m, 'n, 'num, 'prec, 'cd) t -> int -> int -> 'numget_dyn a i j
val set_dyn : ('m, 'n, 'num, 'prec, 'cd) t -> int -> int -> 'num -> unitset_dyn a i j x assigns x to the (i,j) element of the matrix a.
val unsafe_get : ('m, 'n, 'num, 'prec, 'cd) t -> int -> int -> 'numLike Slap_mat.get_dyn, but size checking is not always performed.
val unsafe_set : ('m, 'n, 'num, 'prec, 'cd) t -> int -> int -> 'num -> unitLike Slap_mat.set_dyn, but size checking is not always performed.
val replace_dyn :
('m, 'n, 'num, 'prec, 'cd) t ->
int ->
int ->
('num -> 'num) ->
unitreplace_dyn a i j f is set a i j (f (get a i j)).
val col_dyn :
('m, 'n, 'num, 'prec, 'cd) t ->
int ->
('m, 'num, 'prec, 'cnt) Slap_vec.tcol_dyn a i
val row_dyn :
('m, 'n, 'num, 'prec, 'cd) t ->
int ->
('n, 'num, 'prec, Slap_misc.dsc) Slap_vec.trow_dyn a i
val diag :
('n, 'n, 'num, 'prec, 'cd) t ->
('n, 'num, 'prec, Slap_misc.dsc) Slap_vec.tdiag a
val diag_rect :
('m, 'n, 'num, 'prec, 'cd) t ->
(('m, 'n) Slap_size.min, 'num, 'prec, Slap_misc.dsc) Slap_vec.tdiag_rect a
val as_vec :
('m, 'n, 'num, 'prec, Slap_misc.cnt) t ->
(('m, 'n) Slap_size.mul, 'num, 'prec, 'cnt) Slap_vec.tas_vec a
Basic operations
val fill : ('m, 'n, 'num, 'prec, 'cd) t -> 'num -> unitFill the given matrix with the given value.
val copy :
?b:('m, 'n, 'num, 'prec, 'b_cd) t ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
('m, 'n, 'num, 'prec, 'b_cd) tcopy ?b a copies the matrix a into the matrix b.
Matrix transformations
val packed :
?up:bool ->
?x:('n Slap_size.packed, 'num, 'prec, Slap_misc.cnt) Slap_vec.t ->
('n, 'n, 'num, 'prec, 'cd) t ->
('n Slap_size.packed, 'num, 'prec, 'cnt) Slap_vec.tpacked ?up ?x a transforms triangular matrix a into packed storage format.
val unpacked :
?up:bool ->
?fill_num:'num option ->
?a:('n, 'n, 'num, 'prec, 'cd) t ->
('n Slap_size.packed, 'num, 'prec, Slap_misc.cnt) Slap_vec.t ->
('n, 'n, 'num, 'prec, 'cd) tunpacked ?up ?fill_num ?a x generates an upper or lower triangular matrix from x stored in packed storage.
val geband_dyn :
'kl Slap_size.t ->
'ku Slap_size.t ->
?b:(('m, 'n, 'kl, 'ku) Slap_size.geband, 'n, 'num, 'prec, 'b_cd) t ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
(('m, 'n, 'kl, 'ku) Slap_size.geband, 'n, 'num, 'prec, 'b_cd) tgeband_dyn kl ku ?b a converts matrix a into a matrix stored in band storage.
val ungeband :
'm Slap_size.t ->
'kl Slap_size.t ->
'ku Slap_size.t ->
?fill_num:'num option ->
?a:('m, 'n, 'num, 'prec, 'a_cd) t ->
(('m, 'n, 'kl, 'ku) Slap_size.geband, 'n, 'num, 'prec, 'b_cd) t ->
('m, 'n, 'num, 'prec, 'a_cd) tungeband m kl ku ?a b converts matrix b stored in band storage into a matrix stored in the normal order.
val syband_dyn :
'kd Slap_size.t ->
?up:bool ->
?b:(('n, 'kd) Slap_size.syband, 'n, 'num, 'prec, 'b_cd) t ->
('n, 'n, 'num, 'prec, 'a_cd) t ->
(('n, 'kd) Slap_size.syband, 'n, 'num, 'prec, 'b_cd) tsyband_dyn kd ?b a converts matrix a into a matrix stored in symmetric or Hermitian band storage.
val unsyband :
'kd Slap_size.t ->
?up:bool ->
?fill_num:'num option ->
?a:('n, 'n, 'num, 'prec, 'a_cd) t ->
(('n, 'kd) Slap_size.syband, 'n, 'num, 'prec, 'b_cd) t ->
('n, 'n, 'num, 'prec, 'a_cd) tunsyband kd ?a b converts matrix b stored in symmetric or Hermitian band storage into a matrix stored in the normal order.
val luband_dyn :
'kl Slap_size.t ->
'ku Slap_size.t ->
?ab:(('m, 'n, 'kl, 'ku) Slap_size.luband, 'n, 'num, 'prec, 'b_cd) t ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
(('m, 'n, 'kl, 'ku) Slap_size.luband, 'n, 'num, 'prec, 'b_cd) tluband_dyn kl ku ?ab a converts matrix a into a matrix stored in band storage for LU factorization.
val unluband :
'm Slap_size.t ->
'kl Slap_size.t ->
'ku Slap_size.t ->
?fill_num:'num option ->
?a:('m, 'n, 'num, 'prec, 'a_cd) t ->
(('m, 'n, 'kl, 'ku) Slap_size.luband, 'n, 'num, 'prec, 'b_cd) t ->
('m, 'n, 'num, 'prec, 'a_cd) tunluband m kl ku ?a ab converts matrix ab stored in band storage for LU factorization into a matrix stored in the normal order.
Iterators
val map :
('b_num, 'b_prec) Bigarray.kind ->
('a_num -> 'b_num) ->
?b:('m, 'n, 'b_num, 'b_prec, 'b_cd) t ->
('m, 'n, 'a_num, 'a_prec, 'a_cd) t ->
('m, 'n, 'b_num, 'b_prec, 'b_cd) tval mapi :
('b_num, 'b_prec) Bigarray.kind ->
(int -> int -> 'a_num -> 'b_num) ->
?b:('m, 'n, 'b_num, 'b_prec, 'b_cd) t ->
('m, 'n, 'a_num, 'a_prec, 'a_cd) t ->
('m, 'n, 'b_num, 'b_prec, 'b_cd) tval fold_left :
('accum -> ('m, 'num, 'prec, 'x_cd) Slap_vec.t -> 'accum) ->
'accum ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accumfold_left f init a folds column vectors of matrix a by f in the order left to right.
val fold_lefti :
(int -> 'accum -> ('m, 'num, 'prec, 'x_cd) Slap_vec.t -> 'accum) ->
'accum ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accumfold_lefti f init a folds column vectors of matrix a by f in the order left to right.
val fold_right :
(('m, 'num, 'prec, 'x_cd) Slap_vec.t -> 'accum -> 'accum) ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accum ->
'accumfold_right f a init folds column vectors of matrix a by f in the order right to left.
val fold_righti :
(int -> ('m, 'num, 'prec, 'x_cd) Slap_vec.t -> 'accum -> 'accum) ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accum ->
'accumfold_righti f a init folds column vectors of matrix a by f in the order right to left.
val fold_top :
('accum -> ('n, 'num, 'prec, Slap_misc.dsc) Slap_vec.t -> 'accum) ->
'accum ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accumfold_top f init a folds row vectors of matrix a by f in the order top to bottom.
val fold_topi :
(int -> 'accum -> ('n, 'num, 'prec, Slap_misc.dsc) Slap_vec.t -> 'accum) ->
'accum ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accumfold_topi f init a folds row vectors of matrix a by f in the order top to bottom.
val fold_bottom :
(('n, 'num, 'prec, Slap_misc.dsc) Slap_vec.t -> 'accum -> 'accum) ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accum ->
'accumfold_bottom f a init folds row vectors of matrix a by f in the order bottom to top.
val fold_bottomi :
(int -> ('n, 'num, 'prec, Slap_misc.dsc) Slap_vec.t -> 'accum -> 'accum) ->
('m, 'n, 'num, 'prec, 'a_cd) t ->
'accum ->
'accumfold_bottomi f a init folds row vectors of matrix a by f in the order bottom to top.
val replace_all : ('m, 'n, 'num, 'prec, 'cd) t -> ('num -> 'num) -> unitreplace_all a f modifies the matrix a in place -- the (i,j)-element aij of a will be set to f aij.
val replace_alli :
('m, 'n, 'num, 'prec, 'cd) t ->
(int -> int -> 'num -> 'num) ->
unitreplace_all a f modifies the matrix a in place -- the (i,j)-element aij of a will be set to f i j aij.
Type conversion
val to_array : ('m, 'n, 'num, 'prec, 'cd) t -> 'num array arrayto_array a
val of_array_dyn :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
'num array array ->
('m, 'n, 'num, 'prec, 'cnt) tBuild a matrix initialized from the given array of arrays.
val unsafe_of_array :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
'num array array ->
('m, 'n, 'num, 'prec, 'cnt) tLike of_array_dyn, but size checking is not always performed.
val to_list : ('m, 'n, 'num, 'prec, 'cd) t -> 'num list listto_list a
val of_list_dyn :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
'num list list ->
('m, 'n, 'num, 'prec, 'cnt) tBuild a matrix initialized from the given list of lists.
val unsafe_of_list :
('num, 'prec) Bigarray.kind ->
'm Slap_size.t ->
'n Slap_size.t ->
'num list list ->
('m, 'n, 'num, 'prec, 'cnt) tLike of_list_dyn, but size checking is not always performed.
val to_bigarray :
('m, 'n, 'num, 'prec, 'cd) t ->
('num, 'prec, Bigarray.fortran_layout) Bigarray.Array2.tto_bigarray a
val of_bigarray_dyn :
?share:bool ->
'm Slap_size.t ->
'n Slap_size.t ->
('num, 'prec, Bigarray.fortran_layout) Bigarray.Array2.t ->
('m, 'n, 'num, 'prec, 'cnt) tof_bigarray_dyn ?share m n ba
val unsafe_of_bigarray :
?share:bool ->
'm Slap_size.t ->
'n Slap_size.t ->
('num, 'prec, Bigarray.fortran_layout) Bigarray.Array2.t ->
('m, 'n, 'num, 'prec, 'cnt) tLike of_bigarray_dyn, but size checking is not always performed.
Submatrices
val submat_dyn :
'm Slap_size.t ->
'n Slap_size.t ->
?ar:int ->
?ac:int ->
(_, _, 'num, 'prec, 'cd) t ->
('m, 'n, 'num, 'prec, Slap_misc.dsc) tsubmat_dyn m n ?ar ?ac a
Utilities
dim_array_array aa returns Some (n_rows, n_cols) with the number of rows n_rows and the number of columns n_cols of the given array of arrays. (0, 0) is returned if aa is an empty array. None is returned if aa is not rectangular.