bugGNU Octave - Bugs: bug #42487, issymmetric incompatible with...


bug #42487: issymmetric incompatible with Matlab

Submitted by:  CarnĂ« Draug <carandraug>
Submitted on:  Mon 02 Jun 2014 11:03:07 AM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating 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)

Fri 21 Dec 2018 10:48:44 PM UTC, comment #8: 

The next release of Octave, version 5.0, has "skew" and "nonskew" arguments as well as support for a tolerance field which is unique to Octave.  I added support for logical matrices and a tolerance in this cset (https://hg.savannah.gnu.org/hgweb/octave/rev/0d755097d73f).

Marking as fixed and closing report.

Rik <rik5>
Project Administrator
Thu 15 Dec 2016 04:27:26 PM UTC, comment #7: 

This issue is still present in Octave 4.2.0.

The Octave version of issymmetric.m is still expecting a numerical value as second parameter, as opposed to Matlab.

There is a PATCH proposed in comment #6.

Hartmut <hardy>
Tue 23 Sep 2014 07:18:59 PM UTC, comment #6: 

First, I've figured out that the option in Matlab is called "nonskew" and not "noskew".

Seconds, Matlab issymmetric function doesn't support logical inputs. It returns

Undefined function 'issymmetric' for input arguments of type 'logical'.

I've attached a suggestion for issymmetric which kept the backward compatibility for numeric tolerance input from Octave Version 3.8.2 and is compatible with Matlab char based input arguments 'skew' and 'nonskew'.

(file #32174)

Markus Bergholz <markuman>
Sun 21 Sep 2014 11:07:52 AM UTC, comment #5: 

You're right again. It depends on the fact that logical matrices returned 0 when tested with issymmetric, much like what happens for ishermitian, where instead of

retval = (isnumeric (A) || islogical (A)) && issquare (A);

one has

retval = isnumeric (A) && issquare (A);

I added islogical in order to be consistent with istril, istriu, isbanded and bandwidth, but I didn't notice the problem with ishermitian at that time.

I think that both ishermitian and issymmetric should have the same behaviour. They could return false either when the matrix is boolean or when the matix is boolena AND a tolerance parameter is specified.

Any suggestions or ideas?

Massimiliano Fasi <mfasi>
Sun 21 Sep 2014 08:44:24 AM UTC, comment #4: 

Now I can apply and confirm the results.

One last failure whitch works in 3.8.2 but no more with your patch

with your patch

    >> issymmetric(logical(eye(2)),1)
    error: xnorm: wrong type argument 'bool matrix'
    error: called from:
    error:   /home/markus/git/octave/scripts/linear-algebra/issymmetric.m at line 71, column 16

octave 3.8.2

    octave:2> issymmetric (logical (eye (2)),1)
    ans =                    0

Because this syntax should be matlab incompatible, I don't know if this should be fixed (backward compatible) or if it's just nice to have (matlab compatiblity has a higher priority?).

Markus Bergholz <markuman>
Sun 21 Sep 2014 08:18:09 AM UTC, comment #3: 

Hello Markus,

you were right, the patch didn't work since the source had changed in the meanwhile. I have modified the changeset and attached the new version, thank you for your feedback.

I don't have matlab 2014 to run the tests you suggested, but I asked to run some on IRC when I published the patch and, as far as I remember, it worked fine. Thus, I suspect that the behaviour was changed after 3.8.2 because there was no issymmetric function in Matlab before.

I tried the patched version of issymmetric against the examples from the website, and they seem to work fine for me. Can you detail the issue a bit?

(file #32154)

Massimiliano Fasi <mfasi>
Sun 21 Sep 2014 07:33:09 AM UTC, comment #2: 

I cannot apply this patch. I did it manually, but some of the asserts are failing. Furthermore, the Matlab example results from their website doesn't match to the results from this patch (or with any other Version of octave).

Furthermore, it seems like this patch is partly used already, because the issymmetric version in 3.8.2 differs from the current hg version.

Octave 3.8.2

    octave:1> issymmetric (logical (eye (2)))
    ans =                    0

Current hg version

    >> issymmetric (logical (eye (2)))
    ans =                    1

What are the results in Matlab?

    %!assert (issymmetric (1))
    %!assert (issymmetric (1), 'noskew')
    %!assert (! issymmetric ([1, 2]))
    %!assert (issymmetric ([]))
    %!assert (issymmetric ([]), 'noskew')
    %!assert (issymmetric ([1, 2; 2, 1]))
    %!assert (! (issymmetric ("test")))
    %!assert (issymmetric ([1, 2.1; 2, 1.1], 0.2))
    %!assert (issymmetric ([1, 2i; 2i, 1]))
    %!assert (issymmetric ([1, 2i; 2i, 1], 'noskew'))
    %!assert (! (issymmetric ("t")))
    %!assert (! (issymmetric (["te"; "et"])))
    %!assert (issymmetric (speye (100000)))
    %!assert (issymmetric (speye (100000), 'noskew'))
    %!assert (issymmetric (logical (eye (2))))
    %!assert (issymmetric (logical (eye (2)), 'skew'))


    %! a = [0, 2; -2, 0];
    %! assert (issymmetric (a, 'skew'))
    %! assert (! issymmetric (a, 'noskew'))


    %! s.a = 1;
    %! assert (! issymmetric (s));


    %!error issymmetric ([1, 2; 2, 1], 0, 0)
    %!error issymmetric ()

Markus Bergholz <markuman>
Tue 08 Jul 2014 12:30:29 PM UTC, comment #1: 

As for Octave the second parameter is a number while for Matlab is a string, I think it's possible to add the feature maintaining compatibility with older versions of Octave. I submitted a patch that implement my idea.

(file #31690)

Massimiliano Fasi <mfasi>
Mon 02 Jun 2014 11:03:07 AM UTC, original submission:  

Seems like Matlab has added the issymmetric function to their repertoire with version 2014a (according to http://www.dynare.org/DynareWiki/MatlabVersionsCompatibility ). hg log shows that our version has been around since 2002 with cset 8cb8eff3f44c

Their implementation takes a different second input argument.

Carnë Draug <carandraug>
Project Member


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

Attach Files:

Attached Files
file #32174:  bug_42487_3.patch added by markuman (5KiB - text/x-patch)
file #32154:  bugfix_42487.patch added by mfasi (4KiB - text/x-diff)
file #31690:  bugfix_42487.patch added by mfasi (4KiB - text/x-diff)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by markuman (Posted a comment)
  • -email is unavailable- added by mfasi (Updated the item)
  • -email is unavailable- added by carandraug (Submitted the item)

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

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-21 rik5 StatusNone => Fixed
        Open/ClosedOpen => Closed
    2014-09-23 markuman Attached File- => Added bug_42487_3.patch, #32174
    2014-09-21 mfasi Attached File- => Added bugfix_42487.patch, #32154
    2014-07-08 mfasi Attached File- => Added bugfix_42487.patch, #31690

    Back to the top

    Powered by Savane 3.5