|Subject:||Re: Permuted matrix is not a matrix?|
|Date:||Sun, 28 Aug 2016 08:35:28 +0200|
|User-agent:||Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0|
Le 13/08/2016 à 16:45, Maynard Wright a écrit :
On Saturday, August 13, 2016 06:54:28 AM James Sherman Jr. wrote:
@Maynard : yes, ismatrix has been modified in Octave 4.x for the sake of Matlab compatibilty.
What you observe is the result of the old ismatrix function, which was not Matlab-compatible.
ismatrix (A) now returns 0 in Octave 4.x (and in Matlab) since the result of A=permute([1,2],[1 3 2]); is a 3-dimensional array, as observed earlier by James.
@José : to answer your initial question, there is indeed an "inconsistency", but it is only an inconsistent choice of type and function names (not an actual bug).
To understand why it is so, you have to look at the history of Octave and Matlab... I will try to explain, please forgive me if I fail at being clear...
First, you have to know that Octave aims at being compatible with Matlab, but also has specific features that do not exist in Matlab. Sometimes, this becomes is little messy.
One example of such an Octave-specific feature is the notion of "type" that is returned by typeinfo. This notion does not exist in Matlab, and neither does the associated typeinfo function.
ismatrix has been present in Octave since around 2002, and in the case of your array A=permute([1,2],[1 3 2]); the result was 1 in Octave 3.8.x and earlier, as reported by Maynard (which was consistent with the type returned by typeinfo).
At this time, ismatrix was an Octave-specific function (there was no ismatrix function in Matlab). But at some point around 2010, TMW also introduced an "ismatrix" function in Matlab, which was not compatible with Octave's. Then, Octave's ismatrix function was modified to be compatible with Matlab's (if you want to know everything, here is the corresponding changeset: http://hg.savannah.gnu.org/hgweb/octave/rev/00e31f316a3a) but the result of typeinfo was not modified.
This is why you now have a function "ismatrix" that returns 1 for 2D arrays only (i.e., arrays for which size (A) is of the form [m n]) while typeinfo returns "matrix" when the underlying C++ object is of class octave_matrix.
I agree that this is annoying, but I don't think it is likely to change any time soon...
The lightest option would be to improve the documentation of ismatrix and typeinfo to warn users about this, I think.
|[Prev in Thread]||Current Thread||[Next in Thread]|