Ajout Genarray.dims

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4834 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2002-05-25 08:34:05 +00:00
parent f8e9e42214
commit a21fa9d655
2 changed files with 9 additions and 0 deletions

View File

@ -72,6 +72,11 @@ module Genarray = struct
= "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"
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"

View File

@ -234,6 +234,10 @@ module Genarray :
external num_dims: ('a, 'b, 'c) t -> int = "bigarray_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"
(** [Genarray.nth_dim a n] returns the [n]-th dimension of the
big array [a]. The first dimension corresponds to [n = 0];