Module Bigarray.Array1
Contents
Instructions: Use this module in your project
In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:
Add the following to your project's
dependencies/CMakeLists.txt:DkSDKProject_DeclareAvailable(ocaml CONSTRAINT "= 4.14.0" FINDLIBS str unix runtime_events threads dynlink) DkSDKProject_MakeAvailable(ocaml)Add the
Findlib::ocamllibrary to any desired targets insrc/*/CMakeLists.txt:target_link_libraries(YourPackage_YourLibraryName # ... existing libraries, if any ... Findlib::ocaml)Click your IDE's
Buildbutton
Not using DkSDK?
FIRST, do one or all of the following:
Run:
opam install ocaml.4.14.0Edit your
dune-projectand add:(package (name YourExistingPackage) (depends ; ... existing dependenices ... (ocaml (>= 4.14.0))))Then run:
dune build *.opam # if this fails, run: dune buildEdit your
<package>.opamfile and add:depends: [ # ... existing dependencies ... "ocaml" {>= "4.14.0"} ]Then run:
opam install . --deps-only
FINALLY, add the library to any desired (library)and/or (executable) targets in your **/dune files:
(library
(name YourLibrary)
; ... existing library options ...
(libraries
; ... existing libraries ...
))
(executable
(name YourExecutable)
; ... existing executable options ...
(libraries
; ... existing libraries ...
))type``(!'a, !'b, !'c) t
The type of one-dimensional Bigarrays whose elements have OCaml type
'a, representation kind 'b, and memory layout 'c.
Array1.create kind layout dim returns a new Bigarray of one dimension,
whose size is dim. kind and layout determine the array element
kind and the array layout as described for
Genarray.create.
Array1.init kind layout dim f returns a new Bigarray b of one
dimension, whose size is dim. kind and layout determine the array
element kind and the array layout as described for
Genarray.create.
Each element Array1.get b i of the array is initialized to the result
of f i.
In other words, Array1.init kind layout dimensions f tabulates the
results of f applied to the indices of a new Bigarray whose layout is
described by kind, layout and dim.
- since 4.12.0
valdim : ``('a,'b,'c)``t->int
Return the size (dimension) of the given one-dimensional Bigarray.
Array1.change_layout a layout returns a Bigarray with the specified
layout, sharing the data with a (and hence having the same dimension
as a). No copying of elements is involved: the new array and the
original array share the same storage space.
- since 4.06.0
valsize_in_bytes : ``('a,'b,'c)``t->int
size_in_bytes a is the number of elements in a multiplied by a's
kind_size_in_bytes.
- since 4.03.0
valget : ``('a,'b,'c)``t->``int->'a
Array1.get a x, or alternatively a.{x}, returns the element of a
at index x. x must be greater or equal than 0 and strictly less
than Array1.dim a if a has C layout. If a has Fortran layout, x
must be greater or equal than 1 and less or equal than Array1.dim a.
Otherwise, Invalid_argument is raised.
valset : ``('a,'b,'c)``t->``int->'a->unit
Array1.set a x v, also written a.{x} <- v, stores the value v at
index x in a. x must be inside the bounds of a as described in
Bigarray.Array1.get; otherwise, Invalid_argument is
raised.
Extract a sub-array of the given one-dimensional Bigarray. See
Genarray.sub_left for
more details.
Extract a scalar (zero-dimensional slice) of the given one-dimensional
Bigarray. The integer parameter is the index of the scalar to extract.
See
Bigarray.Genarray.slice_left
and
Bigarray.Genarray.slice_right
for more details.
- since 4.05.0
Copy the first Bigarray to the second Bigarray. See
Genarray.blit for more
details.
valfill : ``('a,'b,'c)``t->'a->unit
Fill the given Bigarray with the given value. See
Genarray.fill for more
details.
Build a one-dimensional Bigarray initialized from the given array.
valunsafe_get : ``('a,'b,'c)``t->``int->'a
Like Bigarray.Array1.get, but bounds checking is not
always performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
valunsafe_set : ``('a,'b,'c)``t->``int->'a->unit
Like Bigarray.Array1.set, but bounds checking is not
always performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
