Infinite.pm

filter: Statementstmt 88.0% 733 / 833 Branchbran 67.4% 317 / 470 Conditioncond 75.4% 77 / 102 MC/DCmcdc 60.3% 38 / 63 Subroutinesub 84.5% 60 / 71 Podpod 75.8% 22 / 29 totaltotal 79.5% 1247 / 1568 CC 280 SCAR 26.4
CC
280
Cov
80%
__ANON__
40.3
trace_close
30.0
__ANON__
30.0
CRAP 14.0
« Infinite/Arithmetic.pm ↑ Summary Infinite/Basic.pm »
1 package Set::Infinite;
2  
3 # Copyright (c) 2001, 2002, 2003, 2004 Flavio Soibelmann Glock.
4 # All rights reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the same terms as Perl itself.
7  
8 11 ▶use 5.005_03;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # These methods are inherited from Set::Infinite::Basic "as-is":
11 # type list fixtype numeric min max integer real new span copy
12 # start_set end_set universal_set empty_set minus difference
13 # symmetric_difference is_empty
14  
15 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 11 ▶use base qw(Set::Infinite::Basic Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 11 ▶use Set::Infinite::Arithmetic;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 use overload
21 11 ▶ '<=>' => \&spaceship,
Subroutine BEGIN: called CC=1 SCAR=0.0
22 11 '""' => \&as_string;
23  
24 11 ▶use vars qw(@EXPORT_OK $VERSION
Subroutine BEGIN: called CC=1 SCAR=0.0
25 $TRACE $DEBUG_BT $PRETTY_PRINT $inf $minus_inf $neg_inf
26 %_first %_last %_backtrack
27 $too_complex $backtrack_depth
28 $max_backtrack_depth $max_intersection_depth
29 11 $trace_level %level_title );
30  
31 11 @EXPORT_OK = qw(inf $inf trace_open trace_close);
32  
33 11 $inf = 100**100**100;
34 11 $neg_inf = $minus_inf = -$inf;
35  
36  
37 # obsolete methods - included for backward compatibility
38 0 ▶sub inf () { $inf }
Subroutine inf: not called CC=1 SCAR=6.9
Pod undocumented
39 0 ▶sub minus_inf () { $minus_inf }
Subroutine minus_inf: not called CC=1 SCAR=6.9
Pod undocumented
40 0 ▶sub no_cleanup { $_[0] }
Subroutine no_cleanup: not called CC=1 SCAR=6.9
Pod undocumented
41 11 *type = \&Set::Infinite::Basic::type;
42 0 ▶sub compact { @_ }
Subroutine compact: not called CC=1 SCAR=6.9
Pod undocumented
43  
44  
45 11 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
46 11 $VERSION = "0.65";
47 11 $TRACE = 0; # enable basic trace method execution
48 11 $DEBUG_BT = 0; # enable backtrack tracer
49 11 $PRETTY_PRINT = 0; # 0 = print 'Too Complex'; 1 = describe functions
50 11 $trace_level = 0; # indentation level when debugging
51  
52 11 $too_complex = "Too complex";
53 11 $backtrack_depth = 0;
54 11 $max_backtrack_depth = 10; # _backtrack()
55 11 $max_intersection_depth = 5; # first()
56 }
57  
58 4193 ▶sub trace { # title=>'aaa'
Subroutine trace: called CC=4 SCAR=25.5
Pod undocumented
59 4193 ▶ return $_[0] unless $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
unless $Set::Infinite::TRACE 4193 0 4193
60 0 my ($self, %parm) = @_;
61 0 my @caller = caller(1);
62 # print "self $self ". ref($self). "\n";
63 print "" . ( ' | ' x $trace_level ) .
64 "$parm{title} ". $self->copy .
65 0 ▶ ( exists $parm{arg} ? " -- " . $parm{arg}->copy : "" ).
Branch: 2 branches
BranchTrueFalseTotal
if $Set::Infinite::TRACE == 1 0 0 0
exists $parm{'arg'} ? : 0 0 0
66 " $caller[1]:$caller[2] ]\n" if $TRACE == 1;
67 0 return $self;
68 }
69  
70 0 ▶sub trace_open {
Subroutine trace_open: not called CC=3 SCAR=24.8
Pod undocumented
71 0 ▶ return $_[0] unless $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
unless $Set::Infinite::TRACE 0 0 0
72 0 my ($self, %parm) = @_;
73 0 my @caller = caller(1);
74 print "" . ( ' | ' x $trace_level ) .
75 "\\ $parm{title} ". $self->copy .
76 0 ▶ ( exists $parm{arg} ? " -- ". $parm{arg}->copy : "" ).
Branch: 1 branch
BranchTrueFalseTotal
exists $parm{'arg'} ? : 0 0 0
77 " $caller[1]:$caller[2] ]\n";
78 0 $trace_level++;
79 0 $level_title{$trace_level} = $parm{title};
80 0 return $self;
81 }
82  
83 0 ▶sub trace_close {
Subroutine trace_close: not called CC=5 SCAR=34.0
Pod undocumented
84 0 ▶ return $_[0] unless $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
unless $Set::Infinite::TRACE 0 0 0
85 0 my ($self, %parm) = @_;
86 0 my @caller = caller(0);
87 print "" . ( ' | ' x ($trace_level-1) ) .
88 "\/ $level_title{$trace_level} ".
89 ( exists $parm{arg} ?
90 (
91 defined $parm{arg} ?
92 "ret ". ( UNIVERSAL::isa($parm{arg}, __PACKAGE__ ) ?
93 $parm{arg}->copy :
94 0 ▶ "<$parm{arg}>" ) :
Branch: 3 branches
BranchTrueFalseTotal
exists $parm{'arg'} ? : 0 0 0
defined $parm{'arg'} ? : 0 0 0
UNIVERSAL::isa($parm{'arg'}, __PACKAGE__) ? : 0 0 0
95 "undef"
96 ) :
97 "" # no arg
98 ).
99 " $caller[1]:$caller[2] ]\n";
100 0 $trace_level--;
101 0 return $self;
102 }
103  
104  
105 # creates a 'function' object that can be solved by _backtrack()
106 4751 ▶sub _function {
Subroutine _function: called CC=1 SCAR=0.0
107 4751 my ($self, $method) = (shift, shift);
108 4751 my $b = $self->empty_set();
109 4751 $b->{too_complex} = 1;
110 4751 $b->{parent} = $self;
111 4751 $b->{method} = $method;
112 4751 $b->{param} = [ @_ ];
113 4751 return $b;
114 }
115  
116  
117 # same as _function, but with 2 arguments
118 1685 ▶sub _function2 {
Subroutine _function2: called CC=3 SCAR=11.0
119 1685 my ($self, $method, $arg) = (shift, shift, shift);
120 1685 ▶ unless ( $self->{too_complex} || $arg->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"too_complex"} or $arg->{"too_complex"}) 791 894 1685
Condition100%3/3
$self->{"too_complex"} or $arg->{"too_complex"}
l!l&&r!l&&!r
79896791
MC/DC100%2/2
$self->{"too_complex"} or $arg->{"too_complex"}
$self->{"too_complex"} $arg->{"too_complex"}
Truth table100%3/3
A or B
A= $self->{"too_complex"}B= $arg->{"too_complex"}
ABresult
1X1
011
000
121 791 return $self->$method($arg, @_);
122 }
123 894 my $b = $self->empty_set();
124 894 $b->{too_complex} = 1;
125 894 $b->{parent} = [ $self, $arg ];
126 894 $b->{method} = $method;
127 894 $b->{param} = [ @_ ];
128 894 return $b;
129 }
130  
131  
132 3742 ▶sub quantize {
Subroutine quantize: called CC=19 SCAR=29.6
Pod documented
133 3742 my $self = shift;
134 3742 ▶ $self->trace_open(title=>"quantize") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 3742 3742
135 3742 my @min = $self->min_a;
136 3742 my @max = $self->max_a;
137 3742 ▶ if (($self->{too_complex}) or
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"too_complex"} or defined $min[0] and $min[0] == $Set::Infinite::neg_inf or defined $max[0] and $max[0] == $Set::Infinite::inf) 2372 1370 3742
Condition100%12/12
$self->{"too_complex"} or defined $min[0] and $min[0] == $Set::Infinite::neg_inf or defined $max[0] and $max[0] == $Set::Infinite::inf
l!l&&r!l&&!r
107612961370
$self->{"too_complex"} or defined $min[0] and $min[0] == $Set::Infinite::neg_inf
l!l&&r!l&&!r
210742666
defined $min[0] and $min[0] == $Set::Infinite::neg_inf
!ll&&!rl&&r
5226141074
defined $max[0] and $max[0] == $Set::Infinite::inf
!ll&&!rl&&r
5213181296
MC/DC80%4/5
$self->{"too_complex"} or defined $min[0] and $min[0] == $Set::Infinite::neg_inf or defined $max[0] and $max[0] == $Set::Infinite::inf
$self->{"too_complex"} defined $min[0] $min[0] == $Set::Infinite::neg_inf defined $max[0] $max[0] == $Set::Infinite::inf
Truth table62%5/8
A or B and C or D and E
A= $self->{"too_complex"}B= defined $min[0]C= $min[0] == $Set::Infinite::neg_infD= defined $max[0]E= $max[0] == $Set::Infinite::inf
ABCDEresult
1XXXX1
011XX1
00X111
010111
00X0X0
00X100
0100X0
010100
138 (defined $min[0] && $min[0] == $neg_inf) or
139 (defined $max[0] && $max[0] == $inf)) {
140  
141 2372 return $self->_function( 'quantize', @_ );
142 }
143  
144 1370 my @a;
145 1370 my %rule = @_;
146 1370 my $b = $self->empty_set();
147 1370 my $parent = $self;
148  
149 1370 ▶ $rule{unit} = 'one' unless $rule{unit};
Branch: 1 branch
BranchTrueFalseTotal
unless $rule{"unit"} 1366 4 1370
150 1370 ▶ $rule{quant} = 1 unless $rule{quant};
Branch: 1 branch
BranchTrueFalseTotal
unless $rule{"quant"} 80 1290 1370
151 1370 $rule{parent} = $parent;
152 1370 ▶ $rule{strict} = $parent unless exists $rule{strict};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rule{"strict"} 1370 0 1370
153 1370 $rule{type} = $parent->{type};
154  
155 1370 my ($min, $open_begin) = $parent->min_a;
156  
157 1370 ▶ unless (defined $min) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $min) 52 1318 1370
158 52 ▶ $self->trace_close( arg => $b ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 52 52
159 52 return $b;
160 }
161  
162 1318 ▶ $rule{fixtype} = 1 unless exists $rule{fixtype};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rule{"fixtype"} 1318 0 1318
163 1318 $Set::Infinite::Arithmetic::Init_quantizer{$rule{unit}}->(\%rule);
164  
165 1318 $rule{sub_unit} = $Set::Infinite::Arithmetic::Offset_to_value{$rule{unit}};
166 1318 ▶ carp "Quantize unit '".$rule{unit}."' not implemented" unless ref( $rule{sub_unit} ) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $rule{"sub_unit"} eq "CODE" 0 1318 1318
167  
168 1318 my ($max, $open_end) = $parent->max_a;
169 1318 $rule{offset} = $Set::Infinite::Arithmetic::Value_to_offset{$rule{unit}}->(\%rule, $min);
170 1318 my $last_offset = $Set::Infinite::Arithmetic::Value_to_offset{$rule{unit}}->(\%rule, $max);
171 1318 $rule{size} = $last_offset - $rule{offset} + 1;
172 1318 my ($index, $tmp, $this, $next);
173 1318 for $index (0 .. $rule{size} ) {
174 # ($this, $next) = $rule{sub_unit} (\%rule, $index);
175 3324 ($this, $next) = $rule{sub_unit}->(\%rule, $index);
176 3324 ▶ unless ( $rule{fixtype} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rule{'fixtype'}) { } 3324 0 3324
177 0 $tmp = { a => $this , b => $next ,
178 open_begin => 0, open_end => 1 };
179 }
180 else {
181 3324 $tmp = Set::Infinite::Basic::_simple_new($this,$next, $rule{type} );
182 3324 $tmp->{open_end} = 1;
183 }
184 3324 ▶ next if ( $rule{strict} and not $rule{strict}->intersects($tmp));
Branch: 1 branch
BranchTrueFalseTotal
if $rule{"strict"} and not $rule{"strict"}->intersects($tmp) 1434 1890 3324
Condition100%3/3
$rule{"strict"} and not $rule{"strict"}->intersects($tmp)
!ll&&!rl&&r
13217581434
MC/DC100%2/2
$rule{"strict"} and not $rule{"strict"}->intersects($tmp)
$rule{"strict"} not $rule{"strict"}->intersects($tmp)
Truth table100%3/3
A and not(B)
A= $rule{"strict"}B= not $rule{"strict"}->intersects($tmp)
ABresult
0X0
100
111
185 1890 push @a, $tmp;
186 }
187  
188 1318 $b->{list} = \@a; # change data
189 1318 ▶ $self->trace_close( arg => $b ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 1318 1318
190 1318 return $b;
191 }
192  
193  
194 8 ▶sub _first_n {
Subroutine _first_n: called CC=3 SCAR=11.0
195 8 my $self = shift;
196 8 my $n = shift;
197 8 my $tail = $self->copy;
198 8 my @result;
199 my $first;
200 8 for ( 1 .. $n )
201 {
202 62 ▶ ( $first, $tail ) = $tail->first if $tail;
Branch: 1 branch
BranchTrueFalseTotal
if $tail 62 0 62
203 62 push @result, $first;
204 }
205 8 return $tail, @result;
206 }
207  
208 6 ▶sub _last_n {
Subroutine _last_n: called CC=3 SCAR=11.0
209 6 my $self = shift;
210 6 my $n = shift;
211 6 my $tail = $self->copy;
212 6 my @result;
213 my $last;
214 6 for ( 1 .. $n )
215 {
216 48 ▶ ( $last, $tail ) = $tail->last if $tail;
Branch: 1 branch
BranchTrueFalseTotal
if $tail 48 0 48
217 48 unshift @result, $last;
218 }
219 6 return $tail, @result;
220 }
221  
222  
223 16 ▶sub select {
Subroutine select: called CC=23 SCAR=31.6
Pod documented
224 16 my $self = shift;
225 16 ▶ $self->trace_open(title=>"select") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 16 16
226  
227 16 my %param = @_;
228 16 ▶ die "select() - parameter 'freq' is deprecated" if exists $param{freq};
Branch: 1 branch
BranchTrueFalseTotal
if exists $param{"freq"} 0 16 16
229  
230 16 my $res;
231 my $count;
232 16 my @by;
233 16 ▶ @by = @{ $param{by} } if exists $param{by};
Branch: 1 branch
BranchTrueFalseTotal
if exists $param{"by"} 11 5 16
234 16 ▶ $count = delete $param{count} || $inf;
Condition66%2/3
delete $param{'count'} || $Set::Infinite::inf
l!l&&r!l&&!r
1150
MC/DC0%0/2
delete $param{'count'} || $Set::Infinite::inf
delete $param{'count'} $Set::Infinite::inf
Truth table66%2/3
A || B
A= delete $param{'count'}B= $Set::Infinite::inf
ABresult
1X1
011
000
235 # warn "select: count=$count by=[@by]";
236  
237 16 ▶ if ($count <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count <= 0) 0 16 16
238 0 ▶ $self->trace_close( arg => $res ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
239 0 return $self->empty_set();
240 }
241  
242 16 my @set;
243 my $tail;
244 16 my $first;
245 16 my $last;
246 16 ▶ if ( @by )
Branch: 1 branch
BranchTrueFalseTotal
if (@by) { } 11 5 16
247 {
248 11 my @res;
249 11 ▶ if ( ! $self->is_too_complex )
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->is_too_complex) { } 3 8 11
250 {
251 3 $res = $self->new;
252 3 @res = @{ $self->{list} }[ @by ] ;
253 }
254 else
255 {
256 8 my ( @pos_by, @neg_by );
257 8 for ( @by ) {
258 28 ▶ ( $_ < 0 ) ? push @neg_by, $_ :
Branch: 1 branch
BranchTrueFalseTotal
$_ < 0 ? : 12 16 28
259 push @pos_by, $_;
260 }
261 8 my @first;
262 8 ▶ if ( @pos_by ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pos_by) 8 0 8
263 8 @pos_by = sort { $a <=> $b } @pos_by;
264 8 ( $tail, @set ) = $self->_first_n( 1 + $pos_by[-1] );
265 8 @first = @set[ @pos_by ];
266 }
267 8 my @last;
268 8 ▶ if ( @neg_by ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@neg_by) 6 2 8
269 6 @neg_by = sort { $a <=> $b } @neg_by;
270 6 ( $tail, @set ) = $self->_last_n( - $neg_by[0] );
271 6 @last = @set[ @neg_by ];
272 }
273 8 @res = map { $_->{list}[0] } ( @first , @last );
274 }
275  
276 11 $res = $self->new;
277 11 @res = sort { $a->{a} <=> $b->{a} } grep { defined } @res;
278 11 my $last;
279 my @a;
280 11 for ( @res ) {
281 40 ▶ push @a, $_ if ! $last || $last->{a} != $_->{a};
Branch: 1 branch
BranchTrueFalseTotal
if not $last or $last->{"a"} != $_->{"a"} 34 6 40
Condition100%3/3
not $last or $last->{"a"} != $_->{"a"}
l!l&&r!l&&!r
11236
MC/DC100%2/2
not $last or $last->{"a"} != $_->{"a"}
not $last $last->{"a"} != $_->{"a"}
Truth table100%3/3
not(A) or B
A= not $lastB= $last->{"a"} != $_->{"a"}
ABresult
1X1
011
000
282 40 $last = $_;
283 }
284 11 $res->{list} = \@a;
285 }
286 else
287 {
288 5 $res = $self;
289 }
290  
291 16 ▶ return $res if $count == $inf;
Branch: 1 branch
BranchTrueFalseTotal
if $count == $Set::Infinite::inf 5 11 16
292 11 my $count_set = $self->empty_set();
293 11 ▶ if ( ! $self->is_too_complex )
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->is_too_complex) { } 3 8 11
294 {
295 3 my @a;
296 3 @a = grep { defined } @{ $res->{list} }[ 0 .. $count - 1 ] ;
297 3 $count_set->{list} = \@a;
298 }
299 else
300 {
301 8 my $last;
302 8 ▶ while ( $res ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res) 21 0 21
303 21 ( $first, $res ) = $res->first;
304 21 ▶ last unless $first;
Branch: 1 branch
BranchTrueFalseTotal
unless $first 0 21 21
305 21 ▶ last if $last && $last->{a} == $first->{list}[0]{a};
Branch: 1 branch
BranchTrueFalseTotal
if $last and $last->{"a"} == $first->{"list"}[0]{"a"} 1 20 21
Condition100%3/3
$last and $last->{"a"} == $first->{"list"}[0]{"a"}
!ll&&!rl&&r
8121
MC/DC100%2/2
$last and $last->{"a"} == $first->{"list"}[0]{"a"}
$last $last->{"a"} == $first->{"list"}[0]{"a"}
Truth table100%3/3
A and B
A= $lastB= $last->{"a"} == $first->{"list"}[0]{"a"}
ABresult
0X0
100
111
306 20 $last = $first->{list}[0];
307 20 push @{$count_set->{list}}, $first->{list}[0];
308 20 $count--;
309 20 ▶ last if $count <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count <= 0 7 13 20
310 }
311 }
312 11 return $count_set;
313 }
314  
315 11 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.2
316  
317 # %_first and %_last hashes are used to backtrack the value
318 # of first() and last() of an infinite set
319  
320 %_first = (
321 'complement' =>
322 5 ▶ sub {
Subroutine __ANON__: called CC=6 SCAR=18.3
323 5 my $self = $_[0];
324 5 my @parent_min = $self->{parent}->first;
325 5 ▶ unless ( defined $parent_min[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parent_min[0]) 0 5 5
326 0 return (undef, 0);
327 }
328 5 my $parent_complement;
329 my $first;
330 5 my @next;
331 5 my $parent;
332 5 ▶ if ( $parent_min[0]->min == $neg_inf ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent_min[0]->min == $Set::Infinite::neg_inf) { } 2 3 5
333 2 my @parent_second = $parent_min[1]->first;
334 # (-inf..min) (second..?)
335 # (min..second) = complement
336 2 $first = $self->new( $parent_min[0]->complement );
337 2 $first->{list}[0]{b} = $parent_second[0]->{list}[0]{a};
338 2 $first->{list}[0]{open_end} = ! $parent_second[0]->{list}[0]{open_begin};
339 2 @{ $first->{list} } = () if
340 ( $first->{list}[0]{a} == $first->{list}[0]{b}) &&
341 ( $first->{list}[0]{open_begin} ||
342 2 ▶ $first->{list}[0]{open_end} );
Branch: 1 branch
BranchTrueFalseTotal
if $first->{"list"}[0]{"a"} == $first->{"list"}[0]{"b"} and $first->{"list"}[0]{"open_begin"} || $first->{"list"}[0]{"open_end"} 2 0 2
Condition33%2/6
$first->{"list"}[0]{"a"} == $first->{"list"}[0]{"b"} and $first->{"list"}[0]{"open_begin"} || $first->{"list"}[0]{"open_end"}
!ll&&!rl&&r
002
$first->{"list"}[0]{"open_begin"} or $first->{"list"}[0]{"open_end"}
l!l&&r!l&&!r
020
MC/DC0%0/3
$first->{"list"}[0]{"a"} == $first->{"list"}[0]{"b"} and $first->{"list"}[0]{"open_begin"} || $first->{"list"}[0]{"open_end"}
$first->{"list"}[0]{"a"} == $first->{"list"}[0]{"b"} $first->{"list"}[0]{"open_begin"} $first->{"list"}[0]{"open_end"}
Truth table25%1/4
A and B or C
A= $first->{"list"}[0]{"a"} == $first->{"list"}[0]{"b"}B= $first->{"list"}[0]{"open_begin"}C= $first->{"list"}[0]{"open_end"}
ABCresult
0XX0
1000
11X1
1011
343 2 @next = $parent_second[0]->max_a;
344 2 $parent = $parent_second[1];
345 }
346 else {
347 # (min..?)
348 # (-inf..min) = complement
349 3 $parent_complement = $parent_min[0]->complement;
350 3 $first = $self->new( $parent_complement->{list}[0] );
351 3 @next = $parent_min[0]->max_a;
352 3 $parent = $parent_min[1];
353 }
354 5 my @no_tail = $self->new($neg_inf,$next[0]);
355 5 $no_tail[0]->{list}[0]{open_end} = $next[1];
356 5 my $tail = $parent->union($no_tail[0])->complement;
357 5 return ($first, $tail);
358 }, # end: first-complement
359 'intersection' =>
360 131 ▶ sub {
Subroutine __ANON__: called CC=18 SCAR=31.9
361 131 my $self = $_[0];
362 131 my @parent = @{ $self->{parent} };
363 # warn "$method parents @parent";
364 131 my $retry_count = 0;
365 131 my (@first, @min, $which, $first1, $intersection);
366 131 ▶ SEARCH: while ($retry_count++ < $max_intersection_depth) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retry_count++ < $Set::Infinite::max_intersection_depth) 188 0 188
367 188 ▶ return undef unless defined $parent[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parent[0] 0 188 188
368 188 ▶ return undef unless defined $parent[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parent[1] 0 188 188
369 188 @{$first[0]} = $parent[0]->first;
370 188 @{$first[1]} = $parent[1]->first;
371 188 ▶ unless ( defined $first[0][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $first[0][0]) 0 188 188
372 # warn "don't know first of $method";
373 0 ▶ $self->trace_close( arg => 'undef' ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
374 0 return undef;
375 }
376 188 ▶ unless ( defined $first[1][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $first[1][0]) 0 188 188
377 # warn "don't know first of $method";
378 0 ▶ $self->trace_close( arg => 'undef' ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
379 0 return undef;
380 }
381 188 @{$min[0]} = $first[0][0]->min_a;
382 188 @{$min[1]} = $first[1][0]->min_a;
383 188 ▶ unless ( defined $min[0][0] && defined $min[1][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $min[0][0] and defined $min[1][0]) 0 188 188
Condition33%1/3
defined $min[0][0] and defined $min[1][0]
!ll&&!rl&&r
00188
MC/DC0%0/2
defined $min[0][0] and defined $min[1][0]
defined $min[0][0] defined $min[1][0]
Truth table33%1/3
A and B
A= defined $min[0][0]B= defined $min[1][0]
ABresult
0X0
100
111
384 0 return undef;
385 }
386 # $which is the index to the bigger "first".
387 188 ▶ $which = ($min[0][0] < $min[1][0]) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$min[0][0] < $min[1][0] ? : 65 123 188
388 188 for my $which1 ( $which, 1 - $which ) {
389 253 my $tmp_parent = $parent[$which1];
390 253 ($first1, $parent[$which1]) = @{ $first[$which1] };
391 253 ▶ if ( $first1->is_empty ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first1->is_empty) 0 253 253
392 # warn "first1 empty! count $retry_count";
393 # trace_close;
394 # return $first1, undef;
395 0 $intersection = $first1;
396 0 $which = $which1;
397 0 last SEARCH;
398 }
399 253 $intersection = $first1->intersection( $parent[1-$which1] );
400 # warn "intersection with $first1 is $intersection";
401 253 ▶ unless ( $intersection->is_null ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($intersection->is_null) 196 57 253
402 # $self->trace( title=>"got an intersection" );
403 196 ▶ if ( $intersection->is_too_complex ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($intersection->is_too_complex) { } 65 131 196
404 65 $parent[$which1] = $tmp_parent;
405 }
406 else {
407 131 $which = $which1;
408 131 last SEARCH;
409 }
410 };
411 }
412 }
413 131 ▶ if ( $#{ $intersection->{list} } > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$intersection{"list"};} > 0) 1 130 131
414 1 my $tail;
415 1 ($intersection, $tail) = $intersection->first;
416 1 $parent[$which] = $parent[$which]->union( $tail );
417 }
418 131 my $tmp;
419 131 ▶ if ( defined $parent[$which] and defined $parent[1-$which] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent[$which] and defined $parent[1 - $which]) 130 1 131
Condition66%2/3
defined $parent[$which] and defined $parent[1 - $which]
!ll&&!rl&&r
10130
MC/DC50%1/2
defined $parent[$which] and defined $parent[1 - $which]
defined $parent[$which] defined $parent[1 - $which]
Truth table66%2/3
A and B
A= defined $parent[$which]B= defined $parent[1 - $which]
ABresult
0X0
100
111
420 130 $tmp = $parent[$which]->intersection ( $parent[1-$which] );
421 }
422 131 return ($intersection, $tmp);
423 }, # end: first-intersection
424 'union' =>
425 23 ▶ sub {
Subroutine __ANON__: called CC=12 SCAR=26.1
426 23 my $self = $_[0];
427 23 my (@first, @min);
428 23 my @parent = @{ $self->{parent} };
429 23 @{$first[0]} = $parent[0]->first;
430 23 @{$first[1]} = $parent[1]->first;
431 23 ▶ unless ( defined $first[0][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $first[0][0]) 0 23 23
432 # looks like one set was empty
433 0 return @{$first[1]};
434 }
435 23 @{$min[0]} = $first[0][0]->min_a;
436 23 @{$min[1]} = $first[1][0]->min_a;
437  
438 # check min1/min2 for undef
439 23 ▶ unless ( defined $min[0][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $min[0][0]) 1 22 23
440 0 ▶ $self->trace_close( arg => "@{$first[1]}" ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 1 1
441 1 return @{$first[1]}
442 }
443 22 ▶ unless ( defined $min[1][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $min[1][0]) 0 22 22
444 0 ▶ $self->trace_close( arg => "@{$first[0]}" ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
445 0 return @{$first[0]}
446 }
447  
448 22 ▶ my $which = ($min[0][0] < $min[1][0]) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$min[0][0] < $min[1][0] ? : 2 20 22
449 22 my $first = $first[$which][0];
450  
451 # find out the tail
452 22 my $parent1 = $first[$which][1];
453 # warn $self->{parent}[$which]." - $first = $parent1";
454 my $parent2 = ($min[0][0] == $min[1][0]) ?
455 $self->{parent}[1-$which]->complement($first) :
456 22 ▶ $self->{parent}[1-$which];
Branch: 1 branch
BranchTrueFalseTotal
$min[0][0] == $min[1][0] ? : 1 21 22
457 22 my $tail;
458 22 ▶ if (( ! defined $parent1 ) || $parent1->is_null) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $parent1 or $parent1->is_null) { } 20 2 22
Condition66%2/3
not defined $parent1 or $parent1->is_null
l!l&&r!l&&!r
2002
MC/DC50%1/2
not defined $parent1 or $parent1->is_null
not defined $parent1 $parent1->is_null
Truth table66%2/3
not(A) or B
A= not defined $parent1B= $parent1->is_null
ABresult
1X1
011
000
459 # warn "union parent1 tail is null";
460 20 $tail = $parent2;
461 }
462 else {
463 2 my $method = $self->{method};
464 2 $tail = $parent1->$method( $parent2 );
465 }
466  
467 22 ▶ if ( $first->intersects( $tail ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first->intersects($tail)) 3 19 22
468 3 my $first2;
469 3 ( $first2, $tail ) = $tail->first;
470 3 $first = $first->union( $first2 );
471 }
472  
473 22 ▶ $self->trace_close( arg => "$first $tail" ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 22 22
474 22 return ($first, $tail);
475 }, # end: first-union
476 'iterate' =>
477 0 ▶ sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
478 0 my $self = $_[0];
479 0 my $parent = $self->{parent};
480 0 my ($first, $tail) = $parent->first;
481 0 ▶ $first = $first->iterate( @{$self->{param}} ) if ref($first);
Branch: 1 branch
BranchTrueFalseTotal
if ref $first 0 0 0
482 0 ▶ $tail = $tail->_function( 'iterate', @{$self->{param}} ) if ref($tail);
Branch: 1 branch
BranchTrueFalseTotal
if ref $tail 0 0 0
483 0 my $more;
484 0 ▶ ($first, $more) = $first->first if ref($first);
Branch: 1 branch
BranchTrueFalseTotal
if ref $first 0 0 0
485 0 ▶ $tail = $tail->_function2( 'union', $more ) if defined $more;
Branch: 1 branch
BranchTrueFalseTotal
if defined $more 0 0 0
486 0 return ($first, $tail);
487 },
488 'until' =>
489 33 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
490 33 my $self = $_[0];
491 33 my ($a1, $b1) = @{ $self->{parent} };
492 33 $a1->trace( title=>"computing first()" );
493 33 my @first1 = $a1->first;
494 33 my @first2 = $b1->first;
495 33 my ($first, $tail);
496 33 ▶ if ( $first2[0] <= $first1[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first2[0] <= $first1[0]) { } 16 17 33
497 # added ->first because it returns 2 spans if $a1 == $a2
498 16 $first = $a1->empty_set()->until( $first2[0] )->first;
499 16 $tail = $a1->_function2( "until", $first2[1] );
500 }
501 else {
502 17 $first = $a1->new( $first1[0] )->until( $first2[0] );
503 17 ▶ if ( defined $first1[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first1[1]) { } 17 0 17
504 17 $tail = $first1[1]->_function2( "until", $first2[1] );
505 }
506 else {
507 0 $tail = undef;
508 }
509 }
510 33 return ($first, $tail);
511 },
512 'offset' =>
513 364 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
514 364 my $self = $_[0];
515 364 my ($first, $tail) = $self->{parent}->first;
516 364 $first = $first->offset( @{$self->{param}} );
517 364 $tail = $tail->_function( 'offset', @{$self->{param}} );
518 364 my $more;
519 364 ($first, $more) = $first->first;
520 364 ▶ $tail = $tail->_function2( 'union', $more ) if defined $more;
Branch: 1 branch
BranchTrueFalseTotal
if defined $more 25 339 364
521 364 return ($first, $tail);
522 },
523 'quantize' =>
524 1109 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
525 1109 my $self = $_[0];
526 1109 my @min = $self->{parent}->min_a;
527 1109 ▶ if ( $min[0] == $neg_inf || $min[0] == $inf ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($min[0] == $Set::Infinite::neg_inf or $min[0] == $Set::Infinite::inf) 669 440 1109
Condition100%3/3
$min[0] == $Set::Infinite::neg_inf or $min[0] == $Set::Infinite::inf
l!l&&r!l&&!r
431238440
MC/DC100%2/2
$min[0] == $Set::Infinite::neg_inf or $min[0] == $Set::Infinite::inf
$min[0] == $Set::Infinite::neg_inf $min[0] == $Set::Infinite::inf
Truth table100%3/3
A or B
A= $min[0] == $Set::Infinite::neg_infB= $min[0] == $Set::Infinite::inf
ABresult
1X1
011
000
528 669 return ( $self->new( $min[0] ) , $self->copy );
529 }
530 440 my $first = $self->new( $min[0] )->quantize( @{$self->{param}} );
531 return ( $first,
532 $self->{parent}->
533 _function2( 'intersection', $first->complement )->
534 440 _function( 'quantize', @{$self->{param}} ) );
535 },
536 'tolerance' =>
537 1 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
538 1 my $self = $_[0];
539 1 my ($first, $tail) = $self->{parent}->first;
540 1 $first = $first->tolerance( @{$self->{param}} );
541 1 $tail = $tail->tolerance( @{$self->{param}} );
542 1 return ($first, $tail);
543 },
544 11 ); # %_first
545  
546 %_last = (
547 'complement' =>
548 5 ▶ sub {
Subroutine __ANON__: called CC=6 SCAR=18.3
549 5 my $self = $_[0];
550 5 my @parent_max = $self->{parent}->last;
551 5 ▶ unless ( defined $parent_max[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parent_max[0]) 0 5 5
552 0 return (undef, 0);
553 }
554 5 my $parent_complement;
555 my $last;
556 5 my @next;
557 5 my $parent;
558 5 ▶ if ( $parent_max[0]->max == $inf ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent_max[0]->max == $Set::Infinite::inf) { } 2 3 5
559 # (inf..min) (second..?) = parent
560 # (min..second) = complement
561 2 my @parent_second = $parent_max[1]->last;
562 2 $last = $self->new( $parent_max[0]->complement );
563 2 $last->{list}[0]{a} = $parent_second[0]->{list}[0]{b};
564 2 $last->{list}[0]{open_begin} = ! $parent_second[0]->{list}[0]{open_end};
565 2 @{ $last->{list} } = () if
566 ( $last->{list}[0]{a} == $last->{list}[0]{b}) &&
567 ( $last->{list}[0]{open_end} ||
568 2 ▶ $last->{list}[0]{open_begin} );
Branch: 1 branch
BranchTrueFalseTotal
if $last->{"list"}[0]{"a"} == $last->{"list"}[0]{"b"} and $last->{"list"}[0]{"open_end"} || $last->{"list"}[0]{"open_begin"} 2 0 2
Condition33%2/6
$last->{"list"}[0]{"a"} == $last->{"list"}[0]{"b"} and $last->{"list"}[0]{"open_end"} || $last->{"list"}[0]{"open_begin"}
!ll&&!rl&&r
002
$last->{"list"}[0]{"open_end"} or $last->{"list"}[0]{"open_begin"}
l!l&&r!l&&!r
200
MC/DC0%0/3
$last->{"list"}[0]{"a"} == $last->{"list"}[0]{"b"} and $last->{"list"}[0]{"open_end"} || $last->{"list"}[0]{"open_begin"}
$last->{"list"}[0]{"a"} == $last->{"list"}[0]{"b"} $last->{"list"}[0]{"open_end"} $last->{"list"}[0]{"open_begin"}
Truth table25%1/4
A and B or C
A= $last->{"list"}[0]{"a"} == $last->{"list"}[0]{"b"}B= $last->{"list"}[0]{"open_end"}C= $last->{"list"}[0]{"open_begin"}
ABCresult
0XX0
1000
11X1
1011
569 2 @next = $parent_second[0]->min_a;
570 2 $parent = $parent_second[1];
571 }
572 else {
573 # (min..?)
574 # (-inf..min) = complement
575 3 $parent_complement = $parent_max[0]->complement;
576 3 $last = $self->new( $parent_complement->{list}[-1] );
577 3 @next = $parent_max[0]->min_a;
578 3 $parent = $parent_max[1];
579 }
580 5 my @no_tail = $self->new($next[0], $inf);
581 5 $no_tail[0]->{list}[-1]{open_begin} = $next[1];
582 5 my $tail = $parent->union($no_tail[-1])->complement;
583 5 return ($last, $tail);
584 },
585 'intersection' =>
586 114 ▶ sub {
Subroutine __ANON__: called CC=23 SCAR=37.0
587 114 my $self = $_[0];
588 114 my @parent = @{ $self->{parent} };
589 # TODO: check max1/max2 for undef
590  
591 114 my $retry_count = 0;
592 114 my (@last, @max, $which, $last1, $intersection);
593  
594 114 ▶ SEARCH: while ($retry_count++ < $max_intersection_depth) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retry_count++ < $Set::Infinite::max_intersection_depth) 123 0 123
595 123 ▶ return undef unless defined $parent[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parent[0] 0 123 123
596 123 ▶ return undef unless defined $parent[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parent[1] 0 123 123
597  
598 123 @{$last[0]} = $parent[0]->last;
599 123 @{$last[1]} = $parent[1]->last;
600 123 ▶ unless ( defined $last[0][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $last[0][0]) 0 123 123
601 0 ▶ $self->trace_close( arg => 'undef' ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
602 0 return undef;
603 }
604 123 ▶ unless ( defined $last[1][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $last[1][0]) 0 123 123
605 0 ▶ $self->trace_close( arg => 'undef' ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
606 0 return undef;
607 }
608 123 @{$max[0]} = $last[0][0]->max_a;
609 123 @{$max[1]} = $last[1][0]->max_a;
610 123 ▶ unless ( defined $max[0][0] && defined $max[1][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $max[0][0] and defined $max[1][0]) 0 123 123
Condition33%1/3
defined $max[0][0] and defined $max[1][0]
!ll&&!rl&&r
00123
MC/DC0%0/2
defined $max[0][0] and defined $max[1][0]
defined $max[0][0] defined $max[1][0]
Truth table33%1/3
A and B
A= defined $max[0][0]B= defined $max[1][0]
ABresult
0X0
100
111
611 0 ▶ $self->trace( title=>"can't find max()" ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
612 0 ▶ $self->trace_close( arg => 'undef' ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
613 0 return undef;
614 }
615  
616 # $which is the index to the smaller "last".
617 123 ▶ $which = ($max[0][0] > $max[1][0]) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$max[0][0] > $max[1][0] ? : 19 104 123
618  
619 123 for my $which1 ( $which, 1 - $which ) {
620 142 my $tmp_parent = $parent[$which1];
621 142 ($last1, $parent[$which1]) = @{ $last[$which1] };
622 142 ▶ if ( $last1->is_null ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last1->is_null) 0 142 142
623 0 $which = $which1;
624 0 $intersection = $last1;
625 0 last SEARCH;
626 }
627 142 $intersection = $last1->intersection( $parent[1-$which1] );
628  
629 142 ▶ unless ( $intersection->is_null ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($intersection->is_null) 133 9 142
630 # $self->trace( title=>"got an intersection" );
631 133 ▶ if ( $intersection->is_too_complex ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($intersection->is_too_complex) { } 19 114 133
632 19 ▶ $self->trace( title=>"got a too_complex intersection" ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 19 19
633 # warn "too complex intersection";
634 19 $parent[$which1] = $tmp_parent;
635 }
636 else {
637 114 ▶ $self->trace( title=>"got an intersection" ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 114 114
638 114 $which = $which1;
639 114 last SEARCH;
640 }
641 };
642 }
643 }
644 114 ▶ $self->trace( title=>"exit loop" ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 114 114
645 114 ▶ if ( $#{ $intersection->{list} } > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$intersection{"list"};} > 0) 1 113 114
646 1 my $tail;
647 1 ($intersection, $tail) = $intersection->last;
648 1 $parent[$which] = $parent[$which]->union( $tail );
649 }
650 114 my $tmp;
651 114 ▶ if ( defined $parent[$which] and defined $parent[1-$which] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent[$which] and defined $parent[1 - $which]) 113 1 114
Condition66%2/3
defined $parent[$which] and defined $parent[1 - $which]
!ll&&!rl&&r
10113
MC/DC50%1/2
defined $parent[$which] and defined $parent[1 - $which]
defined $parent[$which] defined $parent[1 - $which]
Truth table66%2/3
A and B
A= defined $parent[$which]B= defined $parent[1 - $which]
ABresult
0X0
100
111
652 113 $tmp = $parent[$which]->intersection ( $parent[1-$which] );
653 }
654 114 return ($intersection, $tmp);
655 },
656 'union' =>
657 10 ▶ sub {
Subroutine __ANON__: called CC=8 SCAR=20.8
658 10 my $self = $_[0];
659 10 my (@last, @max);
660 10 my @parent = @{ $self->{parent} };
661 10 @{$last[0]} = $parent[0]->last;
662 10 @{$last[1]} = $parent[1]->last;
663 10 @{$max[0]} = $last[0][0]->max_a;
664 10 @{$max[1]} = $last[1][0]->max_a;
665 10 ▶ unless ( defined $max[0][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $max[0][0]) 1 9 10
666 1 return @{$last[1]}
667 }
668 9 ▶ unless ( defined $max[1][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $max[1][0]) 0 9 9
669 0 return @{$last[0]}
670 }
671  
672 9 ▶ my $which = ($max[0][0] > $max[1][0]) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$max[0][0] > $max[1][0] ? : 1 8 9
673 9 my $last = $last[$which][0];
674 # find out the tail
675 9 my $parent1 = $last[$which][1];
676 # warn $self->{parent}[$which]." - $last = $parent1";
677 my $parent2 = ($max[0][0] == $max[1][0]) ?
678 $self->{parent}[1-$which]->complement($last) :
679 9 ▶ $self->{parent}[1-$which];
Branch: 1 branch
BranchTrueFalseTotal
$max[0][0] == $max[1][0] ? : 2 7 9
680 9 my $tail;
681 9 ▶ if (( ! defined $parent1 ) || $parent1->is_null) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $parent1 or $parent1->is_null) { } 7 2 9
Condition66%2/3
not defined $parent1 or $parent1->is_null
l!l&&r!l&&!r
702
MC/DC50%1/2
not defined $parent1 or $parent1->is_null
not defined $parent1 $parent1->is_null
Truth table66%2/3
not(A) or B
A= not defined $parent1B= $parent1->is_null
ABresult
1X1
011
000
682 7 $tail = $parent2;
683 }
684 else {
685 2 my $method = $self->{method};
686 2 $tail = $parent1->$method( $parent2 );
687 }
688  
689 9 ▶ if ( $last->intersects( $tail ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last->intersects($tail)) 2 7 9
690 2 my $last2;
691 2 ( $last2, $tail ) = $tail->last;
692 2 $last = $last->union( $last2 );
693 }
694  
695 9 return ($last, $tail);
696 },
697 'until' =>
698 28 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
699 28 my $self = $_[0];
700 28 my ($a1, $b1) = @{ $self->{parent} };
701 28 $a1->trace( title=>"computing last()" );
702 28 my @last1 = $a1->last;
703 28 my @last2 = $b1->last;
704 28 my ($last, $tail);
705 28 ▶ if ( $last2[0] <= $last1[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last2[0] <= $last1[0]) { } 12 16 28
706 # added ->last because it returns 2 spans if $a1 == $a2
707 12 $last = $last2[0]->until( $a1 )->last;
708 12 $tail = $a1->_function2( "until", $last2[1] );
709 }
710 else {
711 16 $last = $a1->new( $last1[0] )->until( $last2[0] );
712 16 ▶ if ( defined $last1[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last1[1]) { } 14 2 16
713 14 $tail = $last1[1]->_function2( "until", $last2[1] );
714 }
715 else {
716 2 $tail = undef;
717 }
718 }
719 28 return ($last, $tail);
720 },
721 'iterate' =>
722 0 ▶ sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
723 0 my $self = $_[0];
724 0 my $parent = $self->{parent};
725 0 my ($last, $tail) = $parent->last;
726 0 ▶ $last = $last->iterate( @{$self->{param}} ) if ref($last);
Branch: 1 branch
BranchTrueFalseTotal
if ref $last 0 0 0
727 0 ▶ $tail = $tail->_function( 'iterate', @{$self->{param}} ) if ref($tail);
Branch: 1 branch
BranchTrueFalseTotal
if ref $tail 0 0 0
728 0 my $more;
729 0 ▶ ($last, $more) = $last->last if ref($last);
Branch: 1 branch
BranchTrueFalseTotal
if ref $last 0 0 0
730 0 ▶ $tail = $tail->_function2( 'union', $more ) if defined $more;
Branch: 1 branch
BranchTrueFalseTotal
if defined $more 0 0 0
731 0 return ($last, $tail);
732 },
733 'offset' =>
734 158 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
735 158 my $self = $_[0];
736 158 my ($last, $tail) = $self->{parent}->last;
737 158 $last = $last->offset( @{$self->{param}} );
738 158 $tail = $tail->_function( 'offset', @{$self->{param}} );
739 158 my $more;
740 158 ($last, $more) = $last->last;
741 158 ▶ $tail = $tail->_function2( 'union', $more ) if defined $more;
Branch: 1 branch
BranchTrueFalseTotal
if defined $more 0 158 158
742 158 return ($last, $tail);
743 },
744 'quantize' =>
745 1028 ▶ sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
746 1028 my $self = $_[0];
747 1028 my @max = $self->{parent}->max_a;
748 1028 ▶ if (( $max[0] == $neg_inf ) || ( $max[0] == $inf )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max[0] == $Set::Infinite::neg_inf or $max[0] == $Set::Infinite::inf) 677 351 1028
Condition100%3/3
$max[0] == $Set::Infinite::neg_inf or $max[0] == $Set::Infinite::inf
l!l&&r!l&&!r
161516351
MC/DC100%2/2
$max[0] == $Set::Infinite::neg_inf or $max[0] == $Set::Infinite::inf
$max[0] == $Set::Infinite::neg_inf $max[0] == $Set::Infinite::inf
Truth table100%3/3
A or B
A= $max[0] == $Set::Infinite::neg_infB= $max[0] == $Set::Infinite::inf
ABresult
1X1
011
000
749 677 return ( $self->new( $max[0] ) , $self->copy );
750 }
751 351 my $last = $self->new( $max[0] )->quantize( @{$self->{param}} );
752 351 ▶ if ($max[1]) { # open_end
Branch: 1 branch
BranchTrueFalseTotal
if ($max[1]) 107 244 351
753 107 ▶ if ( $last->min <= $max[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last->min <= $max[0]) 107 0 107
754 107 $last = $self->new( $last->min - 1e-9 )->quantize( @{$self->{param}} );
755 }
756 }
757 return ( $last, $self->{parent}->
758 _function2( 'intersection', $last->complement )->
759 351 _function( 'quantize', @{$self->{param}} ) );
760 },
761 'tolerance' =>
762 1 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
763 1 my $self = $_[0];
764 1 my ($last, $tail) = $self->{parent}->last;
765 1 $last = $last->tolerance( @{$self->{param}} );
766 1 $tail = $tail->tolerance( @{$self->{param}} );
767 1 return ($last, $tail);
768 },
769 11 ); # %_last
770 } # BEGIN
771  
772 2322 ▶sub first {
Subroutine first: called CC=6 SCAR=18.7
Pod documented
773 2322 my $self = $_[0];
774 2322 ▶ unless ( exists $self->{first} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"first"}) 2223 99 2322
775 2223 ▶ $self->trace_open(title=>"first") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 2223 2223
776 2223 ▶ if ( $self->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'too_complex'}) { } 1666 557 2223
777 1666 my $method = $self->{method};
778 # warn "method $method ". ( exists $_first{$method} ? "exists" : "does not exist" );
779 1666 ▶ if ( exists $_first{$method} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Set::Infinite::_first{$method}) { } 1666 0 1666
780 1666 @{$self->{first}} = $_first{$method}->($self);
781 }
782 else {
783 0 my $redo = $self->{parent}->$method ( @{ $self->{param} } );
784 0 @{$self->{first}} = $redo->first;
785 }
786 }
787 else {
788 557 return $self->SUPER::first;
789 }
790 }
791 1765 ▶ return wantarray ? @{$self->{first}} : $self->{first}[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1750 15 1765
792 }
793  
794  
795 1688 ▶sub last {
Subroutine last: called CC=6 SCAR=18.7
Pod documented
796 1688 my $self = $_[0];
797 1688 ▶ unless ( exists $self->{last} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"last"}) 1653 35 1688
798 1653 ▶ $self->trace(title=>"last") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 1653 1653
799 1653 ▶ if ( $self->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'too_complex'}) { } 1344 309 1653
800 1344 my $method = $self->{method};
801 1344 ▶ if ( exists $_last{$method} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Set::Infinite::_last{$method}) { } 1344 0 1344
802 1344 @{$self->{last}} = $_last{$method}->($self);
803 }
804 else {
805 0 my $redo = $self->{parent}->$method ( @{ $self->{param} } );
806 0 @{$self->{last}} = $redo->last;
807 }
808 }
809 else {
810 309 return $self->SUPER::last;
811 }
812 }
813 1379 ▶ return wantarray ? @{$self->{last}} : $self->{last}[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1357 22 1379
814 }
815  
816  
817 # offset: offsets subsets
818 3045 ▶sub offset {
Subroutine offset: called CC=15 SCAR=27.4
Pod documented
819 3045 my $self = shift;
820 3045 ▶ if ($self->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"too_complex"}) 1036 2009 3045
821 1036 return $self->_function( 'offset', @_ );
822 }
823 2009 ▶ $self->trace_open(title=>"offset") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 2009 2009
824  
825 2009 my @a;
826 2009 my %param = @_;
827 2009 my $b1 = $self->empty_set();
828 2009 my ($interval, $ia, $i);
829 2009 ▶ $param{mode} = 'offset' unless $param{mode};
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"mode"} 8 2001 2009
830  
831 2009 ▶ unless (ref($param{value}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $param{"value"} eq "ARRAY") 0 2009 2009
832 0 $param{value} = [0 + $param{value}, 0 + $param{value}];
833 }
834 2009 ▶ $param{unit} = 'one' unless $param{unit};
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"unit"} 2009 0 2009
835 2009 my $parts = ($#{$param{value}}) / 2;
836 2009 my $sub_unit = $Set::Infinite::Arithmetic::subs_offset2{$param{unit}};
837 2009 my $sub_mode = $Set::Infinite::Arithmetic::_MODE{$param{mode}};
838  
839 2009 ▶ carp "unknown unit $param{unit} for offset()" unless defined $sub_unit;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sub_unit 0 2009 2009
840 2009 ▶ carp "unknown mode $param{mode} for offset()" unless defined $sub_mode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sub_mode 0 2009 2009
841  
842 2009 my ($j);
843 2009 my ($cmp, $this, $next, $ib, $part, $open_begin, $open_end, $tmp);
844  
845 2009 my @value;
846 2009 foreach $j (0 .. $parts) {
847 2011 push @value, [ $param{value}[$j+$j], $param{value}[$j+$j + 1] ];
848 }
849  
850 2009 foreach $interval ( @{ $self->{list} } ) {
851 2390 $ia = $interval->{a};
852 2390 $ib = $interval->{b};
853 2390 $open_begin = $interval->{open_begin};
854 2390 $open_end = $interval->{open_end};
855 2390 foreach $j (0 .. $parts) {
856 # print " [ofs($ia,$ib)] ";
857 2394 ($this, $next) = $sub_mode->( $sub_unit, $ia, $ib, @{$value[$j]} );
858 2394 ▶ next if ($this > $next); # skip if a > b
Branch: 1 branch
BranchTrueFalseTotal
if $this > $next 1 2393 2394
859 2393 ▶ if ($this == $next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this == $next) 2367 26 2393
860 # TODO: fix this
861 2367 $open_end = $open_begin;
862 }
863 2393 push @a, { a => $this , b => $next ,
864 open_begin => $open_begin , open_end => $open_end };
865 } # parts
866 } # self
867 2009 @a = sort { $a->{a} <=> $b->{a} } @a;
868 2009 $b1->{list} = \@a; # change data
869 2009 ▶ $self->trace_close( arg => $b1 ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 2009 2009
870 2009 ▶ $b1 = $b1->fixtype if $self->{fixtype};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"fixtype"} 2009 0 2009
871 2009 return $b1;
872 }
873  
874  
875 1702 ▶sub is_null {
Subroutine is_null: called CC=2 SCAR=6.9
Pod documented
876 1702 ▶ $_[0]->{too_complex} ? 0 : $_[0]->SUPER::is_null;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'too_complex'} ? : 129 1573 1702
877 }
878  
879  
880 351 ▶sub is_too_complex {
Subroutine is_too_complex: called CC=2 SCAR=6.9
Pod documented
881 351 ▶ $_[0]->{too_complex} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'too_complex'} ? : 100 251 351
882 }
883  
884  
885 # shows how a 'compacted' set looks like after quantize
886 2317 ▶sub _quantize_span {
Subroutine _quantize_span: called CC=9 SCAR=22.0
887 2317 my $self = shift;
888 2317 my %param = @_;
889 2317 ▶ $self->trace_open(title=>"_quantize_span") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 2317 2317
890 2317 my $res;
891 2317 ▶ if ($self->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'too_complex'}) { } 1525 792 2317
892 1525 $res = $self->{parent};
893 1525 ▶ if ($self->{method} ne 'quantize') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"method"} ne "quantize") 697 828 1525
894 697 $self->trace( title => "parent is a ". $self->{method} );
895 697 ▶ if ( $self->{method} eq 'union' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'method'} eq 'union') { } 7 690 697
elsif ($self->{'method'} eq 'intersection') { } 4 686 690
896 7 my $arg0 = $self->{parent}[0]->_quantize_span(%param);
897 7 my $arg1 = $self->{parent}[1]->_quantize_span(%param);
898 7 $res = $arg0->union( $arg1 );
899 }
900 elsif ( $self->{method} eq 'intersection' ) {
901 4 my $arg0 = $self->{parent}[0]->_quantize_span(%param);
902 4 my $arg1 = $self->{parent}[1]->_quantize_span(%param);
903 4 $res = $arg0->intersection( $arg1 );
904 }
905  
906 # TODO: other methods
907 else {
908 686 $res = $self; # ->_function( "_quantize_span", %param );
909 }
910 697 ▶ $self->trace_close( arg => $res ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 697 697
911 697 return $res;
912 }
913  
914 # $res = $self->{parent};
915 828 ▶ if ($res->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->{'too_complex'}) { } 2 826 828
916 2 $res->trace( title => "parent is complex" );
917 2 $res = $res->_quantize_span( %param );
918 2 $res = $res->quantize( @{$self->{param}} )->_quantize_span( %param );
919 }
920 else {
921 $res = $res->iterate (
922 1010 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
923 1010 $_[0]->quantize( @{$self->{param}} )->span;
924 }
925 826 );
926 }
927 }
928 else {
929 792 ▶ $res = $self->iterate ( sub { $_[0] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
930 }
931 1620 ▶ $self->trace_close( arg => $res ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 1620 1620
932 1620 return $res;
933 }
934  
935  
936  
937 11 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
938  
939 %_backtrack = (
940  
941 145 ▶ until => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
942 145 my ($self, $arg) = @_;
943 145 my $before = $self->{parent}[0]->intersection( $neg_inf, $arg->min )->max;
944 145 ▶ $before = $arg->min unless $before;
Branch: 1 branch
BranchTrueFalseTotal
unless $before 48 97 145
945 145 my $after = $self->{parent}[1]->intersection( $arg->max, $inf )->min;
946 145 ▶ $after = $arg->max unless $after;
Branch: 1 branch
BranchTrueFalseTotal
unless $after 17 128 145
947 145 return $arg->new( $before, $after );
948 },
949  
950 6 ▶ iterate => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
951 6 my ($self, $arg) = @_;
952  
953 6 ▶ if ( defined $self->{backtrack_callback} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"backtrack_callback"}) 2 4 6
954 {
955 2 return $arg = $self->new( $self->{backtrack_callback}->( $arg ) );
956 }
957  
958 4 my $before = $self->{parent}->intersection( $neg_inf, $arg->min )->max;
959 4 ▶ $before = $arg->min unless $before;
Branch: 1 branch
BranchTrueFalseTotal
unless $before 2 2 4
960 4 my $after = $self->{parent}->intersection( $arg->max, $inf )->min;
961 4 ▶ $after = $arg->max unless $after;
Branch: 1 branch
BranchTrueFalseTotal
unless $after 0 4 4
962  
963 4 return $arg->new( $before, $after );
964 },
965  
966 880 ▶ quantize => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
967 880 my ($self, $arg) = @_;
968 880 ▶ if ($arg->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{'too_complex'}) { } 2 878 880
969 2 return $arg;
970 }
971 else {
972 878 return $arg->quantize( @{$self->{param}} )->_quantize_span;
973 }
974 },
975  
976 1256 ▶ offset => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
977 1256 my ($self, $arg) = @_;
978 # offset - apply offset with negative values
979 1256 my %tmp = @{$self->{param}};
980 1256 my @values = sort @{$tmp{value}};
981  
982 my $backtrack_arg2 = $arg->offset(
983 unit => $tmp{unit},
984 mode => $tmp{mode},
985 1256 value => [ - $values[-1], - $values[0] ] );
986 1256 return $arg->union( $backtrack_arg2 ); # fixes some problems with 'begin' mode
987 },
988  
989 11 );
990 }
991  
992  
993 3238 ▶sub _backtrack {
Subroutine _backtrack: called CC=11 SCAR=24.2
994 3238 my ($self, $method, $arg) = @_;
995 3238 ▶ return $self->$method ($arg) unless $self->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"too_complex"} 880 2358 3238
996  
997 2358 ▶ $self->trace_open( title => 'backtrack '.$self->{method} ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 2358 2358
998  
999 2358 $backtrack_depth++;
1000 2358 ▶ if ( $backtrack_depth > $max_backtrack_depth ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Set::Infinite::backtrack_depth > $Set::Infinite::max_backtrack_depth) 0 2358 2358
1001 0 carp ( __PACKAGE__ . ": Backtrack too deep " .
1002 "(more than $max_backtrack_depth levels)" );
1003 }
1004  
1005 2358 ▶ if (exists $_backtrack{ $self->{method} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Set::Infinite::_backtrack{$self->{"method"}}) 2287 71 2358
1006 2287 $arg = $_backtrack{ $self->{method} }->( $self, $arg );
1007 }
1008  
1009 2358 my $result;
1010 2358 ▶ if ( ref($self->{parent}) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'parent'} eq 'ARRAY') { } 211 2147 2358
1011 # has 2 parents (intersection, union, until)
1012  
1013 211 my ( $result1, $result2 ) = @{$self->{parent}};
1014 $result1 = $result1->_backtrack( $method, $arg )
1015 211 ▶ if $result1->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
if $result1->{"too_complex"} 211 0 211
1016 $result2 = $result2->_backtrack( $method, $arg )
1017 211 ▶ if $result2->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
if $result2->{"too_complex"} 147 64 211
1018  
1019 211 $method = $self->{method};
1020 211 ▶ if ( $result1->{too_complex} || $result2->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result1->{'too_complex'} or $result2->{'too_complex'}) { } 169 42 211
Condition66%2/3
$result1->{"too_complex"} or $result2->{"too_complex"}
l!l&&r!l&&!r
169042
MC/DC50%1/2
$result1->{"too_complex"} or $result2->{"too_complex"}
$result1->{"too_complex"} $result2->{"too_complex"}
Truth table66%2/3
A or B
A= $result1->{"too_complex"}B= $result2->{"too_complex"}
ABresult
1X1
011
000
1021 169 $result = $result1->_function2( $method, $result2 );
1022 }
1023 else {
1024 42 $result = $result1->$method ($result2);
1025 }
1026 }
1027 else {
1028 # has 1 parent and parameters (offset, select, quantize, iterate)
1029  
1030 2147 $result = $self->{parent}->_backtrack( $method, $arg );
1031 2147 $method = $self->{method};
1032 2147 $result = $result->$method ( @{$self->{param}} );
1033 }
1034  
1035 2358 $backtrack_depth--;
1036 2358 ▶ $self->trace_close( arg => $result ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 2358 2358
1037 2358 return $result;
1038 }
1039  
1040  
1041 3433 ▶sub intersects {
Subroutine intersects: called CC=6 SCAR=17.9
Pod documented
1042 3433 my $a1 = shift;
1043 3433 ▶ my $b1 = (ref ($_[0]) eq ref($a1) ) ? shift : $a1->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq ref $a1 ? : 233 3200 3433
1044  
1045 3433 $a1->trace(title=>"intersects");
1046 3433 ▶ if ($a1->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"}) 8 3425 3433
1047 8 $a1 = $a1->_backtrack('intersection', $b1 );
1048 } # don't put 'else' here
1049 3433 ▶ if ($b1->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b1->{"too_complex"}) 33 3400 3433
1050 33 $b1 = $b1->_backtrack('intersection', $a1);
1051 }
1052 3433 ▶ if (($a1->{too_complex}) or ($b1->{too_complex})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"} or $b1->{"too_complex"}) 8 3425 3433
Condition100%3/3
$a1->{"too_complex"} or $b1->{"too_complex"}
l!l&&r!l&&!r
353425
MC/DC100%2/2
$a1->{"too_complex"} or $b1->{"too_complex"}
$a1->{"too_complex"} $b1->{"too_complex"}
Truth table100%3/3
A or B
A= $a1->{"too_complex"}B= $b1->{"too_complex"}
ABresult
1X1
011
000
1053 8 return undef; # we don't know the answer!
1054 }
1055 3425 return $a1->SUPER::intersects( $b1 );
1056 }
1057  
1058  
1059 1634 ▶sub iterate {
Subroutine iterate: called CC=7 SCAR=19.7
Pod documented
1060 1634 my $self = shift;
1061 1634 my $callback = shift;
1062 1634 ▶ die "First argument to iterate() must be a subroutine reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $callback eq "CODE" 0 1634 1634
1063 unless ref( $callback ) eq 'CODE';
1064 1634 my $backtrack_callback;
1065 1634 ▶ if ( @_ && $_[0] eq 'backtrack_callback' )
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and $_[0] eq "backtrack_callback") 2 1632 1634
Condition66%2/3
@_ and $_[0] eq "backtrack_callback"
!ll&&!rl&&r
163202
MC/DC50%1/2
@_ and $_[0] eq "backtrack_callback"
@_ $_[0] eq "backtrack_callback"
Truth table66%2/3
A and B
A= @_B= $_[0] eq "backtrack_callback"
ABresult
0X0
100
111
1066 {
1067 2 ( undef, $backtrack_callback ) = ( shift, shift );
1068 }
1069 1634 my $set;
1070 1634 ▶ if ($self->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'too_complex'}) { } 6 1628 1634
1071 6 ▶ $self->trace(title=>"iterate:backtrack") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 6 6
1072 6 $set = $self->_function( 'iterate', $callback, @_ );
1073 }
1074 else
1075 {
1076 1628 ▶ $self->trace(title=>"iterate") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 1628 1628
1077 1628 $set = $self->SUPER::iterate( $callback, @_ );
1078 }
1079 1634 $set->{backtrack_callback} = $backtrack_callback;
1080 # warn "set backtrack_callback" if defined $backtrack_callback;
1081 1634 return $set;
1082 }
1083  
1084  
1085 3162 ▶sub intersection {
Subroutine intersection: called CC=15 SCAR=27.1
Pod documented
1086 3162 my $a1 = shift;
1087 3162 ▶ my $b1 = (ref ($_[0]) eq ref($a1) ) ? shift : $a1->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq ref $a1 ? : 2812 350 3162
1088  
1089 3162 ▶ $a1->trace_open(title=>"intersection", arg => $b1) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 3162 3162
1090 3162 ▶ if (($a1->{too_complex}) or ($b1->{too_complex})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"} or $b1->{"too_complex"}) 705 2457 3162
Condition100%3/3
$a1->{"too_complex"} or $b1->{"too_complex"}
l!l&&r!l&&!r
618872457
MC/DC100%2/2
$a1->{"too_complex"} or $b1->{"too_complex"}
$a1->{"too_complex"} $b1->{"too_complex"}
Truth table100%3/3
A or B
A= $a1->{"too_complex"}B= $b1->{"too_complex"}
ABresult
1X1
011
000
1091 705 my $arg0 = $a1->_quantize_span;
1092 705 my $arg1 = $b1->_quantize_span;
1093 705 ▶ unless (($arg0->{too_complex}) or ($arg1->{too_complex})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arg0->{"too_complex"} or $arg1->{"too_complex"}) 20 685 705
Condition100%3/3
$arg0->{"too_complex"} or $arg1->{"too_complex"}
l!l&&r!l&&!r
6018420
MC/DC100%2/2
$arg0->{"too_complex"} or $arg1->{"too_complex"}
$arg0->{"too_complex"} $arg1->{"too_complex"}
Truth table100%3/3
A or B
A= $arg0->{"too_complex"}B= $arg1->{"too_complex"}
ABresult
1X1
011
000
1094 20 my $res = $arg0->intersection( $arg1 );
1095 20 ▶ $a1->trace_close( arg => $res ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 20 20
1096 20 return $res;
1097 }
1098 }
1099 3142 ▶ if ($a1->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"}) 601 2541 3142
1100 601 ▶ $a1 = $a1->_backtrack('intersection', $b1) unless $b1->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
unless $b1->{"too_complex"} 600 1 601
1101 } # don't put 'else' here
1102 3142 ▶ if ($b1->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b1->{"too_complex"}) 85 3057 3142
1103 85 ▶ $b1 = $b1->_backtrack('intersection', $a1) unless $a1->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
unless $a1->{"too_complex"} 84 1 85
1104 }
1105 3142 ▶ if ( $a1->{too_complex} || $b1->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"} or $b1->{"too_complex"}) 572 2570 3142
Condition100%3/3
$a1->{"too_complex"} or $b1->{"too_complex"}
l!l&&r!l&&!r
488842570
MC/DC100%2/2
$a1->{"too_complex"} or $b1->{"too_complex"}
$a1->{"too_complex"} $b1->{"too_complex"}
Truth table100%3/3
A or B
A= $a1->{"too_complex"}B= $b1->{"too_complex"}
ABresult
1X1
011
000
1106 572 ▶ $a1->trace_close( ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 572 572
1107 572 return $a1->_function2( 'intersection', $b1 );
1108 }
1109 2570 return $a1->SUPER::intersection( $b1 );
1110 }
1111  
1112  
1113 12 ▶sub intersected_spans {
Subroutine intersected_spans: called CC=8 SCAR=20.8
Pod documented
1114 12 my $a1 = shift;
1115 12 ▶ my $b1 = ref ($_[0]) eq ref($a1) ? $_[0] : $a1->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq ref $a1 ? : 6 6 12
1116  
1117 12 ▶ if ($a1->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"}) 8 4 12
1118 8 ▶ $a1 = $a1->_backtrack('intersection', $b1 ) unless $b1->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
unless $b1->{"too_complex"} 7 1 8
1119 } # don't put 'else' here
1120 12 ▶ if ($b1->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b1->{"too_complex"}) 2 10 12
1121 2 ▶ $b1 = $b1->_backtrack('intersection', $a1) unless $a1->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
unless $a1->{"too_complex"} 1 1 2
1122 }
1123  
1124 12 ▶ if ( ! $b1->{too_complex} && ! $a1->{too_complex} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($b1->{"too_complex"} or $a1->{"too_complex"}) 8 4 12
Condition100%3/3
$b1->{"too_complex"} or $a1->{"too_complex"}
l!l&&r!l&&!r
138
MC/DC100%2/2
$b1->{"too_complex"} or $a1->{"too_complex"}
$b1->{"too_complex"} $a1->{"too_complex"}
Truth table100%3/3
A or B
A= $b1->{"too_complex"}B= $a1->{"too_complex"}
ABresult
1X1
011
000
1125 {
1126 8 return $a1->SUPER::intersected_spans ( $b1 );
1127 }
1128  
1129 return $b1->iterate(
1130 7 ▶ sub {
Subroutine __ANON__: called CC=6 SCAR=18.1
1131 7 my $tmp = $a1->intersection( $_[0] );
1132 7 ▶ return $tmp unless defined $tmp->max;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp->max 0 7 7
1133  
1134 7 my $before = $a1->intersection( $neg_inf, $tmp->min )->last;
1135 7 my $after = $a1->intersection( $tmp->max, $inf )->first;
1136  
1137 7 $before = $tmp->union( $before )->first;
1138 7 $after = $tmp->union( $after )->last;
1139  
1140 7 ▶ $tmp = $tmp->union( $before )
Branch: 1 branch
BranchTrueFalseTotal
if defined $before and $tmp->intersects($before) 6 1 7
Condition66%2/3
defined $before and $tmp->intersects($before)
!ll&&!rl&&r
016
MC/DC50%1/2
defined $before and $tmp->intersects($before)
defined $before $tmp->intersects($before)
Truth table66%2/3
A and B
A= defined $beforeB= $tmp->intersects($before)
ABresult
0X0
100
111
1141 if defined $before && $tmp->intersects( $before );
1142 7 ▶ $tmp = $tmp->union( $after )
Branch: 1 branch
BranchTrueFalseTotal
if defined $after and $tmp->intersects($after) 5 2 7
Condition66%2/3
defined $after and $tmp->intersects($after)
!ll&&!rl&&r
025
MC/DC50%1/2
defined $after and $tmp->intersects($after)
defined $after $tmp->intersects($after)
Truth table66%2/3
A and B
A= defined $afterB= $tmp->intersects($after)
ABresult
0X0
100
111
1143 if defined $after && $tmp->intersects( $after );
1144 7 return $tmp;
1145 }
1146 4 );
1147  
1148 }
1149  
1150  
1151 1555 ▶sub complement {
Subroutine complement: called CC=8 SCAR=21.1
Pod documented
1152 1555 my $a1 = shift;
1153 # do we have a parameter?
1154 1555 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 362 1193 1555
1155 362 ▶ my $b1 = (ref ($_[0]) eq ref($a1) ) ? shift : $a1->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq ref $a1 ? : 7 355 362
1156  
1157 362 ▶ $a1->trace_open(title=>"complement", arg => $b1) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 362 362
1158 362 $b1 = $b1->complement;
1159 362 my $tmp =$a1->intersection($b1);
1160 362 ▶ $a1->trace_close( arg => $tmp ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 362 362
1161 362 return $tmp;
1162 }
1163 1193 ▶ $a1->trace_open(title=>"complement") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 1193 1193
1164 1193 ▶ if ($a1->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"}) 21 1172 1193
1165 21 ▶ $a1->trace_close( ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 21 21
1166 21 return $a1->_function( 'complement', @_ );
1167 }
1168 1172 return $a1->SUPER::complement;
1169 }
1170  
1171  
1172 146 ▶sub until {
Subroutine until: called CC=4 SCAR=13.9
Pod documented
1173 146 my $a1 = shift;
1174 146 ▶ my $b1 = (ref ($_[0]) eq ref($a1) ) ? shift : $a1->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq ref $a1 ? : 137 9 146
1175  
1176 146 ▶ if (($a1->{too_complex}) or ($b1->{too_complex})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"} or $b1->{"too_complex"}) 35 111 146
Condition100%3/3
$a1->{"too_complex"} or $b1->{"too_complex"}
l!l&&r!l&&!r
287111
MC/DC100%2/2
$a1->{"too_complex"} or $b1->{"too_complex"}
$a1->{"too_complex"} $b1->{"too_complex"}
Truth table100%3/3
A or B
A= $a1->{"too_complex"}B= $b1->{"too_complex"}
ABresult
1X1
011
000
1177 35 return $a1->_function2( 'until', $b1 );
1178 }
1179 111 return $a1->SUPER::until( $b1 );
1180 }
1181  
1182  
1183 3337 ▶sub union {
Subroutine union: called CC=8 SCAR=20.9
Pod documented
1184 3337 my $a1 = shift;
1185 3337 ▶ my $b1 = (ref ($_[0]) eq ref($a1) ) ? shift : $a1->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq ref $a1 ? : 3287 50 3337
1186
1187 3337 ▶ $a1->trace_open(title=>"union", arg => $b1) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 3337 3337
1188 3337 ▶ if (($a1->{too_complex}) or ($b1->{too_complex})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"} or $b1->{"too_complex"}) 37 3300 3337
Condition100%3/3
$a1->{"too_complex"} or $b1->{"too_complex"}
l!l&&r!l&&!r
3433300
MC/DC100%2/2
$a1->{"too_complex"} or $b1->{"too_complex"}
$a1->{"too_complex"} $b1->{"too_complex"}
Truth table100%3/3
A or B
A= $a1->{"too_complex"}B= $b1->{"too_complex"}
ABresult
1X1
011
000
1189 37 ▶ $a1->trace_close( ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 37 37
1190 37 ▶ return $a1 if $b1->is_null;
Branch: 1 branch
BranchTrueFalseTotal
if $b1->is_null 0 37 37
1191 37 ▶ return $b1 if $a1->is_null;
Branch: 1 branch
BranchTrueFalseTotal
if $a1->is_null 3 34 37
1192 34 return $a1->_function2( 'union', $b1);
1193 }
1194 3300 return $a1->SUPER::union( $b1 );
1195 }
1196  
1197  
1198 # there are some ways to process 'contains':
1199 # A CONTAINS B IF A == ( A UNION B )
1200 # - faster
1201 # A CONTAINS B IF B == ( A INTERSECTION B )
1202 # - can backtrack = works for unbounded sets
1203 11 ▶sub contains {
Subroutine contains: called CC=14 SCAR=33.8
Pod documented
1204 11 my $a1 = shift;
1205 11 ▶ $a1->trace_open(title=>"contains") if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 11 11
1206 11 ▶ if ( $a1->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a1->{"too_complex"}) 4 7 11
1207 # we use intersection because it is better for backtracking
1208 4 ▶ my $b0 = (ref $_[0] eq ref $a1) ? shift : $a1->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq ref $a1 ? : 0 4 4
1209 4 my $b1 = $a1->intersection($b0);
1210 4 ▶ if ( $b1->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b1->{"too_complex"}) 0 4 4
1211 0 ▶ $b1->trace_close( arg => 'undef' ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
1212 0 return undef;
1213 }
1214 4 ▶ $a1->trace_close( arg => ($b1 == $b0 ? 1 : 0) ) if $TRACE;
Branch: 2 branches
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 4 4
$b1 == $b0 ? : 0 0 0
1215 4 ▶ return ($b1 == $b0) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$b1 == $b0 ? : 2 2 4
1216 }
1217 7 my $b1 = $a1->union(@_);
1218 7 ▶ if ( $b1->{too_complex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b1->{"too_complex"}) 0 7 7
1219 0 ▶ $b1->trace_close( arg => 'undef' ) if $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 0 0
1220 0 return undef;
1221 }
1222 7 ▶ $a1->trace_close( arg => ($b1 == $a1 ? 1 : 0) ) if $TRACE;
Branch: 2 branches
BranchTrueFalseTotal
if $Set::Infinite::TRACE 0 7 7
$b1 == $a1 ? : 0 0 0
1223 7 ▶ return ($b1 == $a1) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$b1 == $a1 ? : 4 3 7
1224 }
1225  
1226  
1227 11001 ▶sub min_a {
Subroutine min_a: called CC=4 SCAR=14.1
Pod documented
1228 11001 my $self = $_[0];
1229 11001 ▶ return @{$self->{min}} if exists $self->{min};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"min"} 2745 8256 11001
1230 8256 ▶ if ($self->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"too_complex"}) 957 7299 8256
1231 957 my @first = $self->first;
1232 957 ▶ return @{$self->{min}} = $first[0]->min_a if defined $first[0];
Branch: 1 branch
BranchTrueFalseTotal
if defined $first[0] 957 0 957
1233 0 return @{$self->{min}} = (undef, 0);
1234 }
1235 7299 return $self->SUPER::min_a;
1236 };
1237  
1238  
1239 10458 ▶sub max_a {
Subroutine max_a: called CC=4 SCAR=14.1
Pod documented
1240 10458 my $self = $_[0];
1241 10458 ▶ return @{$self->{max}} if exists $self->{max};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"max"} 2859 7599 10458
1242 7599 ▶ if ($self->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"too_complex"}) 940 6659 7599
1243 940 my @last = $self->last;
1244 940 ▶ return @{$self->{max}} = $last[0]->max_a if defined $last[0];
Branch: 1 branch
BranchTrueFalseTotal
if defined $last[0] 940 0 940
1245 0 return @{$self->{max}} = (undef, 0);
1246 }
1247 6659 return $self->SUPER::max_a;
1248 };
1249  
1250  
1251 2 ▶sub count {
Subroutine count: called CC=2 SCAR=7.1
Pod documented
1252 2 my $self = $_[0];
1253 # NOTE: subclasses may return "undef" if necessary
1254 2 ▶ return $inf if $self->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"too_complex"} 0 2 2
1255 2 return $self->SUPER::count;
1256 }
1257  
1258  
1259 13 ▶sub size {
Subroutine size: called CC=4 SCAR=14.2
Pod documented
1260 13 my $self = $_[0];
1261 13 ▶ if ($self->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"too_complex"}) 4 9 13
1262 4 my @min = $self->min_a;
1263 4 my @max = $self->max_a;
1264 4 ▶ return undef unless defined $max[0] && defined $min[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $max[0] and defined $min[0] 0 4 4
Condition33%1/3
defined $max[0] and defined $min[0]
!ll&&!rl&&r
004
MC/DC0%0/2
defined $max[0] and defined $min[0]
defined $max[0] defined $min[0]
Truth table33%1/3
A and B
A= defined $max[0]B= defined $min[0]
ABresult
0X0
100
111
1265 4 return $max[0] - $min[0];
1266 }
1267 9 return $self->SUPER::size;
1268 };
1269  
1270  
1271 72 ▶sub spaceship {
Subroutine spaceship: called CC=3 SCAR=12.5
Pod documented
1272 72 my ($tmp1, $tmp2, $inverted) = @_;
1273 carp "Can't compare unbounded sets"
1274 72 ▶ if $tmp1->{too_complex} or $tmp2->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
if $tmp1->{"too_complex"} or $tmp2->{"too_complex"} 0 72 72
Condition33%1/3
$tmp1->{"too_complex"} or $tmp2->{"too_complex"}
l!l&&r!l&&!r
0072
MC/DC0%0/2
$tmp1->{"too_complex"} or $tmp2->{"too_complex"}
$tmp1->{"too_complex"} $tmp2->{"too_complex"}
Truth table33%1/3
A or B
A= $tmp1->{"too_complex"}B= $tmp2->{"too_complex"}
ABresult
1X1
011
000
1275 72 return $tmp1->SUPER::spaceship( $tmp2, $inverted );
1276 }
1277  
1278  
1279 0 ▶sub _cleanup { @_ } # this subroutine is obsolete
Subroutine _cleanup: not called CC=1 SCAR=6.9
1280  
1281  
1282 3268 ▶sub tolerance {
Subroutine tolerance: called CC=5 SCAR=17.0
Pod documented
1283 3268 my $self = shift;
1284 3268 my $tmp = pop;
1285 3268 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) 3268 0 3268
1286 # local
1287 3268 ▶ return $self->{tolerance} unless defined $tmp;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 3252 16 3268
1288 16 ▶ if ($self->{too_complex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"too_complex"}) 3 13 16
1289 3 my $b1 = $self->_function( 'tolerance', $tmp );
1290 3 $b1->{tolerance} = $tmp; # for max/min processing
1291 3 return $b1;
1292 }
1293 13 return $self->SUPER::tolerance( $tmp );
1294 }
1295 # class method
1296 0 ▶ __PACKAGE__->SUPER::tolerance( $tmp ) if defined($tmp);
Branch: 1 branch
BranchTrueFalseTotal
if defined $tmp 0 0 0
1297 0 return __PACKAGE__->SUPER::tolerance;
1298 }
1299  
1300  
1301 0 ▶sub _pretty_print {
Subroutine _pretty_print: not called CC=3 SCAR=24.8
1302 0 my $self = shift;
1303 0 ▶ return "$self" unless $self->{too_complex};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"too_complex"} 0 0 0
1304 return $self->{method} . "( " .
1305 ( ref($self->{parent}) eq 'ARRAY' ?
1306 $self->{parent}[0] . ' ; ' . $self->{parent}[1] :
1307 0 ▶ $self->{parent} ) .
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{'parent'} eq 'ARRAY' ? : 0 0 0
1308 " )";
1309 }
1310  
1311  
1312 3737 ▶sub as_string {
Subroutine as_string: called CC=3 SCAR=11.1
Pod documented
1313 3737 my $self = shift;
1314 return ( $PRETTY_PRINT ? $self->_pretty_print : $too_complex )
1315 3737 ▶ if $self->{too_complex};
Branch: 2 branches
BranchTrueFalseTotal
if $self->{"too_complex"} 120 3617 3737
$Set::Infinite::PRETTY_PRINT ? : 0 120 120
1316 3617 return $self->SUPER::as_string;
1317 }
1318  
1319  
1320 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
1321  
1322 11 1;
1323  
1324 __END__
« Infinite/Arithmetic.pm ↑ Summary Infinite/Basic.pm »