[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #32901] "diag" returns empty matrix where matl

From: anonymous
Subject: [Octave-bug-tracker] [bug #32901] "diag" returns empty matrix where matlab's diag returns [0]
Date: Mon, 28 Mar 2011 22:42:13 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv: Gecko/20110303 SUSE/3.6.15-0.2.1 Firefox/3.6.15

Follow-up Comment #4, bug #32901 (project octave):

> What is the Matlab behavior for the following...
Matlab says:

>> diag(ones(k,0),2)
ans =

for all k=0,2,3,4,5,..., and

>> diag(ones(1,0),2)
ans =
     0     0
     0     0

I don't think this is inconsistent.
Matlab sees ones(k,0) as a _matrix_, not as a _vector_,
so in this case, it really tries to extract the second super-diagonal and
hence yields [].
On the other hand, ones(1,0) has only one singleton
dimension (0 being non-singleton), so it's a vector by definition, and diag
switches to the create-a-matrix-mode.

> we are open-source numerical computing software which is
> generally compatible with Matlab, but we don't follow
> them slavishly where it doesn't appear to make sense
I see.  I can only speak from a pure user's viewpoint here.  At the moment,
this incompatibility forces me to include another
if-exists(OCTAVE_VERSION)-switch in my code.  But finally, it's up to the
developers to balance the reasons.


Reply to this item at:


  Nachricht geschickt von/durch Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]