CXC::Number::Sequence::Linear - Numeric Sequence with Equal Spacing
version 0.05
use CXC::Number::Sequence::Linear; $sequence = CXC::Number::Sequence::Linear->new( %options ); $values = $sequence->sequence;
CXC::Number::Sequence::Linear constructs a finite sequence of increasing, equally spaced, numbers.
It subclasses CXC::Number::Sequence, so see documentation for that class for additional methods.
Sequence extrema may be specified or may be calculated from other parameters, such as spacing, the number of elements, or a sequence center, and the sequence may be aligned on a fiducial value,
Sequence extrema may be hard, indicating that the sequence must exactly cover the extrema, or soft, indicating that the sequence may cover a larger range. Usually the combination of parameters will uniquely determine whether an extremum is soft or hard, but in some cases soft bounds must be explicitly labelled as soft, requiring use of the soft_min and soft_max parameters.
soft_min
soft_max
A full description of the available parameters may be found in the description of the constructor "new".
Note: If the sequence extrema are equal to the range bounds, then the sequence exactly covers the range. Otherwise, the sequence will cover the range, but may extend beyond one or more of the extrema.
min
max
nelem
The sequence exactly covers the specified range.
spacing
If an integral multiple of spacing fits within the range, the sequence exactly covers it, otherwise the sequence is centered on the range.
The number of elements is chosen to exactly covers the calculated range.
The hard extremum is as specified. The number of elements is chosen to cover the specified range.
center
The sequence is centered as specified and exactly covers the range.
rangew
The sequence is centered as specified and covers the range.
The sequence is centered on the specified center and covers the specified range.
align
The sequence covers the specified range and is aligned so that the specified alignment point is at the specified relative position between elements.
new
$sequence = CXC::Number::Sequence::Linear->new( %attr );
Construct a linear spaced sequence. The available attributes are those for the parent constructor in CXC::Number::Sequence, as well as the following:
force_extrema
Sometimes the extrema of the sequence will not exactly match what was specified because of round-off error. If this option is true, then sequences extrema will be set to the specified values. This may result in spacings which are slightly different in size (the exact spacings are available via the spacing method).
The minimum value that the sequence should cover. Use soft_min to disambiguate hard from soft limits as documented above.
The maximum value that the sequence should cover. Use soft_max to disambiguate hard from soft limits as documented above.
The center of the sequence. If there are an odd number of elements, this will be the center element, otherwise it will be the average of the middle two.
The width of the range to be covered by the sequence.
The number of elements in the sequence
The distance between elements in the sequence.
The sequence will be aligned such that the fiducial value $P is located at the fractional position $f between elements. $P need not be in the range of data covered by the sequence.
$P
$f
For example, to align the sequence such that 0 falls exactly half way between two elements, even though the generated sequence doesn't include 0:
0
use Data::Dump; use aliased 'CXC::Number::Sequence::Linear'; dd Linear->new( min => 5.1, max => 8, spacing => 1, align => [ 0, 0.5 ], )->elements;
results in
[4.5, 5.5, 6.5, 7.5, 8.5]
If an inconsistent set of parameters is passed, new will throw an exception of class CXC::Number::Sequence::Failure::parameter::interface.
CXC::Number::Sequence::Failure::parameter::interface
If an unknown parameter is passed, new will throw an exception of class CXC::Number::Sequence::Failure::parameter::unknown.
CXC::Number::Sequence::Failure::parameter::unknown
If a parameter value is illegal (e.g., a negative spacing), or a combination of values is illegal ( e.g. min > max, new will throw an exception of class CXC::Number::Sequence::Failure::parameter::constraint.
min > max
CXC::Number::Sequence::Failure::parameter::constraint
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=CXC-Number or by email to bug-cxc-number@rt.cpan.org.
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Please see those modules/websites for more information related to this module.
CXC::Number
Diab Jerius <djerius@cpan.org>
This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
To install CXC::Number, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CXC::Number
CPAN shell
perl -MCPAN -e shell install CXC::Number
For more information on module installation, please visit the detailed CPAN module installation guide.