| 1 | package CXC::Number::Sequence::Role::PDL; | ||
| 2 | |||
| 3 | # ABSTRACT: Role to return PDL objects from Sequences | ||
| 4 | |||
| 5 | use v5.28; | ||
| 6 | use PDL::Lite (); | ||
| 7 | |||
| 8 | use Moo::Role; | ||
| 9 | |||
| 10 | use experimental 'signatures'; | ||
| 11 | use namespace::clean; | ||
| 12 | |||
| 13 | our $VERSION = '0.12'; | ||
| 14 | |||
| 15 | sub _convert ( $self, $bignum ) { | ||
| 16 | require Ref::Util; | ||
| 17 | |||
| 18 | return Ref::Util::is_plain_arrayref( $bignum ) | ||
| 19 | ? PDL->pdl( [ map { $_->numify } $bignum->@* ] ) | ||
| 20 | : $bignum->numify; | ||
| 21 | } | ||
| 22 | |||
| 23 | # | ||
| 24 | # This file is part of CXC-Number | ||
| 25 | # | ||
| 26 | # This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. | ||
| 27 | # | ||
| 28 | # This is free software, licensed under: | ||
| 29 | # | ||
| 30 | # The GNU General Public License, Version 3, June 2007 | ||
| 31 | # | ||
| 32 | |||
| 33 | 1; | ||
| 34 | |||
| 35 | __END__ | ||
| 36 | |||
| 37 | =pod | ||
| 38 | |||
| 39 | =for :stopwords Diab Jerius Smithsonian Astrophysical Observatory | ||
| 40 | |||
| 41 | =head1 NAME | ||
| 42 | |||
| 43 | CXC::Number::Sequence::Role::PDL - Role to return PDL objects from Sequences | ||
| 44 | |||
| 45 | =head1 VERSION | ||
| 46 | |||
| 47 | version 0.12 | ||
| 48 | |||
| 49 | =head1 SYNOPSIS | ||
| 50 | |||
| 51 | my $obj = CXC::Number::Sequence->build( $class, %options)->elements => \@elements ); | ||
| 52 | Moo::Role->apply_role_to_object( $obj, 'CXC::Number::Sequence::Role::PDL' ); | ||
| 53 | |||
| 54 | =head1 DESCRIPTION | ||
| 55 | |||
| 56 | A L<Moo> role providing a C<_convert> method which returns passed | ||
| 57 | L<Math::BigFloat> arrays as piddles and passed L<Math::BigFloat> scalars as Perl numbers. | ||
| 58 | |||
| 59 | =head1 INTERNALS | ||
| 60 | |||
| 61 | =head1 SUPPORT | ||
| 62 | |||
| 63 | =head2 Bugs | ||
| 64 | |||
| 65 | 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> | ||
| 66 | |||
| 67 | =head2 Source | ||
| 68 | |||
| 69 | Source is available at | ||
| 70 | |||
| 71 | https://gitlab.com/djerius/cxc-number | ||
| 72 | |||
| 73 | and may be cloned from | ||
| 74 | |||
| 75 | https://gitlab.com/djerius/cxc-number.git | ||
| 76 | |||
| 77 | =head1 SEE ALSO | ||
| 78 | |||
| 79 | Please see those modules/websites for more information related to this module. | ||
| 80 | |||
| 81 | =over 4 | ||
| 82 | |||
| 83 | =item * | ||
| 84 | |||
| 85 | L<CXC::Number|CXC::Number> | ||
| 86 | |||
| 87 | =item * | ||
| 88 | |||
| 89 | L<CXC::Number::Sequence|CXC::Number::Sequence> | ||
| 90 | |||
| 91 | =back | ||
| 92 | |||
| 93 | =head1 AUTHOR | ||
| 94 | |||
| 95 | Diab Jerius <djerius@cpan.org> | ||
| 96 | |||
| 97 | =head1 COPYRIGHT AND LICENSE | ||
| 98 | |||
| 99 | This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. | ||
| 100 | |||
| 101 | This is free software, licensed under: | ||
| 102 | |||
| 103 | The GNU General Public License, Version 3, June 2007 | ||
| 104 | |||
| 105 | =cut |