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