Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000217ILNumerics[All Projects] Feature Requestspublic2015-03-11 12:012015-03-11 14:00
Reporterho 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Summary0000217: Change ".Length" property to exclude empty dimensions
DescriptionILArray<T>.Length currently gives the length of the longest dimension. This is specified (http://ilnumerics.net/apidoc/?topic=html/P_ILNumerics_ILBaseArray_Length.htm [^]) and working as expected in version 4.7.

If there is any empty dimension in the array, Length should give 0.

Please comment below and vote for or against that change. Thanks!

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000215)
ho (administrator)
2015-03-11 12:22

Edit: redefined the change request definition
(0000216)
arnaud (reporter)
2015-03-11 13:07

highly in favor of this - the current behavior is not intuitive. in which use cases it makes sense that length(zeros(1, 0)) == 1 or length(zeros(0)) == 1? at the same time one would think that if a given array returns true on isempty, it would also return 0 on length. it would also be consistent with Matlab behavior.
(0000217)
b.kurtan (reporter)
2015-03-11 13:30

I agree with it, it is not intuitive. But why zeros(0) is size [0,1]? Which should be [0,0] in my opinion. I'd go with Matlab's behavior on Length.
(0000218)
ho (administrator)
2015-03-11 14:00

This change would potentially break existing implementations which rely on the current implementation. It does not make the change impossible but somewhat less favorable.

Let me try to get closer to a potential re-definition. What about that:

A.Length gives the number of elements in the first dimension of A with an individual length of 'max(size(A))'.

Since there are no element in empty arrays it would return 0 in the above mentioned cases.

Btw: we do not create square matrices on zeros(0) or ones(0). Instead we encourage the user to be as specific as possible to prevent from ambiguities. zero(0) would create a 2nd dimension implicitly. Implicitly created dimension are of length 1. Therefore: length(zeros(0),1) == 1.

- Issue History
Date Modified Username Field Change
2015-03-11 12:01 ho New Issue
2015-03-11 12:21 ho Description Updated View Revisions
2015-03-11 12:22 ho Note Added: 0000215
2015-03-11 13:07 arnaud Note Added: 0000216
2015-03-11 13:30 b.kurtan Note Added: 0000217
2015-03-11 14:00 ho Note Added: 0000218


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker