1Bigarray.Array2(3) OCaml library Bigarray.Array2(3)
2
3
4
6 Bigarray.Array2 - Two-dimensional arrays.
7
9 Module Bigarray.Array2
10
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 mension, whose size is dim1 in the first dimension and dim2 in the sec‐
38 ond 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 dim1 : ('a, 'b, 'c) t -> int
44
45 Return the first dimension of the given two-dimensional Bigarray.
46
47
48
49 val dim2 : ('a, 'b, 'c) t -> int
50
51 Return the second dimension of the given two-dimensional Bigarray.
52
53
54
55 val kind : ('a, 'b, 'c) t -> ('a, 'b) Bigarray.kind
56
57 Return the kind of the given Bigarray.
58
59
60
61 val layout : ('a, 'b, 'c) t -> 'c Bigarray.layout
62
63 Return the layout of the given Bigarray.
64
65
66
67 val change_layout : ('a, 'b, 'c) t -> 'd Bigarray.layout -> ('a, 'b,
68 'd) t
69
70
71 Array2.change_layout a layout returns a Bigarray with the specified
72 layout , sharing the data with a (and hence having the same dimensions
73 as a ). No copying of elements is involved: the new array and the orig‐
74 inal array share the same storage space. The dimensions are reversed,
75 such that get v [| a; b |] in C layout becomes get v [| b+1; a+1 |] in
76 Fortran layout.
77
78
79 Since 4.06.0
80
81
82
83 val size_in_bytes : ('a, 'b, 'c) t -> int
84
85
86 size_in_bytes a is the number of elements in a multiplied by a 's Bi‐
87 garray.kind_size_in_bytes .
88
89
90 Since 4.03.0
91
92
93
94 val get : ('a, 'b, 'c) t -> int -> int -> 'a
95
96
97 Array2.get a x y , also written a.{x,y} , returns the element of a at
98 coordinates ( x , y ). x and y must be within the bounds of a , as de‐
99 scribed for Bigarray.Genarray.get ; otherwise, Invalid_argument is
100 raised.
101
102
103
104 val set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
105
106
107 Array2.set a x y v , or alternatively a.{x,y} <- v , stores the value v
108 at coordinates ( x , y ) in a . x and y must be within the bounds of a
109 , as described for Bigarray.Genarray.set ; otherwise, Invalid_argument
110 is raised.
111
112
113
114 val sub_left : ('a, 'b, Bigarray.c_layout) t -> int -> int -> ('a, 'b,
115 Bigarray.c_layout) t
116
117 Extract a two-dimensional sub-array of the given two-dimensional Bigar‐
118 ray by restricting the first dimension. See Bigarray.Genarray.sub_left
119 for more details. Array2.sub_left applies only to arrays with C lay‐
120 out.
121
122
123
124 val sub_right : ('a, 'b, Bigarray.fortran_layout) t -> int -> int ->
125 ('a, 'b, Bigarray.fortran_layout) t
126
127 Extract a two-dimensional sub-array of the given two-dimensional Bigar‐
128 ray by restricting the second dimension. See Bigarray.Genar‐
129 ray.sub_right for more details. Array2.sub_right applies only to ar‐
130 rays with Fortran layout.
131
132
133
134 val slice_left : ('a, 'b, Bigarray.c_layout) t -> int -> ('a, 'b, Bi‐
135 garray.c_layout) Bigarray.Array1.t
136
137 Extract a row (one-dimensional slice) of the given two-dimensional Bi‐
138 garray. The integer parameter is the index of the row to extract. See
139 Bigarray.Genarray.slice_left for more details. Array2.slice_left ap‐
140 plies only to arrays with C layout.
141
142
143
144 val slice_right : ('a, 'b, Bigarray.fortran_layout) t -> int -> ('a,
145 'b, Bigarray.fortran_layout) Bigarray.Array1.t
146
147 Extract a column (one-dimensional slice) of the given two-dimensional
148 Bigarray. The integer parameter is the index of the column to extract.
149 See Bigarray.Genarray.slice_right for more details. Array2.slice_right
150 applies only to arrays with Fortran layout.
151
152
153
154 val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
155
156 Copy the first Bigarray to the second Bigarray. See Bigarray.Genar‐
157 ray.blit for more details.
158
159
160
161 val fill : ('a, 'b, 'c) t -> 'a -> unit
162
163 Fill the given Bigarray with the given value. See Bigarray.Genar‐
164 ray.fill for more details.
165
166
167
168 val of_array : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> 'a array
169 array -> ('a, 'b, 'c) t
170
171 Build a two-dimensional Bigarray initialized from the given array of
172 arrays.
173
174
175
176 val unsafe_get : ('a, 'b, 'c) t -> int -> int -> 'a
177
178 Like Bigarray.Array2.get , but bounds checking is not always performed.
179
180
181
182 val unsafe_set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
183
184 Like Bigarray.Array2.set , but bounds checking is not always performed.
185
186
187
188
189
190OCamldoc 2021-01-26 Bigarray.Array2(3)