bugGNU Octave - Bugs: bug #34655, max(z,0) where z is a complex...

 
 

bug #34655: max(z,0) where z is a complex vector is incorrect

Submitter:  Alan E. Schoen <aeschoen>
Submitted:  Tue 25 Oct 2011 08:58:46 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  aeschoen Open/Closed:  * Closed
Release:  * 3.2.4 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 25 Oct 2011 11:55:37 PM UTC, comment #3: 

The documentation string for max () explains what is being calculated.  Try 'help max'.  Quoting from the documentation "For complex arguments, the magnitude of the elements are used for comparison."

In this case, the magnitude, i.e., length in the plane are all greater than zero and so each value, including complex numbers with negative real parts, are returned. 

Matlab behaves the same way (http://www.mathworks.com/help/techdoc/ref/max.html).  I think you need to modify the script in question to have it do what you want.

Rik <rik5>
Group administrator
Tue 25 Oct 2011 11:29:00 PM UTC, comment #2: 

z=[1.0+1.0i,-1.0+1.0i,1.0+1.0i]
x=max(z,0)

this should result in x being 1.0+1.0i,0.0+0.0i,1.0+1.0i
however, the negative second element persists

y=max(real(z),0) works as expected i.e. 1,0,1

Alan E. Schoen <aeschoen>
Tue 25 Oct 2011 11:00:29 PM UTC, comment #1: 

Please provide a specific small example that shows the problem, including the output you expect to see.

John W. Eaton <jwe>
Group administrator
Tue 25 Oct 2011 08:58:46 PM UTC, original submission:  

In the windows distribution 3.2.4, a matlab script that includes max(z,0) where z is the result of an fft and therefore a complex vector does not function. the intent is to clip the vector to positive values, but negative values persist unchanged. This behavior differs from matlab where this works.

Alan E. Schoen <aeschoen>

 

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

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-10-25 rik5 StatusNeed Info Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2011-10-25 jwe StatusNone Need Info
    2011-10-25 aeschoen Carbon-Copy- Added aeschoen

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code