Provided by: ocaml-nox_3.12.1-2ubuntu2_amd64

**NAME**

Bigarray - Large, multi-dimensional, numerical arrays.

**Module**

Module Bigarray

**Documentation**

ModuleBigarray:sigendLarge, multi-dimensional, numerical arrays. This module implements multi-dimensional arrays of integers and floating-point numbers, thereafter referred to as ``big arrays''. The implementation allows efficient sharing of large numerical arrays between Caml code and C or Fortran numerical libraries. Concerning the naming conventions, users of this module are encouraged to doopenBigarrayin their source, then refer to array types and operations via short dot notation, e.g.Array1.torArray2.sub. Big arrays support all the Caml ad-hoc polymorphic operations: -comparisons (=,<>,<=, etc, as well asPervasives.compare); -hashing (moduleHash); -and structured input-output (Pervasives.output_valueandPervasives.input_value, as well as the functions from theMarshalmodule).===Elementkinds======Bigarrayscancontainelementsofthefollowingkinds:-IEEEsingleprecision(32bits)floating-pointnumbers(Bigarray.float32_elt),-IEEEdoubleprecision(64bits)floating-pointnumbers(Bigarray.float64_elt),-IEEEsingleprecision(2*32bits)floating-pointcomplexnumbers(Bigarray.complex32_elt),-IEEEdoubleprecision(2*64bits)floating-pointcomplexnumbers(Bigarray.complex64_elt),-8-bitintegers(signedorunsigned)(Bigarray.int8_signed_eltorBigarray.int8_unsigned_elt),-16-bitintegers(signedorunsigned)(Bigarray.int16_signed_eltorBigarray.int16_unsigned_elt),-Camlintegers(signed,31bitson32-bitarchitectures,63bitson64-bitarchitectures)(Bigarray.int_elt),-32-bitsignedinteger(Bigarray.int32_elt),-64-bitsignedintegers(Bigarray.int64_elt),-platform-nativesignedintegers(32bitson32-bitarchitectures,64bitson64-bitarchitectures)(Bigarray.nativeint_elt).Eachelementkindisrepresentedatthetypelevelbyoneoftheabstracttypesdefinedbelow.===typefloat32_elttypefloat64_elttypecomplex32_elttypecomplex64_elttypeint8_signed_elttypeint8_unsigned_elttypeint16_signed_elttypeint16_unsigned_elttypeint_elttypeint32_elttypeint64_elttypenativeint_elttype('a,'b)kindTo each element kind is associated a Caml type, which is the type of Caml values that can be stored in the big array or read back from it. This type is not necessarily the same as the type of the array elements proper: for instance, a big array whose elements are of kindfloat32_eltcontains 32-bit single precision floats, but reading or writing one of its elements from Caml uses the Caml typefloat, which is 64-bit double precision floats. The abstract type('a,'b)kindcaptures this association of a Caml type'afor values read or written in the big array, and of an element kind'bwhich represents the actual contents of the big array. The following predefined values of typekindlist all possible associations of Caml types with element kinds:valfloat32:(float,float32_elt)kindSeeBigarray.char.valfloat64:(float,float64_elt)kindSeeBigarray.char.valcomplex32:(Complex.t,complex32_elt)kindSeeBigarray.char.valcomplex64:(Complex.t,complex64_elt)kindSeeBigarray.char.valint8_signed:(int,int8_signed_elt)kindSeeBigarray.char.valint8_unsigned:(int,int8_unsigned_elt)kindSeeBigarray.char.valint16_signed:(int,int16_signed_elt)kindSeeBigarray.char.valint16_unsigned:(int,int16_unsigned_elt)kindSeeBigarray.char.valint:(int,int_elt)kindSeeBigarray.char.valint32:(int32,int32_elt)kindSeeBigarray.char.valint64:(int64,int64_elt)kindSeeBigarray.char.valnativeint:(nativeint,nativeint_elt)kindSeeBigarray.char.valchar:(char,int8_unsigned_elt)kindAs shown by the types of the values above, big arrays of kindfloat32_eltandfloat64_eltare accessed using the Caml typefloat. Big arrays of complex kindscomplex32_elt,complex64_eltare accessed with the Caml typeComplex.t. Big arrays of integer kinds are accessed using the smallest Caml integer type large enough to represent the array elements:intfor 8- and 16-bit integer bigarrays, as well as Caml-integer bigarrays;int32for 32-bit integer bigarrays;int64for 64-bit integer bigarrays; andnativeintfor platform-native integer bigarrays. Finally, big arrays of kindint8_unsigned_eltcan also be accessed as arrays of characters instead of arrays of small integers, by using the kind valuecharinstead ofint8_unsigned.===Arraylayouts===typec_layoutSeeBigarray.fortran_layout.typefortran_layoutTo facilitate interoperability with existing C and Fortran code, this library supports two different memory layouts for big arrays, one compatible with the C conventions, the other compatible with the Fortran conventions. In the C-style layout, array indices start at 0, and multi-dimensional arrays are laid out in row-major format. That is, for a two-dimensional array, all elements of row 0 are contiguous in memory, followed by all elements of row 1, etc. In other terms, the array elements at(x,y)and(x,y+1)are adjacent in memory. In the Fortran-style layout, array indices start at 1, and multi-dimensional arrays are laid out in column-major format. That is, for a two-dimensional array, all elements of column 0 are contiguous in memory, followed by all elements of column 1, etc. In other terms, the array elements at(x,y)and(x+1,y)are adjacent in memory. Each layout style is identified at the type level by the abstract typesBigarray.c_layoutandfortran_layoutrespectively.type'alayoutThe type'alayoutrepresents one of the two supported memory layouts: C-style if'aisBigarray.c_layout, Fortran-style if'aisBigarray.fortran_layout.===SupportedlayoutsTheabstractvaluesc_layoutandfortran_layoutrepresentthetwosupportedlayoutsatthelevelofvalues.===valc_layout:c_layoutlayoutvalfortran_layout:fortran_layoutlayout===Genericarrays(ofarbitrarilymanydimensions)===moduleGenarray:sigend===One-dimensionalarrays===moduleArray1:sigendOne-dimensional arrays. TheArray1structure provides operations similar to those ofBigarray.Genarray, but specialized to the case of one-dimensional arrays. (TheArray2andArray3structures below provide operations specialized for two- and three-dimensional arrays.) Statically knowing the number of dimensions of the array allows faster operations, and more precise static type-checking.===Two-dimensionalarrays===moduleArray2:sigendTwo-dimensional arrays. TheArray2structure provides operations similar to those ofBigarray.Genarray, but specialized to the case of two-dimensional arrays.===Three-dimensionalarrays===moduleArray3:sigendThree-dimensional arrays. TheArray3structure provides operations similar to those ofBigarray.Genarray, but specialized to the case of three-dimensional arrays.===Coercionsbetweengenericbigarraysandfixed-dimensionbigarrays===valgenarray_of_array1:('a,'b,'c)Array1.t->('a,'b,'c)Genarray.tReturn the generic big array corresponding to the given one-dimensional big array.valgenarray_of_array2:('a,'b,'c)Array2.t->('a,'b,'c)Genarray.tReturn the generic big array corresponding to the given two-dimensional big array.valgenarray_of_array3:('a,'b,'c)Array3.t->('a,'b,'c)Genarray.tReturn the generic big array corresponding to the given three-dimensional big array.valarray1_of_genarray:('a,'b,'c)Genarray.t->('a,'b,'c)Array1.tReturn the one-dimensional big array corresponding to the given generic big array. RaiseInvalid_argumentif the generic big array does not have exactly one dimension.valarray2_of_genarray:('a,'b,'c)Genarray.t->('a,'b,'c)Array2.tReturn the two-dimensional big array corresponding to the given generic big array. RaiseInvalid_argumentif the generic big array does not have exactly two dimensions.valarray3_of_genarray:('a,'b,'c)Genarray.t->('a,'b,'c)Array3.tReturn the three-dimensional big array corresponding to the given generic big array. RaiseInvalid_argumentif the generic big array does not have exactly three dimensions.===Re-shapingbigarrays===valreshape:('a,'b,'c)Genarray.t->intarray->('a,'b,'c)Genarray.treshapeb[|d1;...;dN|]converts the big arraybto aN-dimensional array of dimensionsd1...dN. The returned array and the original arraybshare their data and have the same layout. For instance, assuming thatbis a one-dimensional array of dimension 12,reshapeb[|3;4|]returns a two-dimensional arrayb'of dimensions 3 and 4. Ifbhas C layout, the element(x,y)ofb'corresponds to the elementx*3+yofb. Ifbhas Fortran layout, the element(x,y)ofb'corresponds to the elementx+(y-1)*4ofb. The returned big array must have exactly the same number of elements as the original big arrayb. That is, the product of the dimensions ofbmust be equal toi1*...*iN. Otherwise,Invalid_argumentis raised.valreshape_1:('a,'b,'c)Genarray.t->int->('a,'b,'c)Array1.tSpecialized version ofBigarray.reshapefor reshaping to one-dimensional arrays.valreshape_2:('a,'b,'c)Genarray.t->int->int->('a,'b,'c)Array2.tSpecialized version ofBigarray.reshapefor reshaping to two-dimensional arrays.valreshape_3:('a,'b,'c)Genarray.t->int->int->int->('a,'b,'c)Array3.tSpecialized version ofBigarray.reshapefor reshaping to three-dimensional arrays.