| 1 | package Statistics::R::REXP::Complex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: an R numeric vector | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | $Statistics::R::REXP::Complex::VERSION = '1.0002'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use 5.010; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use Scalar::Util qw(blessed looks_like_number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use Math::Complex qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Class::Tiny::Antlers qw(-default around); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use namespace::clean; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 12 | extends 'Statistics::R::REXP::Vector'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | ▶ | use overload; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 12 | ▶ | use constant sexptype => 'CPLXSXP'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 194 | ▶ | sub BUILDARGS { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=5 SCAR=16.1
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 194 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 194 | my $attributes = $class->SUPER::BUILDARGS(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 193 | ▶ | if (ref($attributes->{elements}) eq 'ARRAY') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | $attributes->{elements} = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 318 | ▶ | map { (blessed($_) && $_->isa('Math::Complex')) ? $_ : | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
builtin::blessed($_) and $_->isa("Math::Complex")
MC/DC50%1/2
builtin::blessed($_) and $_->isa("Math::Complex")
builtin::blessed($_)
$_->isa("Math::Complex")
Truth table66%2/3
A and B
A= builtin::blessed($_)B= $_->isa("Math::Complex")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | looks_like_number $_ ? Math::Complex::cplx($_) : | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | undef } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 179 | Statistics::R::REXP::Vector::_flatten(@{$attributes->{elements}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | $attributes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 190 | ▶ | sub BUILD { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=6 SCAR=22.1
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 190 | my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Required attribute type | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | die "Elements of the 'elements' attribute must be scalar numbers or instances of Math::Complex" if | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | defined $self->elements && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 318 | ▶ | grep { defined($_) && !(blessed($_) && $_->isa('Math::Complex') || | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition44%4/9
defined $_ && !(builtin::blessed($_) && $_->isa('Math::Complex') || &Scalar::Util::looks_like_number($_))
builtin::blessed($_) && $_->isa('Math::Complex') || &Scalar::Util::looks_like_number($_)
builtin::blessed($_) and $_->isa("Math::Complex")
MC/DC0%0/4
defined $_ && !(builtin::blessed($_) && $_->isa('Math::Complex') || &Scalar::Util::looks_like_number($_))
defined $_
builtin::blessed($_)
$_->isa("Math::Complex")
&Scalar::Util::looks_like_number($_)
Truth table33%2/6
A && not(B and C || D)
A= defined $_B= builtin::blessed($_)C= $_->isa("Math::Complex")D= &Scalar::Util::looks_like_number($_)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | Scalar::Util::looks_like_number($_)) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 190 | ▶ | @{$self->elements} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->elements and grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
MC/DC0%0/2
defined $self->elements and grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
defined $self->elements
grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
Truth table33%1/3
A and B
A= defined $self->elementsB= grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 123 | ▶ | around _eq => sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 123 | my $orig = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 123 | ▶ | return unless Statistics::R::REXP::_eq(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 121 | my ($self, $obj) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 121 | my $a = $self->elements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 121 | my $b = $obj->elements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 121 | ▶ | return undef unless scalar(@$a) == scalar(@$b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 121 | ▶ | for (my $i = 0; $i < scalar(@{$a}); $i++) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 196 | my $x = $a->[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 196 | my $y = $b->[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 196 | ▶ | if (defined($x) && defined($y)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $x and defined $y
MC/DC50%1/2
defined $x and defined $y
defined $x
defined $y
Truth table66%2/3
A and B
A= defined $xB= defined $y
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | return undef unless | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 177 | ▶ | $x == $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 19 | ▶ | return undef if defined($x) or defined($y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $x or defined $y
MC/DC50%1/2
defined $x or defined $y
defined $x
defined $y
Truth table66%2/3
A or B
A= defined $xB= defined $y
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 119 | 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | ▶ | sub _type { 'complex'; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_type: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | 1; # End of Statistics::R::REXP::Complex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | __END__ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||