[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for cla
From: |
Kai Torben Ohlhus |
Subject: |
[Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size |
Date: |
Tue, 2 Oct 2018 19:00:51 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 |
Update of bug #51308 (project octave):
Status: Confirmed => Patch Submitted
Assigned to: None => siko1056
Release: dev => 4.4.1
_______________________________________________________
Follow-up Comment #1:
After a while, I hope to come up with a satisfying solution:
The root of a series of issues (bug #44498 "isvector", bug #43925 "isscalar",
and this one) is, that Matlab totally relies on "size" to determine the shape
of an object, c.f. the documentation of R2018a:
isscalar(A) returns logical 1 (true) if size(A) returns [1 1], and logical 0
(false) otherwise.
isrow (V) returns logical 1 (true) if size(V) returns [1 n] with a
nonnegative integer value n, and logical 0 (false) otherwise.
iscolumn(V) returns logical 1 (true) if size(V) returns [n 1] with a
nonnegative integer value n, and logical 0 (false) otherwise.
isvector(A) returns logical 1 (true) if size(A) returns [1 n] or [n 1] with a
nonnegative integer value n, and logical 0 (false) otherwise.
ismatrix(V) returns logical 1 (true) if size(V) returns [m n] with nonnegative
integer values m and n, and logical 0 (false) otherwise.
Currently, Octave has a mixture of "numel"- and "dims"-calls (the last one not
Matlab compatible, not overloadable) to address this functionality.
The proposed patch (file #45128) took advantage of the patches of bug #43925
and suggests the following behavior:
rows (@var{a}) Return the number of rows of @var{a}. This is equivalent
to @code{size (@var{a}, 1)}.
columns (@var{a}) Return the number of columns of @var{a}. This is equivalent
to @code{size (@var{a}, 2)}.
isscalar (@var{x}) Return true if @var{x} is a scalar, i.e., @code{size
(@var{x})} returns @code{[1 1]}.
isrow (@var{x}) Return true if @var{x} is a row vector, i.e., @code{size
(@var{x})} returns @code{[1 N]} with non-negative N.
iscolumn (@var{x}) Return true if @var{x} is a column vector, i.e., @code{size
(@var{x})} returns @code{[N 1]} with non-negative N.
isvector (@var{x}) Return true if @var{x} is a vector. A vector is a 2-D
array where one of the dimensions is equal to 1. As a consequence a 1x1
array, or scalar, is also a vector.
ismatrix (@var{a}) Return true if @var{a} is a 2-D array, i.e., @code{size
(@var{a})} returns @code{[M N]} with non-negative M and N.
issquare (@var{x}) Return true if @var{x} is a square matrix, i.e., @code{size
(@var{x})} returns
@code{[N N]} with non-negative N.
The patch resolves two bugs and 10 XFails. The only remaining XFail is
"ndims", because it has an additional predicate "chop trailing singleton
dimensions". I am not sure if "size" does this automatically for me,
especially, if a user is in charge of what is returned ;-) Worst-case: one
has to manually post process the output of size.
The patch does not change functionality, it simply uses another function for
doing the job, i.e. "size", which is overloadable by user-defined classes.
And the documentation for these functions becomes more precise.
Thus I want to apply it to stable in a few days.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?51308>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size, Kai Torben Ohlhus, 2018/10/02
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size, Kai Torben Ohlhus, 2018/10/02
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size, Kai Torben Ohlhus, 2018/10/02
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size,
Kai Torben Ohlhus <=
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size, Mike Miller, 2018/10/02
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size, Kai Torben Ohlhus, 2018/10/03
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size, John W. Eaton, 2018/10/03
- [Octave-bug-tracker] [bug #51308] ndims, rows, columns incorrect for classes that only overload size, Kai Torben Ohlhus, 2018/10/04