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
50       element kind is determined by the parameter  kind  (one  of  float32  ,
51       float64  ,  int8_signed  ,  etc)  and whose layout is determined by the
52       parameter 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 num_dims : ('a, 'b, 'c) t -> int
72
73       Return the number of dimensions of the given Bigarray.
74
75
76
77       val dims : ('a, 'b, 'c) t -> int array
78
79
80       Genarray.dims a returns all dimensions of the Bigarray a , as an  array
81       of integers of length Genarray.num_dims a .
82
83
84
85       val nth_dim : ('a, 'b, 'c) t -> int -> int
86
87
88       Genarray.nth_dim  a  n  returns the n -th dimension of the Bigarray a .
89       The first dimension corresponds to n = 0 ; the second dimension  corre‐
90       sponds to n = 1 ; the last dimension, to n = Genarray.num_dims a - 1 .
91
92
93       Raises  Invalid_argument  if  n is less than 0 or greater or equal than
94       Genarray.num_dims a .
95
96
97
98       val kind : ('a, 'b, 'c) t -> ('a, 'b) Bigarray.kind
99
100       Return the kind of the given Bigarray.
101
102
103
104       val layout : ('a, 'b, 'c) t -> 'c Bigarray.layout
105
106       Return the layout of the given Bigarray.
107
108
109
110       val change_layout : ('a, 'b, 'c) t -> 'd Bigarray.layout  ->  ('a,  'b,
111       'd) t
112
113
114       Genarray.change_layout  a  layout returns a Bigarray with the specified
115       layout , sharing the data with a (and hence having the same  dimensions
116       as a ). No copying of elements is involved: the new array and the orig‐
117       inal array share the same storage space.  The dimensions are  reversed,
118       such  that get v [| a; b |] in C layout becomes get v [| b+1; a+1 |] in
119       Fortran layout.
120
121
122       Since 4.04.0
123
124
125
126       val size_in_bytes : ('a, 'b, 'c) t -> int
127
128
129       size_in_bytes a is the number of elements  in  a  multiplied  by  a  's
130       Bigarray.kind_size_in_bytes .
131
132
133       Since 4.03.0
134
135
136
137       val get : ('a, 'b, 'c) t -> int array -> 'a
138
139       Read  an element of a generic Bigarray.  Genarray.get a [|i1; ...; iN|]
140       returns the element of a whose coordinates are i1 in the  first  dimen‐
141       sion, i2 in the second dimension, ..., iN in the N -th dimension.
142
143       If  a has C layout, the coordinates must be greater or equal than 0 and
144       strictly less than the corresponding dimensions of a .  If a  has  For‐
145       tran  layout,  the coordinates must be greater or equal than 1 and less
146       or equal than the corresponding dimensions of a .
147
148       If N > 3 , alternate syntax is provided: you can write a.{i1, i2,  ...,
149       iN}  instead  of  Genarray.get a [|i1; ...; iN|] .  (The syntax a.{...}
150       with one, two or three coordinates is reserved for accessing one-, two-
151       and three-dimensional arrays as described below.)
152
153
154       Raises  Invalid_argument  if the array a does not have exactly N dimen‐
155       sions, or if the coordinates are outside the array bounds.
156
157
158
159       val set : ('a, 'b, 'c) t -> int array -> 'a -> unit
160
161       Assign an element of a generic Bigarray.   Genarray.set  a  [|i1;  ...;
162       iN|]  v stores the value v in the element of a whose coordinates are i1
163       in the first dimension, i2 in the second dimension, ..., iN  in  the  N
164       -th dimension.
165
166       The  array  a  must have exactly N dimensions, and all coordinates must
167       lie inside the array bounds, as described for Genarray.get ; otherwise,
168       Invalid_argument is raised.
169
170       If  N > 3 , alternate syntax is provided: you can write a.{i1, i2, ...,
171       iN} <- v instead of Genarray.set a [|i1; ...; iN|]  v  .   (The  syntax
172       a.{...}  <- v with one, two or three coordinates is reserved for updat‐
173       ing one-, two- and three-dimensional arrays as described below.)
174
175
176
177       val sub_left : ('a, 'b, Bigarray.c_layout) t -> int -> int -> ('a,  'b,
178       Bigarray.c_layout) t
179
180       Extract  a  sub-array  of  the  given Bigarray by restricting the first
181       (left-most) dimension.  Genarray.sub_left a ofs len returns a  Bigarray
182       with  the same number of dimensions as a , and the same dimensions as a
183       , except the first dimension, which corresponds to  the  interval  [ofs
184       ...  ofs  +  len - 1] of the first dimension of a .  No copying of ele‐
185       ments is involved: the sub-array and the original array share the  same
186       storage  space.   In other terms, the element at coordinates [|i1; ...;
187       iN|] of the sub-array  is  identical  to  the  element  at  coordinates
188       [|i1+ofs; ...; iN|] of the original array a .
189
190
191       Genarray.sub_left applies only to Bigarrays in C layout.
192
193
194       Raises  Invalid_argument  if  ofs  and  len  do  not  designate a valid
195       sub-array of a , that is, if ofs < 0 , or len < 0 ,  or  ofs  +  len  >
196       Genarray.nth_dim a 0 .
197
198
199
200       val  sub_right  :  ('a, 'b, Bigarray.fortran_layout) t -> int -> int ->
201       ('a, 'b, Bigarray.fortran_layout) t
202
203       Extract a sub-array of the  given  Bigarray  by  restricting  the  last
204       (right-most)  dimension.  Genarray.sub_right a ofs len returns a Bigar‐
205       ray with the same number of dimensions as a , and the  same  dimensions
206       as  a  ,  except  the last dimension, which corresponds to the interval
207       [ofs ... ofs + len - 1] of the last dimension of a  .   No  copying  of
208       elements  is  involved:  the sub-array and the original array share the
209       same storage space.  In other terms, the element at  coordinates  [|i1;
210       ...;  iN|]  of the sub-array is identical to the element at coordinates
211       [|i1; ...; iN+ofs|] of the original array a .
212
213
214       Genarray.sub_right applies only to Bigarrays in Fortran layout.
215
216
217       Raises Invalid_argument if  ofs  and  len  do  not  designate  a  valid
218       sub-array  of  a  ,  that  is, if ofs < 1 , or len < 0 , or ofs + len >
219       Genarray.nth_dim a (Genarray.num_dims a - 1) .
220
221
222
223       val slice_left : ('a, 'b, Bigarray.c_layout) t -> int array -> ('a, 'b,
224       Bigarray.c_layout) t
225
226       Extract  a sub-array of lower dimension from the given Bigarray by fix‐
227       ing one or  several  of  the  first  (left-most)  coordinates.   Genar‐
228       ray.slice_left  a [|i1; ... ; iM|] returns the 'slice' of a obtained by
229       setting the first M coordinates to i1 , ..., iM .  If a  has  N  dimen‐
230       sions,  the  slice has dimension N - M , and the element at coordinates
231       [|j1; ...; j(N-M)|] in the slice is identical to the element at coordi‐
232       nates  [|i1;  ...;  iM; j1; ...; j(N-M)|] in the original array a .  No
233       copying of elements is involved: the slice and the original array share
234       the same storage space.
235
236
237       Genarray.slice_left applies only to Bigarrays in C layout.
238
239
240       Raises  Invalid_argument  if M >= N , or if [|i1; ... ; iM|] is outside
241       the bounds of a .
242
243
244
245       val slice_right : ('a, 'b, Bigarray.fortran_layout) t -> int  array  ->
246       ('a, 'b, Bigarray.fortran_layout) t
247
248       Extract  a sub-array of lower dimension from the given Bigarray by fix‐
249       ing one or  several  of  the  last  (right-most)  coordinates.   Genar‐
250       ray.slice_right a [|i1; ... ; iM|] returns the 'slice' of a obtained by
251       setting the last M coordinates to i1 , ..., iM .  If  a  has  N  dimen‐
252       sions,  the  slice has dimension N - M , and the element at coordinates
253       [|j1; ...; j(N-M)|] in the slice is identical to the element at coordi‐
254       nates  [|j1;  ...;  j(N-M); i1; ...; iM|] in the original array a .  No
255       copying of elements is involved: the slice and the original array share
256       the same storage space.
257
258
259       Genarray.slice_right applies only to Bigarrays in Fortran layout.
260
261
262       Raises  Invalid_argument  if M >= N , or if [|i1; ... ; iM|] is outside
263       the bounds of a .
264
265
266
267       val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
268
269       Copy all elements of a Bigarray in another Bigarray.  Genarray.blit src
270       dst copies all elements of src into dst .  Both arrays src and dst must
271       have the same number of dimensions and  equal  dimensions.   Copying  a
272       sub-array  of  src  to  a  sub-array of dst can be achieved by applying
273       Genarray.blit to sub-array or slices of src and dst .
274
275
276
277       val fill : ('a, 'b, 'c) t -> 'a -> unit
278
279       Set all elements of a Bigarray to a given  value.   Genarray.fill  a  v
280       stores  the  value  v in all elements of the Bigarray a .  Setting only
281       some elements of a to v can be achieved by applying Genarray.fill to  a
282       sub-array or a slice of a .
283
284
285
286
287
288OCamldoc                          2020-09-01              Bigarray.Genarray(3)
Impressum