| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################## |
|
2
|
|
|
|
|
|
|
package # hide from PAUSE/MetaCPAN |
|
3
|
|
|
|
|
|
|
PDL::PP::PdlDimsObj; # Hold more dims |
|
4
|
4
|
|
|
4
|
|
34
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
200
|
|
|
5
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
263
|
|
|
6
|
4
|
|
|
4
|
|
27
|
use Carp; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
1843
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
139
|
|
|
139
|
|
700
|
my($type) = @_; |
|
10
|
139
|
|
|
|
|
468
|
bless {},$type; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub get_indobj_make { |
|
14
|
123
|
|
|
123
|
|
488
|
my ($this,$expr,$calc) = @_; |
|
15
|
123
|
50
|
|
|
|
789
|
my ($name, $val) = $expr =~ /^([a-zA-Z0-9]+)(?:=([0-9]+))?$/ or confess "Invalid index expr '$expr'\n"; |
|
16
|
123
|
50
|
33
|
|
|
327
|
confess "Error: both simple value '$val' and CALC '$calc'" |
|
17
|
|
|
|
|
|
|
if $calc && defined $val; |
|
18
|
123
|
|
66
|
|
|
382
|
$val //= $calc; |
|
19
|
123
|
|
66
|
|
|
652
|
my $indobj = $this->{$name} //= PDL::PP::Ind->new($name); |
|
20
|
123
|
100
|
|
|
|
295
|
$indobj->add_value($val) if defined $val; |
|
21
|
123
|
|
|
|
|
522
|
return $indobj; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
63
|
|
|
63
|
|
256
|
sub ind_obj {$_[0]{$_[1]}} |
|
25
|
129
|
|
|
129
|
|
189
|
sub ind_names {keys %{$_[0]}} |
|
|
129
|
|
|
|
|
668
|
|
|
26
|
23
|
|
|
23
|
|
45
|
sub ind_fromcomp {grep defined $_->{From}, values %{$_[0]}} |
|
|
23
|
|
|
|
|
216
|
|
|
27
|
23
|
|
|
23
|
|
42
|
sub ind_notfromcomp {grep !defined $_->{From}, values %{$_[0]}} |
|
|
23
|
|
|
|
|
142
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
##################################################################### |
|
30
|
|
|
|
|
|
|
# |
|
31
|
|
|
|
|
|
|
# Encapsulate one index. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
package # hide from PAUSE/MetaCPAN |
|
34
|
|
|
|
|
|
|
PDL::PP::Ind; |
|
35
|
4
|
|
|
4
|
|
30
|
use Carp; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
2757
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
|
38
|
86
|
|
|
86
|
|
216
|
my($type,$name) = @_; |
|
39
|
86
|
|
|
|
|
386
|
bless {Name => $name},$type; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# set the value of an index, also used by perl level broadcasting |
|
43
|
|
|
|
|
|
|
sub add_value { |
|
44
|
51
|
|
|
51
|
|
87
|
my($this,$val) = @_; |
|
45
|
51
|
50
|
33
|
|
|
346
|
croak("index values for $this->{Name} must be positive") |
|
46
|
|
|
|
|
|
|
if $val =~ /^\d+$/ and $val <= 0; |
|
47
|
|
|
|
|
|
|
return $this->{Value} = $val if |
|
48
|
|
|
|
|
|
|
!defined $this->{Value} or |
|
49
|
|
|
|
|
|
|
$this->{Value} == -1 or |
|
50
|
51
|
50
|
66
|
|
|
286
|
$this->{Value} == 1; |
|
|
|
|
66
|
|
|
|
|
|
51
|
5
|
100
|
100
|
|
|
117
|
croak "For index $this->{Name} conflicting values $this->{Value} and $val given\n" if $val != 1 && $val != $this->{Value}; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# This index will take its size value from outside parameter ... |
|
55
|
2
|
|
|
2
|
|
4
|
sub set_from { my($this,$otherpar) = @_; |
|
56
|
2
|
|
|
|
|
4
|
$this->{From} = $otherpar; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
258
|
|
|
258
|
|
1117
|
sub name {$_[0]{Name}} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# where it occurs in the C arrays that track it (at least name and size) |
|
62
|
|
|
|
|
|
|
sub set_index { |
|
63
|
62
|
|
|
62
|
|
122
|
my ($this, $i) = @_; |
|
64
|
62
|
|
|
|
|
136
|
$this->{Index} = $i; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
15
|
|
33
|
15
|
|
98
|
sub get_index {$_[0]{Index} // confess "unknown index for $_[0]{Name}"} |
|
67
|
|
|
|
|
|
|
|
|
68
|
26
|
|
|
26
|
|
55
|
sub get_initdim { my($this) = @_; |
|
69
|
|
|
|
|
|
|
my $init = $this->{Value} // |
|
70
|
26
|
100
|
100
|
|
|
152
|
($this->{From} ? "\$COMP(".$this->{From}{ProtoName}.")" : undef); |
|
71
|
26
|
100
|
|
|
|
129
|
return if !defined $init; |
|
72
|
2
|
|
|
|
|
12
|
$this->get_size." = $init;" |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
3
|
|
|
3
|
|
7
|
sub get_size { my($this) = @_; |
|
76
|
3
|
|
|
|
|
44
|
"\$PRIV(ind_sizes)[@{[$this->get_index]}]" |
|
|
3
|
|
|
|
|
15
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |