View Functor

This document is auto-generated for Owl’s APIs. #29 entries have been extracted.

Github: {Signature} {Implementation}

Type definition

type t

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

Conversion functions

val of_arr : A.arr -> t

of_arr x creates a view from ndarray x.

source code

val to_arr : t -> A.arr

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

source code

Manipulation functions

val get : t -> int array -> A.elt

Refer to Dense.Ndarray.Generic

source code

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

Refer to Dense.Ndarray.Generic

source code

val get_slice : int list list -> t -> t

Refer to Dense.Ndarray.Generic

source code

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

Refer to Dense.Ndarray.Generic

source code

val shape : t -> int array

Refer to Dense.Ndarray.Generic

val num_dims : t -> int

Refer to Dense.Ndarray.Generic

source code

val nth_dim : t -> int -> int

Refer to Dense.Ndarray.Generic

source code

val numel : t -> int

Refer to Dense.Ndarray.Generic

source code

Iteration functions

val 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 paramater is index. 1d indices are passed to the user function.

source code

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

Similar to iteri, the index is not passed in.

source code

val 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.

source code

val 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.

source code

val 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.

source code

val 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.

source code

val 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.

source code

val 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.

source code

Examination & Comparison

val 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.

source code

val 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.

source code

val 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.

source code

val equal : t -> t -> bool

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

source code

val not_equal : t -> t -> bool

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

source code