Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Full support for Complex sec and asec.
  • Loading branch information
colomon committed Oct 2, 2009
1 parent 1354976 commit be44f6a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/setting/Any-num.pm
Expand Up @@ -154,7 +154,7 @@ class Any is also {
self.Num.atan2($x, $base);
}

our Num multi method asec($base = 'radians') is export {
our Num multi method asec($base = 'radians') {
self.Num.asec($base);
}

Expand Down Expand Up @@ -220,6 +220,14 @@ multi sub atan($x, $base = 'radians') {
$x.atan($base)
}

multi sub sec($x, $base = 'radians') {
$x.sec($base)
}

multi sub asec($x, $base = 'radians') {
$x.asec($base)
}

our Num sub rand (*@args) {
die "too many arguments passed - 0 params expected" if @args;
1.rand
Expand Down
8 changes: 8 additions & 0 deletions src/setting/Complex.pm
Expand Up @@ -48,6 +48,14 @@ class Complex {
((log(1 - (self)i) - log(1 + (self)i))i / 2)!from-radians($base);
}

multi method sec($base = 'radians') {
1 / self.cos($base);
}

multi method asec($base = 'radians') {
(1 / self).acos($base);
}

multi method log() {
Q:PIR {
$P0 = get_root_namespace ['parrot'; 'Complex' ]
Expand Down
2 changes: 1 addition & 1 deletion src/setting/Int.pm
Expand Up @@ -25,7 +25,7 @@ class Int is also {

# Most of the trig functions for Int are in Any-num.pm, but
# sec is a special case.
our Num multi method sec($base = 'radians') is export {
our Num multi method sec($base = 'radians') {
self.Num.sec($base);
}

Expand Down
4 changes: 2 additions & 2 deletions src/setting/Num.pm
Expand Up @@ -87,7 +87,7 @@ class Num is also {
$r!from-radians($base)
}

our Num multi method asec($base = 'radians') is export {
our Num multi method asec($base = 'radians') {
my $r = Q:PIR {
$N0 = self
$N1 = asec $N0
Expand Down Expand Up @@ -250,7 +250,7 @@ class Num is also {
~self
}
our Num multi method sec($base = 'radians') is export {
our Num multi method sec($base = 'radians') {
my $x = self!to-radians($base);
Q:PIR {
$P0 = find_lex "$x"
Expand Down
2 changes: 1 addition & 1 deletion src/setting/Rat.pm
Expand Up @@ -33,7 +33,7 @@ class Rat {

# Most of the trig functions for Rat are in Any-num.pm, but
# sec is a special case.
our Num multi method sec($base = 'radians') is export {
our Num multi method sec($base = 'radians') {
self.Num.sec($base);
}

Expand Down

0 comments on commit be44f6a

Please sign in to comment.