| 1 | package PDL::NDBin::Action::Max; | ||
| 2 | # ABSTRACT: Action for PDL::NDBin that computes maximum | ||
| 3 | $PDL::NDBin::Action::Max::VERSION = '0.016'; | ||
| 4 | |||
| 5 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 2 | ▶ | use PDL::Lite; # do not import any functions into this namespace |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | ▶ | use PDL::NDBin::Actions_PP; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 9 | use Params::Validate qw( validate OBJECT SCALAR UNDEF ); | ||
| 10 | |||
| 11 | |||
| 12 | sub new | ||
| 13 | { | ||
| 14 | my $class = shift; | ||
| 15 | my $self = validate( @_, { | ||
| 16 | N => { type => SCALAR, regex => qr/^\d+$/ }, | ||
| 17 | type => { type => OBJECT | UNDEF, isa => 'PDL::Type', optional => 1 } | ||
| 18 | } ); | ||
| 19 | return bless $self, $class; | ||
| 20 | } | ||
| 21 | |||
| 22 | |||
| 23 | sub process | ||
| 24 | { | ||
| 25 | my $self = shift; | ||
| 26 | my $iter = shift; | ||
| 27 | if( ! defined $self->{out} ) { | ||
| 28 | my $type = defined $self->{type} ? $self->{type} : $iter->data->type; | ||
| 29 | $self->{out} = PDL->zeroes( $type, $self->{N} )->setbadif( 1 ); | ||
| 30 | } | ||
| 31 | PDL::NDBin::Actions_PP::_imax_loop( $iter->data, $iter->idx, $self->{out}, $self->{N} ); | ||
| 32 | # as the plugin processes all bins at once, every variable | ||
| 33 | # needs to be visited only once | ||
| 34 | $iter->var_active( 0 ); | ||
| 35 | return $self; | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | sub result | ||
| 40 | { | ||
| 41 | my $self = shift; | ||
| 42 | return $self->{out}; | ||
| 43 | } | ||
| 44 | |||
| 45 | 1; | ||
| 46 | |||
| 47 | __END__ | ||