Module Gg.Ba
Linear bigarrays and bigarray buffers.
WARNING. This interface is subject to change in the future.
This module has a few convenience functions for linear (1D) bigarrays.
The purpose of buffer is to allow to specify a few more data types than bigarrays are able to express and facilitate the generic handling of linear bigarrays.
Scalar types
type ('a, 'b) ba_scalar_type=|Int8 : (int, Bigarray.int8_signed_elt) ba_scalar_type|Int16 : (int, Bigarray.int16_signed_elt) ba_scalar_type|Int32 : (int32, Bigarray.int32_elt) ba_scalar_type|Int64 : (int64, Bigarray.int64_elt) ba_scalar_type|UInt8 : (int, Bigarray.int8_unsigned_elt) ba_scalar_type|UInt16 : (int, Bigarray.int16_unsigned_elt) ba_scalar_type|UInt32 : (int32, Bigarray.int32_elt) ba_scalar_type|UInt64 : (int64, Bigarray.int64_elt) ba_scalar_type|Float16 : (int, Bigarray.int16_unsigned_elt) ba_scalar_type|Float32 : (float, Bigarray.float32_elt) ba_scalar_type|Float64 : (float, Bigarray.float64_elt) ba_scalar_typeThe type for bigarray scalar types.
val ba_kind_of_ba_scalar_type : ('a, 'b) ba_scalar_type -> ('a, 'b) Bigarray.kindba_kind_of_ba_scalar_type stis the bigarray kind corresponding tost.
type scalar_type=[|`Int8|`Int16|`Int32|`Int64|`UInt8|`UInt16|`UInt32|`UInt64|`Float16|`Float32|`Float64]The type for buffer scalar types.
val scalar_type_of_ba_scalar_type : ('a, 'b) ba_scalar_type -> scalar_typescalar_type_of_ba_scalar_type stis the scalar type corresponding tost.
val scalar_type_byte_count : scalar_type -> intscalar_type_byte_count stis the number of bytes used by a scalar of typest.
val pp_scalar_type : Stdlib.Format.formatter -> scalar_type -> unitpp_scalar_type ppf stprints a textual representation ofstonppf.
Bigarray buffers
module Buffer : sig ... endBigarrays
val create : ('a, 'b) ba_scalar_type -> int -> ('a, 'b) bigarraycreate k countis a bigarray of kindkwithcountscalars.
val length : ('a, 'b) bigarray -> intlength bais the length ofba.
val sub : ('a, 'b) bigarray -> int -> int -> ('a, 'b) bigarraysub ba i lenare theith toith +nscalars ofbaas a bigarray. Note, this is not a copy.
val blit : ('a, 'b) bigarray -> int -> ('a, 'b) bigarray -> int -> int -> unitblit src si dst di lencopieslenscalar values starting atsiinsrctodststarting atdi.
val fill : ('a, 'b) bigarray -> 'a -> unitfill ba vsets each scalar value ofbatov.
val of_array : ('a, 'b) ba_scalar_type -> 'a array -> ('a, 'b) bigarrayof_array st ais a bigarray from arraya.
val of_list : ('a, 'b) ba_scalar_type -> 'a list -> ('a, 'b) bigarrayof_list st lis a bigarray from listl.
val of_bytes : ?be:bool -> ('a, 'b) ba_scalar_type -> string -> ('a, 'b) bigarrayof_bytes be s kis a bigarray of kindkfroms. ifbeistruedata is assumed to be in big endian order (defaults tofalse).TODO For now only
Int8andUInt8are supported.- raises Invalid_argument
if given an unsupported kind or if the data length is not a multiple of the requested scalar type.
val pp : ?count:int -> ?stride:int -> ?first:int -> ?dim:int -> pp_scalar:(Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> ('a, 'b) bigarray -> unitpp count stride first dim pp_scalar ppf bprints onppf,countgroups of sizedimof scalars ofb, starting atfirstusingpp_scalar, and stridingstridescalars to go from group to group. Ifcountis unspecified prints as much as possible.stridedefaults todim,firstdefaults to0anddimto1.
Getting
val get_v2 : (float, 'b) bigarray -> int -> v2get_v2 b iis theith toi+1th scalars ofbas a vector.
val get_v3 : (float, 'b) bigarray -> int -> v3get_v3 b iis theith toi+2th scalars ofbas a vector.
val get_v4 : (float, 'b) bigarray -> int -> v4get_v4 b iis theith toi+3th scalars ofbas a vector.
val get_2d : ('a, 'b) bigarray -> int -> 'a * 'aget_v2 b iis theith toi+1th scalars ofb.
val get_3d : ('a, 'b) bigarray -> int -> 'a * 'a * 'aget_v3 b iis theith toi+2th scalars ofb.
val get_4d : ('a, 'b) bigarray -> int -> 'a * 'a * 'a * 'aget_v4 b iis theith toi+3th scalars ofb.
int32 Bigarray
val geti_2d : (int32, 'b) bigarray -> int -> int * intget_v2 b iis theith toi+1th scalars ofb. The integers are converted withInt32.to_int.
val geti_3d : (int32, 'b) bigarray -> int -> int * int * intget_v3 b iis theith toi+2th scalars ofb. The integers are converted withInt32.to_int
Setting
val set_v2 : (float, 'b) bigarray -> int -> v2 -> unitset_v2 b i vsets theith toi+1th scalars ofbwithv.
val set_v3 : (float, 'b) bigarray -> int -> v3 -> unitset_v3 b i vsets theith toi+2th scalars ofbwithv.
val set_v4 : (float, 'b) bigarray -> int -> v4 -> unitset_v4 b i vsets theith toi+3th scalars ofbwithv.
val set_2d : ('a, 'b) bigarray -> int -> 'a -> 'a -> unitset_2d b i s1 s2sets theith toi+1th scalar ofbtos1,s2.
val set_3d : ('a, 'b) bigarray -> int -> 'a -> 'a -> 'a -> unitset_3d b i s1 s2 s3sets theith toi+2th scalar ofbtos1,s2,s3.
val set_4d : ('a, 'b) bigarray -> int -> 'a -> 'a -> 'a -> 'a -> unitset_4d b i s1 s2 s3 s4sets theith toi+3th scalar ofbtos1,s2,s3,s4.
int32 Bigarray
val seti_2d : (int32, 'b) bigarray -> int -> int -> int -> unitset_2d b i s1 s2sets theith toi+1th scalar ofbtos1,s2.
val seti_3d : (int32, 'b) bigarray -> int -> int -> int -> int -> unitset_3d b i s1 s2 s3sets theith toi+2th scalar ofbtos1,s2,s3.