Data-Frame
view release on metacpan or search on metacpan
lib/PDL/SV.pm view on Meta::CPAN
package PDL::SV;
$PDL::SV::VERSION = '0.006005';
# ABSTRACT: PDL subclass for keeping scalar data (like strings)
use 5.016;
use warnings;
use PDL::Lite (); # PDL::Lite is the minimal to get PDL work
use PDL::Core qw(pdl);
use PDL::Primitive qw(which);
use Ref::Util qw(is_plain_arrayref);
use Safe::Isa;
use Type::Params;
use Types::Standard qw(slurpy ArrayRef ConsumerOf Int);
use List::AllUtils ();
use parent 'PDL';
use Class::Method::Modifiers;
use Role::Tiny::With;
with qw(PDL::Role::Stringifiable);
use Devel::OverloadInfo qw(overload_op_info);
my $overload_info;
my $super_dotassign;
BEGIN {
my $overload_info = overload_op_info('PDL', '.=');
$super_dotassign = $overload_info->{code};
}
use overload
'==' => \&_eq,
'eq' => \&_eq,
'!=' => \&_ne,
'ne' => \&_ne,
'<' => \&_lt,
'lt' => \&_lt,
'<=' => \&_le,
'le' => \&_le,
'>' => \&_gt,
'gt' => \&_gt,
'>=' => \&_ge,
'ge' => \&_ge,
'.=' => sub {
my ( $self, $other, $swap ) = @_;
if ( $other->$_DOES('PDL::SV') ) {
my $internal = $self->_internal;
if ($other->dim(0) == 1) {
for my $i ( 0 .. $self->dim(0) - 1 ) {
my $idx = PDL::Core::at( $self, $i );
$internal->[$idx] = $other->at(0);
}
} else {
for my $i ( 0 .. $self->dim(0) - 1 ) {
my $idx = PDL::Core::at( $self, $i );
$internal->[$idx] = $other->at($i);
}
}
return $self;
}
elsif ($other->$_DOES('PDL')) {
return $super_dotassign->( $self, $other, $swap );
}
else { # non-piddle
my $internal = $self->_internal;
for my $i ( 0 .. $self->dim(0) - 1 ) {
my $idx = PDL::Core::at( $self, $i );
( run in 1.503 second using v1.01-cache-2.11-cpan-39bf76dae61 )