line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDL::StringfiableExtension; |
2
|
|
|
|
|
|
|
$PDL::StringfiableExtension::VERSION = '0.003'; |
3
|
1
|
|
|
1
|
|
254489
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
392
|
use PDL::Lite; |
|
1
|
|
|
|
|
611
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
1326
|
use List::AllUtils (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
{ |
10
|
|
|
|
|
|
|
# This is a hack. |
11
|
|
|
|
|
|
|
# This gets PDL to stringify the single element and then gets the |
12
|
|
|
|
|
|
|
# element out of that string. |
13
|
|
|
|
|
|
|
my $_pdl_stringify_temp = PDL::Core::pdl([[0]]); |
14
|
|
|
|
|
|
|
my $_pdl_stringify_temp_single = PDL::Core::pdl(0); |
15
|
|
|
|
|
|
|
sub PDL::element_stringify { |
16
|
|
|
|
|
|
|
my ($self, $element) = @_; |
17
|
|
|
|
|
|
|
if( $self->ndims == 0 ) { |
18
|
|
|
|
|
|
|
return $_pdl_stringify_temp_single->set(0, $element)->string; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
# otherwise |
21
|
|
|
|
|
|
|
my $string = $_pdl_stringify_temp->set(0,0, $element)->string; |
22
|
|
|
|
|
|
|
( $_pdl_stringify_temp->string =~ /\[(.*)\]/ )[0]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub PDL::element_stringify_max_width { |
27
|
|
|
|
|
|
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
my @vals = @{ $self->uniq->unpdl }; |
29
|
|
|
|
|
|
|
my @lens = map { length $self->element_stringify($_) } @vals; |
30
|
|
|
|
|
|
|
List::AllUtils::max( @lens ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=encoding UTF-8 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
PDL::StringfiableExtension |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 VERSION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
version 0.003 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Zakariyya Mughal <zmughal@cpan.org> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Zakariyya Mughal. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
58
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |