1Bigarray.Array1(3) OCaml library Bigarray.Array1(3)
2
3
4
6 Bigarray.Array1 - One-dimensional arrays.
7
9 Module Bigarray.Array1
10
12 Module Array1
13 : sig end
14
15
16 One-dimensional arrays. The Array1 structure provides operations simi‐
17 lar to those of Bigarray.Genarray , but specialized to the case of
18 one-dimensional arrays. (The Bigarray.Array2 and Bigarray.Array3
19 structures below provide operations specialized for two- and
20 three-dimensional arrays.) Statically knowing the number of dimensions
21 of the array allows faster operations, and more precise static
22 type-checking.
23
24
25
26
27
28 type ('a, 'b, 'c) t
29
30
31 The type of one-dimensional Bigarrays whose elements have OCaml type 'a
32 , representation kind 'b , and memory layout 'c .
33
34
35
36 val create : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> int ->
37 ('a, 'b, 'c) t
38
39
40 Array1.create kind layout dim returns a new Bigarray of one dimension,
41 whose size is dim . kind and layout determine the array element kind
42 and the array layout as described for Bigarray.Genarray.create .
43
44
45
46 val dim : ('a, 'b, 'c) t -> int
47
48 Return the size (dimension) of the given one-dimensional Bigarray.
49
50
51
52 val kind : ('a, 'b, 'c) t -> ('a, 'b) Bigarray.kind
53
54 Return the kind of the given Bigarray.
55
56
57
58 val layout : ('a, 'b, 'c) t -> 'c Bigarray.layout
59
60 Return the layout of the given Bigarray.
61
62
63
64 val change_layout : ('a, 'b, 'c) t -> 'd Bigarray.layout -> ('a, 'b,
65 'd) t
66
67
68 Array1.change_layout a layout returns a Bigarray with the specified
69 layout , sharing the data with a (and hence having the same dimension
70 as a ). No copying of elements is involved: the new array and the orig‐
71 inal array share the same storage space.
72
73
74 Since 4.06.0
75
76
77
78 val size_in_bytes : ('a, 'b, 'c) t -> int
79
80
81 size_in_bytes a is the number of elements in a multiplied by a 's
82 Bigarray.kind_size_in_bytes .
83
84
85 Since 4.03.0
86
87
88
89 val get : ('a, 'b, 'c) t -> int -> 'a
90
91
92 Array1.get a x , or alternatively a.{x} , returns the element of a at
93 index x . x must be greater or equal than 0 and strictly less than
94 Array1.dim a if a has C layout. If a has Fortran layout, x must be
95 greater or equal than 1 and less or equal than Array1.dim a . Other‐
96 wise, Invalid_argument is raised.
97
98
99
100 val set : ('a, 'b, 'c) t -> int -> 'a -> unit
101
102
103 Array1.set a x v , also written a.{x} <- v , stores the value v at
104 index x in a . x must be inside the bounds of a as described in Bigar‐
105 ray.Array1.get ; otherwise, Invalid_argument is raised.
106
107
108
109 val sub : ('a, 'b, 'c) t -> int -> int -> ('a, 'b, 'c) t
110
111 Extract a sub-array of the given one-dimensional Bigarray. See Bigar‐
112 ray.Genarray.sub_left for more details.
113
114
115
116 val slice : ('a, 'b, 'c) t -> int -> ('a, 'b, 'c) Bigarray.Array0.t
117
118 Extract a scalar (zero-dimensional slice) of the given one-dimensional
119 Bigarray. The integer parameter is the index of the scalar to extract.
120 See Bigarray.Genarray.slice_left and Bigarray.Genarray.slice_right for
121 more details.
122
123
124 Since 4.05.0
125
126
127
128 val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
129
130 Copy the first Bigarray to the second Bigarray. See Bigarray.Genar‐
131 ray.blit for more details.
132
133
134
135 val fill : ('a, 'b, 'c) t -> 'a -> unit
136
137 Fill the given Bigarray with the given value. See Bigarray.Genar‐
138 ray.fill for more details.
139
140
141
142 val of_array : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> 'a array
143 -> ('a, 'b, 'c) t
144
145 Build a one-dimensional Bigarray initialized from the given array.
146
147
148
149 val unsafe_get : ('a, 'b, 'c) t -> int -> 'a
150
151 Like Bigarray.Array1.get , but bounds checking is not always performed.
152 Use with caution and only when the program logic guarantees that the
153 access is within bounds.
154
155
156
157 val unsafe_set : ('a, 'b, 'c) t -> int -> 'a -> unit
158
159 Like Bigarray.Array1.set , but bounds checking is not always performed.
160 Use with caution and only when the program logic guarantees that the
161 access is within bounds.
162
163
164
165
166
167OCamldoc 2019-07-30 Bigarray.Array1(3)