| 1 | package Music::CreatingRhythms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:GENE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Combinatorial algorithms to generate rhythms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.0808'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Algorithm::Combinatorics qw(permutations); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Data::Munge qw(list2re); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Integer::Partition (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use List::Util qw(all any); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Math::Sequence::DeBruijn qw(debruijn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Module::Load::Conditional qw(check_install); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Music::AtonalUtil (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use if defined check_install(module => 'Math::NumSeq::SqrtContinued'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | 'Math::NumSeq::SqrtContinued'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | has verbose => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 28 | ▶ | isa => sub { die "$_[0] is not a boolean" unless $_[0] =~ /^[01]$/ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 27 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | ▶ | sub b2int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b2int: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 9 | my ($self, $sequences) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | my @intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | for my $i (@$sequences) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 14 | my $string = join '', @$i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 14 | push @intervals, [ map { length $_ } grep { $_ } split /(10*)/, $string ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 9 | return \@intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | ▶ | sub cfcv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cfcv: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | my ($self, @terms) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 5 | my $p0 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | my $p1 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | my $p2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | my $q0 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | my $q1 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | my $q2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | for my $t (@terms) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 17 | $p2 = $t * $p1 + $p0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 17 | $q2 = $t * $q1 + $q0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 17 | $p0 = $p1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 17 | $p1 = $p2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 17 | $q0 = $q1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 17 | $q1 = $q2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | return [ $p2, $q2 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub cfsqrt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cfsqrt: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $m ||= $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$m ||= $n
MC/DC0%0/2
$m ||= $n
$m
$n
Truth table0%0/3
A ||= B
A= $mB= $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my @terms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $seq = Math::NumSeq::SqrtContinued->new(sqrt => $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | for my $i (1 .. $m) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my ($j, $value) = $seq->next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | push @terms, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return \@terms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 16 | ▶ | sub chsequl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chsequl: called CC=13 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 16 | my ($self, $t, $p, $q, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 16 | ▶ | die "Usage: chsequl(\$type, \$numerator, \$denominator [\$terms])\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$t and defined $p and defined $q
$t and defined $p
MC/DC0%0/3
$t and defined $p and defined $q
$t
defined $p
defined $q
Truth table25%1/4
A and B and C
A= $tB= defined $pC= defined $q
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | unless $t && defined $p && defined $q; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 16 | ▶ | $n ||= $p + $q; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$n ||= $p + $q
MC/DC0%0/2
$n ||= $p + $q
$n
$p + $q
Truth table66%2/3
A ||= B
A= $nB= $p + $q
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 16 | my @word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 16 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 16 | ▶ | while ($i < $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 18 | ▶ | push @word, $t eq 'u' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 18 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | my ($x, $y) = ($p, $q); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 18 | ▶ | while ($x != $y && $i < $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$x != $y and $i < $n
MC/DC100%2/2
$x != $y and $i < $n
$x != $y
$i < $n
Truth table100%3/3
A and B
A= $x != $yB= $i < $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 40 | ▶ | if ($x > $y) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 28 | push @word, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 28 | $y += $q; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 12 | push @word, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 12 | $x += $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 40 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 18 | ▶ | if ($x == $y && $i < $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x == $y and $i < $n
MC/DC50%1/2
$x == $y and $i < $n
$x == $y
$i < $n
Truth table66%2/3
A and B
A= $x == $yB= $i < $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | ▶ | push @word, $t eq 'u' ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 12 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 16 | return \@word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | ▶ | sub comp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | my @compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | my @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 4 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | _compose($n - 1, 1, 0, \$i, \@compositions, \@parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | return \@compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 26 | ▶ | sub _compose { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 26 | my ($n, $p, $k, $i, $compositions, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 26 | ▶ | if ($n == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 15 | ▶ | while ($n < $k) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 17 | push @{ $compositions->[$$i] }, $parts->[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 17 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 15 | push @{ $compositions->[$$i] }, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 15 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 15 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 11 | $parts->[$k] = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 11 | _compose($n - 1, 1, $k + 1, $i, $compositions, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 11 | _compose($n - 1, $p + 1, $k, $i, $compositions, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 7 | ▶ | sub compa { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compa: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 7 | my ($self, $n, @intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | my @compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | my @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 | _composea($n - 1, 1, 0, \$i, \@compositions, \@parts, \@intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | return \@compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 49 | ▶ | sub _composea { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_composea: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 49 | my ($n, $p, $k, $i, $compositions, $parts, $intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 49 | ▶ | if ($n == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 25 | ▶ | if (_allowed($p, $intervals)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 16 | ▶ | while ($n < $k) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 27 | push @{ $compositions->[$$i] }, $parts->[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 27 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 16 | push @{ $compositions->[$$i] }, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 16 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 25 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 24 | ▶ | if (_allowed($p, $intervals)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 18 | $parts->[$k] = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 18 | _composea($n - 1, 1, $k + 1, $i, $compositions, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 24 | _composea($n - 1, $p + 1, $k, $i, $compositions, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 7 | ▶ | sub compam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compam: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 7 | my ($self, $n, $m, @intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 7 | $m--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | my @compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | my @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 7 | _composeam($n - 1, 1, 0, $m, \$i, \@compositions, \@parts, \@intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 7 | return \@compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 44 | ▶ | sub _composeam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_composeam: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 44 | my ($n, $p, $k, $m, $i, $compositions, $parts, $intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 44 | ▶ | if ($n == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 21 | ▶ | if ($k == $m && _allowed($p, $intervals)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$k == $m and _allowed($p, $intervals)
MC/DC50%1/2
$k == $m and _allowed($p, $intervals)
$k == $m
_allowed($p, $intervals)
Truth table66%2/3
A and B
A= $k == $mB= _allowed($p, $intervals)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 10 | ▶ | while ($n < $k) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 15 | push @{ $compositions->[$$i] }, $parts->[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 15 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 10 | push @{ $compositions->[$$i] }, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 10 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 21 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 23 | ▶ | if ($k < $m && _allowed($p, $intervals)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k < $m and _allowed($p, $intervals)
MC/DC100%2/2
$k < $m and _allowed($p, $intervals)
$k < $m
_allowed($p, $intervals)
Truth table100%3/3
A and B
A= $k < $mB= _allowed($p, $intervals)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 14 | $parts->[$k] = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 14 | _composeam($n - 1, 1, $k + 1, $m, $i, $compositions, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 23 | _composeam($n - 1, $p + 1, $k, $m, $i, $compositions, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | ▶ | sub compm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compm: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 7 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 7 | $m--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 7 | my @compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | my @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 7 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | _composem($n - 1, 1, 0, $m, \$i, \@compositions, \@parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 7 | return \@compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 57 | ▶ | sub _composem { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_composem: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 57 | my ($n, $p, $k, $m, $i, $compositions, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 57 | ▶ | if ($n == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 22 | ▶ | if ($k == $m) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 16 | ▶ | while ($n < $k) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 15 | push @{ $compositions->[$$i] }, $parts->[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 15 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 16 | push @{ $compositions->[$$i] }, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 16 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 22 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 35 | ▶ | if ($k < $m) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 15 | $parts->[$k] = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 15 | _composem($n - 1, 1, $k + 1, $m, $i, $compositions, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 35 | _composem($n - 1, $p + 1, $k, $m, $i, $compositions, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3 | ▶ | sub compmrnd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compmrnd: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | return [0] unless $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | my @compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | my ($p, $j, $np); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | for(my $mp = $m - 1, $np = $n - 1, $j = 1; $mp > 0; --$np) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 3 | $p = $mp / $np; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 3 | ▶ | if ($p % 2 == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 3 | push @compositions, $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 3 | $mp--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 3 | $j = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | push @compositions, $j + $np; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | return \@compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | ▶ | sub comprnd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comprnd: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | return [0] unless $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | my @compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | my $p = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | for my $i (1 .. $n - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 15 | ▶ | if ((int rand 2) % 2 == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | $p++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 9 | push @compositions, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 9 | $p = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | push @compositions, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | return \@compositions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 12 | ▶ | sub count_digits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_digits: called CC=14 SCAR=40.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 12 | my ($self, $digit, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 12 | my $x = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 12 | ▶ | if (ref $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 6 | for my $i (@$n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 10 | ▶ | $x++ if $i == $digit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 6 | ▶ | if ($digit == 0) { $x = $n =~ tr/0// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | elsif ($digit == 1) { $x = $n =~ tr/1// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | elsif ($digit == 2) { $x = $n =~ tr/2// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | elsif ($digit == 3) { $x = $n =~ tr/3// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | elsif ($digit == 4) { $x = $n =~ tr/4// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | elsif ($digit == 5) { $x = $n =~ tr/5// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | elsif ($digit == 6) { $x = $n =~ tr/6// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | elsif ($digit == 7) { $x = $n =~ tr/7// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | elsif ($digit == 8) { $x = $n =~ tr/8// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | elsif ($digit == 9) { $x = $n =~ tr/9// } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 12 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 6 | ▶ | sub count_ones { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_ones: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 6 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 6 | return $self->count_digits(1, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 6 | ▶ | sub count_zeros { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_zeros: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 6 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 6 | return $self->count_digits(0, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 4 | ▶ | sub de_bruijn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
de_bruijn: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 4 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 4 | ▶ | my $sequence = $n ? debruijn([1,0], $n) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 4 | return [ split //, $sequence ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 7 | ▶ | sub euclid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
euclid: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 7 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 7 | my $intercept = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 7 | my $slope = $n / $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 7 | my @pattern = ('0') x $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 7 | for my $y ( 1 .. $n ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 13 | $pattern[ sprintf '%.0f', ( $y - $intercept ) / $slope ] = '1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 7 | return \@pattern; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | ▶ | sub int2b { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
int2b: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | my ($self, $intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | my @sequences; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | for my $i (@$intervals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 4 | my @bitstring; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 4 | for my $j (@$i) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 6 | my $bits = '1' . '0' x ($j - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 6 | push @bitstring, split //, $bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 4 | push @sequences, \@bitstring; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 2 | return \@sequences; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 6 | ▶ | sub invert_at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invert_at: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | my ($self, $n, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | my @head = @$parts[ 0 .. $n - 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | ▶ | my @tail = map { $_ ? 0 : 1 } @$parts[ $n .. $#$parts ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 6 | my @data = (@head, @tail); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 6 | return \@data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 4 | ▶ | sub neck { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
neck: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 4 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 4 | my @necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 4 | my @parts = (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 4 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 4 | _neckbin($n, 1, 1, \$i, \@necklaces, \@parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | return \@necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 39 | ▶ | sub _neckbin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_neckbin: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 39 | my ($n, $k, $l, $i, $necklaces, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # k = length of necklace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # l = length of longest prefix that is a lyndon word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 39 | ▶ | if ($k > $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 18 | ▶ | if(($n % $l) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 15 | for $k (1 .. $n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 44 | push @{ $necklaces->[$$i] }, $parts->[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 15 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 21 | $parts->[$k] = $parts->[ $k - $l ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 21 | ▶ | if ($parts->[$k] == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 14 | _neckbin($n, $k + 1, $l, $i, $necklaces, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 14 | $parts->[$k] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 14 | _neckbin($n, $k + 1, $k, $i, $necklaces, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 7 | _neckbin($n, $k + 1, $l, $i, $necklaces, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 7 | ▶ | sub necka { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
necka: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 7 | my ($self, $n, @intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 7 | my @necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 7 | my @parts = (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 7 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 7 | _neckbina($n, 1, 1, 1, \$i, \@necklaces, \@parts, \@intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 7 | return \@necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 73 | ▶ | sub _neckbina { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_neckbina: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 73 | my ($n, $k, $l, $p, $i, $necklaces, $parts, $intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 73 | ▶ | if ($k > $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 30 | ▶ | if (($n % $l) == 0 && _allowed($p, $intervals) && $p <= $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$n % $l == 0 and _allowed($p, $intervals) and $p <= $n
$n % $l == 0 and _allowed($p, $intervals)
MC/DC100%3/3
$n % $l == 0 and _allowed($p, $intervals) and $p <= $n
$n % $l == 0
_allowed($p, $intervals)
$p <= $n
Truth table100%4/4
A and B and C
A= $n % $l == 0B= _allowed($p, $intervals)C= $p <= $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 11 | for $k (1 .. $n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 38 | push @{ $necklaces->[$$i] }, $parts->[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 11 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 43 | $parts->[$k] = $parts->[ $k - $l ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 43 | ▶ | if ($parts->[$k] == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 29 | ▶ | if (_allowed($p, $intervals) || $k == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
_allowed($p, $intervals) or $k == 1
MC/DC100%2/2
_allowed($p, $intervals) or $k == 1
_allowed($p, $intervals)
$k == 1
Truth table100%3/3
A or B
A= _allowed($p, $intervals)B= $k == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 23 | _neckbina($n, $k + 1, $l, 1, $i, $necklaces, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 29 | $parts->[$k] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 29 | _neckbina($n, $k + 1, $k, $p + 1, $i, $necklaces, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 14 | _neckbina($n, $k + 1, $l, $p + 1, $i, $necklaces, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 7 | ▶ | sub neckam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
neckam: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 7 | my ($self, $n, $m, @intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 7 | my @necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 7 | my @parts = (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 7 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 7 | _neckbinam($n, 1, 1, 0, 1, $m, \$i, \@necklaces, \@parts, \@intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 7 | return \@necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 74 | ▶ | sub _neckbinam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_neckbinam: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 74 | my ($n, $k, $l, $q, $p, $m, $i, $necklaces, $parts, $intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 74 | ▶ | if ($k > $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 31 | ▶ | if(($n % $l) == 0 && _allowed($p, $intervals) && $p <= $n && $q == $m) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$n % $l == 0 and _allowed($p, $intervals) and $p <= $n and $q == $m
$n % $l == 0 and _allowed($p, $intervals) and $p <= $n
$n % $l == 0 and _allowed($p, $intervals)
MC/DC75%3/4
$n % $l == 0 and _allowed($p, $intervals) and $p <= $n and $q == $m
$n % $l == 0
_allowed($p, $intervals)
$p <= $n
$q == $m
Truth table80%4/5
A and B and C and D
A= $n % $l == 0B= _allowed($p, $intervals)C= $p <= $nD= $q == $m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 7 | for $k (1 .. $n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 22 | push @{ $necklaces->[$$i] }, $parts->[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 7 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 43 | $parts->[$k] = $parts->[ $k - $l ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 43 | ▶ | if ($parts->[$k] == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 29 | ▶ | if (_allowed($p, $intervals) || $k == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
_allowed($p, $intervals) or $k == 1
MC/DC50%1/2
_allowed($p, $intervals) or $k == 1
_allowed($p, $intervals)
$k == 1
Truth table66%2/3
A or B
A= _allowed($p, $intervals)B= $k == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 24 | _neckbinam($n, $k + 1, $l, $q + 1, 1, $m, $i, $necklaces, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 29 | $parts->[$k] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 29 | _neckbinam($n, $k + 1, $k, $q, $p + 1, $m, $i, $necklaces, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 14 | _neckbinam($n, $k + 1, $l, $q, $p + 1, $m, $i, $necklaces, $parts, $intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 7 | ▶ | sub neckm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
neckm: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 7 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 7 | my @necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 7 | my @parts = (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 7 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 7 | _neckbinm($n, 1, 1, 0, $m, \$i, \@necklaces, \@parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 7 | return \@necklaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 131 | ▶ | sub _neckbinm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_neckbinm: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 131 | my ($n, $k, $l, $p, $m, $i, $necklaces, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # k = length of necklace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # l = length of longest prefix that is a lyndon word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # p = number of parts (ones) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 131 | ▶ | if ($k > $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 57 | ▶ | if (($n % $l) == 0 && $p == $m) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$n % $l == 0 and $p == $m
MC/DC100%2/2
$n % $l == 0 and $p == $m
$n % $l == 0
$p == $m
Truth table100%3/3
A and B
A= $n % $l == 0B= $p == $m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 10 | for $k (1 .. $n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 42 | push @{ $necklaces->[$$i] }, $parts->[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 10 | $$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 74 | $parts->[$k] = $parts->[ $k - $l ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 74 | ▶ | if ($parts->[$k] == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 50 | _neckbinm($n, $k + 1, $l, $p + 1, $m, $i, $necklaces, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 50 | $parts->[$k] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 50 | _neckbinm($n, $k + 1, $k, $p, $m, $i, $necklaces, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 24 | _neckbinm($n, $k + 1, $l, $p, $m, $i, $necklaces, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 4 | ▶ | sub part { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 4 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 4 | my $i = Integer::Partition->new($n, { lexicographic => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 4 | my @partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 4 | ▶ | while (my $p = $i->next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 11 | push @partitions, [ sort { $a <=> $b } @$p ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 4 | return \@partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 7 | ▶ | sub parta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parta: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 7 | my ($self, $n, @parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 7 | my $re = list2re @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 7 | my $i = Integer::Partition->new($n, { lexicographic => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 7 | my @partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 7 | ▶ | while (my $p = $i->next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 24 | push @partitions, [ sort { $a <=> $b } @$p ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 22 | ▶ | if all { $_ =~ /^$re$/ } @$p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 7 | return \@partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 7 | ▶ | sub partam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
partam: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 7 | my ($self, $n, $m, @parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 7 | my $re = list2re @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 7 | my $i = Integer::Partition->new($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 7 | my @partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 7 | ▶ | while (my $p = $i->next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 13 | push @partitions, [ sort { $a <=> $b } @$p ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 22 | ▶ | if @$p == $m && all { $_ =~ /^$re$/ } @$p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition66%2/3
@$p == $m and &all(sub {
$_ =~ /^$re$/;
}
, @$p)
MC/DC50%1/2
@$p == $m and &all(sub {
$_ =~ /^$re$/;
}
, @$p)
@$p == $m
&all(sub {
$_ =~ /^$re$/;
}
, @$p)
Truth table66%2/3
A and B
A= @$p == $mB= &all(sub {
$_ =~ /^$re$/;
}
, @$p)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 7 | return \@partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 7 | ▶ | sub partm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
partm: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 7 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 7 | my $i = Integer::Partition->new($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 7 | my @partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 7 | ▶ | while (my $p = $i->next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 30 | ▶ | push @partitions, [ sort { $a <=> $b } @$p ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | if @$p == $m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 7 | return \@partitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1 | ▶ | sub permi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
permi: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | my ($self, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | my @permutations = permutations($parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | return \@permutations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 7 | ▶ | sub pfold { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pfold: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 7 | my ($self, $n, $m, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 7 | my @sequence; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 7 | my ($j, $k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 7 | ▶ | for (my $i = 1; $i <= $n; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 40 | _oddeven($i, \$k, \$j); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 40 | $k = $k % $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 40 | ▶ | my $y = $f & (1 << $k) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 40 | ▶ | if ((2 * $j + 1) % 4 > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 16 | $y = 1 - $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 40 | push @sequence, $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 7 | return \@sequence; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # find x and y such that n = 2^x * (2*y+1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 40 | ▶ | sub _oddeven { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_oddeven: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 40 | my ($n, $x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 40 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # two's complement of n = -n or ~n + 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 40 | my $l = $n & -$n; # this is 2^a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 40 | $$y = ($n / $l - 1) / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 40 | ▶ | for ($k = 0; $l > 1; ++$k) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 27 | $l >>= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 40 | $$x = $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 40 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 5 | ▶ | sub reverse_at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reverse_at: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 5 | my ($self, $n, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 5 | my @head = @$parts[ 0 .. $n - 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 5 | my @tail = reverse @$parts[ $n .. $#$parts ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 5 | my @data = (@head, @tail); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 5 | return \@data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 6 | ▶ | sub rotate_n { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rotate_n: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 6 | my ($self, $n, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 6 | my $atu = Music::AtonalUtil->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 6 | my $sequence = $atu->rotate($n, $parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 6 | return $sequence; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 191 | ▶ | sub _allowed { # is p one of the parts? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_allowed: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 191 | my ($p, $parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 191 | ▶ | return any { $p == $_ } @$parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||