Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

colomon (8994)

colomon
  (email not shown publicly)

Journal of colomon (8994)

Sunday September 06, 2009
10:17 AM

Struggles with Trig

[ #39590 ]
I'm checking in what I've got of my trig tests / code update, which so far only tackles sin and cos. I thought it would be a good idea to get other people's eyes on it now, before I replicated the changes for all of the other trig functions. I'm up at my in-laws' cabin, had to drive into town to reach the Internet, so this seemed like the best way to pose my questions to the Perl 6 world.

1) Passing non-default $base value does not work for Num.sin / Num.cos or Complex.sin / Complex.cos. As far as I can tell the code is fine, and Num.sin("degrees") seems to work fine using p6eval, but the tests fail for me in trig.t. I thought it was some weird interaction with the fact sin is declared as an operator, but Rat.sin("degrees") works just fine in the tests. I'm stumped on this, if anyone else can offer some insight I'm all ears.

2) Equally weirdly, I've got working implementations of sin(Complex) and sin(Complex, $base). But they only work if defined trig.t, moving them to Complex.pm made those tests fail. Do they need "is export" added or something like that? What is "is export" for, anyway?

3) In general, I'd love it if a few people could look over the new tests for sine (cosine duplicates them). I'm not 100% comfortable with how repetitive they are. You could obviously change my little AngleAndResult to have a method which allows you to select the base and the numeric type to return, but I don't know how to make that cleanly work with the very much needed SKIP directives. (BTW, these changes I've made add over 1000 tests in trig.t, and they are only the tip of the iceberg.)

If you could e-mail comments to my user name here at gmail.com, that's probably the best way to reliably get my attention while I am away from the Internet this weekend. Any comments / suggestions would be deeply appreciated. In the meantime I'll play around with replacing "degrees", etc with a proper enum, as per the spec.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.