PR#1956 renommage: bigarray est prefixe par ocaml_ba_
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7341 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
5017ffdd82
commit
f6190f3d0c
|
@ -615,21 +615,21 @@ let simplif_primitive_32bits = function
|
|||
| Pbintcomp(Pint64, Lambda.Cle) -> Pccall (default_prim "caml_lessequal")
|
||||
| Pbintcomp(Pint64, Lambda.Cge) -> Pccall (default_prim "caml_greaterequal")
|
||||
| Pbigarrayref(n, Pbigarray_int64, layout) ->
|
||||
Pccall (default_prim ("bigarray_get_" ^ string_of_int n))
|
||||
Pccall (default_prim ("caml_ba_get_" ^ string_of_int n))
|
||||
| Pbigarrayset(n, Pbigarray_int64, layout) ->
|
||||
Pccall (default_prim ("bigarray_set_" ^ string_of_int n))
|
||||
Pccall (default_prim ("caml_ba_set_" ^ string_of_int n))
|
||||
| p -> p
|
||||
|
||||
let simplif_primitive p =
|
||||
match p with
|
||||
Pbigarrayref(n, Pbigarray_unknown, layout) ->
|
||||
Pccall (default_prim ("bigarray_get_" ^ string_of_int n))
|
||||
Pccall (default_prim ("caml_ba_get_" ^ string_of_int n))
|
||||
| Pbigarrayset(n, Pbigarray_unknown, layout) ->
|
||||
Pccall (default_prim ("bigarray_set_" ^ string_of_int n))
|
||||
Pccall (default_prim ("caml_ba_set_" ^ string_of_int n))
|
||||
| Pbigarrayref(n, kind, Pbigarray_unknown_layout) ->
|
||||
Pccall (default_prim ("bigarray_get_" ^ string_of_int n))
|
||||
Pccall (default_prim ("caml_ba_get_" ^ string_of_int n))
|
||||
| Pbigarrayset(n, kind, Pbigarray_unknown_layout) ->
|
||||
Pccall (default_prim ("bigarray_set_" ^ string_of_int n))
|
||||
Pccall (default_prim ("caml_ba_set_" ^ string_of_int n))
|
||||
| p ->
|
||||
if size_int = 8 then p else simplif_primitive_32bits p
|
||||
|
||||
|
|
|
@ -351,8 +351,8 @@ let comp_primitive p args =
|
|||
| Pbintcomp(bi, Cgt) -> Kccall("caml_greaterthan", 2)
|
||||
| Pbintcomp(bi, Cle) -> Kccall("caml_lessequal", 2)
|
||||
| Pbintcomp(bi, Cge) -> Kccall("caml_greaterequal", 2)
|
||||
| Pbigarrayref(n, _, _) -> Kccall("bigarray_get_" ^ string_of_int n, n + 1)
|
||||
| Pbigarrayset(n, _, _) -> Kccall("bigarray_set_" ^ string_of_int n, n + 2)
|
||||
| Pbigarrayref(n, _, _) -> Kccall("caml_ba_get_" ^ string_of_int n, n + 1)
|
||||
| Pbigarrayset(n, _, _) -> Kccall("caml_ba_set_" ^ string_of_int n, n + 2)
|
||||
| _ -> fatal_error "Bytegen.comp_primitive"
|
||||
|
||||
let is_immed n = immed_min <= n && n <= immed_max
|
||||
|
|
|
@ -250,12 +250,12 @@ let primitives_table = create_hashtable 57 [
|
|||
"%int64_to_int32", Pcvtbint(Pint64, Pint32);
|
||||
"%int64_of_nativeint", Pcvtbint(Pnativeint, Pint64);
|
||||
"%int64_to_nativeint", Pcvtbint(Pint64, Pnativeint);
|
||||
"%bigarray_ref_1", Pbigarrayref(1, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%bigarray_ref_2", Pbigarrayref(2, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%bigarray_ref_3", Pbigarrayref(3, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%bigarray_set_1", Pbigarrayset(1, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%bigarray_set_2", Pbigarrayset(2, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%bigarray_set_3", Pbigarrayset(3, Pbigarray_unknown, Pbigarray_c_layout)
|
||||
"%caml_ba_ref_1", Pbigarrayref(1, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%caml_ba_ref_2", Pbigarrayref(2, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%caml_ba_ref_3", Pbigarrayref(3, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%caml_ba_set_1", Pbigarrayset(1, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%caml_ba_set_2", Pbigarrayset(2, Pbigarray_unknown, Pbigarray_c_layout);
|
||||
"%caml_ba_set_3", Pbigarrayset(3, Pbigarray_unknown, Pbigarray_c_layout)
|
||||
]
|
||||
|
||||
let prim_makearray =
|
||||
|
|
|
@ -305,5 +305,70 @@
|
|||
|
||||
/* **** asmcomp/asmlink.ml, asmcomp/cmmgen.ml, asmcomp/compilenv.ml */
|
||||
|
||||
/* ************************************************************* */
|
||||
|
||||
/* **** otherlibs/bigarray */
|
||||
#define int8 caml_ba_int8
|
||||
#define uint8 caml_ba_uint8
|
||||
#define int16 caml_ba_int16
|
||||
#define uint16 caml_ba_uint16
|
||||
#define MAX_NUM_DIMS CAML_BA_MAX_NUM_DIMS
|
||||
#define caml_bigarray_kind caml_ba_kind
|
||||
#define BIGARRAY_FLOAT32 CAML_BA_FLOAT32
|
||||
#define BIGARRAY_FLOAT64 CAML_BA_FLOAT64
|
||||
#define BIGARRAY_SINT8 CAML_BA_SINT8
|
||||
#define BIGARRAY_UINT8 CAML_BA_UINT8
|
||||
#define BIGARRAY_SINT16 CAML_BA_SINT16
|
||||
#define BIGARRAY_UINT16 CAML_BA_UINT16
|
||||
#define BIGARRAY_INT32 CAML_BA_INT32
|
||||
#define BIGARRAY_INT64 CAML_BA_INT64
|
||||
#define BIGARRAY_CAML_INT CAML_BA_CAML_INT
|
||||
#define BIGARRAY_NATIVE_INT CAML_BA_NATIVE_INT
|
||||
#define BIGARRAY_COMPLEX32 CAML_BA_COMPLEX32
|
||||
#define BIGARRAY_COMPLEX64 CAML_BA_COMPLEX64
|
||||
#define BIGARRAY_KIND_MASK CAML_BA_KIND_MASK
|
||||
#define caml_bigarray_layout caml_ba_layout
|
||||
#define BIGARRAY_C_LAYOUT CAML_BA_C_LAYOUT
|
||||
#define BIGARRAY_FORTRAN_LAYOUT CAML_BA_FORTRAN_LAYOUT
|
||||
#define BIGARRAY_LAYOUT_MASK CAML_BA_LAYOUT_MASK
|
||||
#define caml_bigarray_managed caml_ba_managed
|
||||
#define BIGARRAY_EXTERNAL CAML_BA_EXTERNAL
|
||||
#define BIGARRAY_MANAGED CAML_BA_MANAGED
|
||||
#define BIGARRAY_MAPPED_FILE CAML_BA_MAPPED_FILE
|
||||
#define BIGARRAY_MANAGED_MASK CAML_BA_MANAGED_MASK
|
||||
#define caml_bigarray_proxy caml_ba_proxy
|
||||
#define caml_bigarray caml_ba_array
|
||||
#define Bigarray_val Caml_ba_array_val
|
||||
#define Data_bigarray_val Caml_ba_data_val
|
||||
#define alloc_bigarray caml_ba_alloc
|
||||
#define alloc_bigarray_dims caml_ba_alloc_dims
|
||||
#define bigarray_map_file caml_ba_map_file
|
||||
#define bigarray_unmap_file caml_ba_unmap_file
|
||||
#define bigarray_element_size caml_ba_element_size
|
||||
#define bigarray_byte_size caml_ba_byte_size
|
||||
#define bigarray_deserialize caml_ba_deserialize
|
||||
#define MAX_BIGARRAY_MEMORY CAML_BA_MAX_MEMORY
|
||||
#define bigarray_create caml_ba_create
|
||||
#define bigarray_get_N caml_ba_get_N
|
||||
#define bigarray_get_1 caml_ba_get_1
|
||||
#define bigarray_get_2 caml_ba_get_2
|
||||
#define bigarray_get_3 caml_ba_get_3
|
||||
#define bigarray_get_generic caml_ba_get_generic
|
||||
#define bigarray_set_1 caml_ba_set_1
|
||||
#define bigarray_set_2 caml_ba_set_2
|
||||
#define bigarray_set_3 caml_ba_set_3
|
||||
#define bigarray_set_N caml_ba_set_N
|
||||
#define bigarray_set_generic caml_ba_set_generic
|
||||
#define bigarray_num_dims caml_ba_num_dims
|
||||
#define bigarray_dim caml_ba_dim
|
||||
#define bigarray_kind caml_ba_kind
|
||||
#define bigarray_layout caml_ba_layout
|
||||
#define bigarray_slice caml_ba_slice
|
||||
#define bigarray_sub caml_ba_sub
|
||||
#define bigarray_blit caml_ba_blit
|
||||
#define bigarray_fill caml_ba_fill
|
||||
#define bigarray_reshape caml_ba_reshape
|
||||
#define bigarray_init caml_ba_init
|
||||
|
||||
#endif /* CAML_NAME_SPACE */
|
||||
#endif /* CAML_COMPATIBILITY_H */
|
||||
|
|
|
@ -13,69 +13,72 @@
|
|||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _bigarray_
|
||||
#define _bigarray_
|
||||
#ifndef CAML_BIGARRAY_H
|
||||
#define CAML_BIGARRAY_H
|
||||
|
||||
#ifndef CAML_NAME_SPACE
|
||||
#include "compatibility.h"
|
||||
#endif
|
||||
#include "config.h"
|
||||
#include "mlvalues.h"
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef signed char caml_ba_int8;
|
||||
typedef unsigned char caml_ba_uint8;
|
||||
#if SIZEOF_SHORT == 2
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef short caml_ba_int16;
|
||||
typedef unsigned short caml_ba_uint16;
|
||||
#else
|
||||
#error "No 16-bit integer type available"
|
||||
#endif
|
||||
|
||||
#define MAX_NUM_DIMS 16
|
||||
#define CAML_BA_MAX_NUM_DIMS 16
|
||||
|
||||
enum caml_bigarray_kind {
|
||||
BIGARRAY_FLOAT32, /* Single-precision floats */
|
||||
BIGARRAY_FLOAT64, /* Double-precision floats */
|
||||
BIGARRAY_SINT8, /* Signed 8-bit integers */
|
||||
BIGARRAY_UINT8, /* Unsigned 8-bit integers */
|
||||
BIGARRAY_SINT16, /* Signed 16-bit integers */
|
||||
BIGARRAY_UINT16, /* Unsigned 16-bit integers */
|
||||
BIGARRAY_INT32, /* Signed 32-bit integers */
|
||||
BIGARRAY_INT64, /* Signed 64-bit integers */
|
||||
BIGARRAY_CAML_INT, /* Caml-style integers (signed 31 or 63 bits) */
|
||||
BIGARRAY_NATIVE_INT, /* Platform-native long integers (32 or 64 bits) */
|
||||
BIGARRAY_COMPLEX32, /* Single-precision complex */
|
||||
BIGARRAY_COMPLEX64, /* Double-precision complex */
|
||||
BIGARRAY_KIND_MASK = 0xFF /* Mask for kind in flags field */
|
||||
enum caml_ba_kind {
|
||||
CAML_BA_FLOAT32, /* Single-precision floats */
|
||||
CAML_BA_FLOAT64, /* Double-precision floats */
|
||||
CAML_BA_SINT8, /* Signed 8-bit integers */
|
||||
CAML_BA_UINT8, /* Unsigned 8-bit integers */
|
||||
CAML_BA_SINT16, /* Signed 16-bit integers */
|
||||
CAML_BA_UINT16, /* Unsigned 16-bit integers */
|
||||
CAML_BA_INT32, /* Signed 32-bit integers */
|
||||
CAML_BA_INT64, /* Signed 64-bit integers */
|
||||
CAML_BA_CAML_INT, /* Caml-style integers (signed 31 or 63 bits) */
|
||||
CAML_BA_NATIVE_INT, /* Platform-native long integers (32 or 64 bits) */
|
||||
CAML_BA_COMPLEX32, /* Single-precision complex */
|
||||
CAML_BA_COMPLEX64, /* Double-precision complex */
|
||||
CAML_BA_KIND_MASK = 0xFF /* Mask for kind in flags field */
|
||||
};
|
||||
|
||||
enum caml_bigarray_layout {
|
||||
BIGARRAY_C_LAYOUT = 0, /* Row major, indices start at 0 */
|
||||
BIGARRAY_FORTRAN_LAYOUT = 0x100, /* Column major, indices start at 1 */
|
||||
BIGARRAY_LAYOUT_MASK = 0x100 /* Mask for layout in flags field */
|
||||
enum caml_ba_layout {
|
||||
CAML_BA_C_LAYOUT = 0, /* Row major, indices start at 0 */
|
||||
CAML_BA_FORTRAN_LAYOUT = 0x100, /* Column major, indices start at 1 */
|
||||
CAML_BA_LAYOUT_MASK = 0x100 /* Mask for layout in flags field */
|
||||
};
|
||||
|
||||
enum caml_bigarray_managed {
|
||||
BIGARRAY_EXTERNAL = 0, /* Data is not allocated by Caml */
|
||||
BIGARRAY_MANAGED = 0x200, /* Data is allocated by Caml */
|
||||
BIGARRAY_MAPPED_FILE = 0x400, /* Data is a memory mapped file */
|
||||
BIGARRAY_MANAGED_MASK = 0x600 /* Mask for "managed" bits in flags field */
|
||||
enum caml_ba_managed {
|
||||
CAML_BA_EXTERNAL = 0, /* Data is not allocated by Caml */
|
||||
CAML_BA_MANAGED = 0x200, /* Data is allocated by Caml */
|
||||
CAML_BA_MAPPED_FILE = 0x400, /* Data is a memory mapped file */
|
||||
CAML_BA_MANAGED_MASK = 0x600 /* Mask for "managed" bits in flags field */
|
||||
};
|
||||
|
||||
struct caml_bigarray_proxy {
|
||||
struct caml_ba_proxy {
|
||||
intnat refcount; /* Reference count */
|
||||
void * data; /* Pointer to base of actual data */
|
||||
uintnat size; /* Size of data in bytes (if mapped file) */
|
||||
};
|
||||
|
||||
struct caml_bigarray {
|
||||
struct caml_ba_array {
|
||||
void * data; /* Pointer to raw data */
|
||||
intnat num_dims; /* Number of dimensions */
|
||||
intnat flags; /* Kind of element array + memory layout + allocation status */
|
||||
struct caml_bigarray_proxy * proxy; /* The proxy for sub-arrays, or NULL */
|
||||
intnat flags; /* Kind of element array + memory layout + allocation status */
|
||||
struct caml_ba_proxy * proxy; /* The proxy for sub-arrays, or NULL */
|
||||
intnat dim[1] /*[num_dims]*/; /* Size in each dimension */
|
||||
};
|
||||
|
||||
#define Bigarray_val(v) ((struct caml_bigarray *) Data_custom_val(v))
|
||||
#define Caml_ba_array_val(v) ((struct caml_ba_array *) Data_custom_val(v))
|
||||
|
||||
#define Data_bigarray_val(v) (Bigarray_val(v)->data)
|
||||
#define Caml_ba_data_val(v) (Caml_ba_array_val(v)->data)
|
||||
|
||||
#if defined(IN_OCAML_BIGARRAY)
|
||||
#define CAMLBAextern CAMLexport
|
||||
|
@ -83,8 +86,9 @@ struct caml_bigarray {
|
|||
#define CAMLBAextern CAMLextern
|
||||
#endif
|
||||
|
||||
CAMLBAextern value alloc_bigarray(int flags, int num_dims, void * data, intnat * dim);
|
||||
CAMLBAextern value alloc_bigarray_dims(int flags, int num_dims, void * data,
|
||||
CAMLBAextern value
|
||||
caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim);
|
||||
CAMLBAextern value caml_ba_alloc_dims(int flags, int num_dims, void * data,
|
||||
... /*dimensions, with type intnat */);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
(* Module [Bigarray]: large, multi-dimensional, numerical arrays *)
|
||||
|
||||
external init : unit -> unit = "bigarray_init"
|
||||
external init : unit -> unit = "caml_ba_init"
|
||||
|
||||
let _ = init()
|
||||
|
||||
|
@ -34,7 +34,7 @@ type float64_elt
|
|||
type complex32_elt
|
||||
type complex64_elt
|
||||
|
||||
(* Keep those constants in sync with the caml_bigarray_kind enumeration
|
||||
(* Keep those constants in sync with the caml_ba_kind enumeration
|
||||
in bigarray.h *)
|
||||
|
||||
let float32 = 0
|
||||
|
@ -56,7 +56,7 @@ type 'a layout = int
|
|||
type c_layout
|
||||
type fortran_layout
|
||||
|
||||
(* Keep those constants in sync with the caml_bigarray_layout enumeration
|
||||
(* Keep those constants in sync with the caml_ba_layout enumeration
|
||||
in bigarray.h *)
|
||||
|
||||
let c_layout = 0
|
||||
|
@ -65,52 +65,52 @@ let fortran_layout = 0x100
|
|||
module Genarray = struct
|
||||
type ('a, 'b, 'c) t
|
||||
external create: ('a, 'b) kind -> 'c layout -> int array -> ('a, 'b, 'c) t
|
||||
= "bigarray_create"
|
||||
= "caml_ba_create"
|
||||
external get: ('a, 'b, 'c) t -> int array -> 'a
|
||||
= "bigarray_get_generic"
|
||||
= "caml_ba_get_generic"
|
||||
external set: ('a, 'b, 'c) t -> int array -> 'a -> unit
|
||||
= "bigarray_set_generic"
|
||||
external num_dims: ('a, 'b, 'c) t -> int = "bigarray_num_dims"
|
||||
external nth_dim: ('a, 'b, 'c) t -> int -> int = "bigarray_dim"
|
||||
= "caml_ba_set_generic"
|
||||
external num_dims: ('a, 'b, 'c) t -> int = "caml_ba_num_dims"
|
||||
external nth_dim: ('a, 'b, 'c) t -> int -> int = "caml_ba_dim"
|
||||
let dims a =
|
||||
let n = num_dims a in
|
||||
let d = Array.make n 0 in
|
||||
for i = 0 to n-1 do d.(i) <- nth_dim a i done;
|
||||
d
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t
|
||||
= "bigarray_sub"
|
||||
= "caml_ba_sub"
|
||||
external sub_right: ('a, 'b, fortran_layout) t -> int -> int ->
|
||||
('a, 'b, fortran_layout) t
|
||||
= "bigarray_sub"
|
||||
external slice_left: ('a, 'b, c_layout) t -> int array ->
|
||||
= "caml_ba_sub"
|
||||
external slice_left: ('a, 'b, c_layout) t -> int array ->
|
||||
('a, 'b, c_layout) t
|
||||
= "bigarray_slice"
|
||||
external slice_right: ('a, 'b, fortran_layout) t -> int array ->
|
||||
= "caml_ba_slice"
|
||||
external slice_right: ('a, 'b, fortran_layout) t -> int array ->
|
||||
('a, 'b, fortran_layout) t
|
||||
= "bigarray_slice"
|
||||
= "caml_ba_slice"
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
|
||||
= "bigarray_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
= "caml_ba_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
external map_file: Unix.file_descr -> ('a, 'b) kind -> 'c layout ->
|
||||
bool -> int array -> ('a, 'b, 'c) t
|
||||
= "bigarray_map_file"
|
||||
= "caml_ba_map_file"
|
||||
end
|
||||
|
||||
module Array1 = struct
|
||||
type ('a, 'b, 'c) t = ('a, 'b, 'c) Genarray.t
|
||||
let create kind layout dim =
|
||||
Genarray.create kind layout [|dim|]
|
||||
external get: ('a, 'b, 'c) t -> int -> 'a = "%bigarray_ref_1"
|
||||
external set: ('a, 'b, 'c) t -> int -> 'a -> unit = "%bigarray_set_1"
|
||||
external get: ('a, 'b, 'c) t -> int -> 'a = "%caml_ba_ref_1"
|
||||
external set: ('a, 'b, 'c) t -> int -> 'a -> unit = "%caml_ba_set_1"
|
||||
let dim a = Genarray.nth_dim a 0
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external sub: ('a, 'b, 'c) t -> int -> int -> ('a, 'b, 'c) t = "bigarray_sub"
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit = "bigarray_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
external sub: ('a, 'b, 'c) t -> int -> int -> ('a, 'b, 'c) t = "caml_ba_sub"
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit = "caml_ba_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
let of_array kind layout data =
|
||||
let ba = create kind layout (Array.length data) in
|
||||
let ofs = if layout = c_layout then 0 else 1 in
|
||||
|
@ -124,18 +124,21 @@ module Array2 = struct
|
|||
type ('a, 'b, 'c) t = ('a, 'b, 'c) Genarray.t
|
||||
let create kind layout dim1 dim2 =
|
||||
Genarray.create kind layout [|dim1; dim2|]
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> 'a = "%bigarray_ref_2"
|
||||
external set: ('a, 'b, 'c) t -> int -> int -> 'a -> unit = "%bigarray_set_2"
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> 'a = "%caml_ba_ref_2"
|
||||
external set: ('a, 'b, 'c) t -> int -> int -> 'a -> unit = "%caml_ba_set_2"
|
||||
let dim1 a = Genarray.nth_dim a 0
|
||||
let dim2 a = Genarray.nth_dim a 1
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t = "bigarray_sub"
|
||||
external sub_right: ('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t = "bigarray_sub"
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t
|
||||
= "caml_ba_sub"
|
||||
external sub_right:
|
||||
('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t
|
||||
= "caml_ba_sub"
|
||||
let slice_left a n = Genarray.slice_left a [|n|]
|
||||
let slice_right a n = Genarray.slice_right a [|n|]
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit = "bigarray_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit = "caml_ba_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
let of_array kind layout data =
|
||||
let dim1 = Array.length data in
|
||||
let dim2 = if dim1 = 0 then 0 else Array.length data.(0) in
|
||||
|
@ -158,21 +161,25 @@ module Array3 = struct
|
|||
type ('a, 'b, 'c) t = ('a, 'b, 'c) Genarray.t
|
||||
let create kind layout dim1 dim2 dim3 =
|
||||
Genarray.create kind layout [|dim1; dim2; dim3|]
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> int -> 'a = "%bigarray_ref_3"
|
||||
external set: ('a, 'b, 'c) t -> int -> int -> int -> 'a -> unit = "%bigarray_set_3"
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> int -> 'a = "%caml_ba_ref_3"
|
||||
external set: ('a, 'b, 'c) t -> int -> int -> int -> 'a -> unit
|
||||
= "%caml_ba_set_3"
|
||||
let dim1 a = Genarray.nth_dim a 0
|
||||
let dim2 a = Genarray.nth_dim a 1
|
||||
let dim3 a = Genarray.nth_dim a 2
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t = "bigarray_sub"
|
||||
external sub_right: ('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t = "bigarray_sub"
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t
|
||||
= "caml_ba_sub"
|
||||
external sub_right:
|
||||
('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t
|
||||
= "caml_ba_sub"
|
||||
let slice_left_1 a n m = Genarray.slice_left a [|n; m|]
|
||||
let slice_right_1 a n m = Genarray.slice_right a [|n; m|]
|
||||
let slice_left_2 a n = Genarray.slice_left a [|n|]
|
||||
let slice_right_2 a n = Genarray.slice_right a [|n|]
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit = "bigarray_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit = "caml_ba_blit"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
let of_array kind layout data =
|
||||
let dim1 = Array.length data in
|
||||
let dim2 = if dim1 = 0 then 0 else Array.length data.(0) in
|
||||
|
@ -197,24 +204,30 @@ module Array3 = struct
|
|||
Genarray.map_file fd kind layout shared [|dim1;dim2;dim3|]
|
||||
end
|
||||
|
||||
external genarray_of_array1: ('a, 'b, 'c) Array1.t -> ('a, 'b, 'c) Genarray.t = "%identity"
|
||||
external genarray_of_array2: ('a, 'b, 'c) Array2.t -> ('a, 'b, 'c) Genarray.t = "%identity"
|
||||
external genarray_of_array3: ('a, 'b, 'c) Array3.t -> ('a, 'b, 'c) Genarray.t = "%identity"
|
||||
external genarray_of_array1: ('a, 'b, 'c) Array1.t -> ('a, 'b, 'c) Genarray.t
|
||||
= "%identity"
|
||||
external genarray_of_array2: ('a, 'b, 'c) Array2.t -> ('a, 'b, 'c) Genarray.t
|
||||
= "%identity"
|
||||
external genarray_of_array3: ('a, 'b, 'c) Array3.t -> ('a, 'b, 'c) Genarray.t
|
||||
= "%identity"
|
||||
let array1_of_genarray a =
|
||||
if Genarray.num_dims a = 1 then a else invalid_arg "Bigarray.array1_of_genarray"
|
||||
if Genarray.num_dims a = 1 then a
|
||||
else invalid_arg "Bigarray.array1_of_genarray"
|
||||
let array2_of_genarray a =
|
||||
if Genarray.num_dims a = 2 then a else invalid_arg "Bigarray.array2_of_genarray"
|
||||
if Genarray.num_dims a = 2 then a
|
||||
else invalid_arg "Bigarray.array2_of_genarray"
|
||||
let array3_of_genarray a =
|
||||
if Genarray.num_dims a = 3 then a else invalid_arg "Bigarray.array3_of_genarray"
|
||||
if Genarray.num_dims a = 3 then a
|
||||
else invalid_arg "Bigarray.array3_of_genarray"
|
||||
|
||||
external reshape:
|
||||
('a, 'b, 'c) Genarray.t -> int array -> ('a, 'b, 'c) Genarray.t
|
||||
= "bigarray_reshape"
|
||||
= "caml_ba_reshape"
|
||||
let reshape_1 a dim1 = reshape a [|dim1|]
|
||||
let reshape_2 a dim1 dim2 = reshape a [|dim1;dim2|]
|
||||
let reshape_3 a dim1 dim2 dim3 = reshape a [|dim1;dim2;dim3|]
|
||||
|
||||
(* Force bigarray_get_{1,2,3,N} to be linked in, since we don't refer
|
||||
(* Force caml_ba_get_{1,2,3,N} to be linked in, since we don't refer
|
||||
to those primitives directly in this file *)
|
||||
|
||||
let _ =
|
||||
|
@ -223,4 +236,3 @@ let _ =
|
|||
let _ = Array2.get in
|
||||
let _ = Array3.get in
|
||||
()
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
Big arrays support all the Caml ad-hoc polymorphic operations:
|
||||
- comparisons ([=], [<>], [<=], etc, as well as {!Pervasives.compare});
|
||||
- hashing (module [Hash]);
|
||||
- and structured input-output ({!Pervasives.output_value}
|
||||
and {!Pervasives.input_value}, as well as the functions from the
|
||||
{!Marshal} module).
|
||||
- and structured input-output ({!Pervasives.output_value}
|
||||
and {!Pervasives.input_value}, as well as the functions from the
|
||||
{!Marshal} module).
|
||||
*)
|
||||
|
||||
(** {6 Element kinds} *)
|
||||
|
@ -47,15 +47,15 @@
|
|||
({!Bigarray.int8_signed_elt} or {!Bigarray.int8_unsigned_elt}),
|
||||
- 16-bit integers (signed or unsigned)
|
||||
({!Bigarray.int16_signed_elt} or {!Bigarray.int16_unsigned_elt}),
|
||||
- Caml integers (signed, 31 bits on 32-bit architectures,
|
||||
- Caml integers (signed, 31 bits on 32-bit architectures,
|
||||
63 bits on 64-bit architectures) ({!Bigarray.int_elt}),
|
||||
- 32-bit signed integer ({!Bigarray.int32_elt}),
|
||||
- 64-bit signed integers ({!Bigarray.int64_elt}),
|
||||
- platform-native signed integers (32 bits on 32-bit architectures,
|
||||
64 bits on 64-bit architectures) ({!Bigarray.nativeint_elt}).
|
||||
|
||||
|
||||
Each element kind is represented at the type level by one
|
||||
of the abstract types defined below.
|
||||
of the abstract types defined below.
|
||||
*)
|
||||
|
||||
type float32_elt
|
||||
|
@ -75,12 +75,12 @@ type ('a, 'b) kind
|
|||
(** To each element kind is associated a Caml type, which is
|
||||
the type of Caml values that can be stored in the big array
|
||||
or read back from it. This type is not necessarily the same
|
||||
as the type of the array elements proper: for instance,
|
||||
as the type of the array elements proper: for instance,
|
||||
a big array whose elements are of kind [float32_elt] contains
|
||||
32-bit single precision floats, but reading or writing one of
|
||||
its elements from Caml uses the Caml type [float], which is
|
||||
64-bit double precision floats.
|
||||
|
||||
|
||||
The abstract type [('a, 'b) kind] captures this association
|
||||
of a Caml type ['a] for values read or written in the big array,
|
||||
and of an element kind ['b] which represents the actual contents
|
||||
|
@ -150,21 +150,21 @@ type fortran_layout
|
|||
this library supports two different memory layouts for big arrays,
|
||||
one compatible with the C conventions,
|
||||
the other compatible with the Fortran conventions.
|
||||
|
||||
In the C-style layout, array indices start at 0, and
|
||||
|
||||
In the C-style layout, array indices start at 0, and
|
||||
multi-dimensional arrays are laid out in row-major format.
|
||||
That is, for a two-dimensional array, all elements of
|
||||
row 0 are contiguous in memory, followed by all elements of
|
||||
row 1, etc. In other terms, the array elements at [(x,y)]
|
||||
and [(x, y+1)] are adjacent in memory.
|
||||
|
||||
In the Fortran-style layout, array indices start at 1, and
|
||||
|
||||
In the Fortran-style layout, array indices start at 1, and
|
||||
multi-dimensional arrays are laid out in column-major format.
|
||||
That is, for a two-dimensional array, all elements of
|
||||
column 0 are contiguous in memory, followed by all elements of
|
||||
column 1, etc. In other terms, the array elements at [(x,y)]
|
||||
and [(x+1, y)] are adjacent in memory.
|
||||
|
||||
|
||||
Each layout style is identified at the type level by the
|
||||
abstract types {!Bigarray.c_layout} and [fortran_layout] respectively. *)
|
||||
|
||||
|
@ -177,7 +177,7 @@ type 'a layout
|
|||
(** {7 Supported layouts}
|
||||
|
||||
The abstract values [c_layout] and [fortran_layout] represent
|
||||
the two supported layouts at the level of values.
|
||||
the two supported layouts at the level of values.
|
||||
*)
|
||||
|
||||
val c_layout : c_layout layout
|
||||
|
@ -192,7 +192,7 @@ module Genarray :
|
|||
(** The type [Genarray.t] is the type of big arrays with variable
|
||||
numbers of dimensions. Any number of dimensions between 1 and 16
|
||||
is supported.
|
||||
|
||||
|
||||
The three type parameters to [Genarray.t] identify the array element
|
||||
kind and layout, as follows:
|
||||
- the first parameter, ['a], is the Caml type for accessing array
|
||||
|
@ -202,14 +202,14 @@ module Genarray :
|
|||
etc);
|
||||
- the third parameter, ['c], identifies the array layout
|
||||
([c_layout] or [fortran_layout]).
|
||||
|
||||
|
||||
For instance, [(float, float32_elt, fortran_layout) Genarray.t]
|
||||
is the type of generic big arrays containing 32-bit floats
|
||||
in Fortran layout; reads and writes in this array use the
|
||||
Caml type [float]. *)
|
||||
|
||||
external create: ('a, 'b) kind -> 'c layout -> int array -> ('a, 'b, 'c) t
|
||||
= "bigarray_create"
|
||||
= "caml_ba_create"
|
||||
(** [Genarray.create kind layout dimensions] returns a new big array
|
||||
whose element kind is determined by the parameter [kind] (one of
|
||||
[float32], [float64], [int8_signed], etc) and whose layout is
|
||||
|
@ -218,27 +218,27 @@ module Genarray :
|
|||
integers that indicate the size of the big array in each dimension.
|
||||
The length of [dimensions] determines the number of dimensions
|
||||
of the bigarray.
|
||||
|
||||
|
||||
For instance, [Genarray.create int32 c_layout [|4;6;8|]]
|
||||
returns a fresh big array of 32-bit integers, in C layout,
|
||||
having three dimensions, the three dimensions being 4, 6 and 8
|
||||
respectively.
|
||||
|
||||
|
||||
Big arrays returned by [Genarray.create] are not initialized:
|
||||
the initial values of array elements is unspecified.
|
||||
|
||||
|
||||
[Genarray.create] raises [Invalid_arg] if the number of dimensions
|
||||
is not in the range 1 to 16 inclusive, or if one of the dimensions
|
||||
is negative. *)
|
||||
|
||||
external num_dims: ('a, 'b, 'c) t -> int = "bigarray_num_dims"
|
||||
|
||||
external num_dims: ('a, 'b, 'c) t -> int = "caml_ba_num_dims"
|
||||
(** Return the number of dimensions of the given big array. *)
|
||||
|
||||
val dims : ('a, 'b, 'c) t -> int array
|
||||
(** [Genarray.dims a] returns all dimensions of the big array [a],
|
||||
as an array of integers of length [Genarray.num_dims a]. *)
|
||||
|
||||
external nth_dim: ('a, 'b, 'c) t -> int -> int = "bigarray_dim"
|
||||
external nth_dim: ('a, 'b, 'c) t -> int -> int = "caml_ba_dim"
|
||||
(** [Genarray.nth_dim a n] returns the [n]-th dimension of the
|
||||
big array [a]. The first dimension corresponds to [n = 0];
|
||||
the second dimension corresponds to [n = 1]; the last dimension,
|
||||
|
@ -246,25 +246,25 @@ module Genarray :
|
|||
Raise [Invalid_arg] if [n] is less than 0 or greater or equal than
|
||||
[Genarray.num_dims a]. *)
|
||||
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
(** Return the kind of the given big array. *)
|
||||
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
(** Return the layout of the given big array. *)
|
||||
|
||||
external get: ('a, 'b, 'c) t -> int array -> 'a = "bigarray_get_generic"
|
||||
external get: ('a, 'b, 'c) t -> int array -> 'a = "caml_ba_get_generic"
|
||||
(** Read an element of a generic big array.
|
||||
[Genarray.get a [|i1; ...; iN|]] returns the element of [a]
|
||||
whose coordinates are [i1] in the first dimension, [i2] in
|
||||
the second dimension, ..., [iN] in the [N]-th dimension.
|
||||
|
||||
|
||||
If [a] has C layout, the coordinates must be greater or equal than 0
|
||||
and strictly less than the corresponding dimensions of [a].
|
||||
If [a] has Fortran layout, the coordinates must be greater or equal
|
||||
than 1 and less or equal than the corresponding dimensions of [a].
|
||||
Raise [Invalid_arg] if the array [a] does not have exactly [N]
|
||||
dimensions, or if the coordinates are outside the array bounds.
|
||||
|
||||
|
||||
If [N > 3], alternate syntax is provided: you can write
|
||||
[a.{i1, i2, ..., iN}] instead of [Genarray.get a [|i1; ...; iN|]].
|
||||
(The syntax [a.{...}] with one, two or three coordinates is
|
||||
|
@ -272,16 +272,16 @@ module Genarray :
|
|||
as described below.) *)
|
||||
|
||||
external set: ('a, 'b, 'c) t -> int array -> 'a -> unit
|
||||
= "bigarray_set_generic"
|
||||
= "caml_ba_set_generic"
|
||||
(** Assign an element of a generic big array.
|
||||
[Genarray.set a [|i1; ...; iN|] v] stores the value [v] in the
|
||||
element of [a] whose coordinates are [i1] in the first dimension,
|
||||
[i2] in the second dimension, ..., [iN] in the [N]-th dimension.
|
||||
|
||||
|
||||
The array [a] must have exactly [N] dimensions, and all coordinates
|
||||
must lie inside the array bounds, as described for [Genarray.get];
|
||||
otherwise, [Invalid_arg] is raised.
|
||||
|
||||
|
||||
If [N > 3], alternate syntax is provided: you can write
|
||||
[a.{i1, i2, ..., iN} <- v] instead of
|
||||
[Genarray.set a [|i1; ...; iN|] v].
|
||||
|
@ -290,7 +290,7 @@ module Genarray :
|
|||
as described below.) *)
|
||||
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t
|
||||
= "bigarray_sub"
|
||||
= "caml_ba_sub"
|
||||
(** Extract a sub-array of the given big array by restricting the
|
||||
first (left-most) dimension. [Genarray.sub_left a ofs len]
|
||||
returns a big array with the same number of dimensions as [a],
|
||||
|
@ -302,7 +302,7 @@ module Genarray :
|
|||
[[|i1; ...; iN|]] of the sub-array is identical to the
|
||||
element at coordinates [[|i1+ofs; ...; iN|]] of the original
|
||||
array [a].
|
||||
|
||||
|
||||
[Genarray.sub_left] applies only to big arrays in C layout.
|
||||
Raise [Invalid_arg] if [ofs] and [len] do not designate
|
||||
a valid sub-array of [a], that is, if [ofs < 0], or [len < 0],
|
||||
|
@ -310,7 +310,7 @@ module Genarray :
|
|||
|
||||
external sub_right:
|
||||
('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t
|
||||
= "bigarray_sub"
|
||||
= "caml_ba_sub"
|
||||
(** Extract a sub-array of the given big array by restricting the
|
||||
last (right-most) dimension. [Genarray.sub_right a ofs len]
|
||||
returns a big array with the same number of dimensions as [a],
|
||||
|
@ -322,7 +322,7 @@ module Genarray :
|
|||
[[|i1; ...; iN|]] of the sub-array is identical to the
|
||||
element at coordinates [[|i1; ...; iN+ofs|]] of the original
|
||||
array [a].
|
||||
|
||||
|
||||
[Genarray.sub_right] applies only to big arrays in Fortran layout.
|
||||
Raise [Invalid_arg] if [ofs] and [len] do not designate
|
||||
a valid sub-array of [a], that is, if [ofs < 1], or [len < 0],
|
||||
|
@ -330,7 +330,7 @@ module Genarray :
|
|||
|
||||
external slice_left:
|
||||
('a, 'b, c_layout) t -> int array -> ('a, 'b, c_layout) t
|
||||
= "bigarray_slice"
|
||||
= "caml_ba_slice"
|
||||
(** Extract a sub-array of lower dimension from the given big array
|
||||
by fixing one or several of the first (left-most) coordinates.
|
||||
[Genarray.slice_left a [|i1; ... ; iM|]] returns the ``slice''
|
||||
|
@ -341,14 +341,14 @@ module Genarray :
|
|||
at coordinates [[|i1; ...; iM; j1; ...; j(N-M)|]] in the original
|
||||
array [a]. No copying of elements is involved: the slice and
|
||||
the original array share the same storage space.
|
||||
|
||||
|
||||
[Genarray.slice_left] applies only to big arrays in C layout.
|
||||
Raise [Invalid_arg] if [M >= N], or if [[|i1; ... ; iM|]]
|
||||
is outside the bounds of [a]. *)
|
||||
|
||||
external slice_right:
|
||||
('a, 'b, fortran_layout) t -> int array -> ('a, 'b, fortran_layout) t
|
||||
= "bigarray_slice"
|
||||
= "caml_ba_slice"
|
||||
(** Extract a sub-array of lower dimension from the given big array
|
||||
by fixing one or several of the last (right-most) coordinates.
|
||||
[Genarray.slice_right a [|i1; ... ; iM|]] returns the ``slice''
|
||||
|
@ -359,13 +359,13 @@ module Genarray :
|
|||
at coordinates [[|j1; ...; j(N-M); i1; ...; iM|]] in the original
|
||||
array [a]. No copying of elements is involved: the slice and
|
||||
the original array share the same storage space.
|
||||
|
||||
|
||||
[Genarray.slice_right] applies only to big arrays in Fortran layout.
|
||||
Raise [Invalid_arg] if [M >= N], or if [[|i1; ... ; iM|]]
|
||||
is outside the bounds of [a]. *)
|
||||
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
|
||||
= "bigarray_blit"
|
||||
= "caml_ba_blit"
|
||||
(** Copy all elements of a big array in another big array.
|
||||
[Genarray.blit src dst] copies all elements of [src] into
|
||||
[dst]. Both arrays [src] and [dst] must have the same number of
|
||||
|
@ -373,7 +373,7 @@ module Genarray :
|
|||
to a sub-array of [dst] can be achieved by applying [Genarray.blit]
|
||||
to sub-array or slices of [src] and [dst]. *)
|
||||
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
(** Set all elements of a big array to a given value.
|
||||
[Genarray.fill a v] stores the value [v] in all elements of
|
||||
the big array [a]. Setting only some elements of [a] to [v]
|
||||
|
@ -382,7 +382,7 @@ module Genarray :
|
|||
|
||||
external map_file:
|
||||
Unix.file_descr -> ('a, 'b) kind -> 'c layout ->
|
||||
bool -> int array -> ('a, 'b, 'c) t = "bigarray_map_file"
|
||||
bool -> int array -> ('a, 'b, 'c) t = "caml_ba_map_file"
|
||||
(** Memory mapping of a file as a big array.
|
||||
[Genarray.map_file fd kind layout shared dims]
|
||||
returns a big array of kind [kind], layout [layout],
|
||||
|
@ -395,11 +395,11 @@ module Genarray :
|
|||
If [shared] is [false], modifications performed on the array
|
||||
are done in memory only, using copy-on-write of the modified
|
||||
pages; the underlying file is not affected.
|
||||
|
||||
|
||||
[Genarray.map_file] is much more efficient than reading
|
||||
the whole file in a big array, modifying that big array,
|
||||
and writing it afterwards.
|
||||
|
||||
|
||||
To adjust automatically the dimensions of the big array to
|
||||
the actual size of the file, the major dimension (that is,
|
||||
the first dimension for an array with C layout, and the last
|
||||
|
@ -408,7 +408,7 @@ module Genarray :
|
|||
from the size of the file. The file must contain an integral
|
||||
number of sub-arrays as determined by the non-major dimensions,
|
||||
otherwise [Failure] is raised.
|
||||
|
||||
|
||||
If all dimensions of the big array are given, the file size is
|
||||
matched against the size of the big array. If the file is larger
|
||||
than the big array, only the initial portion of the file is
|
||||
|
@ -439,41 +439,41 @@ module Array1 : sig
|
|||
as described for [Genarray.create]. *)
|
||||
|
||||
val dim: ('a, 'b, 'c) t -> int
|
||||
(** Return the size (dimension) of the given one-dimensional
|
||||
(** Return the size (dimension) of the given one-dimensional
|
||||
big array. *)
|
||||
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
(** Return the kind of the given big array. *)
|
||||
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
(** Return the layout of the given big array. *)
|
||||
|
||||
external get: ('a, 'b, 'c) t -> int -> 'a = "%bigarray_ref_1"
|
||||
(** [Array1.get a x], or alternatively [a.{x}],
|
||||
external get: ('a, 'b, 'c) t -> int -> 'a = "%caml_ba_ref_1"
|
||||
(** [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_arg] is raised. *)
|
||||
|
||||
external set: ('a, 'b, 'c) t -> int -> 'a -> unit = "%bigarray_set_1"
|
||||
external set: ('a, 'b, 'c) t -> int -> 'a -> unit = "%caml_ba_set_1"
|
||||
(** [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
|
||||
[x] must be inside the bounds of [a] as described in
|
||||
{!Bigarray.Array1.get};
|
||||
otherwise, [Invalid_arg] is raised. *)
|
||||
|
||||
external sub: ('a, 'b, 'c) t -> int -> int -> ('a, 'b, 'c) t
|
||||
= "bigarray_sub"
|
||||
= "caml_ba_sub"
|
||||
(** Extract a sub-array of the given one-dimensional big array.
|
||||
See [Genarray.sub_left] for more details. *)
|
||||
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
|
||||
= "bigarray_blit"
|
||||
= "caml_ba_blit"
|
||||
(** Copy the first big array to the second big array.
|
||||
See [Genarray.blit] for more details. *)
|
||||
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
(** Fill the given big array with the given value.
|
||||
See [Genarray.fill] for more details. *)
|
||||
|
||||
|
@ -512,20 +512,20 @@ module Array2 :
|
|||
val dim2: ('a, 'b, 'c) t -> int
|
||||
(** Return the second dimension of the given two-dimensional big array. *)
|
||||
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
(** Return the kind of the given big array. *)
|
||||
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
(** Return the layout of the given big array. *)
|
||||
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> 'a = "%bigarray_ref_2"
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> 'a = "%caml_ba_ref_2"
|
||||
(** [Array2.get a x y], also written [a.{x,y}],
|
||||
returns the element of [a] at coordinates ([x], [y]).
|
||||
[x] and [y] must be within the bounds
|
||||
of [a], as described for {!Bigarray.Genarray.get};
|
||||
of [a], as described for {!Bigarray.Genarray.get};
|
||||
otherwise, [Invalid_arg] is raised. *)
|
||||
|
||||
external set: ('a, 'b, 'c) t -> int -> int -> 'a -> unit = "%bigarray_set_2"
|
||||
external set: ('a, 'b, 'c) t -> int -> int -> 'a -> unit = "%caml_ba_set_2"
|
||||
(** [Array2.set a x y v], or alternatively [a.{x,y} <- v],
|
||||
stores the value [v] at coordinates ([x], [y]) in [a].
|
||||
[x] and [y] must be within the bounds of [a],
|
||||
|
@ -533,18 +533,18 @@ module Array2 :
|
|||
otherwise, [Invalid_arg] is raised. *)
|
||||
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t
|
||||
= "bigarray_sub"
|
||||
(** Extract a two-dimensional sub-array of the given two-dimensional
|
||||
= "caml_ba_sub"
|
||||
(** Extract a two-dimensional sub-array of the given two-dimensional
|
||||
big array by restricting the first dimension.
|
||||
See {!Bigarray.Genarray.sub_left} for more details.
|
||||
See {!Bigarray.Genarray.sub_left} for more details.
|
||||
[Array2.sub_left] applies only to arrays with C layout. *)
|
||||
|
||||
external sub_right:
|
||||
('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t
|
||||
= "bigarray_sub"
|
||||
(** Extract a two-dimensional sub-array of the given two-dimensional
|
||||
= "caml_ba_sub"
|
||||
(** Extract a two-dimensional sub-array of the given two-dimensional
|
||||
big array by restricting the second dimension.
|
||||
See {!Bigarray.Genarray.sub_right} for more details.
|
||||
See {!Bigarray.Genarray.sub_right} for more details.
|
||||
[Array2.sub_right] applies only to arrays with Fortran layout. *)
|
||||
|
||||
val slice_left: ('a, 'b, c_layout) t -> int -> ('a, 'b, c_layout) Array1.t
|
||||
|
@ -557,16 +557,16 @@ module Array2 :
|
|||
('a, 'b, fortran_layout) t -> int -> ('a, 'b, fortran_layout) Array1.t
|
||||
(** Extract a column (one-dimensional slice) of the given
|
||||
two-dimensional big array. The integer parameter is the
|
||||
index of the column to extract. See {!Bigarray.Genarray.slice_right}
|
||||
index of the column to extract. See {!Bigarray.Genarray.slice_right}
|
||||
for more details. [Array2.slice_right] applies only to arrays
|
||||
with Fortran layout. *)
|
||||
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
|
||||
= "bigarray_blit"
|
||||
= "caml_ba_blit"
|
||||
(** Copy the first big array to the second big array.
|
||||
See {!Bigarray.Genarray.blit} for more details. *)
|
||||
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
(** Fill the given big array with the given value.
|
||||
See {!Bigarray.Genarray.fill} for more details. *)
|
||||
|
||||
|
@ -583,8 +583,9 @@ module Array2 :
|
|||
|
||||
(** {6 Three-dimensional arrays} *)
|
||||
|
||||
(** Three-dimensional arrays. The [Array3] structure provides operations similar to those of
|
||||
{!Bigarray.Genarray}, but specialized to the case of three-dimensional arrays. *)
|
||||
(** Three-dimensional arrays. The [Array3] structure provides operations
|
||||
similar to those of {!Bigarray.Genarray}, but specialized to the case
|
||||
of three-dimensional arrays. *)
|
||||
module Array3 :
|
||||
sig
|
||||
type ('a, 'b, 'c) t
|
||||
|
@ -606,22 +607,22 @@ module Array3 :
|
|||
|
||||
val dim3: ('a, 'b, 'c) t -> int
|
||||
(** Return the third dimension of the given three-dimensional big array. *)
|
||||
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "bigarray_kind"
|
||||
|
||||
external kind: ('a, 'b, 'c) t -> ('a, 'b) kind = "caml_ba_kind"
|
||||
(** Return the kind of the given big array. *)
|
||||
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "bigarray_layout"
|
||||
external layout: ('a, 'b, 'c) t -> 'c layout = "caml_ba_layout"
|
||||
(** Return the layout of the given big array. *)
|
||||
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> int -> 'a = "%bigarray_ref_3"
|
||||
external get: ('a, 'b, 'c) t -> int -> int -> int -> 'a = "%caml_ba_ref_3"
|
||||
(** [Array3.get a x y z], also written [a.{x,y,z}],
|
||||
returns the element of [a] at coordinates ([x], [y], [z]).
|
||||
[x], [y] and [z] must be within the bounds of [a],
|
||||
as described for {!Bigarray.Genarray.get};
|
||||
as described for {!Bigarray.Genarray.get};
|
||||
otherwise, [Invalid_arg] is raised. *)
|
||||
|
||||
external set: ('a, 'b, 'c) t -> int -> int -> int -> 'a -> unit
|
||||
= "%bigarray_set_3"
|
||||
= "%caml_ba_set_3"
|
||||
(** [Array3.set a x y v], or alternatively [a.{x,y,z} <- v],
|
||||
stores the value [v] at coordinates ([x], [y], [z]) in [a].
|
||||
[x], [y] and [z] must be within the bounds of [a],
|
||||
|
@ -629,7 +630,7 @@ module Array3 :
|
|||
otherwise, [Invalid_arg] is raised. *)
|
||||
|
||||
external sub_left: ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t
|
||||
= "bigarray_sub"
|
||||
= "caml_ba_sub"
|
||||
(** Extract a three-dimensional sub-array of the given
|
||||
three-dimensional big array by restricting the first dimension.
|
||||
See {!Bigarray.Genarray.sub_left} for more details. [Array3.sub_left]
|
||||
|
@ -637,7 +638,7 @@ module Array3 :
|
|||
|
||||
external sub_right:
|
||||
('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t
|
||||
= "bigarray_sub"
|
||||
= "caml_ba_sub"
|
||||
(** Extract a three-dimensional sub-array of the given
|
||||
three-dimensional big array by restricting the second dimension.
|
||||
See {!Bigarray.Genarray.sub_right} for more details. [Array3.sub_right]
|
||||
|
@ -678,11 +679,11 @@ module Array3 :
|
|||
layout. *)
|
||||
|
||||
external blit: ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
|
||||
= "bigarray_blit"
|
||||
= "caml_ba_blit"
|
||||
(** Copy the first big array to the second big array.
|
||||
See {!Bigarray.Genarray.blit} for more details. *)
|
||||
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "bigarray_fill"
|
||||
external fill: ('a, 'b, 'c) t -> 'a -> unit = "caml_ba_fill"
|
||||
(** Fill the given big array with the given value.
|
||||
See {!Bigarray.Genarray.fill} for more details. *)
|
||||
|
||||
|
@ -702,15 +703,18 @@ module Array3 :
|
|||
|
||||
external genarray_of_array1 :
|
||||
('a, 'b, 'c) Array1.t -> ('a, 'b, 'c) Genarray.t = "%identity"
|
||||
(** Return the generic big array corresponding to the given one-dimensional big array. *)
|
||||
(** Return the generic big array corresponding to the given one-dimensional
|
||||
big array. *)
|
||||
|
||||
external genarray_of_array2 :
|
||||
('a, 'b, 'c) Array2.t -> ('a, 'b, 'c) Genarray.t = "%identity"
|
||||
(** Return the generic big array corresponding to the given two-dimensional big array. *)
|
||||
(** Return the generic big array corresponding to the given two-dimensional
|
||||
big array. *)
|
||||
|
||||
external genarray_of_array3 :
|
||||
('a, 'b, 'c) Array3.t -> ('a, 'b, 'c) Genarray.t = "%identity"
|
||||
(** Return the generic big array corresponding to the given three-dimensional big array. *)
|
||||
(** Return the generic big array corresponding to the given three-dimensional
|
||||
big array. *)
|
||||
|
||||
val array1_of_genarray : ('a, 'b, 'c) Genarray.t -> ('a, 'b, 'c) Array1.t
|
||||
(** Return the one-dimensional big array corresponding to the given
|
||||
|
@ -747,12 +751,14 @@ val reshape : ('a, 'b, 'c) Genarray.t -> int array -> ('a, 'b, 'c) Genarray.t
|
|||
Otherwise, [Invalid_arg] is raised. *)
|
||||
|
||||
val reshape_1 : ('a, 'b, 'c) Genarray.t -> int -> ('a, 'b, 'c) Array1.t
|
||||
(** Specialized version of {!Bigarray.reshape} for reshaping to one-dimensional arrays. *)
|
||||
(** Specialized version of {!Bigarray.reshape} for reshaping to
|
||||
one-dimensional arrays. *)
|
||||
|
||||
val reshape_2 : ('a, 'b, 'c) Genarray.t -> int -> int -> ('a, 'b, 'c) Array2.t
|
||||
(** Specialized version of {!Bigarray.reshape} for reshaping to two-dimensional arrays. *)
|
||||
(** Specialized version of {!Bigarray.reshape} for reshaping to
|
||||
two-dimensional arrays. *)
|
||||
|
||||
val reshape_3 :
|
||||
('a, 'b, 'c) Genarray.t -> int -> int -> int -> ('a, 'b, 'c) Array3.t
|
||||
(** Specialized version of {!Bigarray.reshape} for reshaping to three-dimensional arrays. *)
|
||||
|
||||
(** Specialized version of {!Bigarray.reshape} for reshaping to
|
||||
three-dimensional arrays. *)
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#include "memory.h"
|
||||
#include "mlvalues.h"
|
||||
|
||||
extern void bigarray_unmap_file(void * addr, uintnat len);
|
||||
extern void caml_ba_unmap_file(void * addr, uintnat len);
|
||||
/* from mmap_xxx.c */
|
||||
|
||||
/* Compute the number of elements of a big array */
|
||||
|
||||
static uintnat bigarray_num_elts(struct caml_bigarray * b)
|
||||
static uintnat caml_ba_num_elts(struct caml_bigarray * b)
|
||||
{
|
||||
uintnat num_elts;
|
||||
int i;
|
||||
|
@ -40,7 +40,7 @@ static uintnat bigarray_num_elts(struct caml_bigarray * b)
|
|||
|
||||
/* Size in bytes of a bigarray element, indexed by bigarray kind */
|
||||
|
||||
int bigarray_element_size[] =
|
||||
int caml_ba_element_size[] =
|
||||
{ 4 /*FLOAT32*/, 8 /*FLOAT64*/,
|
||||
1 /*SINT8*/, 1 /*UINT8*/,
|
||||
2 /*SINT16*/, 2 /*UINT16*/,
|
||||
|
@ -51,32 +51,32 @@ int bigarray_element_size[] =
|
|||
|
||||
/* Compute the number of bytes for the elements of a big array */
|
||||
|
||||
uintnat bigarray_byte_size(struct caml_bigarray * b)
|
||||
uintnat caml_ba_byte_size(struct caml_bigarray * b)
|
||||
{
|
||||
return bigarray_num_elts(b)
|
||||
* bigarray_element_size[b->flags & BIGARRAY_KIND_MASK];
|
||||
return caml_ba_num_elts(b)
|
||||
* caml_ba_element_size[b->flags & CAML_BA_KIND_MASK];
|
||||
}
|
||||
|
||||
/* Operation table for bigarrays */
|
||||
|
||||
static void bigarray_finalize(value v);
|
||||
static int bigarray_compare(value v1, value v2);
|
||||
static intnat bigarray_hash(value v);
|
||||
static void bigarray_serialize(value, uintnat *, uintnat *);
|
||||
uintnat bigarray_deserialize(void * dst);
|
||||
static struct custom_operations bigarray_ops = {
|
||||
static void caml_ba_finalize(value v);
|
||||
static int caml_ba_compare(value v1, value v2);
|
||||
static intnat caml_ba_hash(value v);
|
||||
static void caml_ba_serialize(value, uintnat *, uintnat *);
|
||||
uintnat caml_ba_deserialize(void * dst);
|
||||
static struct custom_operations caml_ba_ops = {
|
||||
"_bigarray",
|
||||
bigarray_finalize,
|
||||
bigarray_compare,
|
||||
bigarray_hash,
|
||||
bigarray_serialize,
|
||||
bigarray_deserialize
|
||||
caml_ba_finalize,
|
||||
caml_ba_compare,
|
||||
caml_ba_hash,
|
||||
caml_ba_serialize,
|
||||
caml_ba_deserialize
|
||||
};
|
||||
|
||||
/* Multiplication of unsigned longs with overflow detection */
|
||||
|
||||
static uintnat
|
||||
bigarray_multov(uintnat a, uintnat b, int * overflow)
|
||||
caml_ba_multov(uintnat a, uintnat b, int * overflow)
|
||||
{
|
||||
#define HALF_SIZE (sizeof(uintnat) * 4)
|
||||
#define HALF_MASK (((uintnat)1 << HALF_SIZE) - 1)
|
||||
|
@ -116,18 +116,18 @@ bigarray_multov(uintnat a, uintnat b, int * overflow)
|
|||
|
||||
/* Allocation of a big array */
|
||||
|
||||
#define MAX_BIGARRAY_MEMORY 256*1024*1024
|
||||
#define CAML_BA_MAX_MEMORY 256*1024*1024
|
||||
/* 256 Mb -- after allocating that much, it's probably worth speeding
|
||||
up the major GC */
|
||||
|
||||
/* [alloc_bigarray] will allocate a new bigarray object in the heap.
|
||||
/* [caml_ba_alloc] will allocate a new bigarray object in the heap.
|
||||
If [data] is NULL, the memory for the contents is also allocated
|
||||
(with [malloc]) by [alloc_bigarray].
|
||||
(with [malloc]) by [caml_ba_alloc].
|
||||
[data] cannot point into the Caml heap.
|
||||
[dim] may point into an object in the Caml heap.
|
||||
*/
|
||||
CAMLexport value
|
||||
alloc_bigarray(int flags, int num_dims, void * data, intnat * dim)
|
||||
caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim)
|
||||
{
|
||||
uintnat num_elts, size;
|
||||
int overflow, i;
|
||||
|
@ -143,20 +143,20 @@ alloc_bigarray(int flags, int num_dims, void * data, intnat * dim)
|
|||
overflow = 0;
|
||||
num_elts = 1;
|
||||
for (i = 0; i < num_dims; i++) {
|
||||
num_elts = bigarray_multov(num_elts, dimcopy[i], &overflow);
|
||||
num_elts = caml_ba_multov(num_elts, dimcopy[i], &overflow);
|
||||
}
|
||||
size = bigarray_multov(num_elts,
|
||||
bigarray_element_size[flags & BIGARRAY_KIND_MASK],
|
||||
&overflow);
|
||||
size = caml_ba_multov(num_elts,
|
||||
caml_ba_element_size[flags & BIGARRAY_KIND_MASK],
|
||||
&overflow);
|
||||
if (overflow) raise_out_of_memory();
|
||||
data = malloc(size);
|
||||
if (data == NULL && size != 0) raise_out_of_memory();
|
||||
flags |= BIGARRAY_MANAGED;
|
||||
}
|
||||
res = alloc_custom(&bigarray_ops,
|
||||
sizeof(struct caml_bigarray)
|
||||
res = alloc_custom(&caml_ba_ops,
|
||||
sizeof(struct caml_ba_array)
|
||||
+ (num_dims - 1) * sizeof(intnat),
|
||||
size, MAX_BIGARRAY_MEMORY);
|
||||
size, CAML_BA_MAX_MEMORY);
|
||||
b = Bigarray_val(res);
|
||||
b->data = data;
|
||||
b->num_dims = num_dims;
|
||||
|
@ -166,10 +166,10 @@ alloc_bigarray(int flags, int num_dims, void * data, intnat * dim)
|
|||
return res;
|
||||
}
|
||||
|
||||
/* Same as alloc_bigarray, but dimensions are passed as a list of
|
||||
/* Same as caml_ba_alloc, but dimensions are passed as a list of
|
||||
arguments */
|
||||
|
||||
CAMLexport value alloc_bigarray_dims(int flags, int num_dims, void * data, ...)
|
||||
CAMLexport value caml_ba_alloc_dims(int flags, int num_dims, void * data, ...)
|
||||
{
|
||||
va_list ap;
|
||||
intnat dim[MAX_NUM_DIMS];
|
||||
|
@ -179,13 +179,13 @@ CAMLexport value alloc_bigarray_dims(int flags, int num_dims, void * data, ...)
|
|||
va_start(ap, data);
|
||||
for (i = 0; i < num_dims; i++) dim[i] = va_arg(ap, intnat);
|
||||
va_end(ap);
|
||||
res = alloc_bigarray(flags, num_dims, data, dim);
|
||||
res = caml_ba_alloc(flags, num_dims, data, dim);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Allocate a bigarray from Caml */
|
||||
|
||||
CAMLprim value bigarray_create(value vkind, value vlayout, value vdim)
|
||||
CAMLprim value caml_ba_create(value vkind, value vlayout, value vdim)
|
||||
{
|
||||
intnat dim[MAX_NUM_DIMS];
|
||||
mlsize_t num_dims;
|
||||
|
@ -200,14 +200,14 @@ CAMLprim value bigarray_create(value vkind, value vlayout, value vdim)
|
|||
invalid_argument("Bigarray.create: negative dimension");
|
||||
}
|
||||
flags = Int_val(vkind) | Int_val(vlayout);
|
||||
return alloc_bigarray(flags, num_dims, NULL, dim);
|
||||
return caml_ba_alloc(flags, num_dims, NULL, dim);
|
||||
}
|
||||
|
||||
/* Given a big array and a vector of indices, check that the indices
|
||||
are within the bounds and return the offset of the corresponding
|
||||
array element in the data part of the array. */
|
||||
|
||||
static long bigarray_offset(struct caml_bigarray * b, intnat * index)
|
||||
static long caml_ba_offset(struct caml_ba_array * b, intnat * index)
|
||||
{
|
||||
intnat offset;
|
||||
int i;
|
||||
|
@ -243,7 +243,7 @@ static value copy_two_doubles(double d0, double d1)
|
|||
|
||||
/* Generic code to read from a big array */
|
||||
|
||||
value bigarray_get_N(value vb, value * vind, int nind)
|
||||
value caml_ba_get_N(value vb, value * vind, int nind)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(vb);
|
||||
intnat index[MAX_NUM_DIMS];
|
||||
|
@ -256,7 +256,7 @@ value bigarray_get_N(value vb, value * vind, int nind)
|
|||
invalid_argument("Bigarray.get: wrong number of indices");
|
||||
/* Compute offset and check bounds */
|
||||
for (i = 0; i < b->num_dims; i++) index[i] = Long_val(vind[i]);
|
||||
offset = bigarray_offset(b, index);
|
||||
offset = caml_ba_offset(b, index);
|
||||
/* Perform read */
|
||||
switch ((b->flags) & BIGARRAY_KIND_MASK) {
|
||||
default:
|
||||
|
@ -290,74 +290,74 @@ value bigarray_get_N(value vb, value * vind, int nind)
|
|||
}
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_get_1(value vb, value vind1)
|
||||
CAMLprim value caml_ba_get_1(value vb, value vind1)
|
||||
{
|
||||
return bigarray_get_N(vb, &vind1, 1);
|
||||
return caml_ba_get_N(vb, &vind1, 1);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_get_2(value vb, value vind1, value vind2)
|
||||
CAMLprim value caml_ba_get_2(value vb, value vind1, value vind2)
|
||||
{
|
||||
value vind[2];
|
||||
vind[0] = vind1; vind[1] = vind2;
|
||||
return bigarray_get_N(vb, vind, 2);
|
||||
return caml_ba_get_N(vb, vind, 2);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_get_3(value vb, value vind1, value vind2, value vind3)
|
||||
CAMLprim value caml_ba_get_3(value vb, value vind1, value vind2, value vind3)
|
||||
{
|
||||
value vind[3];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
return bigarray_get_N(vb, vind, 3);
|
||||
return caml_ba_get_N(vb, vind, 3);
|
||||
}
|
||||
|
||||
#if 0
|
||||
CAMLprim value bigarray_get_4(value vb, value vind1, value vind2,
|
||||
CAMLprim value caml_ba_get_4(value vb, value vind1, value vind2,
|
||||
value vind3, value vind4)
|
||||
{
|
||||
value vind[4];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3; vind[3] = vind4;
|
||||
return bigarray_get_N(vb, vind, 4);
|
||||
return caml_ba_get_N(vb, vind, 4);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_get_5(value vb, value vind1, value vind2,
|
||||
CAMLprim value caml_ba_get_5(value vb, value vind1, value vind2,
|
||||
value vind3, value vind4, value vind5)
|
||||
{
|
||||
value vind[5];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[3] = vind4; vind[4] = vind5;
|
||||
return bigarray_get_N(vb, vind, 5);
|
||||
return caml_ba_get_N(vb, vind, 5);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_get_6(value vb, value vind1, value vind2,
|
||||
CAMLprim value caml_ba_get_6(value vb, value vind1, value vind2,
|
||||
value vind3, value vind4, value vind5, value vind6)
|
||||
{
|
||||
value vind[6];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[3] = vind4; vind[4] = vind5; vind[5] = vind6;
|
||||
return bigarray_get_N(vb, vind, 6);
|
||||
return caml_ba_get_N(vb, vind, 6);
|
||||
}
|
||||
#endif
|
||||
|
||||
CAMLprim value bigarray_get_generic(value vb, value vind)
|
||||
CAMLprim value caml_ba_get_generic(value vb, value vind)
|
||||
{
|
||||
return bigarray_get_N(vb, &Field(vind, 0), Wosize_val(vind));
|
||||
return caml_ba_get_N(vb, &Field(vind, 0), Wosize_val(vind));
|
||||
}
|
||||
|
||||
/* Generic write to a big array */
|
||||
|
||||
static value bigarray_set_aux(value vb, value * vind, intnat nind, value newval)
|
||||
static value caml_ba_set_aux(value vb, value * vind, intnat nind, value newval)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(vb);
|
||||
intnat index[MAX_NUM_DIMS];
|
||||
int i;
|
||||
intnat offset;
|
||||
|
||||
|
||||
/* Check number of indices = number of dimensions of array
|
||||
(maybe not necessary if ML typing guarantees this) */
|
||||
if (nind != b->num_dims)
|
||||
invalid_argument("Bigarray.set: wrong number of indices");
|
||||
/* Compute offset and check bounds */
|
||||
for (i = 0; i < b->num_dims; i++) index[i] = Long_val(vind[i]);
|
||||
offset = bigarray_offset(b, index);
|
||||
offset = caml_ba_offset(b, index);
|
||||
/* Perform write */
|
||||
switch (b->flags & BIGARRAY_KIND_MASK) {
|
||||
default:
|
||||
|
@ -394,68 +394,68 @@ static value bigarray_set_aux(value vb, value * vind, intnat nind, value newval)
|
|||
return Val_unit;
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_set_1(value vb, value vind1, value newval)
|
||||
CAMLprim value caml_ba_set_1(value vb, value vind1, value newval)
|
||||
{
|
||||
return bigarray_set_aux(vb, &vind1, 1, newval);
|
||||
return caml_ba_set_aux(vb, &vind1, 1, newval);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_set_2(value vb, value vind1, value vind2, value newval)
|
||||
CAMLprim value caml_ba_set_2(value vb, value vind1, value vind2, value newval)
|
||||
{
|
||||
value vind[2];
|
||||
vind[0] = vind1; vind[1] = vind2;
|
||||
return bigarray_set_aux(vb, vind, 2, newval);
|
||||
return caml_ba_set_aux(vb, vind, 2, newval);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_set_3(value vb, value vind1, value vind2, value vind3,
|
||||
CAMLprim value caml_ba_set_3(value vb, value vind1, value vind2, value vind3,
|
||||
value newval)
|
||||
{
|
||||
value vind[3];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
return bigarray_set_aux(vb, vind, 3, newval);
|
||||
return caml_ba_set_aux(vb, vind, 3, newval);
|
||||
}
|
||||
|
||||
#if 0
|
||||
CAMLprim value bigarray_set_4(value vb, value vind1, value vind2,
|
||||
CAMLprim value caml_ba_set_4(value vb, value vind1, value vind2,
|
||||
value vind3, value vind4, value newval)
|
||||
{
|
||||
value vind[4];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3; vind[3] = vind4;
|
||||
return bigarray_set_aux(vb, vind, 4, newval);
|
||||
return caml_ba_set_aux(vb, vind, 4, newval);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_set_5(value vb, value vind1, value vind2,
|
||||
CAMLprim value caml_ba_set_5(value vb, value vind1, value vind2,
|
||||
value vind3, value vind4, value vind5, value newval)
|
||||
{
|
||||
value vind[5];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[3] = vind4; vind[4] = vind5;
|
||||
return bigarray_set_aux(vb, vind, 5, newval);
|
||||
return caml_ba_set_aux(vb, vind, 5, newval);
|
||||
}
|
||||
|
||||
CAMLprim value bigarray_set_6(value vb, value vind1, value vind2,
|
||||
CAMLprim value caml_ba_set_6(value vb, value vind1, value vind2,
|
||||
value vind3, value vind4, value vind5,
|
||||
value vind6, value newval)
|
||||
{
|
||||
value vind[6];
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[0] = vind1; vind[1] = vind2; vind[2] = vind3;
|
||||
vind[3] = vind4; vind[4] = vind5; vind[5] = vind6;
|
||||
return bigarray_set_aux(vb, vind, 6, newval);
|
||||
return caml_ba_set_aux(vb, vind, 6, newval);
|
||||
}
|
||||
|
||||
value bigarray_set_N(value vb, value * vind, int nargs)
|
||||
value caml_ba_set_N(value vb, value * vind, int nargs)
|
||||
{
|
||||
return bigarray_set_aux(vb, vind, nargs - 1, vind[nargs - 1]);
|
||||
return caml_ba_set_aux(vb, vind, nargs - 1, vind[nargs - 1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
CAMLprim value bigarray_set_generic(value vb, value vind, value newval)
|
||||
CAMLprim value caml_ba_set_generic(value vb, value vind, value newval)
|
||||
{
|
||||
return bigarray_set_aux(vb, &Field(vind, 0), Wosize_val(vind), newval);
|
||||
return caml_ba_set_aux(vb, &Field(vind, 0), Wosize_val(vind), newval);
|
||||
}
|
||||
|
||||
/* Return the number of dimensions of a big array */
|
||||
|
||||
CAMLprim value bigarray_num_dims(value vb)
|
||||
CAMLprim value caml_ba_num_dims(value vb)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(vb);
|
||||
return Val_long(b->num_dims);
|
||||
|
@ -463,7 +463,7 @@ CAMLprim value bigarray_num_dims(value vb)
|
|||
|
||||
/* Return the n-th dimension of a big array */
|
||||
|
||||
CAMLprim value bigarray_dim(value vb, value vn)
|
||||
CAMLprim value caml_ba_dim(value vb, value vn)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(vb);
|
||||
intnat n = Long_val(vn);
|
||||
|
@ -473,21 +473,21 @@ CAMLprim value bigarray_dim(value vb, value vn)
|
|||
|
||||
/* Return the kind of a big array */
|
||||
|
||||
CAMLprim value bigarray_kind(value vb)
|
||||
CAMLprim value caml_ba_kind(value vb)
|
||||
{
|
||||
return Val_int(Bigarray_val(vb)->flags & BIGARRAY_KIND_MASK);
|
||||
}
|
||||
|
||||
/* Return the layout of a big array */
|
||||
|
||||
CAMLprim value bigarray_layout(value vb)
|
||||
CAMLprim value caml_ba_layout(value vb)
|
||||
{
|
||||
return Val_int(Bigarray_val(vb)->flags & BIGARRAY_LAYOUT_MASK);
|
||||
}
|
||||
|
||||
/* Finalization of a big array */
|
||||
|
||||
static void bigarray_finalize(value v)
|
||||
static void caml_ba_finalize(value v)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(v);
|
||||
|
||||
|
@ -506,10 +506,10 @@ static void bigarray_finalize(value v)
|
|||
break;
|
||||
case BIGARRAY_MAPPED_FILE:
|
||||
if (b->proxy == NULL) {
|
||||
bigarray_unmap_file(b->data, bigarray_byte_size(b));
|
||||
caml_ba_unmap_file(b->data, caml_ba_byte_size(b));
|
||||
} else {
|
||||
if (-- b->proxy->refcount == 0) {
|
||||
bigarray_unmap_file(b->proxy->data, b->proxy->size);
|
||||
caml_ba_unmap_file(b->proxy->data, b->proxy->size);
|
||||
stat_free(b->proxy);
|
||||
}
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ static void bigarray_finalize(value v)
|
|||
|
||||
/* Comparison of two big arrays */
|
||||
|
||||
static int bigarray_compare(value v1, value v2)
|
||||
static int caml_ba_compare(value v1, value v2)
|
||||
{
|
||||
struct caml_bigarray * b1 = Bigarray_val(v1);
|
||||
struct caml_bigarray * b2 = Bigarray_val(v2);
|
||||
|
@ -535,7 +535,7 @@ static int bigarray_compare(value v1, value v2)
|
|||
if (d1 != d2) return d1 < d2 ? -1 : 1;
|
||||
}
|
||||
/* Same dimensions: compare contents lexicographically */
|
||||
num_elts = bigarray_num_elts(b1);
|
||||
num_elts = caml_ba_num_elts(b1);
|
||||
|
||||
#define DO_INTEGER_COMPARISON(type) \
|
||||
{ type * p1 = b1->data; type * p2 = b2->data; \
|
||||
|
@ -608,7 +608,7 @@ static int bigarray_compare(value v1, value v2)
|
|||
|
||||
/* Hashing of a bigarray */
|
||||
|
||||
static intnat bigarray_hash(value v)
|
||||
static intnat caml_ba_hash(value v)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(v);
|
||||
intnat num_elts, n, h;
|
||||
|
@ -677,9 +677,9 @@ static intnat bigarray_hash(value v)
|
|||
return h;
|
||||
}
|
||||
|
||||
static void bigarray_serialize_longarray(void * data,
|
||||
intnat num_elts,
|
||||
intnat min_val, intnat max_val)
|
||||
static void caml_ba_serialize_longarray(void * data,
|
||||
intnat num_elts,
|
||||
intnat min_val, intnat max_val)
|
||||
{
|
||||
#ifdef ARCH_SIXTYFOUR
|
||||
int overflow_32 = 0;
|
||||
|
@ -700,9 +700,9 @@ static void bigarray_serialize_longarray(void * data,
|
|||
#endif
|
||||
}
|
||||
|
||||
static void bigarray_serialize(value v,
|
||||
uintnat * wsize_32,
|
||||
uintnat * wsize_64)
|
||||
static void caml_ba_serialize(value v,
|
||||
uintnat * wsize_32,
|
||||
uintnat * wsize_64)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(v);
|
||||
intnat num_elts;
|
||||
|
@ -734,10 +734,10 @@ static void bigarray_serialize(value v,
|
|||
case BIGARRAY_COMPLEX64:
|
||||
serialize_block_8(b->data, num_elts * 2); break;
|
||||
case BIGARRAY_CAML_INT:
|
||||
bigarray_serialize_longarray(b->data, num_elts, -0x40000000, 0x3FFFFFFF);
|
||||
caml_ba_serialize_longarray(b->data, num_elts, -0x40000000, 0x3FFFFFFF);
|
||||
break;
|
||||
case BIGARRAY_NATIVE_INT:
|
||||
bigarray_serialize_longarray(b->data, num_elts, -0x80000000, 0x7FFFFFFF);
|
||||
caml_ba_serialize_longarray(b->data, num_elts, -0x80000000, 0x7FFFFFFF);
|
||||
break;
|
||||
}
|
||||
/* Compute required size in Caml heap. Assumes struct caml_bigarray
|
||||
|
@ -747,7 +747,7 @@ static void bigarray_serialize(value v,
|
|||
*wsize_64 = (4 + b->num_dims) * 8;
|
||||
}
|
||||
|
||||
static void bigarray_deserialize_longarray(void * dest, intnat num_elts)
|
||||
static void caml_ba_deserialize_longarray(void * dest, intnat num_elts)
|
||||
{
|
||||
int sixty = deserialize_uint_1();
|
||||
#ifdef ARCH_SIXTYFOUR
|
||||
|
@ -765,7 +765,7 @@ static void bigarray_deserialize_longarray(void * dest, intnat num_elts)
|
|||
#endif
|
||||
}
|
||||
|
||||
uintnat bigarray_deserialize(void * dst)
|
||||
uintnat caml_ba_deserialize(void * dst)
|
||||
{
|
||||
struct caml_bigarray * b = dst;
|
||||
int i, elt_size;
|
||||
|
@ -777,11 +777,11 @@ uintnat bigarray_deserialize(void * dst)
|
|||
b->proxy = NULL;
|
||||
for (i = 0; i < b->num_dims; i++) b->dim[i] = deserialize_uint_4();
|
||||
/* Compute total number of elements */
|
||||
num_elts = bigarray_num_elts(b);
|
||||
num_elts = caml_ba_num_elts(b);
|
||||
/* Determine element size in bytes */
|
||||
if ((b->flags & BIGARRAY_KIND_MASK) > BIGARRAY_COMPLEX64)
|
||||
deserialize_error("input_value: bad bigarray kind");
|
||||
elt_size = bigarray_element_size[b->flags & BIGARRAY_KIND_MASK];
|
||||
elt_size = caml_ba_element_size[b->flags & BIGARRAY_KIND_MASK];
|
||||
/* Allocate room for data */
|
||||
b->data = malloc(elt_size * num_elts);
|
||||
if (b->data == NULL)
|
||||
|
@ -806,15 +806,15 @@ uintnat bigarray_deserialize(void * dst)
|
|||
deserialize_block_8(b->data, num_elts * 2); break;
|
||||
case BIGARRAY_CAML_INT:
|
||||
case BIGARRAY_NATIVE_INT:
|
||||
bigarray_deserialize_longarray(b->data, num_elts); break;
|
||||
caml_ba_deserialize_longarray(b->data, num_elts); break;
|
||||
}
|
||||
return sizeof(struct caml_bigarray) + (b->num_dims - 1) * sizeof(intnat);
|
||||
}
|
||||
|
||||
/* Create / update proxy to indicate that b2 is a sub-array of b1 */
|
||||
|
||||
static void bigarray_update_proxy(struct caml_bigarray * b1,
|
||||
struct caml_bigarray * b2)
|
||||
static void caml_ba_update_proxy(struct caml_bigarray * b1,
|
||||
struct caml_bigarray * b2)
|
||||
{
|
||||
struct caml_bigarray_proxy * proxy;
|
||||
/* Nothing to do for un-managed arrays */
|
||||
|
@ -830,7 +830,7 @@ static void bigarray_update_proxy(struct caml_bigarray * b1,
|
|||
proxy->refcount = 2; /* original array + sub array */
|
||||
proxy->data = b1->data;
|
||||
proxy->size =
|
||||
b1->flags & BIGARRAY_MAPPED_FILE ? bigarray_byte_size(b1) : 0;
|
||||
b1->flags & BIGARRAY_MAPPED_FILE ? caml_ba_byte_size(b1) : 0;
|
||||
b1->proxy = proxy;
|
||||
b2->proxy = proxy;
|
||||
}
|
||||
|
@ -838,7 +838,7 @@ static void bigarray_update_proxy(struct caml_bigarray * b1,
|
|||
|
||||
/* Slicing */
|
||||
|
||||
CAMLprim value bigarray_slice(value vb, value vind)
|
||||
CAMLprim value caml_ba_slice(value vb, value vind)
|
||||
{
|
||||
CAMLparam2 (vb, vind);
|
||||
#define b ((struct caml_bigarray *) Bigarray_val(vb))
|
||||
|
@ -858,23 +858,23 @@ CAMLprim value bigarray_slice(value vb, value vind)
|
|||
/* We slice from the left */
|
||||
for (i = 0; i < num_inds; i++) index[i] = Long_val(Field(vind, i));
|
||||
for (/*nothing*/; i < b->num_dims; i++) index[i] = 0;
|
||||
offset = bigarray_offset(b, index);
|
||||
offset = caml_ba_offset(b, index);
|
||||
sub_dims = b->dim + num_inds;
|
||||
} else {
|
||||
/* We slice from the right */
|
||||
for (i = 0; i < num_inds; i++)
|
||||
index[b->num_dims - num_inds + i] = Long_val(Field(vind, i));
|
||||
for (i = 0; i < b->num_dims - num_inds; i++) index[i] = 1;
|
||||
offset = bigarray_offset(b, index);
|
||||
offset = caml_ba_offset(b, index);
|
||||
sub_dims = b->dim;
|
||||
}
|
||||
sub_data =
|
||||
(char *) b->data +
|
||||
offset * bigarray_element_size[b->flags & BIGARRAY_KIND_MASK];
|
||||
offset * caml_ba_element_size[b->flags & BIGARRAY_KIND_MASK];
|
||||
/* Allocate a Caml bigarray to hold the result */
|
||||
res = alloc_bigarray(b->flags, b->num_dims - num_inds, sub_data, sub_dims);
|
||||
/* Create or update proxy in case of managed bigarray */
|
||||
bigarray_update_proxy(b, Bigarray_val(res));
|
||||
caml_ba_update_proxy(b, Bigarray_val(res));
|
||||
/* Return result */
|
||||
CAMLreturn (res);
|
||||
|
||||
|
@ -883,7 +883,7 @@ CAMLprim value bigarray_slice(value vb, value vind)
|
|||
|
||||
/* Extracting a sub-array of same number of dimensions */
|
||||
|
||||
CAMLprim value bigarray_sub(value vb, value vofs, value vlen)
|
||||
CAMLprim value caml_ba_sub(value vb, value vofs, value vlen)
|
||||
{
|
||||
CAMLparam3 (vb, vofs, vlen);
|
||||
CAMLlocal1 (res);
|
||||
|
@ -911,13 +911,13 @@ CAMLprim value bigarray_sub(value vb, value vofs, value vlen)
|
|||
invalid_argument("Bigarray.sub: bad sub-array");
|
||||
sub_data =
|
||||
(char *) b->data +
|
||||
ofs * mul * bigarray_element_size[b->flags & BIGARRAY_KIND_MASK];
|
||||
ofs * mul * caml_ba_element_size[b->flags & BIGARRAY_KIND_MASK];
|
||||
/* Allocate a Caml bigarray to hold the result */
|
||||
res = alloc_bigarray(b->flags, b->num_dims, sub_data, b->dim);
|
||||
/* Doctor the changed dimension */
|
||||
Bigarray_val(res)->dim[changed_dim] = len;
|
||||
/* Create or update proxy in case of managed bigarray */
|
||||
bigarray_update_proxy(b, Bigarray_val(res));
|
||||
caml_ba_update_proxy(b, Bigarray_val(res));
|
||||
/* Return result */
|
||||
CAMLreturn (res);
|
||||
|
||||
|
@ -926,7 +926,7 @@ CAMLprim value bigarray_sub(value vb, value vofs, value vlen)
|
|||
|
||||
/* Copying a big array into another one */
|
||||
|
||||
CAMLprim value bigarray_blit(value vsrc, value vdst)
|
||||
CAMLprim value caml_ba_blit(value vsrc, value vdst)
|
||||
{
|
||||
struct caml_bigarray * src = Bigarray_val(vsrc);
|
||||
struct caml_bigarray * dst = Bigarray_val(vdst);
|
||||
|
@ -939,8 +939,8 @@ CAMLprim value bigarray_blit(value vsrc, value vdst)
|
|||
if (src->dim[i] != dst->dim[i]) goto blit_error;
|
||||
/* Compute number of bytes in array data */
|
||||
num_bytes =
|
||||
bigarray_num_elts(src)
|
||||
* bigarray_element_size[src->flags & BIGARRAY_KIND_MASK];
|
||||
caml_ba_num_elts(src)
|
||||
* caml_ba_element_size[src->flags & BIGARRAY_KIND_MASK];
|
||||
/* Do the copying */
|
||||
memmove (dst->data, src->data, num_bytes);
|
||||
return Val_unit;
|
||||
|
@ -951,10 +951,10 @@ CAMLprim value bigarray_blit(value vsrc, value vdst)
|
|||
|
||||
/* Filling a big array with a given value */
|
||||
|
||||
CAMLprim value bigarray_fill(value vb, value vinit)
|
||||
CAMLprim value caml_ba_fill(value vb, value vinit)
|
||||
{
|
||||
struct caml_bigarray * b = Bigarray_val(vb);
|
||||
intnat num_elts = bigarray_num_elts(b);
|
||||
intnat num_elts = caml_ba_num_elts(b);
|
||||
|
||||
switch (b->flags & BIGARRAY_KIND_MASK) {
|
||||
default:
|
||||
|
@ -978,7 +978,7 @@ CAMLprim value bigarray_fill(value vb, value vinit)
|
|||
for (p = b->data; num_elts > 0; p++, num_elts--) *p = init;
|
||||
break;
|
||||
}
|
||||
case BIGARRAY_SINT16:
|
||||
case BIGARRAY_SINT16:
|
||||
case BIGARRAY_UINT16: {
|
||||
int init = Int_val(vinit);
|
||||
int16 * p;
|
||||
|
@ -1030,7 +1030,7 @@ CAMLprim value bigarray_fill(value vb, value vinit)
|
|||
/* Reshape an array: change dimensions and number of dimensions, preserving
|
||||
array contents */
|
||||
|
||||
CAMLprim value bigarray_reshape(value vb, value vdim)
|
||||
CAMLprim value caml_ba_reshape(value vb, value vdim)
|
||||
{
|
||||
CAMLparam2 (vb, vdim);
|
||||
CAMLlocal1 (res);
|
||||
|
@ -1051,12 +1051,12 @@ CAMLprim value bigarray_reshape(value vb, value vdim)
|
|||
num_elts *= dim[i];
|
||||
}
|
||||
/* Check that sizes agree */
|
||||
if (num_elts != bigarray_num_elts(b))
|
||||
if (num_elts != caml_ba_num_elts(b))
|
||||
invalid_argument("Bigarray.reshape: size mismatch");
|
||||
/* Create bigarray with same data and new dimensions */
|
||||
res = alloc_bigarray(b->flags, num_dims, b->data, dim);
|
||||
/* Create or update proxy in case of managed bigarray */
|
||||
bigarray_update_proxy(b, Bigarray_val(res));
|
||||
caml_ba_update_proxy(b, Bigarray_val(res));
|
||||
/* Return result */
|
||||
CAMLreturn (res);
|
||||
|
||||
|
@ -1065,8 +1065,8 @@ CAMLprim value bigarray_reshape(value vb, value vdim)
|
|||
|
||||
/* Initialization */
|
||||
|
||||
CAMLprim value bigarray_init(value unit)
|
||||
CAMLprim value caml_ba_init(value unit)
|
||||
{
|
||||
register_custom_operations(&bigarray_ops);
|
||||
register_custom_operations(&caml_ba_ops);
|
||||
return Val_unit;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "mlvalues.h"
|
||||
#include "sys.h"
|
||||
|
||||
extern int bigarray_element_size[]; /* from bigarray_stubs.c */
|
||||
extern int caml_ba_element_size[]; /* from bigarray_stubs.c */
|
||||
|
||||
#ifdef HAS_UNISTD
|
||||
#include <unistd.h>
|
||||
|
@ -37,8 +37,8 @@ extern int bigarray_element_size[]; /* from bigarray_stubs.c */
|
|||
#define MAP_FAILED ((void *) -1)
|
||||
#endif
|
||||
|
||||
CAMLprim value bigarray_map_file(value vfd, value vkind, value vlayout,
|
||||
value vshared, value vdim)
|
||||
CAMLprim value caml_ba_map_file(value vfd, value vkind, value vlayout,
|
||||
value vshared, value vdim)
|
||||
{
|
||||
int fd, flags, major_dim, shared;
|
||||
intnat num_dims, i;
|
||||
|
@ -99,8 +99,8 @@ CAMLprim value bigarray_map_file(value vfd, value vkind, value vlayout,
|
|||
|
||||
#else
|
||||
|
||||
value bigarray_map_file(value vfd, value vkind, value vlayout,
|
||||
value vshared, value vdim)
|
||||
value caml_ba_map_file(value vfd, value vkind, value vlayout,
|
||||
value vshared, value vdim)
|
||||
{
|
||||
invalid_argument("Bigarray.map_file: not supported");
|
||||
return Val_unit;
|
||||
|
@ -109,7 +109,7 @@ value bigarray_map_file(value vfd, value vkind, value vlayout,
|
|||
#endif
|
||||
|
||||
|
||||
void bigarray_unmap_file(void * addr, uintnat len)
|
||||
void caml_ba_unmap_file(void * addr, uintnat len)
|
||||
{
|
||||
#if defined(HAS_MMAP)
|
||||
munmap(addr, len);
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
|
||||
/* TODO: handle mappings larger than 2^32 bytes on Win64 */
|
||||
|
||||
extern int bigarray_element_size[]; /* from bigarray_stubs.c */
|
||||
extern int caml_ba_element_size[]; /* from bigarray_stubs.c */
|
||||
|
||||
static void bigarray_sys_error(void);
|
||||
static void caml_ba_sys_error(void);
|
||||
|
||||
CAMLprim value bigarray_map_file(value vfd, value vkind, value vlayout,
|
||||
value vshared, value vdim)
|
||||
CAMLprim value caml_ba_map_file(value vfd, value vkind, value vlayout,
|
||||
value vshared, value vdim)
|
||||
{
|
||||
HANDLE fd, fmap;
|
||||
int flags, major_dim, mode, perm;
|
||||
|
@ -95,16 +95,16 @@ CAMLprim value bigarray_map_file(value vfd, value vkind, value vlayout,
|
|||
return alloc_bigarray(flags | BIGARRAY_MAPPED_FILE, num_dims, addr, dim);
|
||||
}
|
||||
|
||||
void bigarray_unmap_file(void * addr, uintnat len)
|
||||
void caml_ba_unmap_file(void * addr, uintnat len)
|
||||
{
|
||||
UnmapViewOfFile(addr);
|
||||
}
|
||||
|
||||
static void bigarray_sys_error(void)
|
||||
static void caml_ba_sys_error(void)
|
||||
{
|
||||
char buffer[512];
|
||||
DWORD errnum;
|
||||
|
||||
|
||||
errnum = GetLastError();
|
||||
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
|
|
Loading…
Reference in New Issue