ocaml-core / base / core / lib / math.mli

The branch 'bash' does not exist.
module List_math : sig
  (** [frange] is similar to [List.range], but for floats. *)
  val frange : ?stride:float -> float -> float -> float list

  (** [linspace] is similar to [frange], but it takes the number of elements in the output
      as an argument, rather than the size of the stride, which is more numerically
      robust.  The [endpoint] parameter explicitly controls whether [stop] value should be
      included in the output (the default) or not.

      This function is a clone of [numpy.linspace].
  *)
  val linspace: ?endpoint:bool -> float -> float -> int -> float list

  (** [sum] sum a list of floats.  Uses the Kahan summation algorithm. *)
  val sum : float list -> float

  (** [sum_sq] sum the squares of a list of floats  *)
  val sum_sq : float list -> float

  (** [sum_product_exn] compute the sum of element-wise product of two lists of floats *)
  val sum_product_exn : float list -> float list -> float
end

module Array_math : sig
  (* Same functions as [List_math].  [frange] and [linspace] are implmented in terms of
     lists and then converted.  [sum], [sum_sq], and [sum_product_exn] are implemented
     directly in terms of arrays and the list functions are the ones that have to
     convert. *)
  val frange : ?stride:float -> float -> float -> float array
  val linspace: ?endpoint:bool -> float -> float -> int -> float array
  val sum : float array -> float
  val sum_sq : float array -> float
  val sum_product_exn : float array -> float array -> float
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.