bugGNU Octave - Bugs: bug #41346, spconvert() with complex matrices

 
 

bug #41346: spconvert() with complex matrices

Submitter:  tmac
Submitted:  Sat 25 Jan 2014 10:41:50 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 27 Jan 2014 05:06:04 PM UTC, comment #5: 

I think the best solution is the one already implemented--to have PETSc use the documented interface.  Octave tries to match Matlab's documented API, but not its undocumented one.  It's usually a bad idea to rely on the undocumented interface since it won't necessarily work with Octave, and Matlab itself could change it at any time as well.

Rik <rik5>
Group administrator
Mon 27 Jan 2014 03:04:02 PM UTC, comment #4: 

If the fix is indeed merely deleting a few characters from one line, then I would say it's worth applying.  Most users don't program by following the spec/documentation, but by iterating until the code "works".  If they try to run existing MATLAB code in Octave and it fails, their first impulse will be to blame Octave.

Jed Brown <jedbrown>
Mon 27 Jan 2014 02:46:12 PM UTC, comment #3: 

Hi,

Now that the behaviour in PETSc has been modified I think
the motivation of the OP on this issue is gone, but the
question regarding Octave remains open, should we copy the
undocumented Matlab behaviour or not?

I'll wait one more day for comments, then, if no-one cares
I'll just close this report marking it as "Won't fix"

Thanks,
c.

Carlo de Falco <cdf>
Group Member
Sun 26 Jan 2014 06:27:48 PM UTC, comment #2: 

Thanks, everyone.  I have updated PETSc to use the documented interface.

Jed Brown <jedbrown>
Sat 25 Jan 2014 10:53:40 AM UTC, comment #1: 

Hi,

Thanks for posting this report.
As I noted in my reply on the mailing list,
this issue is due to an error on the part of
PETSc which exploits an undocumented feature in
Matlab's 'spconvert' so you should also report
it to the PETSc developers:

http://www.mcs.anl.gov/petsc/documentation/bugreporting.html

The fix would be trivial there to, simply
export complex sparse matrices as real matrices
with four columns instead of complex matrices with
three columns, i.e.:


s = [irow jcol xreal yimag]
mat = spconvert (s)


instead of


s = [irow jcol xreal + i yimag)]
mat = spconvert (s)


Anyway I'll wait for comments
from the core developers
to see if we should follow the undocumented
Matlab behaviour in Octave.

c.

Carlo de Falco <cdf>
Group Member
Sat 25 Jan 2014 10:41:50 AM UTC, original submission:  

Hi!

The Matlab 2013a spconvert() works for three-column complex matrices, but the Octave 3.8.0 spconvert() does not. This prevents me from loading m-files generated by Petsc 3.4.3, i.e. to transfer matrices from Petsc to Octave.

For example, consider the following command:

> spconvert ([8 8  2.3958333333333320e-01+4.7916666666666643e+00i])


In Matlab 2013a, the result is:

   (8,8)      0.2396 + 4.7917i

In Octave 3.8.0, the result is:

 error: spconvert: argument must be sparse or real matrix with 3 or 4 columns
 error: called from:
 error:   /opt/local/share/octave/3.8.0/m/sparse/spconvert.m at line 37, column 7

I posted this to the Octave help mailing list, and one of the resposes included a suggestion for a fix for spconvert. The thread is archived here:

http://octave.1599824.n4.nabble.com/Running-m-files-generated-by-Petsc-3-4-3-td4661348.html

I will quote the fix suggestion of Carlo Defalco:

"If we want to, the ix is trivial, simply change line 35 of "spconvert.m" from
 
 if (nargin != 1 || ! ismatrix (m) || ! isreal (m)

to

 if (nargin != 1 || ! ismatrix (m) "

Best regards
Torquil Sørensen

tmac

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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 jedbrown (Posted a comment)
  • -email is unavailable- added by cdf (Posted a comment)
  • -email is unavailable- added by tmac (Submitted the item)
  • -email is unavailable- added by tmac
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-27 rik5 StatusNone Wont Fix
        Assigned tocdf None
        Open/ClosedOpen Closed
        Operating SystemAny GNU/Linux
    2014-01-27 cdf Assigned toNone cdf
        Operating SystemGNU/Linux Any
    2014-01-25 tmac Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code