On Thu, Nov 20, 2008 at 4:25 PM, Wolfgang Laun <[EMAIL PROTECTED]> wrote:
> So, calling sqrt with a real < 0, should not come back with a complex
> number.
Again, I think this should depend on context. In Perl5, simply
use'ing "Math::Complex" changes the behavior of sqrt such that
sqrt(-1) return
If a programmer calls a function with an argument that has a
well-established type, s/he may very well expect a result according
to that type, (considering that overloading isn't just a word for not
caring about type).
So, calling sqrt with a real < 0, should not come back with a complex
number.
C
HaloO,
Moritz Lenz via RT wrote:
On Wed Nov 19 07:35:48 2008, masak wrote:
what should the behaviour of sign($x) be when $x is complex?
I'd argue that it's a Failure.
This is a bit drastic. If one computes in the complex domain
a complex valued sign function is appropriate.
multi sub s
I'd rather retain the dwimmishness of p5.
$ perl -MMath::Complex -le 'print sqrt(-1)'
i
Note that I didn't have to pass in Math::Complex->make(-1,0). Just -1.
On 11/20/08, Chris Dolan <[EMAIL PROTECTED]> wrote:
>> Mark (>):
>>> I think the most sensible thing is to be consistent. sgn() fails
> Mark (>):
>> I think the most sensible thing is to be consistent. sgn() fails for
>> non-real input as long as sqrt() returns NaN for negative input.
>> Change the latter behavior (via a pragma or whatever) so that sqrt()
>> returns complex numbers, and then sgn() should start behaving on such
>
HaloO,
Moritz Lenz via RT wrote:
On Wed Nov 19 07:35:48 2008, masak wrote:
what should the behaviour of sign($x) be when $x is complex?
I'd argue that it's a Failure.
This is a bit drastic. If one computes in the complex domain
a complex valued sign function is appropriate.
multi sub s
On Thu, Nov 20, 2008 at 04:31:22PM +0100, Carl Mäsak wrote:
: Mark (>):
: > I think the most sensible thing is to be consistent. sgn() fails for
: > non-real input as long as sqrt() returns NaN for negative input.
: > Change the latter behavior (via a pragma or whatever) so that sqrt()
: > returns
Mark (>):
> I think the most sensible thing is to be consistent. sgn() fails for
> non-real input as long as sqrt() returns NaN for negative input.
> Change the latter behavior (via a pragma or whatever) so that sqrt()
> returns complex numbers, and then sgn() should start behaving on such
> numbe
On Thu, Nov 20, 2008 at 8:34 AM, Carl Mäsak <[EMAIL PROTECTED]> wrote:
> I guess the question is more about the programmer's expectations. Is
> this a case where we serve the programmer better by returning Failure,
> or by generalizing the C function to the complex plane?
This is parallel to the c
Wolfgang (>):
> There is a definition for the signum function for a complex argument.
>
> sign( z ) = z / |z| for all z != 0
> sign( 0 ) = 0
>
> See e.g. http://en.wikipedia.org/wiki/Sign_function
>
> Shouldn't be too difficult to implement.
It isn't, and note that I also proposed it in my first e
# New Ticket Created by "Carl Mäsak"
# Please include the string: [perl #60674]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=60674 >
what should the behaviour of sign($x) be when $x is complex?
rakudo: say sign($_) for
Sent: Mittwoch, 19. November 2008 22:24
To: [EMAIL PROTECTED]
Subject: Re: [perl #60674] sign($x) always returns 1 when $x ~~ Complex
Moritz (>), Carl (>>):
>> what should the behaviour of sign($x) be when $x is complex?
>
> I'd argue that it's a Failure.
Aye.
On Wed Nov 19 07:35:48 2008, masak wrote:
> what should the behaviour of sign($x) be when $x is complex?
I'd argue that it's a Failure.
If you care about complex numbers, you usually want an angle instead,
which you can get with Complex.polar. (And it's easier to give it a
another meaning later t
Moritz (>), Carl (>>):
>> what should the behaviour of sign($x) be when $x is complex?
>
> I'd argue that it's a Failure.
Aye.
> [...]
14 matches
Mail list logo