| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CXC::Number::Grid::Types; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Type::Tiny types for CXC::Number::Grid |
|
4
|
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
284371
|
use v5.28; |
|
|
13
|
|
|
|
|
65
|
|
|
6
|
13
|
|
|
13
|
|
129
|
use strict; |
|
|
13
|
|
|
|
|
24
|
|
|
|
13
|
|
|
|
|
335
|
|
|
7
|
13
|
|
|
13
|
|
80
|
use warnings; |
|
|
13
|
|
|
|
|
27
|
|
|
|
13
|
|
|
|
|
1149
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
13
|
|
|
13
|
|
22541
|
use Math::BigInt upgrade => 'Math::BigFloat'; |
|
|
13
|
|
|
|
|
685550
|
|
|
|
13
|
|
|
|
|
75
|
|
|
12
|
13
|
|
|
13
|
|
412622
|
use Math::BigFloat; |
|
|
13
|
|
|
|
|
532719
|
|
|
|
13
|
|
|
|
|
77
|
|
|
13
|
13
|
|
|
13
|
|
1911
|
use List::Util 'all'; |
|
|
13
|
|
|
|
|
28
|
|
|
|
13
|
|
|
|
|
1040
|
|
|
14
|
13
|
|
|
13
|
|
8391
|
use Type::Utils '-all'; |
|
|
13
|
|
|
|
|
169377
|
|
|
|
13
|
|
|
|
|
158
|
|
|
15
|
13
|
|
|
13
|
|
35580
|
use Types::Standard qw[ CycleTuple Num Int Enum Tuple Any InstanceOf Dict ArrayRef Value ]; |
|
|
13
|
|
|
|
|
101583
|
|
|
|
13
|
|
|
|
|
136
|
|
|
16
|
13
|
|
|
13
|
|
59919
|
use Types::Common::Numeric qw[ PositiveNum PositiveOrZeroNum PositiveInt ]; |
|
|
13
|
|
|
|
|
360519
|
|
|
|
13
|
|
|
|
|
185
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
13
|
|
|
|
|
107
|
use Type::Library -base, -declare => qw( |
|
19
|
|
|
|
|
|
|
BinEdges |
|
20
|
|
|
|
|
|
|
BinBounds |
|
21
|
|
|
|
|
|
|
Spacing |
|
22
|
|
|
|
|
|
|
MonotonicallyIncreasingArrayOfBigNums |
|
23
|
13
|
|
|
13
|
|
18181
|
); |
|
|
13
|
|
|
|
|
30
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
13
|
|
|
13
|
|
12159
|
BEGIN { extends 'CXC::Number::Types' } |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
declare BinEdges, as ArrayRef [ BigNum, 2 ], where { |
|
34
|
|
|
|
|
|
|
my $arr = $_; |
|
35
|
|
|
|
|
|
|
$arr->[$_] < $arr->[ $_ + 1 ] || return for 0 .. ( $arr->@* - 2 ); |
|
36
|
|
|
|
|
|
|
1; |
|
37
|
|
|
|
|
|
|
}, message { |
|
38
|
|
|
|
|
|
|
ArrayRef( [ BigNum, 2 ] )->validate( $_ ) |
|
39
|
|
|
|
|
|
|
or 'Must be an array of monotonically increasing numbers with at lest two elements' |
|
40
|
|
|
|
|
|
|
}, coercion => 1; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
coerce BinEdges, from InstanceOf ['CXC::Number::Sequence'], via { $_->bignum->elements } |
|
43
|
|
|
|
|
|
|
; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
declare BinBounds, as CycleTuple [ BigNum, BigNum ], where { |
|
46
|
|
|
|
|
|
|
return unless $_->@*; |
|
47
|
|
|
|
|
|
|
my $lval = $_->[0]; |
|
48
|
|
|
|
|
|
|
my $ub = 0; # this gets toggled between true and false |
|
49
|
|
|
|
|
|
|
return all { |
|
50
|
|
|
|
|
|
|
( my $_lval, $lval ) = ( $lval, $_ ); |
|
51
|
|
|
|
|
|
|
( my $_ub, $ub ) = ( $ub, 1 - $ub ); # save ub flag and toggle it for next round. |
|
52
|
|
|
|
|
|
|
$_ub ? $_ > $_lval : $_ >= $_lval; |
|
53
|
|
|
|
|
|
|
} $_->@*; |
|
54
|
|
|
|
|
|
|
}, message { |
|
55
|
|
|
|
|
|
|
# it's either |
|
56
|
|
|
|
|
|
|
# 1. not pairs, |
|
57
|
|
|
|
|
|
|
# 2. not pairs of numbers, |
|
58
|
|
|
|
|
|
|
# 3. not sorted |
|
59
|
|
|
|
|
|
|
!eval { CycleTuple( [ BigNum, BigNum ] )->assert_coerce( $_ ); $_->@* } |
|
60
|
|
|
|
|
|
|
? 'Must be non-empty array of numbers with an even number of elements' |
|
61
|
|
|
|
|
|
|
: 'The elements in the array must be in ascending order'; |
|
62
|
|
|
|
|
|
|
}, coercion => 1; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# |
|
67
|
|
|
|
|
|
|
# This file is part of CXC-Number |
|
68
|
|
|
|
|
|
|
# |
|
69
|
|
|
|
|
|
|
# This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. |
|
70
|
|
|
|
|
|
|
# |
|
71
|
|
|
|
|
|
|
# This is free software, licensed under: |
|
72
|
|
|
|
|
|
|
# |
|
73
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
|
74
|
|
|
|
|
|
|
# |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=pod |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=for :stopwords Diab Jerius Smithsonian Astrophysical Observatory BinEdges |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
CXC::Number::Grid::Types - Type::Tiny types for CXC::Number::Grid |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 0.13 |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 TYPES |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 BinEdges |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
A array of numbers with at lest two members which is sorted by increasing value |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 INTERNALS |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SUPPORT |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 Bugs |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Please report any bugs or feature requests to bug-cxc-number@rt.cpan.org or through the web interface at: L<https://rt.cpan.org/Public/Dist/Display.html?Name=CXC-Number> |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 Source |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Source is available at |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
https://gitlab.com/djerius/cxc-number |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
and may be cloned from |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
https://gitlab.com/djerius/cxc-number.git |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=over 4 |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L<CXC::Number|CXC::Number> |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=back |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Diab Jerius <djerius@cpan.org> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This is free software, licensed under: |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |