-
-
Notifications
You must be signed in to change notification settings - Fork 40
PMComplex miss a signBit method (used in Pharo) Fix #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PMComplex miss a signBit method (used in Pharo) Fix #69
Conversation
| ] | ||
|
|
||
| { #category : #'*Math-Complex' } | ||
| PMComplex class >> random [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own education, what drives the need for this method?
| ] | ||
|
|
||
| { #category : #testing } | ||
| PMComplex >> signBit [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, as this is a one line block, we might inline this,
PMComplex >> signBit [ ^ self real signBit ]
unless what you've done is the idiomatic way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand ? This is not a block. You are looking at Tonel files, the real method is :
MComplex >> signBit
^ self real signBit
|
I wonder why we need to define the sign of a complex at all??? |
|
I don't know exactly ... In Pharo 7.0, arcTan: has been redesigned to use signBit instead of sign (in order to detect IEEE-754 negative-zero). PMComplex miss this method and test like |
|
Standards (ANSI Smalltalk?) mandates that 0 sign -> 0, same for +0.0 and -0.0... But that applies to numbers, not complex numbers... Introducing functions/operations that are not natural, but are rather hacks for making some other part of a software work is dangerous. One good example is how Matlab defined relational operators for complex (< <= >= >). For what added value? I know of a single usage for sorting complex values: separate stable poles from unstable poles in some algorithms (for example solving a Riccati). For a discrete or continuous system, that's not necessarily the same sort function... (either real part > 0, or module > 1). That's why I ask for complex sign... |
|
I don't want to add a sign on Complex ... there was already a sign method and there was a failing test : testArcTanDenominator
| c1 c2 |
c1 := 1 i.
c2 := 0.
self assert: (c1 arcTan: c1) equals: Float pi / 4.
self assert: (c2 arcTan: c1) equals: 0.
self assert: (c2 arcTan: c1 * c1) equals: Float piI dunno who wrote this test ? |
|
Yes, I understand that. But on the other hand, while at fixing it, I'm saying that rather than hacking a sign/signBit that will not be usefull outside of Does complex extension fits real function when imaginary parts are null? What happens when one or both imaginary part is a negativeZero? I might be able to answer to above questions since I probably implemented those... But does the arcTan: implemented in Number works the same as Complex extension when a Complex parameter is provided? Does it use double dispatching for that? Are there tests for all these cases? |
|
I thought |
|
Can you move discussion on a new issue ? |
|
Yes, I once thought this could be discussed in a new issue. But if Number>>arcTan: has not been patched for being compatible with complex extension of arcTan:, as I think then the correct fix is:
|

No description provided.