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

NAME

6       Bigarray.Genarray - no description
7

Module

9       Module   Bigarray.Genarray
10

Documentation

12       Module Genarray
13        : sig end
14
15
16
17
18
19
20
21       type ('a, 'b, 'c) t
22
23
24       The  type  Genarray.t is the type of Bigarrays with variable numbers of
25       dimensions.  Any number of dimensions between 0 and 16 is supported.
26
27       The three type parameters to Genarray.t identify the array element kind
28       and layout, as follows:
29
30       -the  first  parameter, 'a , is the OCaml type for accessing array ele‐
31       ments ( float , int , int32 , int64 , nativeint );
32
33       -the second parameter, 'b , is the actual  kind  of  array  elements  (
34       float32_elt , float64_elt , int8_signed_elt , int8_unsigned_elt , etc);
35
36       -the  third  parameter,  'c , identifies the array layout ( c_layout or
37       fortran_layout ).
38
39       For instance, (float, float32_elt, fortran_layout)  Genarray.t  is  the
40       type  of  generic Bigarrays containing 32-bit floats in Fortran layout;
41       reads and writes in this array use the OCaml type float .
42
43
44
45       val create : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> int  array
46       -> ('a, 'b, 'c) t
47
48
49       Genarray.create kind layout dimensions returns a new Bigarray whose el‐
50       ement kind is determined by  the  parameter  kind  (one  of  float32  ,
51       float64  , int8_signed , etc) and whose layout is determined by the pa‐
52       rameter layout (one of c_layout or fortran_layout  ).   The  dimensions
53       parameter  is an array of integers that indicate the size of the Bigar‐
54       ray in each dimension.  The length of dimensions determines the  number
55       of dimensions of the Bigarray.
56
57       For  instance, Genarray.create int32 c_layout [|4;6;8|] returns a fresh
58       Bigarray of 32-bit integers, in C layout, having three dimensions,  the
59       three dimensions being 4, 6 and 8 respectively.
60
61       Bigarrays  returned by Genarray.create are not initialized: the initial
62       values of array elements is unspecified.
63
64
65       Genarray.create raises Invalid_argument if the number of dimensions  is
66       not in the range 0 to 16 inclusive, or if one of the dimensions is neg‐
67       ative.
68
69
70
71       val init : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> int array ->
72       (int array -> 'a) -> ('a, 'b, 'c) t
73
74
75       Genarray.init  kind  layout dimensions f returns a new Bigarray b whose
76       element kind is determined by the parameter  kind  (one  of  float32  ,
77       float64  , int8_signed , etc) and whose layout is determined by the pa‐
78       rameter layout (one of c_layout or fortran_layout  ).   The  dimensions
79       parameter  is an array of integers that indicate the size of the Bigar‐
80       ray in each dimension.  The length of dimensions determines the  number
81       of dimensions of the Bigarray.
82
83       Each element Genarray.get b i is initialized to the result of f i .  In
84       other words, Genarray.init kind layout dimensions f tabulates  the  re‐
85       sults of f applied to the indices of a new Bigarray whose layout is de‐
86       scribed by kind , layout and dimensions .  The index  array  i  may  be
87       shared and mutated between calls to f.
88
89       For instance, Genarray.init int c_layout [|2; 1; 3|]
90              (Array.fold_left (+) 0) returns a fresh Bigarray of integers, in
91       C layout, having three dimensions (2, 1, 3, respectively), with the el‐
92       ement values 0, 1, 2, 1, 2, 3.
93
94
95       Genarray.init  raises  Invalid_argument  if the number of dimensions is
96       not in the range 0 to 16 inclusive, or if one of the dimensions is neg‐
97       ative.
98
99
100       Since 4.12.0
101
102
103
104       val num_dims : ('a, 'b, 'c) t -> int
105
106       Return the number of dimensions of the given Bigarray.
107
108
109
110       val dims : ('a, 'b, 'c) t -> int array
111
112
113       Genarray.dims  a returns all dimensions of the Bigarray a , as an array
114       of integers of length Genarray.num_dims a .
115
116
117
118       val nth_dim : ('a, 'b, 'c) t -> int -> int
119
120
121       Genarray.nth_dim a n returns the n -th dimension of the  Bigarray  a  .
122       The  first dimension corresponds to n = 0 ; the second dimension corre‐
123       sponds to n = 1 ; the last dimension, to n = Genarray.num_dims a - 1 .
124
125
126       Raises Invalid_argument if n is less than 0 or greater  or  equal  than
127       Genarray.num_dims a .
128
129
130
131       val kind : ('a, 'b, 'c) t -> ('a, 'b) Bigarray.kind
132
133       Return the kind of the given Bigarray.
134
135
136
137       val layout : ('a, 'b, 'c) t -> 'c Bigarray.layout
138
139       Return the layout of the given Bigarray.
140
141
142
143       val  change_layout  :  ('a, 'b, 'c) t -> 'd Bigarray.layout -> ('a, 'b,
144       'd) t
145
146
147       Genarray.change_layout a layout returns a Bigarray with  the  specified
148       layout  , sharing the data with a (and hence having the same dimensions
149       as a ). No copying of elements is involved: the new array and the orig‐
150       inal  array share the same storage space.  The dimensions are reversed,
151       such that get v [| a; b |] in C layout becomes get v [| b+1; a+1 |]  in
152       Fortran layout.
153
154
155       Since 4.04.0
156
157
158
159       val size_in_bytes : ('a, 'b, 'c) t -> int
160
161
162       size_in_bytes  a  is the number of elements in a multiplied by a 's Bi‐
163       garray.kind_size_in_bytes .
164
165
166       Since 4.03.0
167
168
169
170       val get : ('a, 'b, 'c) t -> int array -> 'a
171
172       Read an element of a generic Bigarray.  Genarray.get a [|i1; ...;  iN|]
173       returns  the  element of a whose coordinates are i1 in the first dimen‐
174       sion, i2 in the second dimension, ..., iN in the N -th dimension.
175
176       If a has C layout, the coordinates must be greater or equal than 0  and
177       strictly  less  than the corresponding dimensions of a .  If a has For‐
178       tran layout, the coordinates must be greater or equal than 1  and  less
179       or equal than the corresponding dimensions of a .
180
181       If  N > 3 , alternate syntax is provided: you can write a.{i1, i2, ...,
182       iN} instead of Genarray.get a [|i1; ...; iN|] .   (The  syntax  a.{...}
183       with one, two or three coordinates is reserved for accessing one-, two-
184       and three-dimensional arrays as described below.)
185
186
187       Raises Invalid_argument if the array a does not have exactly  N  dimen‐
188       sions, or if the coordinates are outside the array bounds.
189
190
191
192       val set : ('a, 'b, 'c) t -> int array -> 'a -> unit
193
194       Assign  an  element  of  a generic Bigarray.  Genarray.set a [|i1; ...;
195       iN|] v stores the value v in the element of a whose coordinates are  i1
196       in  the  first  dimension, i2 in the second dimension, ..., iN in the N
197       -th dimension.
198
199       The array a must have exactly N dimensions, and  all  coordinates  must
200       lie inside the array bounds, as described for Genarray.get ; otherwise,
201       Invalid_argument is raised.
202
203       If N > 3 , alternate syntax is provided: you can write a.{i1, i2,  ...,
204       iN}  <-  v  instead  of Genarray.set a [|i1; ...; iN|] v .  (The syntax
205       a.{...} <- v with one, two or three coordinates is reserved for  updat‐
206       ing one-, two- and three-dimensional arrays as described below.)
207
208
209
210       val  sub_left : ('a, 'b, Bigarray.c_layout) t -> int -> int -> ('a, 'b,
211       Bigarray.c_layout) t
212
213       Extract a sub-array of the given  Bigarray  by  restricting  the  first
214       (left-most)  dimension.  Genarray.sub_left a ofs len returns a Bigarray
215       with the same number of dimensions as a , and the same dimensions as  a
216       ,  except  the  first dimension, which corresponds to the interval [ofs
217       ... ofs + len - 1] of the first dimension of a .  No  copying  of  ele‐
218       ments  is involved: the sub-array and the original array share the same
219       storage space.  In other terms, the element at coordinates  [|i1;  ...;
220       iN|]  of  the  sub-array  is  identical  to  the element at coordinates
221       [|i1+ofs; ...; iN|] of the original array a .
222
223
224       Genarray.sub_left applies only to Bigarrays in C layout.
225
226
227       Raises Invalid_argument if ofs and len do not designate a valid sub-ar‐
228       ray  of  a  ,  that is, if ofs < 0 , or len < 0 , or ofs + len > Genar‐
229       ray.nth_dim a 0 .
230
231
232
233       val sub_right : ('a, 'b, Bigarray.fortran_layout) t -> int  ->  int  ->
234       ('a, 'b, Bigarray.fortran_layout) t
235
236       Extract  a  sub-array  of  the  given  Bigarray by restricting the last
237       (right-most) dimension.  Genarray.sub_right a ofs len returns a  Bigar‐
238       ray  with  the same number of dimensions as a , and the same dimensions
239       as a , except the last dimension, which  corresponds  to  the  interval
240       [ofs ... ofs + len - 1] of the last dimension of a .  No copying of el‐
241       ements is involved: the sub-array and the original array share the same
242       storage  space.   In other terms, the element at coordinates [|i1; ...;
243       iN|] of the sub-array is identical to the element at coordinates  [|i1;
244       ...; iN+ofs|] of the original array a .
245
246
247       Genarray.sub_right applies only to Bigarrays in Fortran layout.
248
249
250       Raises Invalid_argument if ofs and len do not designate a valid sub-ar‐
251       ray of a , that is, if ofs < 1 , or len < 0 , or ofs  +  len  >  Genar‐
252       ray.nth_dim a (Genarray.num_dims a - 1) .
253
254
255
256       val slice_left : ('a, 'b, Bigarray.c_layout) t -> int array -> ('a, 'b,
257       Bigarray.c_layout) t
258
259       Extract a sub-array of lower dimension from the given Bigarray by  fix‐
260       ing  one  or  several  of  the  first  (left-most) coordinates.  Genar‐
261       ray.slice_left a [|i1; ... ; iM|] returns the 'slice' of a obtained  by
262       setting  the  first  M coordinates to i1 , ..., iM .  If a has N dimen‐
263       sions, the slice has dimension N - M , and the element  at  coordinates
264       [|j1; ...; j(N-M)|] in the slice is identical to the element at coordi‐
265       nates [|i1; ...; iM; j1; ...; j(N-M)|] in the original array  a  .   No
266       copying of elements is involved: the slice and the original array share
267       the same storage space.
268
269
270       Genarray.slice_left applies only to Bigarrays in C layout.
271
272
273       Raises Invalid_argument if M >= N , or if [|i1; ... ; iM|]  is  outside
274       the bounds of a .
275
276
277
278       val  slice_right  : ('a, 'b, Bigarray.fortran_layout) t -> int array ->
279       ('a, 'b, Bigarray.fortran_layout) t
280
281       Extract a sub-array of lower dimension from the given Bigarray by  fix‐
282       ing  one  or  several  of  the  last  (right-most) coordinates.  Genar‐
283       ray.slice_right a [|i1; ... ; iM|] returns the 'slice' of a obtained by
284       setting  the  last  M  coordinates to i1 , ..., iM .  If a has N dimen‐
285       sions, the slice has dimension N - M , and the element  at  coordinates
286       [|j1; ...; j(N-M)|] in the slice is identical to the element at coordi‐
287       nates [|j1; ...; j(N-M); i1; ...; iM|] in the original array  a  .   No
288       copying of elements is involved: the slice and the original array share
289       the same storage space.
290
291
292       Genarray.slice_right applies only to Bigarrays in Fortran layout.
293
294
295       Raises Invalid_argument if M >= N , or if [|i1; ... ; iM|]  is  outside
296       the bounds of a .
297
298
299
300       val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
301
302       Copy all elements of a Bigarray in another Bigarray.  Genarray.blit src
303       dst copies all elements of src into dst .  Both arrays src and dst must
304       have  the  same  number  of dimensions and equal dimensions.  Copying a
305       sub-array of src to a sub-array of dst  can  be  achieved  by  applying
306       Genarray.blit to sub-array or slices of src and dst .
307
308
309
310       val fill : ('a, 'b, 'c) t -> 'a -> unit
311
312       Set  all  elements  of  a Bigarray to a given value.  Genarray.fill a v
313       stores the value v in all elements of the Bigarray a  .   Setting  only
314       some  elements of a to v can be achieved by applying Genarray.fill to a
315       sub-array or a slice of a .
316
317
318
319
320
321OCamldoc                          2023-01-23              Bigarray.Genarray(3)
Impressum