Raku / old-design-docs

Raku language design documents
https://design.raku.org/
Artistic License 2.0
124 stars 36 forks source link

numeric types need "conjugate" operator #33

Closed coke closed 11 years ago

coke commented 11 years ago

Originally entered by Dave Whipp as https://rt.perl.org/rt3/Ticket/Display.html?id=76602

I was looking at colomon's Vector.pm in github, and noticed that Vector::length is defined as { sqrt( self dot self ) }. This is obviously incorrect for complex numbers: it should be { sqrt( self dot conjugate self ) } (for some syntax of "conjugate")

I can't just add the method to the Complex class, because then the Vector code would fail ("method not found") for all non-complex numeric types (for which conjugation is an identity operation).

colomon commented 11 years ago

Seems reasonable to me. I have to admit I thought complex conjugate was already in there. I will take a stab at it after rehearsal tonight if no one beats me to it.

dwhipp commented 11 years ago

Yes, I added it to Rakudo a couple of years back ... not sure if it made it to the spec. https://github.com/rakudo/rakudo/commit/cd1154b09ec5b7835193e8a669d35a5d976dec86

On Thu, Mar 28, 2013 at 5:14 PM, colomon notifications@github.com wrote:

Seems reasonable to me. I have to admit I thought complex conjugate was already in there. I will take a stab at it after rehearsal tonight if no one beats me to it.

— Reply to this email directly or view it on GitHubhttps://github.com/perl6/specs/issues/33#issuecomment-15622833 .

leto commented 11 years ago

+1

colomon commented 11 years ago

Complex conjugate is already in there, as conj. It was also as conjugate in one place, I have corrected that. I'm working on updating Math:: Vector, and may add a few additional tests to roast as well.