bugGNU Octave - Bugs: bug #48749, size and dimensionality of java...

 
 

bug #48749: size and dimensionality of java arrays

Submitted by:  Ernst Reissner <ernstreissner>
Submitted on:  Wed 10 Aug 2016 02:05:07 PM UTC  
 
Category: Octave FunctionSeverity: 1 - Wish
Priority: 3 - LowItem Group: Matlab Compatibility
Status: Need InfoAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 19 Aug 2016 10:38:32 AM UTC, comment #7:

in case of confirmation: delivered a fix.

(file #38274)

Ernst Reissner <ernstreissner>
Fri 19 Aug 2016 09:43:10 AM UTC, comment #6:

Hi Mike,
what kind of information do you need to confirm or reject this bugreport?

Ernst Reissner <ernstreissner>
Fri 12 Aug 2016 10:53:10 PM UTC, comment #5:

By the way,
n = numel(A) is equivalent to prod(size(A))
is not appropriate for Java arrays,
because they are usually ragged: the entries of Object[][]
in general do not have the same length.
Thus numel cannot be determined by product but by recursively summing up.

That may be the reason why matlab defines size(arr) for java arrays arr as it does.

Ernst Reissner <ernstreissner>
Fri 12 Aug 2016 09:16:51 PM UTC, comment #4:

Hi Mike,
I overread a comment of you:
'To be compatible, the size of a Java array should always be Nx1 reflecting the length of the outermost array. The number of dimensions (ndims) should always be 2. It would be nice to confirm whether numel agrees with size for 2 or higher-dimensional Java arrays.'

Hm, according to matlab docs
http://de.mathworks.com/help/matlab/ref/numel.html,
n = numel(A) is equivalent to prod(size(A)).
So size(.) determines numel(.) not the other way round.
In the docs, nothing is mentioned on java or not.
This is not necessary,
because size makes the distinction.
That's the way, also Octave shall implement numel.

So, I think there is no futher info required
and I would vote (if i could) for confirming the bug.

Ernst Reissner <ernstreissner>
Thu 11 Aug 2016 06:49:01 PM UTC, comment #3:

To fix this for Matlab compatibility, it would be useful to know what Matlab's numel(arr) returns on an N-dimensional Java array object.

Mike Miller <mtmiller>
Project Administrator
Thu 11 Aug 2016 02:31:30 PM UTC, comment #2:

Hi Mike,
so you can change the status from need info to confirmed?
I would fix easily.

Ernst Reissner <ernstreissner>
Wed 10 Aug 2016 02:39:33 PM UTC, comment #1:

That looks right according to my reading also.

The current Octave behavior is nice, but not fully Matlab compatible. The higher dimensions in the returned size are just the lengths of the first nested arrays.

To be compatible, the size of a Java array should always be Nx1 reflecting the length of the outermost array. The number of dimensions (ndims) should always be 2. It would be nice to confirm whether numel agrees with size for 2 or higher-dimensional Java arrays.

Mike Miller <mtmiller>
Project Administrator
Wed 10 Aug 2016 02:05:07 PM UTC, original submission:

In

http://de.mathworks.com/help/matlab/ref/size.html

we read:

For a Java array, size returns the length of the Java array as the number of rows. The number of columns is always 1. For a Java array of arrays, the result describes only the top level array.

In fact, in octave,

octave:22> arr=javaArray('java.lang.Object',5)
arr =

<Java object: java.lang.Object[]>

octave:23> size(arr)
ans =

5 1

Which is correct: 5 is the number of rows and 1 the number of columns.

But lets go on:

octave:24> arr=javaArray('java.lang.Object',5,4)
arr =

<Java object: java.lang.Object[][]>
octave:25> size(arr)
ans =

5 4

which is not correct.

The result should still be 5 1.

Ernst Reissner <ernstreissner>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #38274:  patchBug48749.patch added by ernstreissner (5KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by ernstreissner (Submitted the item)
  • -unavailable- added by ernstreissner
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 19 Aug 2016 10:38:32 AM UTCernstreissnerAttached File-=>Added patchBug48749.patch, #38274
    Wed 10 Aug 2016 02:39:33 PM UTCmtmillerCategoryNone=>Octave Function
      Severity3 - Normal=>1 - Wish
      Priority5 - Normal=>3 - Low
      Item GroupNone=>Matlab Compatibility
      StatusNone=>Need Info
      Summarysize of java arrays =>size and dimensionality of java arrays
    Wed 10 Aug 2016 02:05:07 PM UTCernstreissnerCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1