line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Vectorize; |
2
|
|
|
|
|
|
|
|
3
|
80
|
|
|
80
|
|
2604293
|
use strict; |
|
80
|
|
|
|
|
318
|
|
|
80
|
|
|
|
|
7324
|
|
4
|
|
|
|
|
|
|
|
5
|
80
|
|
|
80
|
|
637
|
use Carp; |
|
80
|
|
|
|
|
163
|
|
|
80
|
|
|
|
|
12646
|
|
6
|
80
|
|
|
80
|
|
139554
|
use Data::Dumper; |
|
80
|
|
|
|
|
1109955
|
|
|
80
|
|
|
|
|
7393
|
|
7
|
80
|
|
|
80
|
|
787
|
use constant {EPS => 1e-8}; |
|
80
|
|
|
|
|
150
|
|
|
80
|
|
|
|
|
63977
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = ("Exporter"); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = "1.05"; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw(sapply mapply happly tapply initial_array initial_matrix order |
15
|
|
|
|
|
|
|
rank sort_array reverse_array repeat rep copy paste seq c test |
16
|
|
|
|
|
|
|
unique subset subset_value which all any dim t matrix_prod is_array_identical |
17
|
|
|
|
|
|
|
is_matrix_identical outer inner match len abs plus minus multiply divide |
18
|
|
|
|
|
|
|
print_ref print_matrix read_table write_table intersect union |
19
|
|
|
|
|
|
|
setdiff setequal is_element sign sum mean geometric_mean |
20
|
|
|
|
|
|
|
sd var cov cor dist freq table scale sample del_array_item |
21
|
|
|
|
|
|
|
rnorm rbinom max min which_max which_min median quantile iqr cumf |
22
|
|
|
|
|
|
|
is_empty |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
26
|
|
|
|
|
|
|
apply => [qw(sapply mapply happly tapply)], |
27
|
|
|
|
|
|
|
list => [qw(initial_array initial_matrix order rank sort_array reverse_array |
28
|
|
|
|
|
|
|
repeat rep copy paste seq c test unique subset subset_value |
29
|
|
|
|
|
|
|
which all any dim t matrix_prod is_array_identical is_matrix_identical |
30
|
|
|
|
|
|
|
outer inner match len is_empty del_array_item plus minus multiply divide)], |
31
|
|
|
|
|
|
|
io => [qw(print_ref print_matrix read_table write_table)], |
32
|
|
|
|
|
|
|
set => [qw(intersect union setdiff setequal is_element)], |
33
|
|
|
|
|
|
|
stat => [qw(sign sum mean geometric_mean sd var cov cor dist freq table scale |
34
|
|
|
|
|
|
|
sample rnorm rbinom max min which_max which_min |
35
|
|
|
|
|
|
|
median quantile iqr cumf abs)] |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $module = __PACKAGE__; |
39
|
|
|
|
|
|
|
$module =~s/::/\//g; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# find the module library directory |
42
|
|
|
|
|
|
|
my $module_dir = "."; |
43
|
|
|
|
|
|
|
foreach (@INC) { |
44
|
|
|
|
|
|
|
if( -e "$_/$module.pm") { |
45
|
|
|
|
|
|
|
$module_dir = $_; |
46
|
|
|
|
|
|
|
last; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
our $REF_TYPE = {'SCALAR' => '$', |
51
|
|
|
|
|
|
|
'ARRAY' => '@', |
52
|
|
|
|
|
|
|
'HASH' => '%', |
53
|
|
|
|
|
|
|
'CODE' => '&', |
54
|
|
|
|
|
|
|
'GLOB' => '*', |
55
|
|
|
|
|
|
|
'Regexp' => 'm', |
56
|
|
|
|
|
|
|
'REF' => '$', |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# variable in @_ are all references |
60
|
|
|
|
|
|
|
sub check_prototype { |
61
|
3118
|
|
|
3118
|
0
|
4549
|
my $prototype = pop; |
62
|
3118
|
|
|
|
|
3837
|
my $prototype_as_string = $prototype; |
63
|
3118
|
50
|
|
|
|
9474
|
if(ref($prototype) ne "Regexp") { |
64
|
3118
|
|
|
|
|
11718
|
$prototype =~s/\\/\\\\/g; |
65
|
3118
|
|
|
|
|
22253
|
$prototype =~s/([\$\&\%\@\*])/\\$1/g; |
66
|
3118
|
|
|
|
|
46060
|
$prototype = qr/$prototype/; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
3118
|
|
|
|
|
5486
|
my $p = ''; |
70
|
3118
|
|
|
|
|
32902
|
for(my $i = 0; $i < scalar(@_); $i ++) { |
71
|
5082
|
100
|
|
|
|
11932
|
if(ref($_[$i])) { |
72
|
4615
|
|
|
|
|
16664
|
$p .= '\\'.$REF_TYPE->{ref($_[$i])}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
467
|
|
|
|
|
2036
|
$p .= $REF_TYPE->{ref(\$_[$i])}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
3118
|
50
|
|
|
|
35054
|
if($p=~/^$prototype$/) { |
80
|
3118
|
|
|
|
|
12458
|
return 1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
else { |
83
|
0
|
|
|
|
|
|
confess "ERROR: your prototype is '$p', but it should be '$prototype_as_string' ($prototype).\n"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# get all functions |
90
|
|
|
|
|
|
|
require("$module_dir/$module/lib/Apply.pl"); |
91
|
|
|
|
|
|
|
require("$module_dir/$module/lib/List.pl"); |
92
|
|
|
|
|
|
|
require("$module_dir/$module/lib/IO.pl"); |
93
|
|
|
|
|
|
|
require("$module_dir/$module/lib/Set.pl"); |
94
|
|
|
|
|
|
|
require("$module_dir/$module/lib/Statistic.pl"); |
95
|
|
|
|
|
|
|
require("$module_dir/$module/lib/Datatype.pl"); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |