package octez-bls12-381-polynomial

  1. Overview
  2. Docs

Note that an unsafe type casting is performed by this module. USE WITH CARE! The type of get and set changes with whatever Elt.t is given as input. This works because Elt also indicates the size in bytes which would be read/written and because Elt is assumed to be backed by a custom block (it is accessed with Data_custom_val).

Parameters

module Elt : Elt_sig

Signature

type t
type elt = Elt.t
val t : t Repr.t
val empty : t
val allocate : int -> t

allocate len creates a C array of size len initialized with zeros.

val init : int -> (int -> elt) -> t

init n f returns a fresh C array of length n, with element number i initialized to the result of f i.

val degree : t -> int

degree p returns the index of the last non-zero element of p. Returns -1 if all elements of p are zero.

val erase : t -> int -> unit

erase p n fills with zeros the first n elements of p.

val length : t -> int

length c returns the length of a C array c

val get : t -> int -> elt

get c i returns the i-th element of a C array c

val get_inplace : t -> int -> elt -> unit

get_inplace c i res copies the i-th element of a C array c in res

val iter_copy_elt : (elt -> unit) -> t -> unit

iter_copy_elt f a applies function f in turn to a **copy** of all the elements of a. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ().

val iteri_copy_elt : (int -> elt -> unit) -> t -> unit

Same as iter_copy_elt, but the function is applied to the index of the element as first argument, and a **copy** of the element itself as second argument.

val set : t -> elt -> int -> unit
val copy : ?offset:int -> ?len:int -> t -> t

copy c copies len elements from a C array c starting from position offset

val blit : t -> src_off:int -> t -> dst_off:int -> len:int -> unit

blit src src_off dst dst_off len copies len elements from src to dst starting at the respective offsets.

val equal : t -> offset1:int -> t -> offset2:int -> len:int -> bool

equal a offset1 b offset2 returns true if the segments of len elements of a and b are equal starting from their respective offsets offset1 (for a) and offset2 (for b).

val to_array : ?offset:int -> ?len:int -> t -> elt array

to_array c converts a C array c to an OCaml array

val of_array : elt array -> t

of_array c converts an OCaml array c to a C array

val of_bigstring : Bigstringaf.t -> t
val to_bigstring : t -> Bigstringaf.t
val eq : t -> t -> bool

eq a b returns true if C arrays a and b are equals

val sub : t -> off:int -> len:int -> t

sub a off len extracts a sub-array of a

val fold_left_map : ('acc -> elt -> 'acc * elt) -> 'acc -> t -> 'acc * t

fold_left_map is a combination of fold_left and map that threads an accumulator through calls to f.

OCaml

Innovation. Community. Security.