package owl-base
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=4efa33bb2f04fa14f493a3dd9bf4210895ff558d490cf8c3bd1484ba20ff26f3
sha512=1c03d0822a642975ab0b08e621012e17b7b41563196e7c2e93dd2e3338a9b0b37a63c1c6a786b8a40f32f9bd21b4c57f898b12e1b1cdd892b78fe4927e4c35b6
doc/owl-base/Owl_utils_array/index.html
Module Owl_utils_array
Basic functions
``min_i x`` returns the index of minimum value in array ``x``. If ``cmp`` is not passed in then ``Stdlib.compare`` is used as default value.
``max_i x`` returns the index of minimum value in array ``x``. If ``cmp`` is not passed in then ``Stdlib.compare`` is used as default value.
``argsort cmp x`` sorts ``x`` according to the compare function ``cmp`` and returns the corresponding indices.
``sort_fill ~min ~max ~fill x`` first sorts ``x``, then expands it to an array of length ``max - min + 1``, and fills the holes with ``fill``. E.g., ``sort_fill ~min:1 ~max:5 ~fill:0 |4;2|
x`` returns a new array as follows: ``|1; 0; 2; 0; 4; 5|
``.
Extended functions
``get_slice slice x`` returns a copy of slice of ``x`` defined by ``slice``. The ``slice`` definition must have ``|start;stop;step|
`` format. The value of start, stop, and step can be negative, and the boundary is inclusive.
``set_slice slice x y`` sets the elements in ``x`` to the corresponding value of the elements in ``y`` based on the slice definition ``slice``. Please refer to ``get_slice`` function for the information on the format of slice definiton.
``merge x y`` merges two arrays and removes the duplicates.
val iter4i :
(int -> 'a -> 'b -> 'c -> 'd -> unit) ->
'a array ->
'b array ->
'c array ->
'd array ->
unit
TODO
TODO
val map4i :
(int -> 'a -> 'b -> 'c -> 'd -> 'e) ->
'a array ->
'b array ->
'c array ->
'd array ->
'e array
TODO
TODO
``filteri f x`` filters out the elements in ``x`` according to predicate ``f``.
``filter f x`` filters out the elements in ``x`` according to predicate ``f``.
``filter2i f x y`` filters the elements in ``x`` and ``y`` using passed in function ``f``. Both arrays must have same length.
``filter2 f x y`` is similar to ``filter2i`` but without passing index of the elements to function ``f``.
``filter2i_i f x y`` filters the elements in ``x`` and ``y`` using passed in function ``f``. Both arrays must have same length. Note that the indices of those satisfying the predicate ``f`` are returned in an array.
``filter2_i f x y`` is similar to ``filter2i_i`` but without passing index of the elements to function ``f``.
``filter2_split f x y`` is similar to ``filter2 f x y``, but the returned results are two separated arrays rather than merging into one tuple array.
``resize ~head v n x`` resizes ``x`` of length ``m`` to length ``n``. If ``m <= n``, a copy of ``x`` subarray is returned. If ``m > n``, then ``x`` is extended, the extra space is filled with value ``v``.
``fold2 a x y`` folds both ``x`` and ``y`` from left with starting value ``a``.
``align side v x y`` aligns two arrays ``x`` and ``y`` along the specified side with value ``v``. The copies of two arrays are returned.
val align3 :
[ `Left | `Right ] ->
'a ->
'a array ->
'a array ->
'a array ->
'a array * 'a array * 'a array
``align3 side v x y z`` aligns three arrays ``x``, ``y``, and ``z``.
``balance_last mass x`` performs the following function. Let ``l`` be the length of ``x``, if ``i < l - 1``, then ``x.(i) = x.(i)``, otherwise ``x.(l - 1) = mass - \sum_< l - 1 x.(i)``.
``index_of x a`` returns the index of first occurrence of ``a`` in ``x``.
Binary search. ``bsearch cmp x a`` returns the index of the largest value in the sorted array ``a`` less than or equal to ``x``, according to the comparison function ``cmp``. If ``x`` is smaller than all elements, returns -1. The function raises an exception if ``a`` is empty.