Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bigarray.Array3.of_array broken #3793

Closed
vicuna opened this issue Sep 19, 2005 · 1 comment
Closed

Bigarray.Array3.of_array broken #3793

vicuna opened this issue Sep 19, 2005 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Sep 19, 2005

Original bug ID: 3793
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Reed Wilson
Version: 3.08.3
OS: Windows XP
Submission from: pool0052.cvx20-bradley.dialup.earthlink.net (209.179.250.52)

I noticed a few minutes ago that Bigarray.Array3.of_array is not working. The
values in the last dimension are all the same. Looking at bigarray.ml, I find:

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
let dim3 = if dim2 = 0 then 0 else Array.length data.(0).(0) in
let ba = create kind layout dim1 dim2 dim3 in
let ofs = if (Obj.magic layout : 'a layout) = c_layout then 0 else 1 in
for i = 0 to dim1 - 1 do
let row = data.(i) in
if Array.length row <> dim2 then
invalid_arg("Bigarray.Array3.of_array: non-cubic data");
for j = 0 to dim2 - 1 do
let col = row.(j) in
if Array.length col <> dim3 then
invalid_arg("Bigarray.Array3.of_array: non-cubic data");
for k = 0 to dim3 - 1 do
set ba (i + ofs) (j + ofs) (k + ofs) col.(j)
done
done
done;
ba

I'm quite sure that the assignment in the center should be:
set ba (i + ofs) (j + ofs) (k + ofs) col.(k)

The current assignment is ba.{i,j,k} <- data.(i).(j).(j), which doesn't make a
lot of sense.

@vicuna
Copy link
Author

vicuna commented Sep 24, 2005

Comment author: administrator

Fixed in main branch, 2005-09-24, XL

@vicuna vicuna closed this as completed Sep 24, 2005
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant