man-pages/man3/Bigarray.Array2.3o.html
2021-03-31 01:06:50 +01:00

459 lines
6.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Bigarray.Array2</TITLE>
</HEAD><BODY>
<H1>Bigarray.Array2</H1>
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Bigarray.Array2 - Two-dimensional arrays.
<A NAME="lbAC">&nbsp;</A>
<H2>Module</H2>
Module Bigarray.Array2
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module
<B>Array2</B>
<BR>&nbsp;:&nbsp;
<B>sig end</B>
<P>
<P>
Two-dimensional arrays. The
<B>Array2</B>
structure provides operations
similar to those of
<B>Bigarray.Genarray</B>
, but specialized to the
case of two-dimensional arrays.
<P>
<P>
<P>
<P>
<P>
<I>type </I>
<B>('a, 'b, 'c)</B>
<I>t </I>
<P>
<P>
The type of two-dimensional Bigarrays whose elements have
OCaml type
<B>'a</B>
, representation kind
<B>'b</B>
, and memory layout
<B>'c</B>
.
<P>
<P>
<P>
<I>val create </I>
:
<B>('a, 'b) Bigarray.kind -&gt;</B>
<B>'c Bigarray.layout -&gt; int -&gt; int -&gt; ('a, 'b, 'c) t</B>
<P>
<P>
<B>Array2.create kind layout dim1 dim2</B>
returns a new Bigarray of
two dimension, whose size is
<B>dim1</B>
in the first dimension
and
<B>dim2</B>
in the second dimension.
<B>kind</B>
and
<B>layout</B>
determine the array element kind and the array layout
as described for
<B>Bigarray.Genarray.create</B>
.
<P>
<P>
<P>
<I>val dim1 </I>
:
<B>('a, 'b, 'c) t -&gt; int</B>
<P>
Return the first dimension of the given two-dimensional Bigarray.
<P>
<P>
<P>
<I>val dim2 </I>
:
<B>('a, 'b, 'c) t -&gt; int</B>
<P>
Return the second dimension of the given two-dimensional Bigarray.
<P>
<P>
<P>
<I>val kind </I>
:
<B>('a, 'b, 'c) t -&gt; ('a, 'b) Bigarray.kind</B>
<P>
Return the kind of the given Bigarray.
<P>
<P>
<P>
<I>val layout </I>
:
<B>('a, 'b, 'c) t -&gt; 'c Bigarray.layout</B>
<P>
Return the layout of the given Bigarray.
<P>
<P>
<P>
<I>val change_layout </I>
:
<B>('a, 'b, 'c) t -&gt;</B>
<B>'d Bigarray.layout -&gt; ('a, 'b, 'd) t</B>
<P>
<P>
<B>Array2.change_layout a layout</B>
returns a Bigarray with the
specified
<B>layout</B>
, sharing the data with
<B>a</B>
(and hence having
the same dimensions as
<B>a</B>
). No copying of elements is involved: the
new array and the original array share the same storage space.
The dimensions are reversed, such that
<B>get v [| a; b |]</B>
in
C layout becomes
<B>get v [| b+1; a+1 |]</B>
in Fortran layout.
<P>
<P>
<B>Since</B>
4.06.0
<P>
<P>
<P>
<I>val size_in_bytes </I>
:
<B>('a, 'b, 'c) t -&gt; int</B>
<P>
<P>
<B>size_in_bytes a</B>
is the number of elements in
<B>a</B>
multiplied by
<B>a</B>
's
<B>Bigarray.kind_size_in_bytes</B>
.
<P>
<P>
<B>Since</B>
4.03.0
<P>
<P>
<P>
<I>val get </I>
:
<B>('a, 'b, 'c) t -&gt; int -&gt; int -&gt; 'a</B>
<P>
<P>
<B>Array2.get a x y</B>
, also written
<B>a.{x,y}</B>
,
returns the element of
<B>a</B>
at coordinates (
<B>x</B>
,
<B>y</B>
).
<B>x</B>
and
<B>y</B>
must be within the bounds
of
<B>a</B>
, as described for
<B>Bigarray.Genarray.get</B>
;
otherwise,
<B>Invalid_argument</B>
is raised.
<P>
<P>
<P>
<I>val set </I>
:
<B>('a, 'b, 'c) t -&gt; int -&gt; int -&gt; 'a -&gt; unit</B>
<P>
<P>
<B>Array2.set a x y v</B>
, or alternatively
<B>a.{x,y} &lt;- v</B>
,
stores the value
<B>v</B>
at coordinates (
<B>x</B>
,
<B>y</B>
) in
<B>a</B>
.
<B>x</B>
and
<B>y</B>
must be within the bounds of
<B>a</B>
,
as described for
<B>Bigarray.Genarray.set</B>
;
otherwise,
<B>Invalid_argument</B>
is raised.
<P>
<P>
<P>
<I>val sub_left </I>
:
<B>('a, 'b, Bigarray.c_layout) t -&gt;</B>
<B>int -&gt; int -&gt; ('a, 'b, Bigarray.c_layout) t</B>
<P>
Extract a two-dimensional sub-array of the given two-dimensional
Bigarray by restricting the first dimension.
See
<B>Bigarray.Genarray.sub_left</B>
for more details.
<B>Array2.sub_left</B>
applies only to arrays with C layout.
<P>
<P>
<P>
<I>val sub_right </I>
:
<B>('a, 'b, Bigarray.fortran_layout) t -&gt;</B>
<B>int -&gt; int -&gt; ('a, 'b, Bigarray.fortran_layout) t</B>
<P>
Extract a two-dimensional sub-array of the given two-dimensional
Bigarray by restricting the second dimension.
See
<B>Bigarray.Genarray.sub_right</B>
for more details.
<B>Array2.sub_right</B>
applies only to arrays with Fortran layout.
<P>
<P>
<P>
<I>val slice_left </I>
:
<B>('a, 'b, Bigarray.c_layout) t -&gt;</B>
<B>int -&gt; ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t</B>
<P>
Extract a row (one-dimensional slice) of the given two-dimensional
Bigarray. The integer parameter is the index of the row to
extract. See
<B>Bigarray.Genarray.slice_left</B>
for more details.
<B>Array2.slice_left</B>
applies only to arrays with C layout.
<P>
<P>
<P>
<I>val slice_right </I>
:
<B>('a, 'b, Bigarray.fortran_layout) t -&gt;</B>
<B>int -&gt; ('a, 'b, Bigarray.fortran_layout) Bigarray.Array1.t</B>
<P>
Extract a column (one-dimensional slice) of the given
two-dimensional Bigarray. The integer parameter is the
index of the column to extract. See
<B>Bigarray.Genarray.slice_right</B>
for more details.
<B>Array2.slice_right</B>
applies only to arrays
with Fortran layout.
<P>
<P>
<P>
<I>val blit </I>
:
<B>('a, 'b, 'c) t -&gt; ('a, 'b, 'c) t -&gt; unit</B>
<P>
Copy the first Bigarray to the second Bigarray.
See
<B>Bigarray.Genarray.blit</B>
for more details.
<P>
<P>
<P>
<I>val fill </I>
:
<B>('a, 'b, 'c) t -&gt; 'a -&gt; unit</B>
<P>
Fill the given Bigarray with the given value.
See
<B>Bigarray.Genarray.fill</B>
for more details.
<P>
<P>
<P>
<I>val of_array </I>
:
<B>('a, 'b) Bigarray.kind -&gt;</B>
<B>'c Bigarray.layout -&gt; 'a array array -&gt; ('a, 'b, 'c) t</B>
<P>
Build a two-dimensional Bigarray initialized from the
given array of arrays.
<P>
<P>
<P>
<I>val unsafe_get </I>
:
<B>('a, 'b, 'c) t -&gt; int -&gt; int -&gt; 'a</B>
<P>
Like
<B>Bigarray.Array2.get</B>
, but bounds checking is not always
performed.
<P>
<P>
<P>
<I>val unsafe_set </I>
:
<B>('a, 'b, 'c) t -&gt; int -&gt; int -&gt; 'a -&gt; unit</B>
<P>
Like
<B>Bigarray.Array2.set</B>
, but bounds checking is not always
performed.
<P>
<P>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">Module</A><DD>
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:36 GMT, March 31, 2021
</BODY>
</HTML>