logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Bigarray.Array1 - One-dimensional arrays.

Documentation

       Module Array1
        : sigend

       One-dimensional  arrays. The Array1 structure provides operations similar to those of Bigarray.Genarray ,
       but specialized to  the  case  of  one-dimensional  arrays.   (The  Bigarray.Array2  and  Bigarray.Array3
       structures  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.

       type(!'a,!'b,!'c)t

       The  type  of  one-dimensional Bigarrays whose elements have OCaml type 'a , representation kind 'b , and
       memory layout 'c .

       valcreate : ('a,'b)Bigarray.kind->'cBigarray.layout->int->('a,'b,'c)tArray1.createkindlayoutdim returns a new Bigarray of one dimension, whose size  is  dim  .   kind  and
       layout determine the array element kind and the array layout as described for Bigarray.Genarray.create .

       valinit : ('a,'b)Bigarray.kind->'cBigarray.layout->int->(int->'a)->('a,'b,'c)tArray1.initkindlayoutdimf returns a new Bigarray b of one dimension, whose size is dim .  kind and
       layout determine the array element kind and the array layout as described for Bigarray.Genarray.create .

       Each element Array1.getbi of the array is initialized to the result of fi .

       In other words, Array1.initkindlayoutdimensionsf tabulates the results of f applied to the indices of
       a new Bigarray whose layout is described by kind , layout and dim .

       Since 4.12

       valdim : ('a,'b,'c)t->int

       Return the size (dimension) of the given one-dimensional Bigarray.

       valkind : ('a,'b,'c)t->('a,'b)Bigarray.kind

       Return the kind of the given Bigarray.

       vallayout : ('a,'b,'c)t->'cBigarray.layout

       Return the layout of the given Bigarray.

       valchange_layout : ('a,'b,'c)t->'dBigarray.layout->('a,'b,'d)tArray1.change_layoutalayout returns a Bigarray with the specified layout , sharing the data with a (and
       hence having the same dimension as a ). No copying of  elements  is  involved:  the  new  array  and  the
       original array share the same storage space.

       Since 4.06

       valsize_in_bytes : ('a,'b,'c)t->intsize_in_bytesa is the number of elements in a multiplied by a 's Bigarray.kind_size_in_bytes .

       Since 4.03

       valget : ('a,'b,'c)t->int->'aArray1.getax  ,  or alternatively a.{x} , returns the element of a at index x .  x must be greater or
       equal than 0 and strictly less than Array1.dima if a has C layout.  If a has Fortran layout, x  must  be
       greater or equal than 1 and less or equal than Array1.dima .  Otherwise, Invalid_argument is raised.

       valset : ('a,'b,'c)t->int->'a->unitArray1.setaxv , also written a.{x}<-v , stores the value v at index x in a .  x must be inside the
       bounds of a as described in Bigarray.Array1.get ; otherwise, Invalid_argument is raised.

       valsub : ('a,'b,'c)t->int->int->('a,'b,'c)t

       Extract a sub-array of the given  one-dimensional  Bigarray.   See  Bigarray.Genarray.sub_left  for  more
       details.

       valslice : ('a,'b,'c)t->int->('a,'b,'c)Bigarray.Array0.t

       Extract  a  scalar (zero-dimensional slice) of the given one-dimensional Bigarray.  The integer parameter
       is   the    index    of    the    scalar    to    extract.     See    Bigarray.Genarray.slice_left    and
       Bigarray.Genarray.slice_right for more details.

       Since 4.05

       valblit : ('a,'b,'c)t->('a,'b,'c)t->unit

       Copy the first Bigarray to the second Bigarray.  See Bigarray.Genarray.blit for more details.

       valfill : ('a,'b,'c)t->'a->unit

       Fill the given Bigarray with the given value.  See Bigarray.Genarray.fill for more details.

       valof_array : ('a,'b)Bigarray.kind->'cBigarray.layout->'aarray->('a,'b,'c)t

       Build a one-dimensional Bigarray initialized from the given array.

       valunsafe_get : ('a,'b,'c)t->int->'a

       Like  Bigarray.Array1.get  , but bounds checking is not always performed.  Use with caution and only when
       the program logic guarantees that the access is within bounds.

       valunsafe_set : ('a,'b,'c)t->int->'a->unit

       Like Bigarray.Array1.set , but bounds checking is not always performed.  Use with caution and  only  when
       the program logic guarantees that the access is within bounds.

OCamldoc                                           2025-06-12                                Bigarray.Array1(3o)

Module

       Module   Bigarray.Array1

Name

       Bigarray.Array1 - One-dimensional arrays.

See Also