| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CXC::Number::Sequence; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Numerical Sequence Generation |
|
4
|
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
656843
|
use v5.28; |
|
|
11
|
|
|
|
|
42
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
5229
|
use POSIX (); |
|
|
11
|
|
|
|
|
75149
|
|
|
|
11
|
|
|
|
|
498
|
|
|
8
|
11
|
|
|
11
|
|
2205
|
use CXC::Number::Sequence::Types qw( Sequence ); |
|
|
11
|
|
|
|
|
298
|
|
|
|
11
|
|
|
|
|
134
|
|
|
9
|
11
|
|
|
11
|
|
12569
|
use CXC::Number::Sequence::Failure -all; |
|
|
11
|
|
|
|
|
34
|
|
|
|
11
|
|
|
|
|
133
|
|
|
10
|
11
|
|
|
11
|
|
3868
|
use CXC::Number::Sequence::Utils qw( load_class ); |
|
|
11
|
|
|
|
|
37
|
|
|
|
11
|
|
|
|
|
165
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
11
|
|
|
11
|
|
4365
|
use Moo; |
|
|
11
|
|
|
|
|
12438
|
|
|
|
11
|
|
|
|
|
94
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
11
|
|
|
11
|
|
6853
|
use experimental 'signatures'; |
|
|
11
|
|
|
|
|
36
|
|
|
|
11
|
|
|
|
|
101
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
11
|
|
|
11
|
|
2364
|
use namespace::clean; |
|
|
11
|
|
|
|
|
23
|
|
|
|
11
|
|
|
|
|
117
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
11
|
|
|
11
|
|
10283
|
use MooX::StrictConstructor; |
|
|
11
|
|
|
|
|
106896
|
|
|
|
11
|
|
|
|
|
89
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# subclass should define |
|
23
|
|
|
|
|
|
|
has _raw_elements => ( |
|
24
|
|
|
|
|
|
|
is => 'lazy', |
|
25
|
|
|
|
|
|
|
init_arg => 'elements', |
|
26
|
|
|
|
|
|
|
isa => Sequence, |
|
27
|
|
|
|
|
|
|
required => 1, |
|
28
|
|
|
|
|
|
|
coerce => 1, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
255
|
|
|
255
|
|
2287
|
sub _convert ( $self, $bignum ) { |
|
|
255
|
|
|
|
|
550
|
|
|
|
255
|
|
|
|
|
377
|
|
|
|
255
|
|
|
|
|
397
|
|
|
33
|
255
|
|
|
|
|
4612
|
require Ref::Util; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return Ref::Util::is_plain_arrayref( $bignum ) |
|
36
|
255
|
100
|
|
|
|
7075
|
? [ map { $_->numify } $bignum->@* ] |
|
|
1050
|
|
|
|
|
169676
|
|
|
37
|
|
|
|
|
|
|
: $bignum->numify; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
55
|
|
|
55
|
1
|
63959
|
sub elements ( $self ) { |
|
|
55
|
|
|
|
|
176
|
|
|
|
55
|
|
|
|
|
91
|
|
|
50
|
55
|
|
|
|
|
1898
|
$self->_convert( $self->_raw_elements ); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
54
|
|
|
54
|
1
|
1366
|
sub nelem ( $self ) { |
|
|
54
|
|
|
|
|
107
|
|
|
|
54
|
|
|
|
|
262
|
|
|
62
|
54
|
|
|
|
|
1248
|
scalar $self->_raw_elements->@*; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
51
|
|
|
51
|
1
|
88008
|
sub spacing ( $self ) { |
|
|
51
|
|
|
|
|
213
|
|
|
|
51
|
|
|
|
|
134
|
|
|
76
|
51
|
|
|
|
|
2405
|
my $elements = $self->_raw_elements; |
|
77
|
51
|
|
|
|
|
562
|
my @spacing = map { $elements->[$_] - $elements->[ $_ - 1 ] } 1 .. ( $self->nelem - 1 ); |
|
|
493
|
|
|
|
|
226788
|
|
|
78
|
51
|
|
|
|
|
28027
|
return $self->_convert( \@spacing ); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
77
|
|
|
77
|
1
|
168610
|
sub min ( $self ) { |
|
|
77
|
|
|
|
|
195
|
|
|
|
77
|
|
|
|
|
138
|
|
|
90
|
77
|
|
|
|
|
3455
|
return $self->_convert( $self->_raw_elements->[0] ); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
77
|
|
|
77
|
1
|
39176
|
sub max ( $self ) { |
|
|
77
|
|
|
|
|
274
|
|
|
|
77
|
|
|
|
|
164
|
|
|
102
|
77
|
|
|
|
|
2514
|
return $self->_convert( $self->_raw_elements->[-1] ); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
5
|
|
|
5
|
1
|
22208
|
sub build ( $, $type, %options ) { |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
25
|
|
|
|
5
|
|
|
|
|
79
|
|
|
124
|
5
|
|
|
|
|
28
|
load_class( $type )->new( %options ); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
2
|
|
|
2
|
1
|
74
|
sub bignum ( $self ) { |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
5
|
|
|
142
|
2
|
|
|
|
|
34
|
require Moo::Role; |
|
143
|
2
|
|
|
|
|
43
|
return Moo::Role->apply_roles_to_object( |
|
144
|
|
|
|
|
|
|
__PACKAGE__->new( elements => $self->_raw_elements ), |
|
145
|
|
|
|
|
|
|
__PACKAGE__ . '::Role::BigNum', |
|
146
|
|
|
|
|
|
|
); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
0
|
1
|
|
sub pdl ( $self ) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
require Moo::Role; |
|
163
|
0
|
|
|
|
|
|
return Moo::Role->apply_roles_to_object( |
|
164
|
|
|
|
|
|
|
__PACKAGE__->new( elements => $self->_raw_elements ), |
|
165
|
|
|
|
|
|
|
__PACKAGE__ . '::Role::PDL', |
|
166
|
|
|
|
|
|
|
); |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# |
|
171
|
|
|
|
|
|
|
# This file is part of CXC-Number |
|
172
|
|
|
|
|
|
|
# |
|
173
|
|
|
|
|
|
|
# This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. |
|
174
|
|
|
|
|
|
|
# |
|
175
|
|
|
|
|
|
|
# This is free software, licensed under: |
|
176
|
|
|
|
|
|
|
# |
|
177
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
|
178
|
|
|
|
|
|
|
# |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
__END__ |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=pod |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=for :stopwords Diab Jerius Smithsonian Astrophysical Observatory nelem bignum pdl |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 NAME |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
CXC::Number::Sequence - Numerical Sequence Generation |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 VERSION |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
version 0.13 |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
use CXC::Number::Sequence; |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
CXC::Number::Sequence->build( $type, %options ); |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This is an entry point for building sequences of numbers. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
B<WARNING> |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Currently, a sequence is a subclass of C<CXC::Number::Sequence>, but |
|
209
|
|
|
|
|
|
|
this may change to a role based relationship. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head2 Constraints |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
At present sequences are not lazily built. This can easily be |
|
214
|
|
|
|
|
|
|
accommodated and iterators added. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head2 build |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
$sequence = CXC::Number::Sequence->build( $class, %options ); |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Construct a sequence of type C<$class>, where C<$class> is a subclass of |
|
223
|
|
|
|
|
|
|
B<CXC::Number::Sequence>. If C<$class> is in the C<CXC::Number::Sequence> |
|
224
|
|
|
|
|
|
|
namespace, only the relative class name is required, e.g. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
linear => CXC::Number::Sequence::Linear |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
(note that C<$class> is converted to I<CamelCase>; input words should be separated by a C<_>). |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
C<build> will first attempt to load C<$class> in the |
|
231
|
|
|
|
|
|
|
C<CXC::Number::Sequence> namespace, and if not present will assume |
|
232
|
|
|
|
|
|
|
C<$class> is a full package name. |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 METHODS |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 elements |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
$array_ref = $sequence->elements; |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Return the sequence elements as a reference to an array of Perl |
|
241
|
|
|
|
|
|
|
numbers. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 nelem |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
$nelem = $sequence->nelem; |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
The number of elements in the sequence. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 spacing |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$spacing = $sequence->spacing; |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Return the spacing between elements as a reference to an array of Perl |
|
254
|
|
|
|
|
|
|
numbers. |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head2 min |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$min = $sequence->min; |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Returns the minimum bound of the sequence as a Perl number. |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head2 max |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
$max = $sequence->max; |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Returns the maximum bound of the sequence as a Perl number. |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head2 bignum |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
$elements = $sequence->bignum->elements; |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Returns an object which returns copies of the internal |
|
273
|
|
|
|
|
|
|
L<Math::BigFloat> objects for the following methods |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
elements -> Array[Math::BigFloat] |
|
276
|
|
|
|
|
|
|
spacing -> Array[Math::BigFloat] |
|
277
|
|
|
|
|
|
|
min -> Math::BigFloat |
|
278
|
|
|
|
|
|
|
max -> Math::BigFloat |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head2 pdl |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
$elements = $sequence->pdl->elements; |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Returns an object which returns piddles for the following methods |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
elements -> piddle |
|
287
|
|
|
|
|
|
|
spacing -> piddle |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=head1 INTERNALS |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 SUPPORT |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head2 Bugs |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
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> |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head2 Source |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Source is available at |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
https://gitlab.com/djerius/cxc-number |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
and may be cloned from |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
https://gitlab.com/djerius/cxc-number.git |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=over 4 |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=item * |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
L<CXC::Number|CXC::Number> |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=item * |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
L<CXC::Number::Grid|CXC::Number::Grid> |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=item * |
|
322
|
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
L<CXC::Number::Sequence::Linear|CXC::Number::Sequence::Linear> |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=item * |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
L<CXC::Number::Sequence::Ratio|CXC::Number::Sequence::Ratio> |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=item * |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
L<CXC::Number::Sequence::Fixed|CXC::Number::Sequence::Fixed> |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=back |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=head1 AUTHOR |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
Diab Jerius <djerius@cpan.org> |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
This is free software, licensed under: |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=cut |