| 1 | package Math::GComplex; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | our $VERSION = '0.13'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | use overload | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | '""' => \&stringify, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.1
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | '0+' => \&numify, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | bool => \&boolify, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | '+' => \&add, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | '*' => \&mul, | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | '==' => \&eq, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | '!=' => \&ne, | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | '~' => \&conj, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | '&' => \&and, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | '|' => \&or, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | '^' => \&xor, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | '>>' => \&rsft, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | '<<' => \&lsft, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | '>' => sub { $_[2] ? (goto <) : (goto >) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | '>=' => sub { $_[2] ? (goto &le) : (goto &ge) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 29 | ▶ | '<' => sub { $_[2] ? (goto >) : (goto <) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | '<=' => sub { $_[2] ? (goto &ge) : (goto &le) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | '<=>' => sub { $_[2] ? -(&cmp($_[0], $_[1]) // return undef) : &cmp($_[0], $_[1]) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/2
&cmp($_[0], $_[1]) // (return undef)
MC/DC0%0/1
&cmp($_[0], $_[1]) // (return undef)
&cmp($_[0], $_[1])
Truth table0%0/2
A
A= &cmp($_[0], $_[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 240 | ▶ | '/' => sub { @_ = ($_[1], $_[0]) if $_[2]; goto &div }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 233 | ▶ | '-' => sub { @_ = ($_[1], $_[0]) if $_[2]; goto &sub }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 105 | ▶ | '**' => sub { @_ = $_[2] ? @_[1, 0] : @_[0, 1]; goto &pow }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | '%' => sub { @_ = $_[2] ? @_[1, 0] : @_[0, 1]; goto &mod }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | atan2 => sub { @_ = $_[2] ? @_[1, 0] : @_[0, 1]; goto &atan2 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 29 | ▶ | eq => sub { "$_[0]" eq "$_[1]" }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | ne => sub { "$_[0]" ne "$_[1]" }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | cmp => sub { $_[2] ? ("$_[1]" cmp $_[0]->stringify) : ($_[0]->stringify cmp "$_[1]") }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | neg => \&neg, | |||||||||||||||||||||||||||||||||||||||||
| 49 | sin => \&sin, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | cos => \&cos, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | exp => \&exp, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | log => \&log, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | int => \&int, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | abs => \&abs, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | sqrt => \&sqrt; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | my %const = ( # prototypes are assigned in import() | |||||||||||||||||||||||||||||||||||||||||
| 60 | i => \&i, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | my %trig = ( | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 10 | ▶ | sin => sub (_) { goto &sin }, # built-in function | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | sinh => \&sinh, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | asin => \&asin, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | asinh => \&asinh, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 10 | ▶ | cos => sub (_) { goto &cos }, # built-in function | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | cosh => \&cosh, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | acos => \&acos, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | acosh => \&acosh, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | tan => \&tan, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | tanh => \&tanh, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | atan => \&atan, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | atanh => \&atanh, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | cot => \&cot, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | coth => \&coth, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | acot => \&acot, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | acoth => \&acoth, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | sec => \&sec, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | sech => \&sech, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | asec => \&asec, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | asech => \&asech, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | csc => \&csc, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | csch => \&csch, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | acsc => \&acsc, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | acsch => \&acsch, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 5 | ▶ | atan2 => sub ($$) { goto &atan2 }, # built-in function | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | deg2rad => \°2rad, | |||||||||||||||||||||||||||||||||||||||||
| 97 | rad2deg => \&rad2deg, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | my %special = ( | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 24 | ▶ | exp => sub (_) { goto &exp }, # built-in function | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 30 | ▶ | log => sub (_) { goto &log }, # built-in function | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 15 | ▶ | sqrt => sub (_) { goto &sqrt }, # built-in function | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | cbrt => \&cbrt, | |||||||||||||||||||||||||||||||||||||||||
| 107 | logn => \&logn, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | root => \&root, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | pow => \&pow, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | pown => \&pown, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | gcd => \&gcd, | ||||||||||||||||||||||||||||||||||||||||||
| 113 | invmod => \&invmod, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | powmod => \&powmod, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | my %misc = ( | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | acmp => \&acmp, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | cplx => \&cplx, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | polar => \&polar, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | abs => sub (_) { goto &abs }, # built-in function | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | inv => \&inv, | |||||||||||||||||||||||||||||||||||||||||
| 126 | sgn => \&sgn, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | conj => \&conj, | ||||||||||||||||||||||||||||||||||||||||||
| 128 | norm => \&norm, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | real => \&real, | ||||||||||||||||||||||||||||||||||||||||||
| 131 | imag => \&imag, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | floor => \&floor, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ceil => \&ceil, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | round => \&round, | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | reals => \&reals, | ||||||||||||||||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=14 SCAR=27.0
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | shift; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | my $caller = caller(0); | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 46 | my $name = shift(@_); | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 46 | ▶ | if ($name eq ':overload') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | overload::constant | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 159 | ▶ | integer => sub { __PACKAGE__->new($_[0], 0) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | float => sub { __PACKAGE__->new($_[0], 0) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # Export the 'i' constant | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | foreach my $pair (['i', i()]) { | |||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | my $sub = $caller . '::' . $pair->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | my $value = $pair->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | *$sub = sub () { $value }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | elsif (exists $const{$name}) { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | my $caller_sub = $caller . '::' . $name; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | my $sub = $const{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | my $value = $sub->(); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | *$caller_sub = sub() { $value } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 170 | ▶ | elsif ( exists($trig{$name}) | |||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
exists $trig{$name} or exists $special{$name} or exists $misc{$name}
exists $trig{$name} or exists $special{$name}
MC/DC66%2/3
exists $trig{$name} or exists $special{$name} or exists $misc{$name}
exists $trig{$name}
exists $special{$name}
exists $misc{$name}
Truth table75%3/4
A or B or C
A= exists $trig{$name}B= exists $special{$name}C= exists $misc{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | or exists($special{$name}) | ||||||||||||||||||||||||||||||||||||||||||
| 172 | or exists($misc{$name})) { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 42 | my $caller_sub = $caller . '::' . $name; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 42 | ▶ | *$caller_sub = $trig{$name} // $misc{$name} // $special{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
($trig{$name} // $misc{$name}) // $special{$name}
$trig{$name} // $misc{$name}
MC/DC0%0/3
($trig{$name} // $misc{$name}) // $special{$name}
$trig{$name}
$misc{$name}
$special{$name}
Truth table50%2/4
A // B // C
A= $trig{$name}B= $misc{$name}C= $special{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | elsif ($name eq ':trig') { | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | push @_, keys(%trig); | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif ($name eq ':misc') { | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | push @_, keys(%misc); | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif ($name eq ':special') { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | push @_, keys(%special); | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | elsif ($name eq ':all') { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | push @_, keys(%const), keys(%trig), keys(%special), keys(%misc); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | die "unknown import: <<$name>>"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub unimport { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unimport: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | overload::remove_constant(float => '', | |||||||||||||||||||||||||||||||||||||||||
| 199 | integer => '',); | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | # | ||||||||||||||||||||||||||||||||||||||||||
| 204 | ## Be somewhat compatible with Math::Complex | ||||||||||||||||||||||||||||||||||||||||||
| 205 | # | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | ▶ | sub _cartesian { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cartesian: not called CC=2 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $self->{cartesian} //= [$self->{a}, $self->{b}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"cartesian"} //= [$self->{"a"}, $self->{"b"}]
MC/DC0%0/1
$self->{"cartesian"} //= [$self->{"a"}, $self->{"b"}]
$self->{"cartesian"}
Truth table0%0/2
A
A= $self->{"cartesian"}
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub _polar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_polar: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $self->{polar} //= [CORE::sqrt($self->{a} * $self->{a} + $self->{b} * $self->{b}), CORE::atan2($self->{b}, $self->{a})]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"polar"} //= [CORE::sqrt $self->{"a"} * $self->{"a"} + $self->{"b"} * $self->{"b"}, CORE::atan2($self->{"b"}, $self->{"a"})]
MC/DC0%0/1
$self->{"polar"} //= [CORE::sqrt $self->{"a"} * $self->{"a"} + $self->{"b"} * $self->{"b"}, CORE::atan2($self->{"b"}, $self->{"a"})]
$self->{"polar"}
Truth table0%0/2
A
A= $self->{"polar"}
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | # | ||||||||||||||||||||||||||||||||||||||||||
| 218 | ## Return the polar form | ||||||||||||||||||||||||||||||||||||||||||
| 219 | # | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub polar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
polar: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | @{$self->_polar}; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | # | ||||||||||||||||||||||||||||||||||||||||||
| 227 | ## Create a new Math::GComplex object | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 4070 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 4070 | my ($class, $x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 4070 | ▶ | bless { | ||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$x // 0
$y // 0
MC/DC0%0/1
$x // 0
$x
MC/DC100%1/1
$y // 0
$y
Truth table50%1/2
A
A= $x
Truth table100%2/2
A
A= $y
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | a => $x // 0, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | b => $y // 0, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 3 | *make = \&new; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | # | ||||||||||||||||||||||||||||||||||||||||||
| 242 | ## cplx(a, b) = a + b*i | ||||||||||||||||||||||||||||||||||||||||||
| 243 | # | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub cplx { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cplx: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | bless { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$x // 0
$y // 0
MC/DC0%0/1
$x // 0
$x
MC/DC0%0/1
$y // 0
$y
Truth table0%0/2
A
A= $x
Truth table0%0/2
A
A= $y
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | a => $x // 0, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | b => $y // 0, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 252 | __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub emake { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emake: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my ($class, $r, $theta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | bless { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$r // 0
$theta // 0
$r // 0
$theta // 0
MC/DC0%0/1
$r // 0
$r
MC/DC0%0/1
$theta // 0
$theta
MC/DC0%0/1
$r // 0
$r
MC/DC0%0/1
$theta // 0
$theta
Truth table0%0/2
A
A= $r
Truth table0%0/2
A
A= $theta
Truth table0%0/2
A
A= $r
Truth table0%0/2
A
A= $theta
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | a => ($r // 0) * CORE::cos($theta // 0), | ||||||||||||||||||||||||||||||||||||||||||
| 260 | b => ($r // 0) * CORE::sin($theta // 0), | ||||||||||||||||||||||||||||||||||||||||||
| 261 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | # | ||||||||||||||||||||||||||||||||||||||||||
| 265 | ## cplxe(r, theta) = r*cos(theta) + r*sin(theta)*i | ||||||||||||||||||||||||||||||||||||||||||
| 266 | # | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub cplxe { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cplxe: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my ($r, $theta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | bless { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$r // 0
$theta // 0
$r // 0
$theta // 0
MC/DC0%0/1
$r // 0
$r
MC/DC0%0/1
$theta // 0
$theta
MC/DC0%0/1
$r // 0
$r
MC/DC0%0/1
$theta // 0
$theta
Truth table0%0/2
A
A= $r
Truth table0%0/2
A
A= $theta
Truth table0%0/2
A
A= $r
Truth table0%0/2
A
A= $theta
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | a => ($r // 0) * CORE::cos($theta // 0), | ||||||||||||||||||||||||||||||||||||||||||
| 273 | b => ($r // 0) * CORE::sin($theta // 0), | ||||||||||||||||||||||||||||||||||||||||||
| 274 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 275 | __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | # | ||||||||||||||||||||||||||||||||||||||||||
| 279 | ## i = sqrt(-1) | ||||||||||||||||||||||||||||||||||||||||||
| 280 | # | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | sub i { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
i: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | __PACKAGE__->new(0, 1); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | # | ||||||||||||||||||||||||||||||||||||||||||
| 287 | ## (a + b*i) + (x + y*i) = (a + x) + (b + y)*i | ||||||||||||||||||||||||||||||||||||||||||
| 288 | # | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 131 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 131 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 131 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 131 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 131 | __PACKAGE__->new($x->{a} + $y->{a}, $x->{b} + $y->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | # | ||||||||||||||||||||||||||||||||||||||||||
| 300 | ## (a + b*i) - (x + y*i) = (a - x) + (b - y)*i | ||||||||||||||||||||||||||||||||||||||||||
| 301 | # | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 468 | ▶ | sub sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sub: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 468 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 468 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 468 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 468 | __PACKAGE__->new($x->{a} - $y->{a}, $x->{b} - $y->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | # | ||||||||||||||||||||||||||||||||||||||||||
| 313 | ## (a + b*i) * (x + y*i) = i*(a*y + b*x) + a*x - b*y | ||||||||||||||||||||||||||||||||||||||||||
| 314 | # | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 640 | ▶ | sub mul { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mul: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 640 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 640 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 640 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 640 | __PACKAGE__->new($x->{a} * $y->{a} - $x->{b} * $y->{b}, $x->{a} * $y->{b} + $x->{b} * $y->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | # | ||||||||||||||||||||||||||||||||||||||||||
| 326 | ## (a + b*i) / (x + y*i) = (a*x + b*y)/(x*x + y*y) + (b*x - a*y)/(x*x + y*y) * i | ||||||||||||||||||||||||||||||||||||||||||
| 327 | # | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 563 | ▶ | sub div { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
div: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 563 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 563 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 563 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 563 | my $d = $y->{a} * $y->{a} + $y->{b} * $y->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 563 | ▶ | if ($d == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return $x->log->sub($y->log)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 563 | __PACKAGE__->new(($x->{a} * $y->{a} + $x->{b} * $y->{b}) / $d, ($x->{b} * $y->{a} - $x->{a} * $y->{b}) / $d); | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | # | ||||||||||||||||||||||||||||||||||||||||||
| 345 | ## mod(x, y) = x - y*floor(x/y) | ||||||||||||||||||||||||||||||||||||||||||
| 346 | # | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 139 | ▶ | sub mod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mod: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 139 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 139 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 139 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 139 | $x->sub($x->div($y)->floor->mul($y)); | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | # | ||||||||||||||||||||||||||||||||||||||||||
| 358 | ## inv(x) = 1/x | ||||||||||||||||||||||||||||||||||||||||||
| 359 | # | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 37 | ▶ | sub inv ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inv: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 37 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 37 | state $one = __PACKAGE__->new(1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 37 | $one->div($x); | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | # | ||||||||||||||||||||||||||||||||||||||||||
| 370 | ## abs(a + b*i) = sqrt(a^2 + b^2) | ||||||||||||||||||||||||||||||||||||||||||
| 371 | # | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 203 | ▶ | sub abs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abs: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 203 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 203 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 203 | CORE::sqrt($x->{a} * $x->{a} + $x->{b} * $x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | # | ||||||||||||||||||||||||||||||||||||||||||
| 382 | ## sgn(a + b*i) = (a + b*i) / abs(a + b*i) | ||||||||||||||||||||||||||||||||||||||||||
| 383 | # | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | sub sgn ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sgn: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ($x->{a} == 0 and $x->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$x->{"a"} == 0 and $x->{"b"} == 0
MC/DC0%0/2
$x->{"a"} == 0 and $x->{"b"} == 0
$x->{"a"} == 0
$x->{"b"} == 0
Truth table0%0/3
A and B
A= $x->{"a"} == 0B= $x->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | return __PACKAGE__->new(0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $x->div($x->abs); | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | # | ||||||||||||||||||||||||||||||||||||||||||
| 398 | ## neg(a + b*i) = -a - b*i | ||||||||||||||||||||||||||||||||||||||||||
| 399 | # | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 38 | ▶ | sub neg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
neg: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 38 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 38 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 38 | __PACKAGE__->new(-$x->{a}, -$x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | # | ||||||||||||||||||||||||||||||||||||||||||
| 410 | ## conj(a + b*i) = a - b*i | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 6 | ▶ | sub conj ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conj: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 6 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 6 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 6 | __PACKAGE__->new($x->{a}, -$x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | # | ||||||||||||||||||||||||||||||||||||||||||
| 422 | ## norm(a + b*i) = a**2 + b**2 | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | sub norm ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
norm: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $x->{a} * $x->{a} + $x->{b} * $x->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | # | ||||||||||||||||||||||||||||||||||||||||||
| 434 | ## (a+b*i) AND (x+y*i) = (a AND x) + (b AND y)*i | ||||||||||||||||||||||||||||||||||||||||||
| 435 | # | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | ▶ | sub and { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
and: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | __PACKAGE__->new($x->{a} & $y->{a}, $x->{b} & $y->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | # | ||||||||||||||||||||||||||||||||||||||||||
| 447 | ## (a+b*i) OR (x+y*i) = (a OR x) + (b OR y)*i | ||||||||||||||||||||||||||||||||||||||||||
| 448 | # | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | ▶ | sub or { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
or: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | __PACKAGE__->new($x->{a} | $y->{a}, $x->{b} | $y->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | # | ||||||||||||||||||||||||||||||||||||||||||
| 460 | ## (a+b*i) XOR (x+y*i) = (a XOR x) + (b XOR y)*i | ||||||||||||||||||||||||||||||||||||||||||
| 461 | # | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 1 | ▶ | sub xor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xor: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 1 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 1 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | __PACKAGE__->new($x->{a} ^ $y->{a}, $x->{b} ^ $y->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | # | ||||||||||||||||||||||||||||||||||||||||||
| 473 | ## (a+b*i) << n = (a << n) + (b << n)*i | ||||||||||||||||||||||||||||||||||||||||||
| 474 | ## (a+b*i) << (x+y*i) = int((a+b*i) * 2^(x+y*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 475 | # | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | ▶ | sub lsft { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lsft: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 1 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 1 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | ▶ | if ($y->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | return __PACKAGE__->new($x->{a} << $y->{a}, $x->{b} << $y->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | state $two = __PACKAGE__->new(2, 0); | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $x->mul($two->pow($y))->int; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | # | ||||||||||||||||||||||||||||||||||||||||||
| 492 | ## (a+b*i) >> n = (a >> n) + (b >> n)*i | ||||||||||||||||||||||||||||||||||||||||||
| 493 | ## (a+b*i) >> (x+y*i) = int((a+b*i) / 2^(x+y*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 494 | # | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | ▶ | sub rsft { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rsft: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 1 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 1 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 1 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | ▶ | if ($y->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | return __PACKAGE__->new($x->{a} >> $y->{a}, $x->{b} >> $y->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | state $two = __PACKAGE__->new(2, 0); | |||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $x->div($two->pow($y))->int; | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | # | ||||||||||||||||||||||||||||||||||||||||||
| 511 | ## log(a + b*i) = log(a^2 + b^2)/2 + atan2(b, a)*i -- where a,b are real | ||||||||||||||||||||||||||||||||||||||||||
| 512 | # | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 409 | ▶ | sub log { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 409 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 409 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 409 | my $t = $x->{a} * $x->{a} + $x->{b} * $x->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 409 | ▶ | if (!ref($t) and $t == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $t and $t == 0
MC/DC0%0/2
not ref $t and $t == 0
not ref $t
$t == 0
Truth table66%2/3
not(A) and B
A= not ref $tB= $t == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | return __PACKAGE__->new(0 + '-Inf', 0); | |||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 409 | __PACKAGE__->new(CORE::log($t) / 2, CORE::atan2($x->{b}, $x->{a})); | |||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | # | ||||||||||||||||||||||||||||||||||||||||||
| 529 | ## logn(x, n) = log(x) / log(n) | ||||||||||||||||||||||||||||||||||||||||||
| 530 | # | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | ▶ | sub logn ($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logn: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | my ($x, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 3 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | 3 | ▶ | $n = __PACKAGE__->new($n) if ref($n) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 3 | $x->log->div($n->log); | |||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # | ||||||||||||||||||||||||||||||||||||||||||
| 542 | ## exp(a + b*i) = exp(a)*cos(b) + exp(a)*sin(b)*i | ||||||||||||||||||||||||||||||||||||||||||
| 543 | # | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 486 | ▶ | sub exp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exp: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 486 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 486 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 486 | my $exp = CORE::exp($x->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 486 | __PACKAGE__->new($exp * CORE::cos($x->{b}), $exp * CORE::sin($x->{b})); | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | # | ||||||||||||||||||||||||||||||||||||||||||
| 556 | ## x^y = exp(log(x) * y) | ||||||||||||||||||||||||||||||||||||||||||
| 557 | # | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 108 | ▶ | sub pow ($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pow: called CC=8 SCAR=28.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 108 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 108 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 108 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 108 | ▶ | if ($x->{a} == 0 and $x->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x->{"a"} == 0 and $x->{"b"} == 0
MC/DC0%0/2
$x->{"a"} == 0 and $x->{"b"} == 0
$x->{"a"} == 0
$x->{"b"} == 0
Truth table66%2/3
A and B
A= $x->{"a"} == 0B= $x->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | if ($y->{a} < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | return $x->inv; | |||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | if ($y->{a} == 0 and $y->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$y->{"a"} == 0 and $y->{"b"} == 0
MC/DC0%0/2
$y->{"a"} == 0 and $y->{"b"} == 0
$y->{"a"} == 0
$y->{"b"} == 0
Truth table0%0/3
A and B
A= $y->{"a"} == 0B= $y->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | return __PACKAGE__->new($x->{a} + 1, $x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | return $x; | |||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 108 | $x->log->mul($y)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | # | ||||||||||||||||||||||||||||||||||||||||||
| 582 | ## x^n using the exponentiation by squaring method | ||||||||||||||||||||||||||||||||||||||||||
| 583 | # | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | 17 | ▶ | sub pown ($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pown: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | 17 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | 17 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | 17 | $y = CORE::int($y); | |||||||||||||||||||||||||||||||||||||||||
| 591 | 17 | my $neg = $y < 0; | |||||||||||||||||||||||||||||||||||||||||
| 592 | 17 | $y = CORE::int(CORE::abs($y)); | |||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 17 | ▶ | if ($x->{a} == 0 and $x->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$x->{"a"} == 0 and $x->{"b"} == 0
MC/DC100%2/2
$x->{"a"} == 0 and $x->{"b"} == 0
$x->{"a"} == 0
$x->{"b"} == 0
Truth table100%3/3
A and B
A= $x->{"a"} == 0B= $x->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | ▶ | if ($neg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return $x->inv; | |||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | 2 | ▶ | if ($y == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 1 | return __PACKAGE__->new($x->{a} + 1, $x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | 1 | return $x; | |||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | 15 | my ($rx, $ry) = (1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 608 | 15 | my ($ax, $bx) = (@{$x}{qw(a b)}); | |||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 15 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 611 | 42 | ▶ | ($rx, $ry) = ($rx * $ax - $ry * $bx, $rx * $bx + $ry * $ax) if ($y & 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | 42 | ▶ | ($y >>= 1) or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 27 | ($ax, $bx) = ($ax * $ax - $bx * $bx, $ax * $bx + $bx * $ax); | |||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 15 | ▶ | $neg ? __PACKAGE__->new($rx, $ry)->inv : __PACKAGE__->new($rx, $ry); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | # | ||||||||||||||||||||||||||||||||||||||||||
| 620 | ## Greatest common divisor | ||||||||||||||||||||||||||||||||||||||||||
| 621 | # | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | 8 | ▶ | sub gcd ($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gcd: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 8 | my ($n, $k) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 8 | ▶ | $n = __PACKAGE__->new($n) if ref($n) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | 8 | ▶ | $k = __PACKAGE__->new($k) if ref($k) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 8 | my $norm_n = $n->{a} * $n->{a} + $n->{b} * $n->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 630 | 8 | my $norm_k = $k->{a} * $k->{a} + $k->{b} * $k->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 8 | ▶ | if ($norm_n > $norm_k) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 2 | ($n, $k) = ($k, $n); | |||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | 8 | ▶ | while (!($k->{a} == 0 and $k->{b} == 0)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k->{"a"} == 0 and $k->{"b"} == 0
MC/DC100%2/2
$k->{"a"} == 0 and $k->{"b"} == 0
$k->{"a"} == 0
$k->{"b"} == 0
Truth table100%3/3
A and B
A= $k->{"a"} == 0B= $k->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 38 | my $q = $n->div($k)->round; | |||||||||||||||||||||||||||||||||||||||||
| 639 | 38 | my $r = $n->sub($q->mul($k)); | |||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 38 | ($n, $k) = ($k, $r); | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | 8 | $n; | |||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | # | ||||||||||||||||||||||||||||||||||||||||||
| 648 | ## Modular multiplicative inverse: 1/x (mod m) | ||||||||||||||||||||||||||||||||||||||||||
| 649 | # | ||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | 6 | ▶ | sub invmod ($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invmod: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | 6 | my ($x, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 6 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | 6 | ▶ | $m = __PACKAGE__->new($m) if ref($m) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | 6 | my $g = $x->gcd($m); | |||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | 6 | ▶ | $g->abs == 1 or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | 6 | state $zero = __PACKAGE__->new(0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 6 | ▶ | my $inverse = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 6 | my ($x, $m, $k) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | 6 | my ($u, $w) = ($k, $zero); | |||||||||||||||||||||||||||||||||||||||||
| 667 | 6 | my ($q, $r); | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 6 | my $c = $m; | |||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 6 | ▶ | while (!($c->{a} == 0 and $c->{b} == 0)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c->{"a"} == 0 and $c->{"b"} == 0
MC/DC100%2/2
$c->{"a"} == 0 and $c->{"b"} == 0
$c->{"a"} == 0
$c->{"b"} == 0
Truth table100%3/3
A and B
A= $c->{"a"} == 0B= $c->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 29 | $q = $x->div($c)->round; | |||||||||||||||||||||||||||||||||||||||||
| 674 | 29 | $r = $x->sub($q->mul($c)); | |||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | 29 | ($x, $c) = ($c, $r); | |||||||||||||||||||||||||||||||||||||||||
| 677 | 29 | ($u, $w) = ($w, $u->sub($q->mul($w))); | |||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | 6 | return $u; | |||||||||||||||||||||||||||||||||||||||||
| 681 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | 6 | state $one = __PACKAGE__->new(1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 684 | 6 | state $mone = __PACKAGE__->new(-1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | 6 | state $i = __PACKAGE__->new(0, 1); | |||||||||||||||||||||||||||||||||||||||||
| 687 | 6 | state $mi = __PACKAGE__->new(0, -1); | |||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 6 | foreach my $k ($g->conj, $one, $mone, $i, $mi) { | |||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | 6 | my $inv = $inverse->($x, $m, $k); | |||||||||||||||||||||||||||||||||||||||||
| 692 | 6 | my $t = $x->mul($inv)->mod($m); | |||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||
| 694 | 6 | ▶ | if ($t->{a} == 1 and $t->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$t->{"a"} == 1 and $t->{"b"} == 0
MC/DC0%0/2
$t->{"a"} == 1 and $t->{"b"} == 0
$t->{"a"} == 1
$t->{"b"} == 0
Truth table33%1/3
A and B
A= $t->{"a"} == 1B= $t->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | 6 | return $inv->mod($m); | |||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | # | ||||||||||||||||||||||||||||||||||||||||||
| 703 | ## x^n mod m using the exponentiation by squaring method | ||||||||||||||||||||||||||||||||||||||||||
| 704 | # | ||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | 13 | ▶ | sub powmod ($$$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
powmod: called CC=11 SCAR=27.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | 13 | my ($x, $y, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | 13 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 710 | 13 | ▶ | $m = __PACKAGE__->new($m) if ref($m) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | 13 | $y = CORE::int($y); | |||||||||||||||||||||||||||||||||||||||||
| 713 | 13 | my $neg = $y < 0; | |||||||||||||||||||||||||||||||||||||||||
| 714 | 13 | $y = CORE::int(CORE::abs($y)); | |||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | 13 | ▶ | if ($x->{a} == 0 and $x->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x->{"a"} == 0 and $x->{"b"} == 0
MC/DC0%0/2
$x->{"a"} == 0 and $x->{"b"} == 0
$x->{"a"} == 0
$x->{"b"} == 0
Truth table66%2/3
A and B
A= $x->{"a"} == 0B= $x->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | if ($neg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | return $x->invmod($m); | |||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if ($y == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | return __PACKAGE__->new($x->{a} + 1, $x->{b})->mod($m); | |||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | return $x->mod($m); | |||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 13 | ▶ | $x = $x->invmod($m) if $neg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 13 | ▶ | $x // return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$x // (return undef)
MC/DC0%0/1
$x // (return undef)
$x
Truth table50%1/2
A
A= $x
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | 13 | my $r = __PACKAGE__->new(1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | 13 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 735 | 83 | ▶ | $r = $r->mul($x)->mod($m) if ($y & 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | 83 | ▶ | ($y >>= 1) or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 70 | $x = $x->mul($x)->mod($m); | |||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 13 | $r->mod($m); | |||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | # | ||||||||||||||||||||||||||||||||||||||||||
| 744 | ## root(x, y) = exp(log(x) / y) | ||||||||||||||||||||||||||||||||||||||||||
| 745 | # | ||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | 3 | ▶ | sub root ($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | 3 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | 3 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 3 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | 3 | $x->pow($y->inv); | |||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||
| 756 | # | ||||||||||||||||||||||||||||||||||||||||||
| 757 | ## sqrt(a + b*i) = exp(log(a + b*i) / 2) | ||||||||||||||||||||||||||||||||||||||||||
| 758 | # | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | 133 | ▶ | sub sqrt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sqrt: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 761 | 133 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | 133 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | 133 | my $r = $x->log; | |||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | 133 | $r->{a} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 768 | 133 | $r->{b} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | 133 | $r->exp; | |||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | # | ||||||||||||||||||||||||||||||||||||||||||
| 774 | ## cbrt(a + b*i) = exp(log(a + b*i) / 3) | ||||||||||||||||||||||||||||||||||||||||||
| 775 | # | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | 6 | ▶ | sub cbrt ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cbrt: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 778 | 6 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | 6 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 6 | ▶ | if ($x->{a} == 0 and $x->{b} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$x->{"a"} == 0 and $x->{"b"} == 0
MC/DC0%0/2
$x->{"a"} == 0 and $x->{"b"} == 0
$x->{"a"} == 0
$x->{"b"} == 0
Truth table33%1/3
A and B
A= $x->{"a"} == 0B= $x->{"b"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | return __PACKAGE__->new(0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | 6 | my $r = $x->log; | |||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 6 | $r->{a} /= 3; | |||||||||||||||||||||||||||||||||||||||||
| 789 | 6 | $r->{b} /= 3; | |||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | 6 | $r->exp; | |||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||
| 794 | # | ||||||||||||||||||||||||||||||||||||||||||
| 795 | ## int(a + b*i) = int(a) + int(b)*i | ||||||||||||||||||||||||||||||||||||||||||
| 796 | # | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | 29 | ▶ | sub int { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
int: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 799 | 29 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 29 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | 29 | my $t1 = CORE::int($x->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 804 | 29 | my $t2 = CORE::int($x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||
| 806 | 29 | __PACKAGE__->new($t1, $t2); | |||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | # | ||||||||||||||||||||||||||||||||||||||||||
| 810 | ## round to the nearest Gaussian integer | ||||||||||||||||||||||||||||||||||||||||||
| 811 | # | ||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | 134 | ▶ | sub _round ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_round: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 814 | 134 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 815 | 134 | ▶ | CORE::int(($n + $n + (($n < 0) ? -1 : 1)) / 2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | 67 | ▶ | sub round ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
round: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 819 | 67 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 820 | 67 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 821 | 67 | __PACKAGE__->new(_round($x->{a}), _round($x->{b})); | |||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | # | ||||||||||||||||||||||||||||||||||||||||||
| 825 | ## floor(a + b*i) = floor(a) + floor(b)*i | ||||||||||||||||||||||||||||||||||||||||||
| 826 | # | ||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | 139 | ▶ | sub floor ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
floor: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 829 | 139 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | 139 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | 139 | my $t1 = CORE::int($x->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 834 | 139 | ▶ | $t1 -= 1 if ($x->{a} != $t1 and $x->{a} < 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$x->{"a"} != $t1 and $x->{"a"} < 0
MC/DC100%2/2
$x->{"a"} != $t1 and $x->{"a"} < 0
$x->{"a"} != $t1
$x->{"a"} < 0
Truth table100%3/3
A and B
A= $x->{"a"} != $t1B= $x->{"a"} < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||
| 836 | 139 | my $t2 = CORE::int($x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 837 | 139 | ▶ | $t2 -= 1 if ($x->{b} != $t2 and $x->{b} < 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$x->{"b"} != $t2 and $x->{"b"} < 0
MC/DC100%2/2
$x->{"b"} != $t2 and $x->{"b"} < 0
$x->{"b"} != $t2
$x->{"b"} < 0
Truth table100%3/3
A and B
A= $x->{"b"} != $t2B= $x->{"b"} < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||
| 839 | 139 | __PACKAGE__->new($t1, $t2); | |||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | # | ||||||||||||||||||||||||||||||||||||||||||
| 843 | ## ceil(a + b*i) = -floor(-(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 844 | # | ||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | sub ceil ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ceil: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | my $t = $x->neg->floor; | |||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $t->{a} = -$t->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | $t->{b} = -$t->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | $t; | |||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||
| 859 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 860 | # SIN / SINH / ASIN / ASINH | ||||||||||||||||||||||||||||||||||||||||||
| 861 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | # | ||||||||||||||||||||||||||||||||||||||||||
| 864 | ## sin(a + b*i) = i*(exp(b - i*a) - exp(-b + i*a))/2 | ||||||||||||||||||||||||||||||||||||||||||
| 865 | # | ||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||
| 867 | 11 | ▶ | sub sin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sin: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 11 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | 11 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | 11 | my $t1 = __PACKAGE__->new(+$x->{b}, -$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 873 | 11 | my $t2 = __PACKAGE__->new(-$x->{b}, +$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | 11 | $t1->{a} -= $t2->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 876 | 11 | $t1->{b} -= $t2->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||
| 878 | 11 | $t1->{a} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 879 | 11 | $t1->{b} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | 11 | @{$t1}{qw(a b)} = (-$t1->{b}, $t1->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||
| 883 | 11 | $t1; | |||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | # | ||||||||||||||||||||||||||||||||||||||||||
| 887 | ## sinh(a + b*i) = (exp(2 * (a + b*i)) - 1) / (2*exp(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 888 | # | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | 13 | ▶ | sub sinh ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sinh: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | 13 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||
| 893 | 13 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | 13 | my $t1 = __PACKAGE__->new($x->{a} * 2, $x->{b} * 2)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | 13 | $t1->{a} -= 1; | |||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||
| 899 | 13 | my $t2 = $x->exp; | |||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | 13 | $t2->{a} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 902 | 13 | $t2->{b} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||
| 904 | 13 | $t1->div($t2); | |||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | # | ||||||||||||||||||||||||||||||||||||||||||
| 908 | ## asin(a + b*i) = -i*log(sqrt(1 - (a + b*i)^2) + i*a - b) | ||||||||||||||||||||||||||||||||||||||||||
| 909 | # | ||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | 12 | ▶ | sub asin ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
asin: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 912 | 12 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||
| 914 | 12 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | 12 | my $r = __PACKAGE__->new(1 - ($x->{a} * $x->{a} - $x->{b} * $x->{b}), -($x->{a} * $x->{b} + $x->{b} * $x->{a}))->sqrt; | |||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 12 | $r->{a} -= $x->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 919 | 12 | $r->{b} += $x->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | 12 | $r = $r->log; | |||||||||||||||||||||||||||||||||||||||||
| 922 | 12 | @{$r}{qw(a b)} = ($r->{b}, -$r->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 923 | 12 | $r; | |||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | # | ||||||||||||||||||||||||||||||||||||||||||
| 927 | ## asinh(a + b*i) = log(sqrt((a + b*i)^2 + 1) + (a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 928 | # | ||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | 12 | ▶ | sub asinh ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
asinh: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 931 | 12 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | 12 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | 12 | my $r = __PACKAGE__->new($x->{a} * $x->{a} - $x->{b} * $x->{b} + 1, $x->{a} * $x->{b} + $x->{b} * $x->{a})->sqrt; | |||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | 12 | $r->{a} += $x->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 938 | 12 | $r->{b} += $x->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | 12 | $r->log; | |||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 944 | # COS / COSH / ACOS / ACOSH | ||||||||||||||||||||||||||||||||||||||||||
| 945 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | # | ||||||||||||||||||||||||||||||||||||||||||
| 948 | ## cos(a + b*i) = (exp(-b + i*a) + exp(b - i*a))/2 | ||||||||||||||||||||||||||||||||||||||||||
| 949 | # | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | 20 | ▶ | sub cos { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cos: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | 20 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | 20 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 20 | my $t1 = __PACKAGE__->new(-$x->{b}, +$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 957 | 20 | my $t2 = __PACKAGE__->new(+$x->{b}, -$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||
| 959 | 20 | $t1->{a} += $t2->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 960 | 20 | $t1->{b} += $t2->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||
| 962 | 20 | $t1->{a} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 963 | 20 | $t1->{b} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | 20 | $t1; | |||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | # | ||||||||||||||||||||||||||||||||||||||||||
| 969 | ## cosh(a + b*i) = (exp(2 * (a + b*i)) + 1) / (2*exp(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 970 | # | ||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | 21 | ▶ | sub cosh ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cosh: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 973 | 21 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | 21 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | 21 | my $t1 = __PACKAGE__->new($x->{a} * 2, $x->{b} * 2)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | 21 | $t1->{a} += 1; | |||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | 21 | my $t2 = $x->exp; | |||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | 21 | $t2->{a} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 984 | 21 | $t2->{b} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | 21 | $t1->div($t2); | |||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||
| 989 | # | ||||||||||||||||||||||||||||||||||||||||||
| 990 | ## acos(a + b*i) = -2*i*log(i*sqrt((1 - (a + b*i))/2) + sqrt((1 + (a + b*i))/2)) | ||||||||||||||||||||||||||||||||||||||||||
| 991 | # | ||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||
| 993 | 20 | ▶ | sub acos ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acos: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | 20 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | 20 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | 20 | my $t1 = __PACKAGE__->new((1 - $x->{a}) / 2, $x->{b} / -2)->sqrt; | |||||||||||||||||||||||||||||||||||||||||
| 999 | 20 | my $t2 = __PACKAGE__->new((1 + $x->{a}) / 2, $x->{b} / +2)->sqrt; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 20 | @{$t1}{qw(a b)} = (-$t1->{b}, $t1->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||
| 1003 | 20 | $t1->{a} += $t2->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | 20 | $t1->{b} += $t2->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 20 | my $r = $t1->log; | |||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 20 | $r->{a} *= -2; | |||||||||||||||||||||||||||||||||||||||||
| 1009 | 20 | $r->{b} *= -2; | |||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | 20 | @{$r}{qw(a b)} = (-$r->{b}, $r->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 20 | $r; | |||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | ## acosh(a + b*i) = log((a + b*i) + sqrt((a + b*i) - 1) * sqrt((a + b*i) + 1)) | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 10 | ▶ | sub acosh ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acosh: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 10 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 10 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 10 | my $t1 = __PACKAGE__->new($x->{a} - 1, $x->{b})->sqrt; | |||||||||||||||||||||||||||||||||||||||||
| 1026 | 10 | my $t2 = __PACKAGE__->new($x->{a} + 1, $x->{b})->sqrt; | |||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 10 | my $t3 = $t1->mul($t2); | |||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 10 | $t3->{a} += $x->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1031 | 10 | $t3->{b} += $x->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||
| 1033 | 10 | $t3->log; | |||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | # TAN / TANH / ATAN / ATANH | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | ## tan(a + b*i) = (2*i)/(exp(2*i*(a + b*i)) + 1) - i | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | 10 | ▶ | sub tan ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tan: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 10 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||
| 1047 | 10 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||
| 1049 | 10 | my $r = __PACKAGE__->new(-2 * $x->{b}, 2 * $x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||
| 1051 | 10 | $r->{a} += 1; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | 10 | my $den = $r->{a} * $r->{a} + $r->{b} * $r->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 10 | $r->{a} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1056 | 10 | $r->{b} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | 10 | ▶ | if (!ref($den) and $den == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $den and $den == 0
MC/DC0%0/2
not ref $den and $den == 0
not ref $den
$den == 0
Truth table33%1/3
not(A) and B
A= not ref $denB= $den == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | $r = $r->div($den); | |||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | 10 | $r->{a} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 10 | $r->{b} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1064 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 10 | $r->{a} -= 1; | |||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||
| 1068 | 10 | @{$r}{qw(a b)} = ($r->{b}, $r->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | 10 | $r; | |||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||
| 1073 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1074 | ## tanh(a + b*i) = (exp(2 * (a + b*i)) - 1) / (exp(2 * (a + b*i)) + 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | 13 | ▶ | sub tanh ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tanh: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1078 | 13 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||
| 1080 | 13 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||
| 1082 | 13 | my $t1 = __PACKAGE__->new($x->{a} * 2, $x->{b} * 2)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||
| 1084 | 13 | my $t2 = __PACKAGE__->new($t1->{a} - 1, $t1->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 1085 | 13 | my $t3 = __PACKAGE__->new($t1->{a} + 1, $t1->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||
| 1087 | 13 | $t2->div($t3); | |||||||||||||||||||||||||||||||||||||||||
| 1088 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||
| 1090 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | ## atan(a + b*i) = i * (log(1 - i*(a + b*i)) - log(1 + i*(a + b*i))) / 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||
| 1094 | 16 | ▶ | sub atan ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
atan: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1095 | 16 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 16 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||
| 1099 | 16 | my $t1 = __PACKAGE__->new(+$x->{b} + 1, -$x->{a})->log; | |||||||||||||||||||||||||||||||||||||||||
| 1100 | 16 | my $t2 = __PACKAGE__->new(-$x->{b} + 1, +$x->{a})->log; | |||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||
| 1102 | 16 | $t1->{a} -= $t2->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1103 | 16 | $t1->{b} -= $t2->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 16 | $t1->{a} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1106 | 16 | $t1->{b} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||
| 1108 | 16 | @{$t1}{qw(a b)} = (-$t1->{b}, $t1->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||
| 1110 | 16 | $t1; | |||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||
| 1113 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | ## atan2(a, b) = -i * log((b + a*i) / sqrt(a^2 + b^2)) | ||||||||||||||||||||||||||||||||||||||||||
| 1115 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | 9 | ▶ | sub atan2 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
atan2: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1118 | 9 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | 9 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1121 | 9 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||
| 1123 | 9 | my $t = __PACKAGE__->new($y->{a} - $x->{b}, $x->{a} + $y->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | 9 | $t = $t->div($x->mul($x)->add($y->mul($y))->sqrt)->log; | |||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||
| 1127 | 9 | @{$t}{qw(a b)} = ($t->{b}, -$t->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||
| 1129 | 9 | $t; | |||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||
| 1132 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | ## atanh(a + b*i) = (log(1 + (a + b*i)) - log(1 - (a + b*i))) / 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||
| 1136 | 14 | ▶ | sub atanh ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
atanh: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1137 | 14 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||
| 1139 | 14 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||
| 1141 | 14 | my $t1 = __PACKAGE__->new(1 + $x->{a}, +$x->{b})->log; | |||||||||||||||||||||||||||||||||||||||||
| 1142 | 14 | my $t2 = __PACKAGE__->new(1 - $x->{a}, -$x->{b})->log; | |||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||
| 1144 | 14 | $t1->{a} -= $t2->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1145 | 14 | $t1->{b} -= $t2->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||
| 1147 | 14 | $t1->{a} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1148 | 14 | $t1->{b} /= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||
| 1150 | 14 | $t1; | |||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||
| 1153 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | # COT / COTH / ACOT / ACOTH | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||
| 1157 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | ## cot(a + b*i) = (2*i)/(exp(2*i*(a + b*i)) - 1) + i | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||
| 1161 | 6 | ▶ | sub cot ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cot: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1162 | 6 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||
| 1164 | 6 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||
| 1166 | 6 | my $r = __PACKAGE__->new(-2 * $x->{b}, 2 * $x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||
| 1168 | 6 | $r->{a} -= 1; | |||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | 6 | my $den = $r->{a} * $r->{a} + $r->{b} * $r->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||
| 1172 | 6 | $r->{a} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1173 | 6 | $r->{b} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||
| 1175 | 6 | ▶ | if (!ref($den) and $den == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $den and $den == 0
MC/DC0%0/2
not ref $den and $den == 0
not ref $den
$den == 0
Truth table33%1/3
not(A) and B
A= not ref $denB= $den == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | $r = $r->div($den); | |||||||||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | 6 | $r->{a} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1180 | 6 | $r->{b} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||
| 1183 | 6 | $r->{a} += 1; | |||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||
| 1185 | 6 | @{$r}{qw(a b)} = ($r->{b}, $r->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||
| 1187 | 6 | $r; | |||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||
| 1190 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | ## coth(a + b*i) = (exp(2 * (a + b*i)) + 1) / (exp(2 * (a + b*i)) - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||
| 1194 | 7 | ▶ | sub coth ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coth: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1195 | 7 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||
| 1197 | 7 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||
| 1199 | 7 | my $t1 = __PACKAGE__->new($x->{a} * 2, $x->{b} * 2)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||
| 1201 | 7 | my $t2 = __PACKAGE__->new($t1->{a} + 1, $t1->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 1202 | 7 | my $t3 = __PACKAGE__->new($t1->{a} - 1, $t1->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||
| 1204 | 7 | $t2->div($t3); | |||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||
| 1207 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | ## acot(a + b*i) = atan(1/(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||
| 1211 | 8 | ▶ | sub acot ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acot: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1212 | 8 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | 8 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||
| 1216 | 8 | $x->inv->atan; | |||||||||||||||||||||||||||||||||||||||||
| 1217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||
| 1219 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | ## acoth(a + b*i) = atanh(1 / (a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | 7 | ▶ | sub acoth ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acoth: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1224 | 7 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||
| 1226 | 7 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||
| 1228 | 7 | $x->inv->atanh; | |||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||
| 1231 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1232 | # SEC / SECH / ASEC / ASECH | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||
| 1235 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | ## sec(a + b*i) = 2/(exp(-i*(a + b*i)) + exp(i*(a + b*i))) | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||
| 1239 | 5 | ▶ | sub sec ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sec: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1240 | 5 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||
| 1242 | 5 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||
| 1244 | 5 | my $t1 = __PACKAGE__->new(+$x->{b}, -$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1245 | 5 | my $t2 = __PACKAGE__->new(-$x->{b}, +$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||
| 1247 | 5 | $t1->{a} += $t2->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1248 | 5 | $t1->{b} += $t2->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||
| 1250 | 5 | my $den = $t1->{a} * $t1->{a} + $t1->{b} * $t1->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | 5 | $t1->{a} *= +2; | |||||||||||||||||||||||||||||||||||||||||
| 1253 | 5 | $t1->{b} *= -2; | |||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||
| 1255 | 5 | ▶ | if (!ref($den) and $den == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $den and $den == 0
MC/DC0%0/2
not ref $den and $den == 0
not ref $den
$den == 0
Truth table33%1/3
not(A) and B
A= not ref $denB= $den == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | $t1 = $t1->div($den); | |||||||||||||||||||||||||||||||||||||||||
| 1257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1258 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1259 | 5 | $t1->{a} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 5 | $t1->{b} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||
| 1263 | 5 | $t1; | |||||||||||||||||||||||||||||||||||||||||
| 1264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||
| 1266 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | ## sech(a + b*i) = (2 * exp(a + b*i)) / (exp(2 * (a + b*i)) + 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | 7 | ▶ | sub sech ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sech: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1271 | 7 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||
| 1273 | 7 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||
| 1275 | 7 | my $t1 = $x->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | 7 | my $t2 = __PACKAGE__->new($x->{a} * 2, $x->{b} * 2)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||
| 1278 | 7 | $t1->{a} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1279 | 7 | $t1->{b} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||
| 1281 | 7 | $t2->{a} += 1; | |||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||
| 1283 | 7 | $t1->div($t2); | |||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||
| 1286 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1287 | ## asec(a + b*i) = acos(1/(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||
| 1290 | 4 | ▶ | sub asec ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
asec: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1291 | 4 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||
| 1293 | 4 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||
| 1295 | 4 | $x->inv->acos; | |||||||||||||||||||||||||||||||||||||||||
| 1296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||
| 1298 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1299 | ## asech(a + b*i) = acosh(1/(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 1300 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||
| 1302 | 4 | ▶ | sub asech ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
asech: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1303 | 4 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||
| 1305 | 4 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||
| 1307 | 4 | $x->inv->acosh; | |||||||||||||||||||||||||||||||||||||||||
| 1308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||
| 1310 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | # CSC / CSCH / ACSC / ACSCH | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||
| 1314 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1315 | ## csc(a + b*i) = -(2*i)/(exp(-i * (a + b*i)) - exp(i * (a + b*i))) | ||||||||||||||||||||||||||||||||||||||||||
| 1316 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||
| 1318 | 5 | ▶ | sub csc ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csc: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1319 | 5 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||
| 1321 | 5 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||
| 1323 | 5 | my $t1 = __PACKAGE__->new(+$x->{b}, -$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1324 | 5 | my $t2 = __PACKAGE__->new(-$x->{b}, +$x->{a})->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||
| 1326 | 5 | $t1->{a} -= $t2->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1327 | 5 | $t1->{b} -= $t2->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | 5 | my $den = $t1->{a} * $t1->{a} + $t1->{b} * $t1->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||
| 1331 | 5 | $t1->{a} *= -2; | |||||||||||||||||||||||||||||||||||||||||
| 1332 | 5 | $t1->{b} *= -2; | |||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||
| 1334 | 5 | ▶ | if (!ref($den) and $den == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $den and $den == 0
MC/DC0%0/2
not ref $den and $den == 0
not ref $den
$den == 0
Truth table33%1/3
not(A) and B
A= not ref $denB= $den == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | $t1 = $t1->div($den); | |||||||||||||||||||||||||||||||||||||||||
| 1336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1337 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1338 | 5 | $t1->{a} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1339 | 5 | $t1->{b} /= $den; | |||||||||||||||||||||||||||||||||||||||||
| 1340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||
| 1342 | 5 | @{$t1}{qw(a b)} = ($t1->{b}, $t1->{a}); | |||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||
| 1344 | 5 | $t1; | |||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||
| 1347 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | ## csch(a + b*i) = (2*exp(a + b*i)) / (exp(2 * (a + b*i)) - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||
| 1351 | 7 | ▶ | sub csch ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1352 | 7 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||
| 1354 | 7 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||
| 1356 | 7 | my $t1 = $x->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1357 | 7 | my $t2 = __PACKAGE__->new($x->{a} * 2, $x->{b} * 2)->exp; | |||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||
| 1359 | 7 | $t1->{a} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1360 | 7 | $t1->{b} *= 2; | |||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||
| 1362 | 7 | $t2->{a} -= 1; | |||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | 7 | $t1->div($t2); | |||||||||||||||||||||||||||||||||||||||||
| 1365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||
| 1367 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1368 | ## acsc(a + b*i) = asin(1/(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 1369 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||
| 1371 | 4 | ▶ | sub acsc ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acsc: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1372 | 4 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||
| 1374 | 4 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||
| 1376 | 4 | $x->inv->asin; | |||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||
| 1379 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1380 | ## acsch(a + b*i) = asinh(1/(a + b*i)) | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||
| 1383 | 5 | ▶ | sub acsch ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acsch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1384 | 5 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||
| 1386 | 5 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||
| 1388 | 5 | $x->inv->asinh; | |||||||||||||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||
| 1391 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | ## deg2rad(x) = x / 180 * atan2(0, -abs(x)) | ||||||||||||||||||||||||||||||||||||||||||
| 1393 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | 7 | ▶ | sub deg2rad ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deg2rad: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1396 | 7 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||
| 1398 | 7 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||||||||||
| 1400 | 7 | my $t = __PACKAGE__->new($x->{a} / 180, $x->{b} / 180); | |||||||||||||||||||||||||||||||||||||||||
| 1401 | 7 | my $pi = CORE::atan2(0, -($x->{a} * $x->{a} + $x->{b} * $x->{b})); | |||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||
| 1403 | 7 | ▶ | if (!ref($pi)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1404 | 7 | $t->{a} *= $pi; | |||||||||||||||||||||||||||||||||||||||||
| 1405 | 7 | $t->{b} *= $pi; | |||||||||||||||||||||||||||||||||||||||||
| 1406 | 7 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 1407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | $t->mul($pi); | |||||||||||||||||||||||||||||||||||||||||
| 1410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||
| 1412 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | ## rad2deg(x) = x * 180 / atan2(0, -abs(x)) | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||
| 1416 | 7 | ▶ | sub rad2deg ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rad2deg: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1417 | 7 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||
| 1419 | 7 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||
| 1421 | 7 | my $r = __PACKAGE__->new($x->{a} * 180, $x->{b} * 180); | |||||||||||||||||||||||||||||||||||||||||
| 1422 | 7 | my $t = $x->{a} * $x->{a} + $x->{b} * $x->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||
| 1424 | 7 | ▶ | if ($t == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1425 | 3 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||
| 1428 | 4 | my $pi = CORE::atan2(0, -$t); | |||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||
| 1430 | 4 | ▶ | if (!ref($pi) and $pi != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $pi and $pi != 0
MC/DC0%0/2
not ref $pi and $pi != 0
not ref $pi
$pi != 0
Truth table33%1/3
not(A) and B
A= not ref $piB= $pi != 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1431 | 4 | $r->{a} /= $pi; | |||||||||||||||||||||||||||||||||||||||||
| 1432 | 4 | $r->{b} /= $pi; | |||||||||||||||||||||||||||||||||||||||||
| 1433 | 4 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 1434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | $r->div($pi); | |||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||
| 1439 | ########################### MISC FUNCTIONS ########################### | ||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||
| 1441 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1442 | ## real(a + b*i) = a | ||||||||||||||||||||||||||||||||||||||||||
| 1443 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||
| 1445 | 14 | ▶ | sub real ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
real: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1446 | 14 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||
| 1448 | 14 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||
| 1450 | 14 | $x->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||
| 1453 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1454 | ## imag(a + b*i) = b | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||||||||||||||||
| 1457 | 14 | ▶ | sub imag ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
imag: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1458 | 14 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||
| 1460 | 14 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||
| 1462 | 14 | $x->{b}; | |||||||||||||||||||||||||||||||||||||||||
| 1463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1464 | |||||||||||||||||||||||||||||||||||||||||||
| 1465 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1466 | ## reals(a + b*i) = (a, b) | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||||||||||||
| 1469 | 14 | ▶ | sub reals ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reals: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1470 | 14 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||
| 1472 | 14 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||
| 1474 | 14 | ($x->{a}, $x->{b}); | |||||||||||||||||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||
| 1477 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1478 | ## Equality | ||||||||||||||||||||||||||||||||||||||||||
| 1479 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||
| 1481 | 5 | ▶ | sub eq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eq: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1482 | 5 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||||||||||||||||
| 1484 | 5 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1485 | 5 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||
| 1487 | $x->{a} == $y->{a} | ||||||||||||||||||||||||||||||||||||||||||
| 1488 | 5 | ▶ | and $x->{b} == $y->{b}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||
| 1491 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | ## Inequality | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | ▶ | sub ne { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ne: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||
| 1501 | $x->{a} != $y->{a} | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | ▶ | or $x->{b} != $y->{b}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||
| 1505 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1506 | ## Comparisons | ||||||||||||||||||||||||||||||||||||||||||
| 1507 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||
| 1509 | 31 | ▶ | sub cmp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmp: called CC=6 SCAR=19.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1510 | 31 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||
| 1512 | 31 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1513 | 31 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||
| 1515 | (($x->{a} <=> $y->{a}) // return undef) | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | 31 | ▶ | or (($x->{b} <=> $y->{b}) // return undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition57%4/7
($x->{'a'} <=> $y->{'a'} // (return undef)) || ($x->{'b'} <=> $y->{'b'} // (return undef))
$x->{"a"} <=> $y->{"a"} // (return undef)
$x->{"b"} <=> $y->{"b"} // (return undef)
MC/DC0%0/2
($x->{'a'} <=> $y->{'a'} // (return undef)) || ($x->{'b'} <=> $y->{'b'} // (return undef))
$x->{"a"} <=> $y->{"a"}
$x->{"b"} <=> $y->{"b"}
Truth table33%1/3
A || B
A= $x->{"a"} <=> $y->{"a"}B= $x->{"b"} <=> $y->{"b"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1517 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | ▶ | sub acmp ($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acmp: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||
| 1522 | 0 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||||||||||||||||
| 1525 | 0 | $x->abs <=> $y->abs; | |||||||||||||||||||||||||||||||||||||||||
| 1526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||
| 1528 | 29 | ▶ | sub lt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lt: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1529 | 29 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||||||||||||||||
| 1531 | 29 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1532 | 29 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||
| 1534 | 29 | ▶ | ($x->cmp($y) // return undef) < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$x->cmp($y) // (return undef)
MC/DC0%0/1
$x->cmp($y) // (return undef)
$x->cmp($y)
Truth table50%1/2
A
A= $x->cmp($y)
| |||||||||||||||||||||||||||||||||||||||||||
| 1535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||
| 1537 | 0 | ▶ | sub le { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
le: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | ($x->cmp($y) // return undef) <= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$x->cmp($y) // (return undef)
MC/DC0%0/1
$x->cmp($y) // (return undef)
$x->cmp($y)
Truth table0%0/2
A
A= $x->cmp($y)
| |||||||||||||||||||||||||||||||||||||||||||
| 1544 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | ▶ | sub gt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gt: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1547 | 0 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1550 | 0 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | ▶ | ($x->cmp($y) // return undef) > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$x->cmp($y) // (return undef)
MC/DC0%0/1
$x->cmp($y) // (return undef)
$x->cmp($y)
Truth table0%0/2
A
A= $x->cmp($y)
| |||||||||||||||||||||||||||||||||||||||||||
| 1553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||
| 1555 | 2 | ▶ | sub ge { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ge: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1556 | 2 | my ($x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||||||||||||||||
| 1558 | 2 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1559 | 2 | ▶ | $y = __PACKAGE__->new($y) if ref($y) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||
| 1561 | 2 | ▶ | ($x->cmp($y) // return undef) >= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$x->cmp($y) // (return undef)
MC/DC0%0/1
$x->cmp($y) // (return undef)
$x->cmp($y)
Truth table50%1/2
A
A= $x->cmp($y)
| |||||||||||||||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||
| 1564 | 68 | ▶ | sub stringify { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1565 | 68 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||
| 1567 | 68 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||
| 1569 | 68 | "($x->{a} $x->{b})"; | |||||||||||||||||||||||||||||||||||||||||
| 1570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||||||||||||||||
| 1572 | 174 | ▶ | sub boolify { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
boolify: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1573 | 174 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||
| 1575 | 174 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||
| 1577 | 174 | ▶ | !!$x->{a} or !!$x->{b}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
!$x->{'a'} && !$x->{'b'}
MC/DC0%0/2
!$x->{'a'} && !$x->{'b'}
!$x->{'a'}
!$x->{'b'}
Truth table33%1/3
not(A) && not(B)
A= !$x->{'a'}B= !$x->{'b'}
| |||||||||||||||||||||||||||||||||||||||||||
| 1578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||||||||||||||||
| 1580 | 13 | ▶ | sub numify { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numify: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1581 | 13 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||
| 1583 | 13 | ▶ | $x = __PACKAGE__->new($x) if ref($x) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||
| 1585 | 13 | $x->{a}; | |||||||||||||||||||||||||||||||||||||||||
| 1586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | |||||||||||||||||||||||||||||||||||||||||||
| 1588 | 3 | 1; # End of Math::GComplex | |||||||||||||||||||||||||||||||||||||||||