package owl-base

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Owl_view.MakeSource

Parameters

Signature

Type definition
Sourcetype t

t is the abstract type to represent a view atop of an ndarray.

Conversion functions
Sourceval of_arr : A.arr -> t

of_arr x creates a view from ndarray x.

Sourceval to_arr : t -> A.arr

to_arr x creates an new ndarray based on the view x.

Manipulation functions
Sourceval get : t -> int array -> A.elt

Refer to :doc:`owl_dense_ndarray_generic`

Sourceval set : t -> int array -> A.elt -> unit

Refer to :doc:`owl_dense_ndarray_generic`

Sourceval get_slice : int list list -> t -> t

Refer to :doc:`owl_dense_ndarray_generic`

Sourceval set_slice : int list list -> t -> t -> unit

Refer to :doc:`owl_dense_ndarray_generic`

Sourceval shape : t -> int array

Refer to :doc:`owl_dense_ndarray_generic`

Sourceval num_dims : t -> int

Refer to :doc:`owl_dense_ndarray_generic`

Sourceval nth_dim : t -> int -> int

Refer to :doc:`owl_dense_ndarray_generic`

Sourceval numel : t -> int

Refer to :doc:`owl_dense_ndarray_generic`

Iteration functions
Sourceval iteri : (int -> A.elt -> unit) -> t -> unit

iteri f x iterates and applies f to every element in x. f has type f : int array -> elt -> unit, the first parameter is index. 1d indices are passed to the user function.

Sourceval iter : (A.elt -> unit) -> t -> unit

Similar to iteri, the index is not passed in.

Sourceval mapi : (int -> A.elt -> A.elt) -> t -> unit

mapi f x applies f : int array -> elt -> elt to every element in x, then save the result in place. 1d indices are passed to the user function.

Sourceval map : (A.elt -> A.elt) -> t -> unit

map f x applies f : elt -> elt to every element in x, then save the the result in place in x.

Sourceval iter2 : (A.elt -> A.elt -> unit) -> t -> t -> unit

iter2 f x y applies f : elt -> elt -> elt every pair of elements in x and y. The indices are not passed in the user function.

Sourceval map2 : (A.elt -> A.elt -> A.elt) -> t -> t -> unit

map2 f x y applies f : elt -> elt -> elt every pair of elements in x and y, then saves the result in y. So be careful with the order, it matters, the data reflected by view y will be modified.

Sourceval iteri_nd : (int array -> A.elt -> unit) -> t -> unit

Similar to `iteri` but n-d indices are passed in. This function is much slower than `iteri`.

Sourceval mapi_nd : (int array -> A.elt -> A.elt) -> t -> unit

Similar to `mapi` but n-d indices are passed in. This function is much slower than `mapi`.

Examination & Comparison
Sourceval exists : (A.elt -> bool) -> t -> bool

exists f x checks all the elements in x using f. If at least one element satisfies f then the function returns true otherwise false.

Sourceval not_exists : (A.elt -> bool) -> t -> bool

not_exists f x checks all the elements in x, the function returns true only if all the elements fail to satisfy f : float -> bool.

Sourceval for_all : (A.elt -> bool) -> t -> bool

for_all f x checks all the elements in x, the function returns true if and only if all the elements pass the check of function f.

Sourceval equal : t -> t -> bool

equal x y returns true if x and y are elementwise equal.

Sourceval not_equal : t -> t -> bool

not_equal x y returns true if x and y are not elementwise equal.