bugGNU Octave - Bugs: bug #38959, Conversion from complex double to...

 
 

bug #38959: Conversion from complex double to int32

Submitted by:  Clemens Buchacher <drizzd>
Submitted on:  Fri 10 May 2013 09:58:28 AM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Clemens BuchacherOpen/Closed: Open
Release: 3.6.4Operating System: Any

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 10 May 2013 03:26:20 PM UTC, comment #2:

I noticed it in one of our unit tests and worked around it by disabling the test for complex integer types. I have no real world example of usefulness.

Clemens Buchacher <drizzd>
Fri 10 May 2013 02:16:57 PM UTC, comment #1:

Alright, looks like Matlab allows complex integers, even though it doesn't allow complex integer arithmetic.

This will require a major retooling of our integer types so that we can make them all complex. If this bug is important (does a lot of Matlab code rely on being able to create complex integers?), this would be a good opportunity to revisit our stupidly boneheaded numeric class hierarchy so we can make it less boneheaded.

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Fri 10 May 2013 09:58:28 AM UTC, original submission:

The int32 conversion function refuses to convert complex input:

  • Expected result:

> int32(1+1i)

ans = 1 + 1i

  • Actual result:

> int32(1+1i)

error: invalid conversion from complex scalar to int32 scalar

The complex() function does not provide a workaround, since it converts int32 input to double output:

> complex(int32(1), int32(1))

ans = 1 + 1i

> class(complex(int32(1), int32(1)))

ans = double

Conversion functions for other types do not have this issue:

> single(1+1i)

ans = 1 + 1i

Clemens Buchacher <drizzd>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by drizzd (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 10 May 2013 02:18:22 PM UTCjordighOpen/ClosedClosed=>Open
    Fri 10 May 2013 02:16:57 PM UTCjordighStatusNone=>Confirmed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup