Module Float_arraySource

Sourcemodule type S = sig ... end
Sourcemodule type Permissioned = sig ... end
include S with type t = Core.floatarray and type float_elt := float
include Core.Bin_prot.Binable.S__local with type t := t
include Bin_prot.Binable.S_only_functions__local with type t := t
include sig ... end
Sourceval bin_size_t : t Bin_prot.Size.sizer
Sourceval bin_write_t : t Bin_prot.Write.writer
Sourceval bin_read_t : t Bin_prot.Read.reader
Sourceval __bin_read_t__ : t Bin_prot.Read.vtag_reader

This function only needs implementation if t exposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the variant t afterwards.

Sourceval bin_shape_t : Bin_prot.Shape.t
include Ppx_compare_lib.Comparable.S with type t := t
Sourceval compare : t -> t -> int
Sourceval globalize : t @ local -> t
include Sexplib0.Sexpable.S__stack with type t := t
include Sexplib0.Sexpable.Of_sexp with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
include Sexplib0.Sexpable.Sexp_of__stack with type t := t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval t_sexp_grammar : t Sexplib0.Sexp_grammar.t @@ portable
Sourceval custom_sexp_of_t : (float -> Core.Sexp.t) -> t -> Core.Sexp.t @@ portable
Sourceval custom_t_of_sexp : (Core.Sexp.t -> float) -> Core.Sexp.t -> t @@ portable
include Core.Binary_searchable.S with type t := t with type elt := float

See Binary_search.binary_search in binary_search.ml

See Binary_search.binary_search_segmented in binary_search.ml

Sourceval binary_search_segmented : ?pos:int -> ?len:int -> t -> segment_of:(float -> [ `Left | `Right ]) @ local -> [ `Last_on_left | `First_on_right ] -> int option @ local
include Core.Container.S0 with type t := t with type elt := float
include sig ... end
include sig ... end
Sourceval is_empty : ('a : value mod separable) 'p1 'p2. t -> bool
Sourceval iter : ('a : value mod separable) 'p1 'p2. t -> f:(float -> unit) @ local -> unit

iter must allow exceptions raised in f to escape, terminating the iteration cleanly. The same holds for all functions below taking an f.

Sourceval exists : ('a : value mod separable) 'p1 'p2. t -> f:(float -> bool) @ local -> bool

Returns true if and only if there exists an element for which the provided function evaluates to true. This is a short-circuiting operation.

Sourceval for_all : ('a : value mod separable) 'p1 'p2. t -> f:(float -> bool) @ local -> bool

Returns true if and only if the provided function evaluates to true for all elements. This is a short-circuiting operation.

Sourceval count : ('a : value mod separable) 'p1 'p2. t -> f:(float -> bool) @ local -> int

Returns the number of elements for which the provided function evaluates to true.

Sourceval find : ('a : value mod separable) 'p1 'p2. t -> f:(float -> bool) @ local -> float option

Returns as an option the first element for which f evaluates to true.

Sourceval to_list : ('a : value mod separable) 'p1 'p2. t -> float list
Sourceval min_elt : ('a : value mod separable) 'p1 'p2. t -> compare:(float -> (float -> int) @ local) @ local -> float option

Returns a min (resp. max) element from the collection using the provided compare function. In case of a tie, the first element encountered while traversing the collection is returned. The implementation uses fold so it has the same complexity as fold. Returns None iff the collection is empty.

Sourceval max_elt : ('a : value mod separable) 'p1 'p2. t -> compare:(float -> (float -> int) @ local) @ local -> float option
Sourceval sum : ('a : value mod separable) 'sum 'p1 'p2. (module Base.Container.Summable with type t = 'sum) -> t -> f:(float -> 'sum) @ local -> 'sum

Returns the sum of f i for all i in the container. The order in which the elements will be summed is unspecified.

Sourceval iter_until : ('a : value mod separable) 'p1 'p2 'final. t -> f:(float -> (unit, 'final) Base.Container.Continue_or_stop.t) @ local -> finish:(unit -> 'final) @ local -> 'final

iter_until t ~f ~finish is a short-circuiting version of iter. If f returns Stop x the computation ceases and returns x. If f always returns Continue () the final result is computed by finish.

Sourceval fold : ('a : value mod separable) 'p1 'p2 'acc. t -> init:'acc -> f:('acc -> (float -> 'acc) @ local) @ local -> 'acc

fold t ~init ~f returns f (... f (f (f init e1) e2) e3 ...) en, where e1..en are the elements of t.

Sourceval fold_result : ('a : value mod separable) 'p1 'p2 'acc 'e. t -> init:'acc -> f:('acc -> (float -> ('acc, 'e) result) @ local) @ local -> ('acc, 'e) result

fold_result t ~init ~f is a short-circuiting version of fold that runs in the Result monad. If f returns an Error _, that value is returned without any additional invocations of f.

Sourceval find_map : ('a : value mod separable) 'p1 'p2 'b. t -> f:(float -> 'b option) @ local -> 'b option

Returns the first evaluation of f that returns Some, and returns None if there is no such element.

include sig ... end
Sourceval fold_until : ('a : value mod separable) 'p1 'p2 'acc 'final. t -> init:'acc -> f: ('acc -> (float -> ('acc, 'final) Base.Container.Continue_or_stop.t) @ local) @ local -> finish:('acc -> 'final) @ local -> 'final

fold_until t ~init ~f ~finish is a short-circuiting version of fold. If f returns Stop _ the computation ceases and results in that value. If f returns Continue _, the fold will proceed. If f never returns Stop _, the final result is computed by finish.

Example:

  type maybe_negative =
    | Found_negative of int
    | All_nonnegative of { sum : int }

  (** [first_neg_or_sum list] returns the first negative number in [list], if any,
      otherwise returns the sum of the list. *)
  let first_neg_or_sum =
    List.fold_until ~init:0
      ~f:(fun sum x ->
        if x < 0
        then Stop (Found_negative x)
        else Continue (sum + x))
      ~finish:(fun sum -> All_nonnegative { sum })
  ;;

  let x = first_neg_or_sum [1; 2; 3; 4; 5]
  val x : maybe_negative = All_nonnegative {sum = 15}

  let y = first_neg_or_sum [1; 2; -3; 4; 5]
  val y : maybe_negative = Found_negative -3
Sourceval mem : t -> float -> bool

Checks whether the provided element is there, using equality on elts.

Sourceval to_array : t -> float array
Sourceval length : t @ local -> int @@ portable
Sourceval empty : t @@ portable

The empty array.

Sourceval of_array : float array -> t @@ portable

Create a floatarray from a normal array of boxed floats.

Sourceval max_length : int @@ portable

Maximum length of a normal array. The maximum length of a float array is max_length/2 on 32-bit machines and max_length on 64-bit machines.

Sourceval get : t @ local -> int -> float @@ portable

Float_array.get a n returns the element number n of array a. The first element has number 0. The last element has number Float_array.length a - 1.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to (Float_array.length a - 1).

Sourceval set : t @ local -> int -> float @ local -> unit @@ portable

Float_array.set a n x modifies array a in place, replacing element number n with x.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to Float_array.length a - 1.

Sourceval unsafe_get : t @ local -> int -> float @@ portable

Unsafe version of get. Can cause arbitrary behavior when used for an out-of-bounds array access.

Sourceval unsafe_set : t @ local -> int -> float @ local -> unit @@ portable

Unsafe version of set. Can cause arbitrary behavior when used for an out-of-bounds array access.

Sourceval create : len:int -> float -> t @@ portable

create ~len x creates an array of length len with the value x populated in each element.

Sourceval create_local : len:int -> float -> t @ local @@ portable

create_local ~len x is like create. It allocates the array on the local stack. The array's elements are still global.

Sourceval init : int -> f:(int -> float) -> t @@ portable

init n ~f creates an array of length n where the ith element (starting at zero) is initialized with f i.

Sourceval make_matrix : dimx:int -> dimy:int -> float -> t Core.Array.t @@ portable

Float_array.make_matrix dimx dimy e returns a two-dimensional array (an array of arrays) with first dimension dimx and second dimension dimy. All the elements of this new matrix are initially physically equal to e.

Raise Invalid_argument if dimx or dimy is negative or greater than Float_array.max_length / 2.

Sourceval append : t -> t -> t @@ portable

Float_array.append v1 v2 returns a fresh array containing the concatenation of the arrays v1 and v2.

Sourceval concat : t list -> t @@ portable

Like Float_array.append, but concatenates a list of arrays.

Sourceval copy : t @ local -> t @@ portable

Float_array.copy a returns a copy of a, that is, a fresh array containing the same elements as a.

Sourceval fill : t -> pos:int -> len:int -> float -> unit @@ portable

Float_array.fill a ofs len x modifies the array a in place, storing x in elements number ofs to ofs + len - 1.

Raise Invalid_argument "Float_array.fill" if ofs and len do not designate a valid subarray of a.

Float_array.blit v1 o1 v2 o2 len copies len elements from array v1, starting at element number o1, to array v2, starting at element number o2. It works correctly even if v1 and v2 are the same array, and the source and destination chunks overlap.

Raise Invalid_argument "Float_array.blit" if o1 and len do not designate a valid subarray of v1, or if o2 and len do not designate a valid subarray of v2.

The unsafe versions do not bound-check the arguments.

include Core.Blit.S with type t := t
Sourceval blit : 'a 'p1 'p2 'p3 'p4. src:t @ local -> src_pos:int -> dst:t @ local -> dst_pos:int -> len:int -> unit
Sourceval blito : 'a 'p1 'p2 'p3 'p4. src:t @ local -> ?src_pos:int -> ?src_len:int -> dst:t @ local -> ?dst_pos:int -> unit -> unit
Sourceval unsafe_blit : 'a 'p1 'p2 'p3 'p4. src:t @ local -> src_pos:int -> dst:t @ local -> dst_pos:int -> len:int -> unit
Sourceval sub : 'a 'p1 'p2 'p3 'p4. t @ local -> pos:int -> len:int -> t
Sourceval subo : 'a 'p1 'p2 'p3 'p4. ?pos:int -> ?len:int -> t @ local -> t
Sourceval of_list : float list -> t @@ portable

Float_array.of_list l returns a fresh array containing the elements of l.

Sourceval map : t -> f:(float -> float) -> t @@ portable

Float_array.map t ~f applies function f to all the elements of t, and builds an array with the results returned by f: [| f t.(0); f t.(1); ...; f t.(Float_array.length t - 1) |].

Sourceval folding_map : t -> init:'a -> f:('a -> float -> 'a * float) -> t @@ portable

folding_map is a version of map that threads an accumulator through calls to f.

Sourceval folding_mapi : t -> init:'a -> f:(int -> 'a -> float -> 'a * float) -> t @@ portable
Sourceval fold_map : t -> init:'a -> f:('a -> float -> 'a * float) -> 'a * t @@ portable

Float_array.fold_map is a combination of Float_array.fold and Float_array.map that threads an accumulator through calls to f.

Sourceval fold_mapi : t -> init:'a -> f:(int -> 'a -> float -> 'a * float) -> 'a * t @@ portable
Sourceval iteri : t -> f:(int -> float -> unit) -> unit @@ portable

Like Float_array.iter, but the function is applied to the index of the element as first argument, and the element itself as second argument.

Sourceval mapi : t -> f:(int -> float -> float) -> t @@ portable

Like Float_array.map, but the function is applied to the index of the element as first argument, and the element itself as second argument.

Sourceval foldi : t -> init:'a -> f:(int -> 'a -> float -> 'a) -> 'a @@ portable
Sourceval fold_right : t -> f:(float -> 'a -> 'a) -> init:'a -> 'a @@ portable

Float_array.fold_right f a ~init computes f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...)), where n is the length of the array a.

All sort functions in this module sort in increasing order by default.

Sourceval sort : ?pos:int -> ?len:int -> t -> compare:(float -> float -> int) -> unit @@ portable

sort uses constant heap space. stable_sort uses linear heap space.

To sort only part of the array, specify pos to be the index to start sorting from and len indicating how many elements to sort.

Sourceval stable_sort : t -> compare:(float -> float -> int) -> unit @@ portable
Sourceval is_sorted : t -> compare:(float -> float -> int) -> bool @@ portable
Sourceval is_sorted_strictly : t -> compare:(float -> float -> int) -> bool @@ portable

is_sorted_strictly xs ~compare iff is_sorted xs ~compare and no two consecutive elements in xs are equal according to compare.

Sourceval concat_map : t -> f:(float -> t) -> t @@ portable

Like List.concat_map, List.concat_mapi.

Sourceval concat_mapi : t -> f:(int -> float -> t) -> t @@ portable
Sourceval partition_tf : t -> f:(float -> bool) -> t * t @@ portable
Sourceval partitioni_tf : t -> f:(int -> float -> bool) -> t * t @@ portable
Sourceval cartesian_product : t -> t -> (float * float) Core.Array.t @@ portable
Sourceval transpose : t Core.Array.t -> t Core.Array.t option @@ portable

transpose in the sense of a matrix transpose. It returns None if the arrays are not all the same length.

Sourceval transpose_exn : t Core.Array.t -> t Core.Array.t @@ portable
Sourceval filter_opt : float option Core.Array.t -> t @@ portable

filter_opt array returns a float array where None entries are omitted and Some x entries are replaced with x. Note that this changes the index at which elements will appear.

Sourceval filter_map : t -> f:(float -> float option) -> t @@ portable

filter_map ~f array maps f over array and filters None out of the results.

Sourceval filter_mapi : t -> f:(int -> float -> float option) -> t @@ portable

Like filter_map but uses Float_array.mapi.

Sourceval for_alli : t -> f:(int -> float -> bool) -> bool @@ portable

Like for_all, but passes the index as an argument.

Sourceval existsi : t -> f:(int -> float -> bool) -> bool @@ portable

Like exists, but passes the index as an argument.

Sourceval counti : t -> f:(int -> float -> bool) -> int @@ portable

Like count, but passes the index as an argument.

Functions with the 2 suffix raise an exception if the lengths of the two given arrays aren't the same.

Sourceval iter2_exn : t -> t -> f:(float -> float -> unit) -> unit @@ portable
Sourceval map2_exn : t -> t -> f:(float -> float -> float) -> t @@ portable
Sourceval fold2_exn : t -> t -> init:'c -> f:('c -> float -> float -> 'c) -> 'c @@ portable
Sourceval for_all2_exn : t -> t -> f:(float -> float -> bool) -> bool @@ portable

for_all2_exn t1 t2 ~f fails if length t1 <> length t2.

Sourceval exists2_exn : t -> t -> f:(float -> float -> bool) -> bool @@ portable

exists2_exn t1 t2 ~f fails if length t1 <> length t2.

Sourceval filter : t -> f:(float -> bool) -> t @@ portable

filter t ~f removes the elements for which f returns false.

Sourceval filteri : t -> f:(int -> float -> bool) -> t @@ portable

Like filter except f also receives the index.

Sourceval swap : t -> int -> int -> unit @@ portable

swap arr i j swaps the value at index i with that at index j.

Sourceval rev_inplace : t -> unit @@ portable

rev_inplace t reverses t in place.

Sourceval of_list_rev : float list -> t @@ portable

of_list_rev l converts from list then reverses in place.

Sourceval of_list_map : float list -> f:(float -> float) -> t @@ portable

of_list_map l ~f is the same as of_list (List.map l ~f).

Sourceval of_list_mapi : float list -> f:(int -> float -> float) -> t @@ portable

of_list_mapi l ~f is the same as of_list (List.mapi l ~f).

Sourceval of_list_rev_map : float list -> f:(float -> float) -> t @@ portable

of_list_rev_map l ~f is the same as of_list (List.rev_map l ~f).

Sourceval of_list_rev_mapi : float list -> f:(int -> float -> float) -> t @@ portable

of_list_rev_mapi l ~f is the same as of_list (List.rev_mapi l ~f).

Sourceval map_inplace : t -> f:(float -> float) -> unit @@ portable

Modifies an array in place, applying f to every element of the array

Sourceval find_exn : t -> f:(float -> bool) -> float @@ portable

find_exn f t returns the first a in t for which f (get t i) is true. It raises Caml.Not_found or Not_found_s if there is no such a.

Sourceval find_map_exn : t -> f:(float -> 'a option) -> 'a @@ portable

Returns the first evaluation of f that returns Some. Raises Caml.Not_found or Not_found_s if f always returns None.

Sourceval findi : t -> f:(int -> float -> bool) -> (int * float) option @@ portable

findi t f returns the first index i of t for which f i (get t i) is true

Sourceval findi_exn : t -> f:(int -> float -> bool) -> int * float @@ portable

findi_exn t f returns the first index i of t for which f i (get t i) is true. It raises Caml.Not_found or Not_found_s if there is no such element.

Sourceval find_mapi : t -> f:(int -> float -> 'a option) -> 'a option @@ portable

find_mapi t f is like find_map but passes the index as an argument.

Sourceval find_mapi_exn : t -> f:(int -> float -> 'a option) -> 'a @@ portable

find_mapi_exn is like find_map_exn but passes the index as an argument.

Sourceval find_consecutive_duplicate : t -> equal:(float -> float -> bool) -> (float * float) option @@ portable

find_consecutive_duplicate t ~equal returns the first pair of consecutive elements (a1, a2) in t such that equal a1 a2. They are returned in the same order as they appear in t.

Sourceval reduce : t -> f:(float -> float -> float) -> float option @@ portable

reduce f [a1; ...; an] is Some (f (... (f (f a1 a2) a3) ...) an). Returns None on the empty array.

Sourceval reduce_exn : t -> f:(float -> float -> float) -> float @@ portable
Sourceval permute : ?random_state:Core.Random.State.t -> t -> unit @@ portable

permute ?random_state t randomly permutes t in place.

permute side-effects random_state by repeated calls to Random.State.int. If random_state is not supplied, permute uses Random.State.default.

Sourceval random_element : ?random_state:Core.Random.State.t -> t -> float option @@ portable

random_element ?random_state t is None if t is empty, else it is Some x for some x chosen uniformly at random from t.

random_element side-effects random_state by calling Random.State.int. If random_state is not supplied, random_element uses Random.State.default.

Sourceval random_element_exn : ?random_state:Core.Random.State.t -> t -> float @@ portable
Sourceval zip : t -> t -> (float * float) Core.Array.t option @@ portable

zip is like List.zip, but for arrays.

Sourceval zip_exn : t -> t -> (float * float) Core.Array.t @@ portable
Sourceval unzip : (float * float) Core.Array.t -> t * t @@ portable

unzip is like List.unzip, but for arrays.

Sourceval sorted_copy : t -> compare:(float -> float -> int) -> t @@ portable

sorted_copy ar compare returns a shallow copy of ar that is sorted. Similar to List.sort

Sourceval last : t -> float @@ portable
Sourceval equal : (float -> float -> bool) -> t -> t -> bool @@ portable
Sourceval to_sequence : t -> float Core.Sequence.t @@ portable

The input array is copied internally so that future modifications of it do not change the sequence.

Sourceval to_sequence_mutable : t -> float Core.Sequence.t @@ portable

The input array is shared with the sequence and modifications of it will result in modification of the sequence.

Sourcemodule Permissioned : Permissioned with type permissionless := t and type float_elt := float