.TH "Bigarray.Array1" 3o 2020-01-30 OCamldoc "OCaml library"
.SH NAME
Bigarray.Array1 \- One-dimensional arrays.
.SH Module
Module   Bigarray.Array1
.SH Documentation
.sp
Module
.BI "Array1"
 : 
.B sig  end

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

.sp

.sp
.sp
.I type 
.B ('a, 'b, 'c)
.I t 

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

.sp

.I val create 
: 
.B ('a, 'b) Bigarray.kind ->
.B   'c Bigarray.layout -> int -> ('a, 'b, 'c) t
.sp

.B Array1\&.create kind layout dim
returns a new Bigarray of
one dimension, whose size is 
.B dim
\&.  
.B kind
and 
.B layout
determine the array element kind and the array layout
as described for 
.B Bigarray\&.Genarray\&.create
\&.

.sp

.I val dim 
: 
.B ('a, 'b, 'c) t -> int
.sp
Return the size (dimension) of the given one\-dimensional
Bigarray\&.

.sp

.I val kind 
: 
.B ('a, 'b, 'c) t -> ('a, 'b) Bigarray.kind
.sp
Return the kind of the given Bigarray\&.

.sp

.I val layout 
: 
.B ('a, 'b, 'c) t -> 'c Bigarray.layout
.sp
Return the layout of the given Bigarray\&.

.sp

.I val change_layout 
: 
.B ('a, 'b, 'c) t ->
.B   'd Bigarray.layout -> ('a, 'b, 'd) t
.sp

.B Array1\&.change_layout a layout
returns a Bigarray with the
specified 
.B layout
, sharing the data with 
.B a
(and hence having
the same dimension as 
.B a
)\&. No copying of elements is involved: the
new array and the original array share the same storage space\&.

.sp
.B "Since"
4.06.0

.sp

.I val size_in_bytes 
: 
.B ('a, 'b, 'c) t -> int
.sp

.B size_in_bytes a
is the number of elements in 
.B a
multiplied by 
.B a
\&'s 
.B Bigarray\&.kind_size_in_bytes
\&.

.sp
.B "Since"
4.03.0

.sp

.I val get 
: 
.B ('a, 'b, 'c) t -> int -> 'a
.sp

.B Array1\&.get a x
, or alternatively 
.B a\&.{x}
,
returns the element of 
.B a
at index 
.B x
\&.
.B x
must be greater or equal than 
.B 0
and strictly less than
.B Array1\&.dim a
if 
.B a
has C layout\&.  If 
.B a
has Fortran layout,
.B x
must be greater or equal than 
.B 1
and less or equal than
.B Array1\&.dim a
\&.  Otherwise, 
.B Invalid_argument
is raised\&.

.sp

.I val set 
: 
.B ('a, 'b, 'c) t -> int -> 'a -> unit
.sp

.B Array1\&.set a x v
, also written 
.B a\&.{x} <\- v
,
stores the value 
.B v
at index 
.B x
in 
.B a
\&.
.B x
must be inside the bounds of 
.B a
as described in
.B Bigarray\&.Array1\&.get
;
otherwise, 
.B Invalid_argument
is raised\&.

.sp

.I val sub 
: 
.B ('a, 'b, 'c) t ->
.B   int -> int -> ('a, 'b, 'c) t
.sp
Extract a sub\-array of the given one\-dimensional Bigarray\&.
See 
.B Bigarray\&.Genarray\&.sub_left
for more details\&.

.sp

.I val slice 
: 
.B ('a, 'b, 'c) t -> int -> ('a, 'b, 'c) Bigarray.Array0.t
.sp
Extract a scalar (zero\-dimensional slice) of the given one\-dimensional
Bigarray\&.  The integer parameter is the index of the scalar to
extract\&.  See 
.B Bigarray\&.Genarray\&.slice_left
and
.B Bigarray\&.Genarray\&.slice_right
for more details\&.

.sp
.B "Since"
4.05.0

.sp

.I val blit 
: 
.B ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
.sp
Copy the first Bigarray to the second Bigarray\&.
See 
.B Bigarray\&.Genarray\&.blit
for more details\&.

.sp

.I val fill 
: 
.B ('a, 'b, 'c) t -> 'a -> unit
.sp
Fill the given Bigarray with the given value\&.
See 
.B Bigarray\&.Genarray\&.fill
for more details\&.

.sp

.I val of_array 
: 
.B ('a, 'b) Bigarray.kind ->
.B   'c Bigarray.layout -> 'a array -> ('a, 'b, 'c) t
.sp
Build a one\-dimensional Bigarray initialized from the
given array\&.

.sp

.I val unsafe_get 
: 
.B ('a, 'b, 'c) t -> int -> 'a
.sp
Like 
.B 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\&.

.sp

.I val unsafe_set 
: 
.B ('a, 'b, 'c) t -> int -> 'a -> unit
.sp
Like 
.B 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\&.

.sp
