1Bigarray.Array2(3)               OCaml library              Bigarray.Array2(3)
2
3
4

NAME

6       Bigarray.Array2 - Two-dimensional arrays.
7

Module

9       Module   Bigarray.Array2
10

Documentation

12       Module Array2
13        : sig end
14
15
16       Two-dimensional  arrays. The Array2 structure provides operations simi‐
17       lar to those of Bigarray.Genarray , but  specialized  to  the  case  of
18       two-dimensional arrays.
19
20
21
22
23
24       type ('a, 'b, 'c) t
25
26
27       The type of two-dimensional Bigarrays whose elements have OCaml type 'a
28       , representation kind 'b , and memory layout 'c .
29
30
31
32       val create : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> int -> int
33       -> ('a, 'b, 'c) t
34
35
36       Array2.create  kind  layout dim1 dim2 returns a new Bigarray of two di‐
37       mensions, whose size is dim1 in the first dimension  and  dim2  in  the
38       second dimension.  kind and layout determine the array element kind and
39       the array layout as described for Bigarray.Genarray.create .
40
41
42
43       val init : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> int  ->  int
44       -> (int -> int -> 'a) -> ('a, 'b, 'c) t
45
46
47       Array2.init kind layout dim1 dim2 f returns a new Bigarray b of two di‐
48       mensions, whose size is dim2 in the first dimension  and  dim2  in  the
49       second dimension.  kind and layout determine the array element kind and
50       the array layout as described for Bigarray.Genarray.create .
51
52       Each element Array2.get b i j of the array is initialized to the result
53       of f i j .
54
55       In  other  words, Array2.init kind layout dim1 dim2 f tabulates the re‐
56       sults of f applied to the indices of a new Bigarray whose layout is de‐
57       scribed by kind , layout , dim1 and dim2 .
58
59
60       Since 4.12.0
61
62
63
64       val dim1 : ('a, 'b, 'c) t -> int
65
66       Return the first dimension of the given two-dimensional Bigarray.
67
68
69
70       val dim2 : ('a, 'b, 'c) t -> int
71
72       Return the second dimension of the given two-dimensional Bigarray.
73
74
75
76       val kind : ('a, 'b, 'c) t -> ('a, 'b) Bigarray.kind
77
78       Return the kind of the given Bigarray.
79
80
81
82       val layout : ('a, 'b, 'c) t -> 'c Bigarray.layout
83
84       Return the layout of the given Bigarray.
85
86
87
88       val  change_layout  :  ('a, 'b, 'c) t -> 'd Bigarray.layout -> ('a, 'b,
89       'd) t
90
91
92       Array2.change_layout a layout returns a  Bigarray  with  the  specified
93       layout  , sharing the data with a (and hence having the same dimensions
94       as a ). No copying of elements is involved: the new array and the orig‐
95       inal  array share the same storage space.  The dimensions are reversed,
96       such that get v [| a; b |] in C layout becomes get v [| b+1; a+1 |]  in
97       Fortran layout.
98
99
100       Since 4.06.0
101
102
103
104       val size_in_bytes : ('a, 'b, 'c) t -> int
105
106
107       size_in_bytes  a  is the number of elements in a multiplied by a 's Bi‐
108       garray.kind_size_in_bytes .
109
110
111       Since 4.03.0
112
113
114
115       val get : ('a, 'b, 'c) t -> int -> int -> 'a
116
117
118       Array2.get a x y , also written a.{x,y} , returns the element of  a  at
119       coordinates ( x , y ).  x and y must be within the bounds of a , as de‐
120       scribed for  Bigarray.Genarray.get  ;  otherwise,  Invalid_argument  is
121       raised.
122
123
124
125       val set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
126
127
128       Array2.set a x y v , or alternatively a.{x,y} <- v , stores the value v
129       at coordinates ( x , y ) in a .  x and y must be within the bounds of a
130       ,  as described for Bigarray.Genarray.set ; otherwise, Invalid_argument
131       is raised.
132
133
134
135       val sub_left : ('a, 'b, Bigarray.c_layout) t -> int -> int -> ('a,  'b,
136       Bigarray.c_layout) t
137
138       Extract a two-dimensional sub-array of the given two-dimensional Bigar‐
139       ray by restricting the first dimension.  See Bigarray.Genarray.sub_left
140       for  more  details.  Array2.sub_left applies only to arrays with C lay‐
141       out.
142
143
144
145       val sub_right : ('a, 'b, Bigarray.fortran_layout) t -> int  ->  int  ->
146       ('a, 'b, Bigarray.fortran_layout) t
147
148       Extract a two-dimensional sub-array of the given two-dimensional Bigar‐
149       ray  by  restricting  the  second   dimension.    See   Bigarray.Genar‐
150       ray.sub_right  for  more details.  Array2.sub_right applies only to ar‐
151       rays with Fortran layout.
152
153
154
155       val slice_left : ('a, 'b, Bigarray.c_layout) t -> int -> ('a,  'b,  Bi‐
156       garray.c_layout) Bigarray.Array1.t
157
158       Extract  a row (one-dimensional slice) of the given two-dimensional Bi‐
159       garray.  The integer parameter is the index of the row to extract.  See
160       Bigarray.Genarray.slice_left  for  more details.  Array2.slice_left ap‐
161       plies only to arrays with C layout.
162
163
164
165       val slice_right : ('a, 'b, Bigarray.fortran_layout) t ->  int  ->  ('a,
166       'b, Bigarray.fortran_layout) Bigarray.Array1.t
167
168       Extract  a  column (one-dimensional slice) of the given two-dimensional
169       Bigarray.  The integer parameter is the index of the column to extract.
170       See Bigarray.Genarray.slice_right for more details.  Array2.slice_right
171       applies only to arrays with Fortran layout.
172
173
174
175       val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
176
177       Copy the first Bigarray to the second  Bigarray.   See  Bigarray.Genar‐
178       ray.blit for more details.
179
180
181
182       val fill : ('a, 'b, 'c) t -> 'a -> unit
183
184       Fill  the  given  Bigarray  with  the given value.  See Bigarray.Genar‐
185       ray.fill for more details.
186
187
188
189       val of_array : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> 'a array
190       array -> ('a, 'b, 'c) t
191
192       Build  a  two-dimensional  Bigarray initialized from the given array of
193       arrays.
194
195
196
197       val unsafe_get : ('a, 'b, 'c) t -> int -> int -> 'a
198
199       Like Bigarray.Array2.get , but bounds checking is not always performed.
200
201
202
203       val unsafe_set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
204
205       Like Bigarray.Array2.set , but bounds checking is not always performed.
206
207
208
209
210
211OCamldoc                          2021-07-22                Bigarray.Array2(3)
Impressum