bugGNU Octave - Bugs: bug #42528, textscan: complex numbers are...

 
 

bug #42528: textscan: complex numbers are incorrectly processed when format is empty

Submitter:  sergey plotnikov <nul0m>
Submitted:  Mon 09 Jun 2014 09:57:07 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 25 Apr 2015 05:46:50 AM UTC, comment #7: 

The patch was applied a long time ago back in 2014.  This bug is fixed.  Closing report.

Rik <rik5>
Group administrator
Fri 04 Jul 2014 12:57:39 PM UTC, comment #6: 

Better cs attached (commit message adapted)

(file #31673)

Philip Nienhuis <philipnienhuis>
Group Member
Sun 15 Jun 2014 09:22:29 PM UTC, comment #5: 

Thanks for suggestion!

Attached is a changeset (I found some time during train delays).


(file #31559)

Philip Nienhuis <philipnienhuis>
Group Member
Thu 12 Jun 2014 02:20:11 PM UTC, comment #4: 

Why not use the transpose operator (.') instead?

John W. Eaton <jwe>
Group administrator
Wed 11 Jun 2014 09:04:26 PM UTC, comment #3: 

I had a brief look:

The culprit is a matrix transpose operator that also invokes the complex transpose (as per the definition of the transpose operator BTW, see the docs).

Quick & dirty fix:  replace L. 332:
C(1) = reshape (C{1}, ncols, numel (C{1}) / ncols)';
by
C(1) = conj (reshape (C{1}, ncols, numel (C{1}) / ncols))';

textscan passes all tests then, but I'm not sure yet whether this is a reliable fix. More investigation is needed for other data types - but I have not time for that now.

Note that Matlab doesn't accept "textscan ('1i')" (it complains about a missing format string).

Philip Nienhuis <philipnienhuis>
Group Member
Mon 09 Jun 2014 07:31:29 PM UTC, comment #2: 

Hmmm well just one thing: strread.m (textscan's workhorse-behind-the-scenes) does it right. That's at least a clue.:

octave:1> strread ('1i')
ans =  0 + 1i
octave:2> strread ('1i', '')
ans =  0 + 1i
octave:3>


Philip Nienhuis <philipnienhuis>
Group Member
Mon 09 Jun 2014 07:28:49 PM UTC, comment #1: 

Confirmed.

I'll look into it, but the next weeks I'll have almost no time for Octave stuff. Maybe someone will beat me to it.

Thanks for reporting

Philip Nienhuis <philipnienhuis>
Group Member
Mon 09 Jun 2014 09:57:07 AM UTC, original submission:  

Transpose at around line 332 of textscan.m transforms complex numbers to their complex conjugates, which may cause weird results (see below).


>> textscan('1i')
ans =
{
  [1,1] =  0 + 1i
}
>> textscan('1i','')
ans =
{
  [1,1] =  0 - 1i
}


sergey plotnikov <nul0m>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31673:  bug42528_v2.cs added by philipnienhuis (1KiB - text/x-csharp)
file #31559:  textscan_bug42528.cs added by philipnienhuis (1KiB - text/x-csharp)

 

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

    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
    2015-04-25 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2014-07-04 philipnienhuis Attached File- Added bug42528_v2.cs, #31673
    2014-06-15 philipnienhuis Attached File- Added textscan_bug42528.cs, #31559
        StatusConfirmed Patch Submitted
    2014-06-09 philipnienhuis StatusNone Confirmed
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code